Best Python code snippet using autotest_python
StatementsMixin.py
Source:StatementsMixin.py
...9697 """,98 ).format(99 statement_name=self._CreateStatementName(parser_info),100 self_region=self._ToString(parser_info.regions__.self__),101 visibility_region=self._ToString(parser_info.regions__.visibility),102 name_region=self._ToString(parser_info.regions__.name),103 documentation_region=self._ToString(parser_info.regions__.documentation),104 mutability_modifier_region=self._ToString(parser_info.regions__.mutability_modifier),105 keyword_initialization_region=self._ToString(parser_info.regions__.keyword_initialization),106 no_initialization_region=self._ToString(parser_info.regions__.no_initialization),107 no_serialize_region=self._ToString(parser_info.regions__.no_serialize),108 no_compare_region=self._ToString(parser_info.regions__.no_compare),109 class_capabilities=class_capabilities,110 visibility=self._ToString(parser_info.visibility),111 type=self._ToString(parser_info.type),112 name=self._ToString(parser_info.name),113 documentation=self._ToString(parser_info.documentation),114 initialized_value=self._ToString(parser_info.initialized_value),115 mutability_modifier=self._ToString(parser_info.mutability_modifier),116 keyword_initialization=self._ToString(parser_info.keyword_initialization),117 no_initialization=self._ToString(parser_info.no_initialization),118 no_serialize=self._ToString(parser_info.no_serialize),119 no_compare=self._ToString(parser_info.no_compare),120 ),121 )122123 # ----------------------------------------------------------------------124 # | ClassStatementParserInfo125 # ----------------------------------------------------------------------126 @contextmanager127 def OnClassStatementParserInfo(128 self,129 parser_info: ClassStatementParserInfo,130 ):131 yield132133 self._imports.add("from v1.Parser.ParserInfos.Statements.ClassStatementParserInfo import ClassStatementParserInfo")134135 class_capabilities = "{}Capabilities".format(parser_info.class_capabilities.name)136137 self._imports.add(138 "from v1.Parser.ParserInfos.Statements.ClassCapabilities.{class_capabilities} import {class_capabilities}".format(139 class_capabilities=class_capabilities,140 ),141 )142143 if parser_info.parent_class_capabilities is None:144 parent_class_capabilities = None145 else:146 parent_class_capabilities = "{}Capabilities".format(parser_info.parent_class_capabilities.name)147148 self._imports.add(149 "from v1.Parser.ParserInfos.Statements.ClassCapabilities.{parent_class_capabilities} import {parent_class_capabilities}".format(150 parent_class_capabilities=parent_class_capabilities,151 ),152 )153154 self._stream.write(155 textwrap.dedent(156 """\157 {statement_name} = ClassStatementParserInfo.Create(158 regions=[{self_region}, {visibility_region}, {statements_region}, {class_modifier_region}, {name_region}, {documentation_region}, {extends_region}, {implements_region}, {uses_region}, {constructor_visibility_region}, {is_fundamental_region}, {is_abstract_region}, {is_final_region}],159 name={name},160 visibility_param={visibility},161 statements={statements},162 templates_param={templates},163 constraints_param={constraints},164 parent_class_capabilities={parent_class_capabilities},165 class_capabilities={class_capabilities},166 class_modifier_param={class_modifier},167 documentation={documentation},168 extends={extends},169 implements={implements},170 uses={uses},171 constructor_visibility_param={constructor_visibility},172 is_fundamental={is_fundamental},173 is_abstract={is_abstract},174 is_final={is_final},175 )176177 """,178 ).format(179 statement_name=self._CreateStatementName(parser_info),180 self_region=self._ToString(parser_info.regions__.self__),181 visibility_region=self._ToString(parser_info.regions__.visibility),182 class_modifier_region=self._ToString(parser_info.regions__.class_modifier),183 name_region=self._ToString(parser_info.regions__.name),184 documentation_region=self._ToString(parser_info.regions__.documentation),185 extends_region=self._ToString(parser_info.regions__.extends),186 implements_region=self._ToString(parser_info.regions__.implements),187 uses_region=self._ToString(parser_info.regions__.uses),188 statements_region=self._ToString(parser_info.regions__.statements),189 constructor_visibility_region=self._ToString(parser_info.regions__.constructor_visibility),190 is_fundamental_region=self._ToString(parser_info.regions__.is_fundamental),191 is_abstract_region=self._ToString(parser_info.regions__.is_abstract),192 is_final_region=self._ToString(parser_info.regions__.is_final),193 parent_class_capabilities=parent_class_capabilities,194 class_capabilities=class_capabilities,195 visibility=self._ToString(parser_info.visibility),196 class_modifier=self._ToString(parser_info.class_modifier),197 name=self._ToString(parser_info.name),198 documentation=self._ToString(parser_info.documentation),199 templates=self._ToString(parser_info.templates),200 constraints=self._ToString(parser_info.constraints),201 extends=self._ToString(parser_info.extends), # type: ignore202 implements=self._ToString(parser_info.implements), # type: ignore203 uses=self._ToString(parser_info.uses), # type: ignore204 statements=self._ToString(parser_info.statements), # type: ignore205 constructor_visibility=self._ToString(parser_info.constructor_visibility),206 is_fundamental=self._ToString(parser_info.is_fundamental),207 is_abstract=self._ToString(parser_info.is_abstract),208 is_final=self._ToString(parser_info.is_final),209 ),210 )211212 # ----------------------------------------------------------------------213 @contextmanager214 def OnClassStatementDependencyParserInfo(215 self,216 parser_info: ClassStatementDependencyParserInfo,217 ):218 yield219220 self._imports.add("from v1.Parser.ParserInfos.Statements.ClassStatementParserInfo import ClassStatementDependencyParserInfo")221222 self._stream.write(223 textwrap.dedent(224 """\225 {statement_name} = ClassStatementDependencyParserInfo.Create(226 regions=[{self_region}, {visibility_region}],227 visibility={visibility},228 type={type},229 )230231 """,232 ).format(233 statement_name=self._CreateStatementName(parser_info),234 self_region=self._ToString(parser_info.regions__.self__),235 visibility_region=self._ToString(parser_info.regions__.visibility),236 visibility=self._ToString(parser_info.visibility),237 type=self._ToString(parser_info.type),238 ),239 )240241 # ----------------------------------------------------------------------242 # | ClassUsingStatementParserInfo243 # ----------------------------------------------------------------------244 @contextmanager245 def OnClassUsingStatementParserInfo(246 self,247 parser_info: ClassUsingStatementParserInfo,248 ):249 yield250251 self._imports.add("from v1.Parser.ParserInfos.Statements.ClassUsingStatementParserInfo import ClassUsingStatementParserInfo")252253 self._stream.write(254 textwrap.dedent(255 """\256 {statement_name} = ClassUsingStatementParserInfo.Create(257 regions=[{self_region}, {visibility_region}],258 visibility={visibility},259 type={type},260 )261262 """,263 ).format(264 statement_name=self._CreateStatementName(parser_info),265 self_region=self._ToString(parser_info.regions__.self__),266 visibility_region=self._ToString(parser_info.regions__.visibility),267 visibility=self._ToString(parser_info.visibility),268 type=self._ToString(parser_info.type),269 ),270 )271272 # ----------------------------------------------------------------------273 # | FuncDefinitionStatementParserInfo274 # ----------------------------------------------------------------------275 @contextmanager276 def OnFuncDefinitionStatementParserInfo(277 self,278 parser_info: FuncDefinitionStatementParserInfo,279 ):280 yield281282 self._imports.add("from v1.Parser.ParserInfos.Statements.FuncDefinitionStatementParserInfo import FuncDefinitionStatementParserInfo, OperatorType as FuncDefinitionStatementParserInfoOperatorType")283284 if parser_info.parent_class_capabilities is None:285 parent_class_capabilities = None286 else:287 parent_class_capabilities = "{}Capabilities".format(parser_info.parent_class_capabilities.name)288289 self._imports.add(290 "from v1.Parser.ParserInfos.Statements.ClassCapabilities.{parent_class_capabilities} import {parent_class_capabilities}".format(291 parent_class_capabilities=parent_class_capabilities,292 ),293 )294295 self._stream.write(296 textwrap.dedent(297 """\298 {statement_name} = FuncDefinitionStatementParserInfo.Create(299 regions=[{self_region}, {name_region}, {visibility_region}, {statements_region}, {function_modifier_region}, {parameters_region}, {mutability_modifier_region}, {method_hierarchy_modifier_region}, {documentation_region}, {captured_variables_region}, {is_deferred_region}, {is_exceptional_region}, {is_static_region}, {resets_hierarchy_region}],300 name={name},301 visibility_param={visibility},302 statements={statements},303 templates_param={templates},304 parent_class_capabilities={parent_class_capabilities},305 function_modifier_param={function_modifier},306 parameters={parameters},307 mutability_modifier_param={mutability},308 method_hierarchy_modifier_param={method_hierarchy_modifier},309 return_type={return_type},310 documentation={documentation},311 captured_variables={captured_variables},312 is_deferred={is_deferred},313 is_exceptional={is_exceptional},314 is_static={is_static},315 resets_hierarchy={resets_hierarchy},316 )317318 """,319 ).format(320 statement_name=self._CreateStatementName(parser_info),321 self_region=self._ToString(parser_info.regions__.self__),322 visibility_region=self._ToString(parser_info.regions__.visibility),323 mutability_modifier_region=self._ToString(parser_info.regions__.mutability_modifier),324 method_hierarchy_modifier_region=self._ToString(parser_info.regions__.method_hierarchy_modifier),325 name_region=self._ToString(parser_info.regions__.name),326 documentation_region=self._ToString(parser_info.regions__.documentation),327 captured_variables_region=self._ToString(parser_info.regions__.captured_variables),328 function_modifier_region=self._ToString(parser_info.regions__.function_modifier),329 parameters_region=self._ToString(parser_info.regions__.parameters),330 statements_region=self._ToString(parser_info.regions__.statements),331 is_deferred_region=self._ToString(parser_info.regions__.is_deferred),332 is_exceptional_region=self._ToString(parser_info.regions__.is_exceptional),333 is_static_region=self._ToString(parser_info.regions__.is_static),334 resets_hierarchy_region=self._ToString(parser_info.regions__.resets_hierarchy),335 parent_class_capabilities=parent_class_capabilities,336 visibility=self._ToString(parser_info.visibility),337 mutability=self._ToString(parser_info.mutability_modifier),338 method_hierarchy_modifier=self._ToString(parser_info.method_hierarchy_modifier),339 return_type=self._ToString(parser_info.return_type),340 name=self._ToString(parser_info.name) if isinstance(parser_info.name, str) else "FuncDefinitionStatementParserInfoOperatorType.{}".format(parser_info.name.name),341 documentation=self._ToString(parser_info.documentation),342 templates=self._ToString(parser_info.templates),343 captured_variables=self._ToString(parser_info.captured_variables), # type: ignore344 function_modifier=self._ToString(parser_info.function_modifier),345 parameters=self._ToString(parser_info.parameters),346 statements=self._ToString(parser_info.statements), # type: ignore347 is_deferred=self._ToString(parser_info.is_deferred),348 is_exceptional=self._ToString(parser_info.is_exceptional),349 is_static=self._ToString(parser_info.is_static),350 resets_hierarchy=self._ToString(parser_info.resets_hierarchy),351 ),352 )353354 # ----------------------------------------------------------------------355 # | FuncInvocationStatementParserInfo356 # ----------------------------------------------------------------------357 @contextmanager358 def OnFuncInvocationStatementParserInfo(359 self,360 parser_info: FuncInvocationStatementParserInfo,361 ):362 yield363364 self._imports.add("from v1.Parser.ParserInfos.Statements.FuncInvocationStatementParserInfo import FuncInvocationStatementParserInfo")365366 self._stream.write(367 textwrap.dedent(368 """\369 {statement_name} = FuncInvocationStatementParserInfo.Create(370 regions=[{self_region}],371 expression={expression},372 )373374 """,375 ).format(376 statement_name=self._CreateStatementName(parser_info),377 self_region=self._ToString(parser_info.regions__.self__),378 expression=self._ToString(parser_info.expression),379 ),380 )381382 # ----------------------------------------------------------------------383 # | IfStatementParserInfo384 # ----------------------------------------------------------------------385 @contextmanager386 def OnIfStatementParserInfo(387 self,388 parser_info: IfStatementParserInfo,389 ):390 yield391392 self._imports.add("from v1.Parser.ParserInfos.Statements.IfStatementParserInfo import IfStatementParserInfo")393394 self._stream.write(395 textwrap.dedent(396 """\397 {statement_name} = IfStatementParserInfo.Create(398 regions=[{self_region}],399 clauses={clauses},400 else_clause={else_clause},401 )402403 """,404 ).format(405 statement_name=self._CreateStatementName(parser_info),406 self_region=self._ToString(parser_info.regions__.self__),407 clauses=self._ToString(parser_info.clauses), # type: ignore408 else_clause=self._ToString(parser_info.else_clause),409 ),410 )411412 # ----------------------------------------------------------------------413 @contextmanager414 def OnIfStatementClauseParserInfo(415 self,416 parser_info: IfStatementClauseParserInfo,417 ):418 yield419420 self._imports.add("from v1.Parser.ParserInfos.Statements.IfStatementParserInfo import IfStatementClauseParserInfo")421422 self._stream.write(423 textwrap.dedent(424 """\425 {statement_name} = IfStatementClauseParserInfo.Create(426 statements={statements},427 regions=[{self_region}, {statements_region}, {documentation_region}],428 expression={expression},429 documentation={documentation},430 )431432 """,433 ).format(434 statement_name=self._CreateStatementName(parser_info),435 self_region=self._ToString(parser_info.regions__.self__),436 statements_region=self._ToString(parser_info.regions__.statements),437 documentation_region=self._ToString(parser_info.regions__.documentation),438 expression=self._ToString(parser_info.expression),439 statements=self._ToString(parser_info.statements), # type: ignore440 documentation=self._ToString(parser_info.documentation),441 ),442 )443444 # ----------------------------------------------------------------------445 @contextmanager446 def OnIfStatementElseClauseParserInfo(447 self,448 parser_info: IfStatementElseClauseParserInfo,449 ):450 yield451452 self._imports.add("from v1.Parser.ParserInfos.Statements.IfStatementParserInfo import IfStatementElseClauseParserInfo")453454 self._stream.write(455 textwrap.dedent(456 """\457 {statement_name} = IfStatementElseClauseParserInfo.Create(458 statements={statements},459 regions=[{self_region}, {statements_region}, {documentation_region}],460 documentation={documentation},461 )462463 """,464 ).format(465 statement_name=self._CreateStatementName(parser_info),466 self_region=self._ToString(parser_info.regions__.self__),467 statements_region=self._ToString(parser_info.regions__.statements),468 documentation_region=self._ToString(parser_info.regions__.documentation),469 statements=self._ToString(parser_info.statements), # type: ignore470 documentation=self._ToString(parser_info.documentation),471 ),472 )473474 # ----------------------------------------------------------------------475 # | ImportStatementParserInfo476 # ----------------------------------------------------------------------477 @contextmanager478 def OnImportStatementParserInfo(479 self,480 parser_info: ImportStatementParserInfo,481 ):482 yield483484 self._imports.add("from v1.Parser.ParserInfos.Statements.ImportStatementParserInfo import ImportStatementParserInfo, ImportType as ImportStatementParserInfoImportType")485486 self._stream.write(487 textwrap.dedent(488 """\489 {statement_name} = ImportStatementParserInfo.Create(490 regions=[{self_region}, {name_region}, {visibility_region}, {source_parts_region}, {importing_name_region}],491 name={name},492 visibility_param={visibility},493 source_parts={source_parts},494 importing_name={importing_name},495 import_type={import_type},496 )497498 """,499 ).format(500 statement_name=self._CreateStatementName(parser_info),501 self_region=self._ToString(parser_info.regions__.self__),502 name_region=self._ToString(parser_info.regions__.name),503 visibility_region=self._ToString(parser_info.regions__.visibility),504 source_parts_region=self._ToString(parser_info.regions__.source_parts),505 importing_name_region=self._ToString(parser_info.regions__.importing_name),506 visibility=self._ToString(parser_info.visibility),507 source_parts=str(parser_info.source_parts),508 importing_name=self._ToString(parser_info.importing_name),509 name=self._ToString(parser_info.name),510 import_type="ImportStatementParserInfoImportType.{}".format(parser_info.import_type.name),511 ),512 )513514 # ----------------------------------------------------------------------515 # | PassStatementParserInfo516 # ----------------------------------------------------------------------517 @contextmanager518 def OnPassStatementParserInfo(519 self,520 parser_info: PassStatementParserInfo, # pylint: disable=unused-argument521 ):522 yield523524 self._imports.add("from v1.Parser.ParserInfos.Statements.PassStatementParserInfo import PassStatementParserInfo")525526 self._stream.write(527 textwrap.dedent(528 """\529 {statement_name} = PassStatementParserInfo.Create(530 parser_info_type={parser_info_type},531 regions=[{self_region}],532 )533 """,534 ).format(535 statement_name=self._CreateStatementName(parser_info),536 parser_info_type=parser_info.parser_info_type__,537 self_region=self._ToString(parser_info.regions__.self__),538 ),539 )540541 # ----------------------------------------------------------------------542 # | RootStatementParserInfo543 # ----------------------------------------------------------------------544 @contextmanager545 def OnRootStatementParserInfo(546 self,547 parser_info: RootStatementParserInfo,548 ):549 if parser_info.documentation is not None:550 self._stream.write(551 textwrap.dedent(552 '''553 """\\554 {}555 """556557 ''',558 ).format(parser_info.documentation),559 )560561 yield562563 self._imports.add("from v1.Parser.ParserInfos.Statements.RootStatementParserInfo import RootStatementParserInfo")564565 self._stream.write(566 textwrap.dedent(567 """\568 root_parser_info = RootStatementParserInfo.Create(569 regions=[{self_region}, {statements_region}, {documentation_region}],570 name={name},571 statements={statements},572 documentation={documentation},573 )574575 """,576 ).format(577 self_region=self._ToString(parser_info.regions__.self__),578 statements_region=self._ToString(parser_info.regions__.statements),579 name=self._ToString(parser_info.name),580 documentation_region=self._ToString(parser_info.regions__.documentation),581 statements=self._ToString(cast(Optional[List[ParserInfo]], parser_info.statements)),582 documentation=self._ToString(parser_info.documentation),583 ),584 )585586 # ----------------------------------------------------------------------587 # | SpecialMethodStatementParserInfo588 # ----------------------------------------------------------------------589 @contextmanager590 def OnSpecialMethodStatementParserInfo(591 self,592 parser_info: SpecialMethodStatementParserInfo,593 ):594 yield595596 self._imports.add("from v1.Parser.ParserInfos.Statements.SpecialMethodStatementParserInfo import SpecialMethodStatementParserInfo, SpecialMethodType")597598 parent_class_capabilities = "{}Capabilities".format(parser_info.parent_class_capabilities.name)599600 self._imports.add(601 "from v1.Parser.ParserInfos.Statements.ClassCapabilities.{parent_class_capabilities} import {parent_class_capabilities}".format(602 parent_class_capabilities=parent_class_capabilities,603 ),604 )605606 self._stream.write(607 textwrap.dedent(608 """\609 {statement_name} = SpecialMethodStatementParserInfo.Create(610 regions=[{self_region}, {name_region}, {statements_region}],611 parent_class_capabilities={parent_class_capabilities},612 name={name},613 statements={statements},614 )615616 """,617 ).format(618 statement_name=self._CreateStatementName(parser_info),619 self_region=self._ToString(parser_info.regions__.self__),620 name_region=self._ToString(parser_info.regions__.name),621 statements_region=self._ToString(parser_info.regions__.statements),622 parent_class_capabilities=parent_class_capabilities,623 name="SpecialMethodType.{}".format(parser_info.special_method_type.name),624 statements=self._ToString(cast(List[ParserInfo], parser_info.statements)),625 ),626 )627628 # ----------------------------------------------------------------------629 # | TypeAliasStatementParserInfo630 # ----------------------------------------------------------------------631 @contextmanager632 def OnTypeAliasStatementParserInfo(633 self,634 parser_info: TypeAliasStatementParserInfo,635 ):636 yield637638 self._imports.add("from v1.Parser.ParserInfos.Statements.TypeAliasStatementParserInfo import TypeAliasStatementParserInfo")639640 if parser_info.parent_class_capabilities is None:641 parent_class_capabilities = None642 else:643 parent_class_capabilities = "{}Capabilities".format(parser_info.parent_class_capabilities.name)644645 self._imports.add(646 "from v1.Parser.ParserInfos.Statements.ClassCapabilities.{parent_class_capabilities} import {parent_class_capabilities}".format(647 parent_class_capabilities=parent_class_capabilities,648 ),649 )650651 self._stream.write(652 textwrap.dedent(653 """\654 {statement_name} = TypeAliasStatementParserInfo.Create(655 regions=[{self_region}, {name_region}, {visibility_region}],656 name={name},657 visibility_param={visibility},658 templates_param={templates},659 constraints_param={constraints},660 parent_class_capabilities={parent_class_capabilities},661 type={type},662 )663664 """,665 ).format(666 statement_name=self._CreateStatementName(parser_info),667 self_region=self._ToString(parser_info.regions__.self__),668 visibility_region=self._ToString(parser_info.regions__.visibility),669 name_region=self._ToString(parser_info.regions__.name),670 visibility=self._ToString(parser_info.visibility),671 parent_class_capabilities=parent_class_capabilities,672 name=self._ToString(parser_info.name),673 templates=self._ToString(parser_info.templates),674 constraints=self._ToString(parser_info.constraints),675 type=self._ToString(parser_info.type),676 ),
...
common.py
Source:common.py
1import json2import datetime3from collections import deque4from dachar import CONFIG5UNDEFINED = "UNDEFINED"6FIX_STATUS_VALUES = ["proposed", "rejected", "accepted", "withdrawn"]7# if coordinates are given different names but are equivalent8coord_mappings = {"ni": "i", "nj": "j", "i": "ni", "j": "nj"}9def is_undefined(x):10 if x and x != UNDEFINED:11 return True12 return False13def nested_lookup(key_path, item, must_exist=False):14 not_found = "__NOT_FOUND__"15 for key in key_path.split("."):16 if type(item) == dict:17 if key == "*":18 item = [item.get(key, not_found) for key in item]19 else:20 item = item.get(key, not_found)21 elif type(item) == list:22 item = [each.get(key, not_found) for each in item]23 else:24 item = not_found25 if item == not_found:26 if must_exist:27 raise KeyError(f'Required content "{key}" not found.')28 return None29 return item30def now_string():31 return datetime.datetime.now().isoformat().split(".")[0]32class JDict(dict):33 def _tostring(self, obj):34 return json.dumps(obj)35 def __setitem__(self, key, value):36 jkey = self._tostring(key)37 super().__setitem__(jkey, value)38 def __getitem__(self, key):39 jkey = self._tostring(key)40 return super().__getitem__(jkey)41 def __delitem__(self, key):42 jkey = self._tostring(key)43 super().__delitem__(jkey)44 def __contains__(self, key):45 jkey = self._tostring(key)46 return super().__contains__(jkey)47 def keys(self):48 return [json.loads(_) for _ in super().keys()]49 def setdefault(self, key, default):50 jkey = self._tostring(key)51 return super().setdefault(jkey, default)52def is_subsequence(s1, s2):53 """54 Returns True if s1 is a sub-sequence of s2. All elements in s1 must55 exist in s2 and be found in the same order. s2 can include additional56 items that are not in s1.57 :param s1: sub-sequence [sequence]58 :param s2: main sequence [sequence]59 :return: Boolean60 """61 # Convert to deque so that we can popleft() items62 s1, s2 = sorted(s1), sorted(s2)63 s1 = deque(s1)64 for i in s2:65 if i == s1[0]:66 s1.popleft()67 if not s1:68 return True69 return False70def get_extra_items_in_larger_sequence(small, large):71 """72 Returns a list of items found only in sequence `large`.73 :param small: sub-sequence [sequence]74 :param large: main sequence [sequence]75 :return: list or False (if not subsequence)76 """77 if not is_subsequence(small, large):78 return None79 # Convert to deque so that we can popleft() items80 small = deque(small)81 large = deque(large)82 excess = []83 while large:84 item = large.popleft()85 if item not in small:86 excess.append(item)87 return excess88def get_checks(project):89 # Return list of checks to carry out based on project90 project_checks = CONFIG['dachar:checks'][f'{project}']91 common_checks = CONFIG['dachar:checks']['common']...
color.py
Source:color.py
1# pylint: disable=missing-function-docstring,missing-module-docstring2import sys3from dataclasses import dataclass4from typing import Any, Optional5from colorama import Fore, Style6@dataclass7class Color:8 """9 Easy way to print optionally colored messages10 """11 enabled: bool12 def __post_init__(self):13 if self.enabled is None:14 self.enabled = sys.stdin.isatty()15 def _tostring(self, *messages: str, style: Optional[str] = None, sep: str = " "):16 text = sep.join(map(str, messages))17 if self.enabled and style:18 return f"{style}{text}{Style.RESET_ALL}"19 return text20 def red(self, *data: Any, **kwargs):21 return self._tostring(*data, style=Fore.RED, **kwargs)22 def green(self, *data: Any, **kwargs):23 return self._tostring(*data, style=Fore.GREEN, **kwargs)24 def yellow(self, *data: Any, **kwargs):25 return self._tostring(*data, style=Fore.YELLOW, **kwargs)26 def blue(self, *data: Any, **kwargs):27 return self._tostring(*data, style=Fore.BLUE, **kwargs)28 def grey(self, *data: Any, **kwargs):...
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!!