• No results found

Utils API

In document Brownie Documentation (Page 168-175)

The utils package contains utility classes and methods that are used throughout Brownie.

27.6.1 brownie.utils.color

The color module contains the Color class, used for to apply color and formatting to text before printing.

Color

class brownie.utils.color.Color

The Color class is used to apply color and formatting to text before displaying it to the user. It is primarily used within the console. An instance of Color is available at brownie.utils.color:

>>> from brownie.utils import color

>>> color

<brownie.utils.color.Color object at 0x7fa9ec851ba8>

Coloris designed for use informatted string literals. When called it returns anANSI escape codefor the given color:

>>> color('red')

'\x1b[0;31m'

You can also prefix any color with “bright” or “dark”:

Brownie Documentation, Release v1.6.2

>>> color('bright red')

'\x1b[0;1;31m'

>>> color('dark red')

'\x1b[0;2;31m'

Calling it with no values or Converting to a string returns the base color code:

>>> color()

'\x1b[0;m'

>>> str(color)

'\x1b[0;m'

Color Methods

classmethod Color.pretty_dict(value, _indent=0) → str

Given a dict, returns a colored and formatted string suitable for printing.

• value: dict to format

• _indent: used for recursive internal calls, should always be left as 0 classmethod Color.pretty_sequence(value, _indent=0) → str

Given a sequence (list, tuple, set), returns a colored and formatted string suitable for printing.

• value: Sequence to format

• _indent: used for recursive internal calls, should always be left as 0

classmethod Color.format_tb(exc, filename=None, start=None, stop=None) → str Given a raised Exception, returns a colored and formatted string suitable for printing.

• exc: An Exception object

• filename: An optional path as a string. If given, only lines in the traceback related to this filename will be displayed.

• start: Optional. If given, the displayed traceback not include items prior to this index.

• stop: Optional. If given, the displayed traceback not include items beyond this index.

classmethod Color.format_syntaxerror(exc)→ str

Given a raised SyntaxError, returns a colored and formatted string suitable for printing.

• exc: A SyntaxError object.

27.6. Utils API 163

Index

Symbols

__init__()(StateMachine class method),69 _add()(Build class method),151

_add_contract() (brownie.network.state method), 135

_copy()(ConfigDict class method),109

_decode_logs() (brownie.network.event method),

_generate_revert_map() (Build class method), 151

_get_ast_hash()(scripts method),155 _get_current_dependencies()

(brownie.network.state method),136 _get_dev_revert()(build method),152

_get_error_source_from_pc() (build method), 152

_get_highlights()(output method),161

_get_topics()(brownie.network.event method),133 _get_totals()(output method),161

_internal_revert()(Rpc class method),138 _internal_snap()(Rpc class method),138 _lock()(ConfigDict class method),109 _mainnet(Web3 attribute),147

_print_coverage_totals()(output method),160 _print_gas_profile()(output method),160 _remove()(Build class method),151

_remove_contract() (brownie.network.state method),135

_reset()(Accounts class method),117

_reset()(ContractContainer class method),126 _reset()(TxHistory class method),135

_resolve_address() (brownie.network.web3 method),147

_revert()(Accounts class method),117

_revert()(ContractContainer class method),126

_revert()(TxHistory class method),135 _reverted(Contract attribute),127

_save_coverage_report()(output method),160 _split_by_fn()(output method),161

_unlock()(ConfigDict class method),109

A

a,55

a(fixtures attribute),158

abi(ContractCall attribute),127 abi(ContractContainer attribute),123 abi(ContractTx attribute),129 accounts,55

accounts(fixtures attribute),158 add()(Accounts class method),116

add_cached_transaction() (coverage method), 162

add_transaction()(coverage method),162 address(Account attribute),117

at()(Accounts class method),116

at()(ContractContainer class method),125 attach()(Rpc class method),136

B

balance()(Account class method),118 balance()(Contract class method),127

balance()(PublicKeyAccount class method),120 block_number(TransactionReceipt attribute),139 brownie._config.ConfigDict (built-in class),

brownie.convert.datatypes.Wei (built-in

brownie.network.rpc.Rpc(built-in class),136 brownie.network.state.TxHistory (built-in

class),134

brownie.network.transaction.TransactionReceipt (built-in class),139

brownie.network.web3.Web3(built-in class),146 brownie.project.build.Build (built-in class),

brownie.utils.color.Color(built-in class),162 bytecode(Contract attribute),127

bytecode(ContractContainer attribute),123

C

call()(ContractTx class method),129

call_trace() (TransactionReceipt class method), 145

chain_uri()(Web3 class method),147 check_cached()(coverage method),162 check_for_project()(main method),149 clear()(Accounts class method),116 clear()(coverage method),162

clear_active_txlist()(coverage method),162 close()(Project class method),148

compile_and_format()(compiler method),152 compile_from_input_json()(compiler method),

153

compile_source()(main method),150 compiler,97

connect()(main method),114 connect()(Web3 class method),147 contains()(Build class method),151

contract_address (TransactionReceipt attribute), 139

contract_name(TransactionReceipt attribute),140 copy()(TxHistory class method),134

count()(EventDict class method),131 create_manifest()(ethpm method),154

D

deadline,65

Brownie Documentation, Release v1.6.2

decode_output()(ContractTx class method),129 deploy()(Account class method),118

deploy()(ContractContainer class method),124 deployment_networks(settings attribute),92 dict()(Project class method),148

dict()(ReturnValue class method),112 disconnect()(main method),114 disconnect()(Web3 class method),147

E

encode_input()(ContractTx class method),129 error()(TransactionReceipt class method),145 estimate_gas()(Account class method),118 events(TransactionReceipt attribute),140 evm_compatible()(Rpc class method),137 evm_version()(Rpc class method),137

expand_build_offsets() (Build class method), 151

expand_offset()(Sources class method),156

F

find_best_solc_version() (compiler method), 153

find_solc_versions()(compiler method),153 fn_isolation,56

fn_isolation()(fixtures method),158 fn_name(TransactionReceipt attribute),140 format_event()(normalize method),114 format_input()(normalize method),113 format_output()(normalize method),113

format_syntaxerror()(Color class method),163 format_tb()(Color class method),163

from_brownie_mix()(main method),149 from_sender()(TxHistory class method),135

G

gas_limit(TransactionReceipt attribute),140 gas_limit()(main method),115

gas_price(TransactionReceipt attribute),140 gas_price()(main method),115

gas_profile(TxHistory attribute),134 gas_used(TransactionReceipt attribute),141 generate_build_json()(compiler method),153 generate_input_json()(compiler method),153 genesis_hash()(Web3 class method),147 get()(Build class method),150

get()(Sources class method),156

get_active_txlist()(coverage method),162 get_contract_list()(Sources class method),156 get_contracts()(sources method),157

get_coverage_eval()(coverage method),162 get_dependents()(Build class method),151 get_deployment_addresses() (ethpm method),

154

get_hash()(sources method),157

get_installed_packages()(ethpm method),154 get_int_bounds()(utils method),114

get_interface_hashes()(Sources class method), 156

get_interface_list() (Sources class method), 156

get_interface_sources() (Sources class method),156

get_loaded_projects()(main method),149 get_manifest()(ethpm method),154

get_merged_coverage_eval() (coverage method),162

get_method()(ContractContainer class method),125 get_path_list()(Sources class method),156 get_pragma_spec()(sources method),157 get_source_path()(Sources class method),156 get_type_strings()(utils method),114

H

history,55

history(fixtures attribute),158

I

include_dependencies(settings attribute),92 info()(TransactionReceipt class method),144 input(TransactionReceipt attribute),141 install_package()(ethpm method),154 install_solc()(compiler method),152

internal_transfers (TransactionReceipt at-tribute),141

is_active()(Rpc class method),137 is_alive()(Alert class method),122 is_child()(Rpc class method),137 is_connected()(main method),115

is_inside_offset()(sources method),157 items()(_EventItem class method),132 items()(Build class method),151 items()(EventDict class method),131 items()(ReturnValue class method),112

K

keys()(_EventItem class method),132 keys()(EventDict class method),131 keys()(ReturnValue class method),112 kill()(Rpc class method),136

L

launch()(Rpc class method),136 load()(Accounts class method),116 load()(main method),149

load()(Project class method),148

load_config()(Project class method),148

Index 167

logs(TransactionReceipt attribute),141

mine()(Rpc class method),137 minify()(sources method),157

modified_state(TransactionReceipt attribute),142 module_isolation,56

module_isolation(fixtures attribute),158

N

name(_EventItem attribute),132 network,96

networks(network attribute),96 new()(alert method),122 new()(main method),149

new_contracts(TransactionReceipt attribute),142 no_call_coverage,56

no_call_coverage(fixtures attribute),159 nonce(Account attribute),117

nonce(PublicKeyAccount attribute),120 nonce(TransactionReceipt attribute),142

O

of_address()(TxHistory class method),135

P

package_name,91

pos(_EventItem attribute),132

pretty_dict()(Color class method),163 pretty_sequence()(Color class method),163 private_key(LocalAccount attribute),119 process_manifest()(ethpm method),154 public_key(LocalAccount attribute),119 pytest,97

R

receiver(TransactionReceipt attribute),142 release_package()(ethpm method),155 remove()(Accounts class method),117

remove()(ContractContainer class method),125 remove_package()(ethpm method),154 reset()(Rpc class method),137

return_value(TransactionReceipt attribute),142

revert()(Rpc class method),138

revert_msg(TransactionReceipt attribute),142 rpc,55

rpc(fixtures attribute),158 run()(scripts method),155

S

save()(LocalAccount class method),120 sender(TransactionReceipt attribute),143 set_solc_version()(compiler method),152 settings(network attribute),96

setup()(StateMachine class method),69 show()(alert method),122

show_active()(main method),115 signature(ContractCall attribute),128 signature(ContractTx attribute),129

signatures(ContractContainer attribute),123 skip_coverage,57

skip_coverage(fixtures attribute),159 sleep()(Rpc class method),137 snapshot()(Rpc class method),138 solc(compiler attribute),97

source()(TransactionReceipt class method),146 state_machine,56

state_machine(fixtures attribute),158

state_machine()(brownie.test.stateful method),70 state_machine()(stateful method),159

stateful_step_count,65

status(TransactionReceipt attribute),143 stop()(Alert class method),122

stop_all()(alert method),122 strategy()(strategies method),159

T

teardown()(StateMachine class method),69

teardown_final()(StateMachine class method),69 test_rpc(network.networks attribute),97

time()(Rpc class method),137

to_address()(brownie.convert method),110 to_bool()(brownie.convert method),110 to_bytes()(brownie.convert method),110 to_decimal()(brownie.convert method),110 to_int()(brownie.convert method),110 to_receiver()(TxHistory class method),135 to_string()(brownie.convert method),110 to_uint()(brownie.convert method),110 topics(ContractContainer attribute),124 trace(TransactionReceipt attribute),143

traceback()(TransactionReceipt class method),145 transact()(ContractCall class method),128 transfer()(Account class method),118 tx(Contract attribute),127

txid(TransactionReceipt attribute),144 txindex(TransactionReceipt attribute),144

Brownie Documentation, Release v1.6.2

V

value(TransactionReceipt attribute),144 values()(_EventItem class method),132 values()(EventDict class method),131 verify_manifest()(ethpm method),155 version,92

W

wait()(Alert class method),122 web3,56

web3(fixtures attribute),158

Index 169

In document Brownie Documentation (Page 168-175)