How to use print_formatters method in Behave

Best Python code snippet using behave

__main__.py

Source:__main__.py Github

copy

Full Screen

...74 if len(config.format) == len(config.defaults["format"]):75 # -- NO FORMATTER on command-line: Add default formatter.76 config.format.append(config.default_format)77 if 'help' in config.format:78 print_formatters("Available formatters:")79 return 080 if len(config.outputs) > len(config.format):81 print('CONFIG-ERROR: More outfiles (%d) than formatters (%d).' % \82 (len(config.outputs), len(config.format)))83 return 184 failed = True85 runner = Runner(config)86 try:87 failed = runner.run()88 except ParserError as e:89 print(u"ParseError: %s" % e)90 except ConfigError as e:91 print(u"ConfigError: %s" % e)92 except FileNotFoundError as e:93 print(u"FileNotFoundError: %s" % e)94 except InvalidFileLocationError as e:95 print(u"InvalidFileLocationError: %s" % e)96 except InvalidFilenameError as e:97 print(u"InvalidFilenameError: %s" % e)98 except Exception as e:99 # -- DIAGNOSTICS:100 text = _text(e)101 print(u"Exception %s: %s" % (e.__class__.__name__, text))102 raise103 if config.show_snippets and runner.undefined_steps:104 print_undefined_step_snippets(runner.undefined_steps,105 colored=config.color)106 return_code = 0107 if failed:108 return_code = 1109 return return_code110def print_formatters(title=None, stream=None):111 """112 Prints the list of available formatters and their description.113 :param title: Optional title (as string).114 :param stream: Optional, output stream to use (default: sys.stdout).115 """116 from behave.formatter._registry import format_items117 from behave.textutil import compute_words_maxsize, text as _text118 from operator import itemgetter119 if stream is None:120 stream = sys.stdout121 if title:122 stream.write(u"%s\n" % title)123 format_items = sorted(format_items(resolved=True), key=itemgetter(0))124 format_names = [item[0] for item in format_items]...

Full Screen

Full Screen

editor.py

Source:editor.py Github

copy

Full Screen

...31 elif self.user_input in self.formatters:32 self.handle_formatters_call()33 self.save_file()34 self.exit_program()35 def print_formatters(self) -> None:36 print(*self.formatted, sep="")37 def handle_formatters_call(self) -> None:38 self.formatters[self.user_input]()39 self.print_formatters()40 def plain(self) -> None:41 self.formatted.append(input("- Text: "))42 def bold(self) -> None:43 string_formatted = f"**{input('- Text: ')}**"44 self.formatted.append(string_formatted)45 def italic(self) -> None:46 string_formatted = f"*{input('- Text: ')}*"47 self.formatted.append(string_formatted)48 def header(self) -> None:49 header_level = "#" * int(input("- Level: "))50 string_formatted = f"{header_level} {input('- Text: ')}\n"51 self.formatted.append(string_formatted)52 def link(self) -> None:53 label = input("- Label: ")...

Full Screen

Full Screen

srw.py

Source:srw.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#3# This file is part of validator-cli4#5# Copyright (C) 2021 SKALE Labs6#7# This program is free software: you can redistribute it and/or modify8# it under the terms of the GNU Affero General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# This program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU Affero General Public License for more details.16#17# You should have received a copy of the GNU Affero General Public License18# along with this program. If not, see <https://www.gnu.org/licenses/>.19import sys20import click21from yaspin import yaspin22from utils.web3_utils import init_skale_from_config, init_skale_w_wallet_from_config23from utils.helper import to_wei, print_gas_price24from utils.print_formatters import print_srw_balance25from utils.constants import SPIN_COLOR26def validator_id_by_address(skale, address):27 try:28 return skale.validator_service.validator_id_by_address(address)29 except ValueError:30 print(f'Error occurred when trying to get validator ID by address ({address})')31 sys.exit(2)32def recharge(amount: str, validator_id: int, pk_file: str, gas_price: int) -> None:33 skale = init_skale_w_wallet_from_config(pk_file)34 if not skale:35 return36 if gas_price is None:37 gas_price = skale.gas_price38 print_gas_price(gas_price)39 if not validator_id:40 validator_id = validator_id_by_address(skale, skale.wallet.address)41 amount_wei = to_wei(amount)42 print(f'Validator ID {validator_id} will be recharged with {amount} ETH ({amount_wei} WEI)')43 if not click.confirm('Do you want to continue?'):44 print('Operation canceled')45 return46 with yaspin(text='Recharging ETH from validator SRW wallet', color=SPIN_COLOR) as sp:47 tx_res = skale.wallets.recharge_validator_wallet(48 validator_id=validator_id,49 value=amount_wei,50 gas_price=gas_price51 )52 sp.write("✔ Wallet recharged")53 print(f'Transaction hash: {tx_res.tx_hash}')54def withdraw(amount: str, pk_file: str, gas_price: int) -> None:55 skale = init_skale_w_wallet_from_config(pk_file)56 if not skale:57 return58 if gas_price is None:59 gas_price = skale.gas_price60 print_gas_price(gas_price)61 validator_id = validator_id_by_address(skale, skale.wallet.address)62 amount_wei = to_wei(amount)63 print(f'{amount} ETH ({amount_wei} WEI) will be withdrawn from validator ID {validator_id}')64 if not click.confirm('Do you want to continue?'):65 print('Operation canceled')66 return67 with yaspin(text='Withdrawing ETH from validator SRW wallet', color=SPIN_COLOR) as sp:68 tx_res = skale.wallets.withdraw_funds_from_validator_wallet(69 amount=amount_wei,70 gas_price=gas_price71 )72 sp.write("✔ ETH withdrawn")73 print(f'Transaction hash: {tx_res.tx_hash}')74def balance(validator_id, wei=False):75 skale = init_skale_from_config()76 srw_balance = skale.wallets.get_validator_balance(validator_id)...

Full Screen

Full Screen

health.py

Source:health.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2#3# This file is part of node-cli4#5# Copyright (C) 2020 SKALE Labs6#7# This program is free software: you can redistribute it and/or modify8# it under the terms of the GNU Affero General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# This program is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU Affero General Public License for more details.16#17# You should have received a copy of the GNU Affero General Public License18# along with this program. If not, see <https://www.gnu.org/licenses/>.19import json20from terminaltables import SingleTable21from node_cli.utils.print_formatters import (22 print_containers,23 print_schains_healthchecks24)25from node_cli.utils.helper import error_exit, get_request26from node_cli.utils.exit_codes import CLIExitCodes27BLUEPRINT_NAME = 'health'28def get_containers(_all):29 status, payload = get_request(30 blueprint=BLUEPRINT_NAME,31 method='containers',32 params={'all': _all}33 )34 if status == 'ok':35 print_containers(payload)36 else:37 error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)38def get_schains_checks(json_format: bool = False) -> None:39 status, payload = get_request(40 blueprint=BLUEPRINT_NAME,41 method='schains'42 )43 if status == 'ok':44 if not payload:45 print('No sChains found')46 return47 if json_format:48 print(json.dumps(payload))49 else:50 print_schains_healthchecks(payload)51 else:52 error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)53def get_sgx_info():54 status, payload = get_request(55 blueprint=BLUEPRINT_NAME,56 method='sgx'57 )58 if status == 'ok':59 data = payload60 table_data = [61 ['SGX info', ''],62 ['Server URL', data['sgx_server_url']],63 ['SGXWallet Version', data['sgx_wallet_version']],64 ['Node SGX keyname', data['sgx_keyname']],65 ['Status', data['status_name']]66 ]67 table = SingleTable(table_data)68 print(table.table)69 else:...

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 Behave 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