How to use prefixed_write method in avocado

Best Python code snippet using avocado_python

tree.py

Source:tree.py Github

copy

Full Screen

...350 :param verbose: verbosity (0, 1, 2, 3)351 :param use_utf8: Use utf-8 encoding (None=autodetect)352 :return: string representing this node's tree structure353 """354 def prefixed_write(prefix1, prefix2, value):355 """356 Split value's lines and prepend empty prefix to 2nd+ lines357 :return: list of lines358 """359 value = astring.to_text(value)360 if '\n' not in value:361 return [prefix1 + prefix2 + value]362 value = value.splitlines()363 empty_prefix2 = ' ' * len(prefix2)364 return [prefix1 + prefix2 + value[0]] + [prefix1 + empty_prefix2 +365 _ for _ in value[1:]]366 def process_node(node):367 """368 Generate this node's tree-view369 :return: list of lines370 """371 if getattr(node, "multiplex", None):372 down = charset['DoubleDown']373 down_right = charset['DoubleDownRight']374 right = charset['DoubleRight']375 else:376 down = charset['Down']377 down_right = charset['DownRight']378 right = charset['Right']379 out = [node.name]380 if verbose is not None and verbose >= 2 and node.is_leaf:381 values = itertools.chain(iter(node.environment.items()),382 [("filter-only", _)383 for _ in node.environment.filter_only],384 [("filter-out", _)385 for _ in node.environment.filter_out])386 elif verbose in (1, 3):387 values = itertools.chain(iter(node.value.items()),388 [("filter-only", _)389 for _ in node.filters[0]],390 [("filter-out", _)391 for _ in node.filters[1]])392 else:393 values = None394 if values:395 val = charset['Value']396 if node.children:397 val_prefix = down398 else:399 val_prefix = ' '400 for key, value in values:401 out.extend(prefixed_write(val_prefix, "%s%s: " % (val, key),402 value))403 if node.children:404 for child in node.children[:-1]:405 lines = process_node(child)406 out.append(down_right + lines[0])407 out.extend(down + line for line in lines[1:])408 lines = process_node(node.children[-1])409 out.append(right + lines[0])410 empty_down_right = ' ' * len(down_right)411 out.extend(empty_down_right + line for line in lines[1:])412 return out413 if use_utf8 is None:414 use_utf8 = locale.getdefaultlocale()[1] == 'UTF-8'415 if use_utf8:416 charset = {'DoubleDown': u' \u2551 ',417 'DoubleDownRight': u' \u2560\u2550\u2550 ',418 'DoubleRight': u' \u255a\u2550\u2550 ',419 'Down': u' \u2503 ',420 'DownRight': u' \u2523\u2501\u2501 ',421 'Right': u' \u2517\u2501\u2501 ',422 'Value': u'\u2192 '}423 else: # ASCII fallback424 charset = {'Down': ' | ',425 'DownRight': ' |-- ',426 'Right': ' \\-- ',427 'DoubleDown': ' # ',428 'DoubleDownRight': ' #== ',429 'DoubleRight': ' #== ',430 'Value': ' -> '}431 if getattr(root, "multiplex", None):432 down = charset['DoubleDown']433 down_right = charset['DoubleDownRight']434 right = charset['DoubleRight']435 else:436 down = charset['Down']437 down_right = charset['DownRight']438 right = charset['Right']439 out = []440 if verbose is not None and verbose >= 2 and root.is_leaf:441 values = root.environment.items()442 elif verbose in (1, 3):443 values = root.value.items()444 else:445 values = None446 if values:447 prefix = charset['Value'].lstrip()448 for key, value in values:449 out.extend(prefixed_write(prefix, key + ': ', value))450 if root.children:451 for child in root.children[:-1]:452 lines = process_node(child)453 out.append(down_right + lines[0])454 out.extend(down + line for line in lines[1:])455 lines = process_node(root.children[-1])456 out.append(right + lines[0])457 out.extend(' ' * len(down_right) + line for line in lines[1:])458 # When not on TTY we need to force the encoding459 return '\n'.join(out).encode('utf-8' if use_utf8 else 'ascii',...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful