Best Python code snippet using slash
console_color.py
Source:console_color.py
...9 ENDC = '\033[0m'10 BOLD = '\033[1m'11 UNDERLINE = '\033[4m'12 @staticmethod13 def _colored_print(color, msg, width=80, *args, **kwargs):14 if 'process' in kwargs.keys():15 process = ''16 for item in kwargs['process']:17 try:18 process += ' ' + item['Name'] + \19 ' [' + str(item['Cur']).rjust(len(str(item['Tot'])), '0') + \20 '/' + str(item['Tot']) + ']'21 except KeyError:22 f = str(23 [{24 'Name': 'Name1',25 'Cur': 1,26 'Tot': 100,27 }, {28 'Name': 'Name2',29 'Cur': 1,30 'Tot': 100,31 }]32 )33 Prints.FAIL('please follow the format: '34 f'process = {f}')35 raise KeyError36 process = process[1:]37 msg += ' ' * (width - len(msg) - len(process)) + process38 kwargs.pop('process')39 print(color + msg + Prints.ENDC, *args, **kwargs)40 @staticmethod41 def warning(msg, *args, **kwargs):42 Prints._colored_print(Prints.WARNING, msg, *args, **kwargs)43 @staticmethod44 def info(msg, *args, **kwargs):45 Prints._colored_print('', msg, *args, **kwargs)46 @staticmethod47 def ok(msg, *args, **kwargs):48 Prints._colored_print(Prints.OKGREEN, msg, *args, **kwargs)49 50 @staticmethod51 def train(msg, *args, **kwargs):52 Prints._colored_print(Prints.OKCYAN, msg, *args, **kwargs)53 @staticmethod54 def evaluate(msg, *args, **kwargs):55 Prints._colored_print(Prints.FAIL, msg, *args, **kwargs)56 @staticmethod57 def heading(msg, *args, **kwargs):...
colored_print.py
Source:colored_print.py
...30RESET = '\033[0;0m'31def style_text(text, style):32 return style + text + RESET33def print_red(output_string):34 _colored_print(output_string, RED)35def print_blue(output_string):36 _colored_print(output_string, BLUE)37def print_cyan(output_string):38 _colored_print(output_string, CYAN)39def print_green(output_string):40 _colored_print(output_string, GREEN)41def print_bold(output_string):42 _colored_print(output_string, BOLD)43def print_reverse(output_string):44 _colored_print(output_string, REVERSE)45def _colored_print(output_string, style):46 sys.stdout.write(style)47 sys.stdout.write(output_string)...
messages_service.py
Source:messages_service.py
2class MessagesService:3 def __init__(self):4 pass5 def info(self, text):6 self._colored_print(Fore.RESET, text)7 def default(self, text):8 self._colored_print(Fore.WHITE, text)9 def warning(self, text):10 self._colored_print(Fore.YELLOW, text)11 def error(self, text):12 self._colored_print(Fore.RED, text)13 def success(self, text):14 self._colored_print(Fore.GREEN, text)15 def result(self, text):16 self._colored_print(Fore.MAGENTA, text)17 @staticmethod18 def _colored_print(color, text):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!