repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_name_from_name_hash128
def namedb_get_name_from_name_hash128( cur, name_hash128, block_number ): """ Given the hexlified 128-bit hash of a name, get the name. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_query = "SELECT name FROM name_records JOIN namespaces ON name_re...
python
def namedb_get_name_from_name_hash128( cur, name_hash128, block_number ): """ Given the hexlified 128-bit hash of a name, get the name. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_query = "SELECT name FROM name_records JOIN namespaces ON name_re...
[ "def", "namedb_get_name_from_name_hash128", "(", "cur", ",", "name_hash128", ",", "block_number", ")", ":", "unexpired_query", ",", "unexpired_args", "=", "namedb_select_where_unexpired_names", "(", "block_number", ")", "select_query", "=", "\"SELECT name FROM name_records JO...
Given the hexlified 128-bit hash of a name, get the name.
[ "Given", "the", "hexlified", "128", "-", "bit", "hash", "of", "a", "name", "get", "the", "name", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2765-L2783
train
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_names_with_value_hash
def namedb_get_names_with_value_hash( cur, value_hash, block_number ): """ Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_quer...
python
def namedb_get_names_with_value_hash( cur, value_hash, block_number ): """ Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_quer...
[ "def", "namedb_get_names_with_value_hash", "(", "cur", ",", "value_hash", ",", "block_number", ")", ":", "unexpired_query", ",", "unexpired_args", "=", "namedb_select_where_unexpired_names", "(", "block_number", ")", "select_query", "=", "\"SELECT name FROM name_records JOIN ...
Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names.
[ "Get", "the", "names", "with", "the", "given", "value", "hash", ".", "Only", "includes", "current", "non", "-", "revoked", "names", ".", "Return", "None", "if", "there", "are", "no", "names", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2786-L2806
train
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_value_hash_txids
def namedb_get_value_hash_txids(cur, value_hash): """ Get the list of txs that sent this value hash, ordered by block and vtxindex """ query = 'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;' args = (value_hash,) rows = namedb_query_execute(cur, query, args) txids...
python
def namedb_get_value_hash_txids(cur, value_hash): """ Get the list of txs that sent this value hash, ordered by block and vtxindex """ query = 'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;' args = (value_hash,) rows = namedb_query_execute(cur, query, args) txids...
[ "def", "namedb_get_value_hash_txids", "(", "cur", ",", "value_hash", ")", ":", "query", "=", "'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;'", "args", "=", "(", "value_hash", ",", ")", "rows", "=", "namedb_query_execute", "(", "cur", ",", "q...
Get the list of txs that sent this value hash, ordered by block and vtxindex
[ "Get", "the", "list", "of", "txs", "that", "sent", "this", "value", "hash", "ordered", "by", "block", "and", "vtxindex" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2809-L2824
train
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_num_block_vtxs
def namedb_get_num_block_vtxs( cur, block_number ): """ How many virtual transactions were processed for this block? """ select_query = "SELECT vtxindex FROM history WHERE history_id = ?;" args = (block_number,) rows = namedb_query_execute( cur, select_query, args ) count = 0 for r in ...
python
def namedb_get_num_block_vtxs( cur, block_number ): """ How many virtual transactions were processed for this block? """ select_query = "SELECT vtxindex FROM history WHERE history_id = ?;" args = (block_number,) rows = namedb_query_execute( cur, select_query, args ) count = 0 for r in ...
[ "def", "namedb_get_num_block_vtxs", "(", "cur", ",", "block_number", ")", ":", "select_query", "=", "\"SELECT vtxindex FROM history WHERE history_id = ?;\"", "args", "=", "(", "block_number", ",", ")", "rows", "=", "namedb_query_execute", "(", "cur", ",", "select_query"...
How many virtual transactions were processed for this block?
[ "How", "many", "virtual", "transactions", "were", "processed", "for", "this", "block?" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2827-L2839
train
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_is_name_zonefile_hash
def namedb_is_name_zonefile_hash(cur, name, zonefile_hash): """ Determine if a zone file hash was sent by a name. Return True if so, false if not """ select_query = 'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?' select_args = (name,zonefile_hash) rows = name...
python
def namedb_is_name_zonefile_hash(cur, name, zonefile_hash): """ Determine if a zone file hash was sent by a name. Return True if so, false if not """ select_query = 'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?' select_args = (name,zonefile_hash) rows = name...
[ "def", "namedb_is_name_zonefile_hash", "(", "cur", ",", "name", ",", "zonefile_hash", ")", ":", "select_query", "=", "'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?'", "select_args", "=", "(", "name", ",", "zonefile_hash", ")", "rows", "=", ...
Determine if a zone file hash was sent by a name. Return True if so, false if not
[ "Determine", "if", "a", "zone", "file", "hash", "was", "sent", "by", "a", "name", ".", "Return", "True", "if", "so", "false", "if", "not" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2842-L2857
train
blockstack/blockstack-core
blockstack/lib/operations/announce.py
process_announcement
def process_announcement( sender_namerec, op, working_dir ): """ If the announcement is valid, then immediately record it. """ node_config = get_blockstack_opts() # valid announcement announce_hash = op['message_hash'] announcer_id = op['announcer_id'] # verify that it came from thi...
python
def process_announcement( sender_namerec, op, working_dir ): """ If the announcement is valid, then immediately record it. """ node_config = get_blockstack_opts() # valid announcement announce_hash = op['message_hash'] announcer_id = op['announcer_id'] # verify that it came from thi...
[ "def", "process_announcement", "(", "sender_namerec", ",", "op", ",", "working_dir", ")", ":", "node_config", "=", "get_blockstack_opts", "(", ")", "announce_hash", "=", "op", "[", "'message_hash'", "]", "announcer_id", "=", "op", "[", "'announcer_id'", "]", "na...
If the announcement is valid, then immediately record it.
[ "If", "the", "announcement", "is", "valid", "then", "immediately", "record", "it", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/announce.py#L39-L75
train
blockstack/blockstack-core
blockstack/lib/operations/announce.py
check
def check( state_engine, nameop, block_id, checked_ops ): """ Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise """ sender = nameop['sender'] sending_blockc...
python
def check( state_engine, nameop, block_id, checked_ops ): """ Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise """ sender = nameop['sender'] sending_blockc...
[ "def", "check", "(", "state_engine", ",", "nameop", ",", "block_id", ",", "checked_ops", ")", ":", "sender", "=", "nameop", "[", "'sender'", "]", "sending_blockchain_id", "=", "None", "found", "=", "False", "blockchain_namerec", "=", "None", "for", "blockchain...
Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise
[ "Log", "an", "announcement", "from", "the", "blockstack", "developers", "but", "first", "verify", "that", "it", "is", "correct", ".", "Return", "True", "if", "the", "announcement", "came", "from", "the", "announce", "IDs", "whitelist", "Return", "False", "othe...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/announce.py#L157-L188
train
blockstack/blockstack-core
blockstack/lib/snv.py
get_bitcoind_client
def get_bitcoind_client(): """ Connect to the bitcoind node """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] bitcoind_user = bitcoind_opts['bitcoind_user'] bitcoind_passwd = bitcoind_opts['bitcoind_pass...
python
def get_bitcoind_client(): """ Connect to the bitcoind node """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] bitcoind_user = bitcoind_opts['bitcoind_user'] bitcoind_passwd = bitcoind_opts['bitcoind_pass...
[ "def", "get_bitcoind_client", "(", ")", ":", "bitcoind_opts", "=", "get_bitcoin_opts", "(", ")", "bitcoind_host", "=", "bitcoind_opts", "[", "'bitcoind_server'", "]", "bitcoind_port", "=", "bitcoind_opts", "[", "'bitcoind_port'", "]", "bitcoind_user", "=", "bitcoind_o...
Connect to the bitcoind node
[ "Connect", "to", "the", "bitcoind", "node" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L58-L68
train
blockstack/blockstack-core
blockstack/lib/snv.py
txid_to_block_data
def txid_to_block_data(txid, bitcoind_proxy, proxy=None): """ Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, t...
python
def txid_to_block_data(txid, bitcoind_proxy, proxy=None): """ Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, t...
[ "def", "txid_to_block_data", "(", "txid", ",", "bitcoind_proxy", ",", "proxy", "=", "None", ")", ":", "proxy", "=", "get_default_proxy", "(", ")", "if", "proxy", "is", "None", "else", "proxy", "timeout", "=", "1.0", "while", "True", ":", "try", ":", "unt...
Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, txdata) on success Return (None, None, None) on error
[ "Given", "a", "txid", "get", "its", "block", "s", "data", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L71-L150
train
blockstack/blockstack-core
blockstack/lib/snv.py
get_consensus_hash_from_tx
def get_consensus_hash_from_tx(tx): """ Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error. """ opcode, payload = parse_tx_...
python
def get_consensus_hash_from_tx(tx): """ Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error. """ opcode, payload = parse_tx_...
[ "def", "get_consensus_hash_from_tx", "(", "tx", ")", ":", "opcode", ",", "payload", "=", "parse_tx_op_return", "(", "tx", ")", "if", "opcode", "is", "None", "or", "payload", "is", "None", ":", "return", "None", "if", "opcode", "in", "[", "NAME_PREORDER", "...
Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error.
[ "Given", "an", "SPV", "-", "verified", "transaction", "extract", "its", "consensus", "hash", ".", "Only", "works", "of", "the", "tx", "encodes", "a", "NAME_PREORDER", "NAMESPACE_PREORDER", "or", "NAME_TRANSFER", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L278-L304
train
blockstack/blockstack-core
blockstack/lib/client.py
json_is_exception
def json_is_exception(resp): """ Is the given response object an exception traceback? Return True if so Return False if not """ if not json_is_error(resp): return False if 'traceback' not in resp.keys() or 'error' not in resp.keys(): return False return True
python
def json_is_exception(resp): """ Is the given response object an exception traceback? Return True if so Return False if not """ if not json_is_error(resp): return False if 'traceback' not in resp.keys() or 'error' not in resp.keys(): return False return True
[ "def", "json_is_exception", "(", "resp", ")", ":", "if", "not", "json_is_error", "(", "resp", ")", ":", "return", "False", "if", "'traceback'", "not", "in", "resp", ".", "keys", "(", ")", "or", "'error'", "not", "in", "resp", ".", "keys", "(", ")", "...
Is the given response object an exception traceback? Return True if so Return False if not
[ "Is", "the", "given", "response", "object", "an", "exception", "traceback?" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L240-L254
train
blockstack/blockstack-core
blockstack/lib/client.py
put_zonefiles
def put_zonefiles(hostport, zonefile_data_list, timeout=30, my_hostport=None, proxy=None): """ Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error """ assert hostp...
python
def put_zonefiles(hostport, zonefile_data_list, timeout=30, my_hostport=None, proxy=None): """ Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error """ assert hostp...
[ "def", "put_zonefiles", "(", "hostport", ",", "zonefile_data_list", ",", "timeout", "=", "30", ",", "my_hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "hostport", "or", "proxy", ",", "'need either hostport or proxy'", "saved_schema", "=",...
Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error
[ "Push", "one", "or", "more", "zonefiles", "to", "the", "given", "server", ".", "Each", "zone", "file", "in", "the", "list", "must", "be", "base64", "-", "encoded" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L879-L945
train
blockstack/blockstack-core
blockstack/lib/client.py
get_zonefiles_by_block
def get_zonefiles_by_block(from_block, to_block, hostport=None, proxy=None): """ Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 't...
python
def get_zonefiles_by_block(from_block, to_block, hostport=None, proxy=None): """ Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 't...
[ "def", "get_zonefiles_by_block", "(", "from_block", ",", "to_block", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "hostport", "or", "proxy", ",", "'need either hostport or proxy'", "if", "proxy", "is", "None", ":", "proxy", "=",...
Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 'txid' : '...', 'block_height' : '...' } ] }
[ "Get", "zonefile", "information", "for", "zonefiles", "announced", "in", "[" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L948-L1005
train
blockstack/blockstack-core
blockstack/lib/client.py
get_account_tokens
def get_account_tokens(address, hostport=None, proxy=None): """ Get the types of tokens that an address owns Returns a list of token types """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) tokens_schema = { 'type': 'o...
python
def get_account_tokens(address, hostport=None, proxy=None): """ Get the types of tokens that an address owns Returns a list of token types """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) tokens_schema = { 'type': 'o...
[ "def", "get_account_tokens", "(", "address", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect_hostport", "(", "ho...
Get the types of tokens that an address owns Returns a list of token types
[ "Get", "the", "types", "of", "tokens", "that", "an", "address", "owns", "Returns", "a", "list", "of", "token", "types" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L1378-L1441
train
blockstack/blockstack-core
blockstack/lib/client.py
get_account_balance
def get_account_balance(address, token_type, hostport=None, proxy=None): """ Get the balance of an account for a particular token Returns an int """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) balance_schema = { 'ty...
python
def get_account_balance(address, token_type, hostport=None, proxy=None): """ Get the balance of an account for a particular token Returns an int """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) balance_schema = { 'ty...
[ "def", "get_account_balance", "(", "address", ",", "token_type", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect...
Get the balance of an account for a particular token Returns an int
[ "Get", "the", "balance", "of", "an", "account", "for", "a", "particular", "token", "Returns", "an", "int" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L1504-L1558
train
blockstack/blockstack-core
blockstack/lib/client.py
get_name_DID
def get_name_DID(name, proxy=None, hostport=None): """ Get the DID for a name or subdomain Return the DID string on success Return None if not found """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) did_schema = { ...
python
def get_name_DID(name, proxy=None, hostport=None): """ Get the DID for a name or subdomain Return the DID string on success Return None if not found """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) did_schema = { ...
[ "def", "get_name_DID", "(", "name", ",", "proxy", "=", "None", ",", "hostport", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect_hostport", "(", "hostport", ...
Get the DID for a name or subdomain Return the DID string on success Return None if not found
[ "Get", "the", "DID", "for", "a", "name", "or", "subdomain", "Return", "the", "DID", "string", "on", "success", "Return", "None", "if", "not", "found" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L2473-L2536
train
blockstack/blockstack-core
blockstack/lib/client.py
get_JWT
def get_JWT(url, address=None): """ Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library """ jwt_txt = No...
python
def get_JWT(url, address=None): """ Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library """ jwt_txt = No...
[ "def", "get_JWT", "(", "url", ",", "address", "=", "None", ")", ":", "jwt_txt", "=", "None", "jwt", "=", "None", "log", ".", "debug", "(", "\"Try {}\"", ".", "format", "(", "url", ")", ")", "urlinfo", "=", "urllib2", ".", "urlparse", ".", "urlparse",...
Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library
[ "Given", "a", "URL", "fetch", "and", "decode", "the", "JWT", "it", "points", "to", ".", "If", "address", "is", "given", "then", "authenticate", "the", "JWT", "with", "the", "address", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L3460-L3554
train
blockstack/blockstack-core
blockstack/lib/client.py
decode_name_zonefile
def decode_name_zonefile(name, zonefile_txt): """ Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error """ user_zonefile = None try: # by default, it's a zonefile-formatted text file user_zonefile_defaul...
python
def decode_name_zonefile(name, zonefile_txt): """ Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error """ user_zonefile = None try: # by default, it's a zonefile-formatted text file user_zonefile_defaul...
[ "def", "decode_name_zonefile", "(", "name", ",", "zonefile_txt", ")", ":", "user_zonefile", "=", "None", "try", ":", "user_zonefile_defaultdict", "=", "blockstack_zones", ".", "parse_zone_file", "(", "zonefile_txt", ")", "user_zonefile", "=", "dict", "(", "user_zone...
Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error
[ "Decode", "a", "zone", "file", "for", "a", "name", ".", "Must", "be", "either", "a", "well", "-", "formed", "DNS", "zone", "file", "or", "a", "legacy", "Onename", "profile", ".", "Return", "None", "on", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L3738-L3776
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._send_headers
def _send_headers(self, status_code=200, content_type='application/json', more_headers={}): """ Generate and reply headers """ self.send_response(status_code) self.send_header('content-type', content_type) self.send_header('Access-Control-Allow-Origin', '*') # CORS ...
python
def _send_headers(self, status_code=200, content_type='application/json', more_headers={}): """ Generate and reply headers """ self.send_response(status_code) self.send_header('content-type', content_type) self.send_header('Access-Control-Allow-Origin', '*') # CORS ...
[ "def", "_send_headers", "(", "self", ",", "status_code", "=", "200", ",", "content_type", "=", "'application/json'", ",", "more_headers", "=", "{", "}", ")", ":", "self", ".", "send_response", "(", "status_code", ")", "self", ".", "send_header", "(", "'conte...
Generate and reply headers
[ "Generate", "and", "reply", "headers" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L124-L134
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._reply_json
def _reply_json(self, json_payload, status_code=200): """ Return a JSON-serializable data structure """ self._send_headers(status_code=status_code) json_str = json.dumps(json_payload) self.wfile.write(json_str)
python
def _reply_json(self, json_payload, status_code=200): """ Return a JSON-serializable data structure """ self._send_headers(status_code=status_code) json_str = json.dumps(json_payload) self.wfile.write(json_str)
[ "def", "_reply_json", "(", "self", ",", "json_payload", ",", "status_code", "=", "200", ")", ":", "self", ".", "_send_headers", "(", "status_code", "=", "status_code", ")", "json_str", "=", "json", ".", "dumps", "(", "json_payload", ")", "self", ".", "wfil...
Return a JSON-serializable data structure
[ "Return", "a", "JSON", "-", "serializable", "data", "structure" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L137-L143
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._read_json
def _read_json(self, schema=None, maxlen=JSONRPC_MAX_SIZE): """ Read a JSON payload from the requester Return the parsed payload on success Return None on error """ # JSON post? request_type = self.headers.get('content-type', None) client_address_str = "{}...
python
def _read_json(self, schema=None, maxlen=JSONRPC_MAX_SIZE): """ Read a JSON payload from the requester Return the parsed payload on success Return None on error """ # JSON post? request_type = self.headers.get('content-type', None) client_address_str = "{}...
[ "def", "_read_json", "(", "self", ",", "schema", "=", "None", ",", "maxlen", "=", "JSONRPC_MAX_SIZE", ")", ":", "request_type", "=", "self", ".", "headers", ".", "get", "(", "'content-type'", ",", "None", ")", "client_address_str", "=", "\"{}:{}\"", ".", "...
Read a JSON payload from the requester Return the parsed payload on success Return None on error
[ "Read", "a", "JSON", "payload", "from", "the", "requester", "Return", "the", "parsed", "payload", "on", "success", "Return", "None", "on", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L176-L217
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.parse_qs
def parse_qs(self, qs): """ Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error """ qs_state = urllib2.urlparse.parse_qs(qs) ret = {} for qs_var, qs_value_list in qs_state.it...
python
def parse_qs(self, qs): """ Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error """ qs_state = urllib2.urlparse.parse_qs(qs) ret = {} for qs_var, qs_value_list in qs_state.it...
[ "def", "parse_qs", "(", "self", ",", "qs", ")", ":", "qs_state", "=", "urllib2", ".", "urlparse", ".", "parse_qs", "(", "qs", ")", "ret", "=", "{", "}", "for", "qs_var", ",", "qs_value_list", "in", "qs_state", ".", "items", "(", ")", ":", "if", "le...
Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error
[ "Parse", "query", "string", "but", "enforce", "one", "instance", "of", "each", "variable", ".", "Return", "a", "dict", "with", "the", "variables", "on", "success", "Return", "None", "on", "parse", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L220-L234
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.get_path_and_qs
def get_path_and_qs(self): """ Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error """ path_parts = self.path.split("?", 1) if len(path_parts) > 1: ...
python
def get_path_and_qs(self): """ Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error """ path_parts = self.path.split("?", 1) if len(path_parts) > 1: ...
[ "def", "get_path_and_qs", "(", "self", ")", ":", "path_parts", "=", "self", ".", "path", ".", "split", "(", "\"?\"", ",", "1", ")", "if", "len", "(", "path_parts", ")", ">", "1", ":", "qs", "=", "path_parts", "[", "1", "]", ".", "split", "(", "\"...
Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error
[ "Parse", "and", "obtain", "the", "path", "and", "query", "values", ".", "We", "don", "t", "care", "about", "fragments", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L237-L261
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.OPTIONS_preflight
def OPTIONS_preflight( self, path_info ): """ Give back CORS preflight check headers """ self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') # CORS self.send_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE') self.send_hea...
python
def OPTIONS_preflight( self, path_info ): """ Give back CORS preflight check headers """ self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') # CORS self.send_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE') self.send_hea...
[ "def", "OPTIONS_preflight", "(", "self", ",", "path_info", ")", ":", "self", ".", "send_response", "(", "200", ")", "self", ".", "send_header", "(", "'Access-Control-Allow-Origin'", ",", "'*'", ")", "self", ".", "send_header", "(", "'Access-Control-Allow-Methods'"...
Give back CORS preflight check headers
[ "Give", "back", "CORS", "preflight", "check", "headers" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L290-L301
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_names_owned_by_address
def GET_names_owned_by_address( self, path_info, blockchain, address ): """ Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason """ if not check_address(...
python
def GET_names_owned_by_address( self, path_info, blockchain, address ): """ Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason """ if not check_address(...
[ "def", "GET_names_owned_by_address", "(", "self", ",", "path_info", ",", "blockchain", ",", "address", ")", ":", "if", "not", "check_address", "(", "address", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid address'", "}", ...
Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason
[ "Get", "all", "names", "owned", "by", "an", "address", "Returns", "the", "list", "on", "success", "Return", "404", "on", "unsupported", "blockchain", "Return", "502", "on", "failure", "to", "get", "names", "for", "any", "non", "-", "specified", "reason" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L304-L339
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_account_record
def GET_account_record(self, path_info, account_addr, token_type): """ Get the state of a particular token account Returns the account """ if not check_account_address(account_addr): return self._reply_json({'error': 'Invalid address'}, status_code=400) if no...
python
def GET_account_record(self, path_info, account_addr, token_type): """ Get the state of a particular token account Returns the account """ if not check_account_address(account_addr): return self._reply_json({'error': 'Invalid address'}, status_code=400) if no...
[ "def", "GET_account_record", "(", "self", ",", "path_info", ",", "account_addr", ",", "token_type", ")", ":", "if", "not", "check_account_address", "(", "account_addr", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid address'"...
Get the state of a particular token account Returns the account
[ "Get", "the", "state", "of", "a", "particular", "token", "account", "Returns", "the", "account" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L360-L378
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_names
def GET_names( self, path_info ): """ Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names """ include_expired = False qs_val...
python
def GET_names( self, path_info ): """ Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names """ include_expired = False qs_val...
[ "def", "GET_names", "(", "self", ",", "path_info", ")", ":", "include_expired", "=", "False", "qs_values", "=", "path_info", "[", "'qs_values'", "]", "page", "=", "qs_values", ".", "get", "(", "'page'", ",", "None", ")", "if", "page", "is", "None", ":", ...
Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names
[ "Get", "all", "names", "in", "existence", "If", "all", "=", "true", "is", "set", "then", "include", "expired", "names", ".", "Returns", "the", "list", "on", "success", "Returns", "400", "on", "invalid", "arguments", "Returns", "502", "on", "failure", "to",...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L458-L496
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_name_history
def GET_name_history(self, path_info, name): """ Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server """ i...
python
def GET_name_history(self, path_info, name): """ Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server """ i...
[ "def", "GET_name_history", "(", "self", ",", "path_info", ",", "name", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invali...
Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server
[ "Get", "the", "history", "of", "a", "name", "or", "subdomain", ".", "Requires", "page", "in", "the", "query", "string", "return", "the", "history", "on", "success", "return", "400", "on", "invalid", "start_block", "or", "end_block", "return", "502", "on", ...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L650-L683
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_name_zonefile_by_hash
def GET_name_zonefile_by_hash( self, path_info, name, zonefile_hash ): """ Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standar...
python
def GET_name_zonefile_by_hash( self, path_info, name, zonefile_hash ): """ Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standar...
[ "def", "GET_name_zonefile_by_hash", "(", "self", ",", "path_info", ",", "name", ",", "zonefile_hash", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(", ...
Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standard Reply 404 on not found Reply 502 on failure to fetch data
[ "Get", "a", "historic", "zonefile", "for", "a", "name", "With", "raw", "=", "1", "on", "the", "query", "string", "return", "the", "raw", "zone", "file" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L823-L879
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespaces
def GET_namespaces( self, path_info ): """ Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason """ qs_values = path_info['qs_values'] offset = qs_values.get('offset', None) count = qs_valu...
python
def GET_namespaces( self, path_info ): """ Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason """ qs_values = path_info['qs_values'] offset = qs_values.get('offset', None) count = qs_valu...
[ "def", "GET_namespaces", "(", "self", ",", "path_info", ")", ":", "qs_values", "=", "path_info", "[", "'qs_values'", "]", "offset", "=", "qs_values", ".", "get", "(", "'offset'", ",", "None", ")", "count", "=", "qs_values", ".", "get", "(", "'count'", ",...
Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason
[ "Get", "the", "list", "of", "all", "namespaces", "Reply", "all", "existing", "namespaces", "Reply", "502", "if", "we", "can", "t", "reach", "the", "server", "for", "whatever", "reason" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L980-L998
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_info
def GET_namespace_info( self, path_info, namespace_id ): """ Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server """ if not check_namespace(namespace_id...
python
def GET_namespace_info( self, path_info, namespace_id ): """ Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server """ if not check_namespace(namespace_id...
[ "def", "GET_namespace_info", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "status_c...
Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server
[ "Look", "up", "a", "namespace", "s", "info", "Reply", "information", "about", "a", "namespace", "Reply", "404", "if", "the", "namespace", "doesn", "t", "exist", "Reply", "502", "for", "any", "error", "in", "talking", "to", "the", "blocksatck", "server" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1001-L1019
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_num_names
def GET_namespace_num_names(self, path_info, namespace_id): """ Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server """ if not check_namespace(namespace_...
python
def GET_namespace_num_names(self, path_info, namespace_id): """ Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server """ if not check_namespace(namespace_...
[ "def", "GET_namespace_num_names", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "sta...
Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server
[ "Get", "the", "number", "of", "names", "in", "a", "namespace", "Reply", "the", "number", "on", "success", "Reply", "404", "if", "the", "namespace", "does", "not", "exist", "Reply", "502", "on", "failure", "to", "talk", "to", "the", "blockstack", "server" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1022-L1038
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_names
def GET_namespace_names( self, path_info, namespace_id ): """ Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server """ if not check_namespac...
python
def GET_namespace_names( self, path_info, namespace_id ): """ Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server """ if not check_namespac...
[ "def", "GET_namespace_names", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "status_...
Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server
[ "Get", "the", "list", "of", "names", "in", "a", "namespace", "Reply", "the", "list", "of", "names", "in", "a", "namespace", "Reply", "404", "if", "the", "namespace", "doesn", "t", "exist", "Reply", "502", "for", "any", "error", "in", "talking", "to", "...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1041-L1077
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_blockchain_ops
def GET_blockchain_ops( self, path_info, blockchain_name, blockheight ): """ Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blocksta...
python
def GET_blockchain_ops( self, path_info, blockchain_name, blockheight ): """ Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blocksta...
[ "def", "GET_blockchain_ops", "(", "self", ",", "path_info", ",", "blockchain_name", ",", "blockheight", ")", ":", "try", ":", "blockheight", "=", "int", "(", "blockheight", ")", "assert", "check_block", "(", "blockheight", ")", "except", ":", "return", "self",...
Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blockstack server
[ "Get", "the", "name", "s", "historic", "name", "operations", "Reply", "the", "list", "of", "nameops", "at", "the", "given", "block", "height", "Reply", "404", "for", "blockchains", "other", "than", "those", "supported", "Reply", "502", "for", "any", "error",...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1080-L1105
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_blockchain_name_record
def GET_blockchain_name_record( self, path_info, blockchain_name, name ): """ Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server """ if not chec...
python
def GET_blockchain_name_record( self, path_info, blockchain_name, name ): """ Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server """ if not chec...
[ "def", "GET_blockchain_name_record", "(", "self", ",", "path_info", ",", "blockchain_name", ",", "name", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(",...
Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server
[ "Get", "the", "name", "s", "blockchain", "record", "in", "full", "Reply", "the", "raw", "blockchain", "record", "on", "success", "Reply", "404", "if", "the", "name", "is", "not", "found", "Reply", "502", "if", "we", "have", "an", "error", "talking", "to"...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1108-L1130
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._get_balance
def _get_balance( self, get_address, min_confs ): """ Works only in test mode! Get the confirmed balance for an address """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] b...
python
def _get_balance( self, get_address, min_confs ): """ Works only in test mode! Get the confirmed balance for an address """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] b...
[ "def", "_get_balance", "(", "self", ",", "get_address", ",", "min_confs", ")", ":", "bitcoind_opts", "=", "get_bitcoin_opts", "(", ")", "bitcoind_host", "=", "bitcoind_opts", "[", "'bitcoind_server'", "]", "bitcoind_port", "=", "bitcoind_opts", "[", "'bitcoind_port'...
Works only in test mode! Get the confirmed balance for an address
[ "Works", "only", "in", "test", "mode!", "Get", "the", "confirmed", "balance", "for", "an", "address" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1210-L1233
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpoint.bind
def bind(self): """ Bind to our port """ log.debug("Set SO_REUSADDR") self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) # we want daemon threads, so we join on abrupt shutdown (applies if multithreaded) self.daemon_threads = True ...
python
def bind(self): """ Bind to our port """ log.debug("Set SO_REUSADDR") self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) # we want daemon threads, so we join on abrupt shutdown (applies if multithreaded) self.daemon_threads = True ...
[ "def", "bind", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Set SO_REUSADDR\"", ")", "self", ".", "socket", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_REUSEADDR", ",", "1", ")", "self", ".", "daemon_threads", "=",...
Bind to our port
[ "Bind", "to", "our", "port" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1624-L1635
train
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpoint.overloaded
def overloaded(self, client_addr): """ Deflect if we have too many inbound requests """ overloaded_txt = 'HTTP/1.0 429 Too Many Requests\r\nServer: BaseHTTP/0.3 Python/2.7.14+\r\nContent-type: text/plain\r\nContent-length: 17\r\n\r\nToo many requests' if BLOCKSTACK_TEST: ...
python
def overloaded(self, client_addr): """ Deflect if we have too many inbound requests """ overloaded_txt = 'HTTP/1.0 429 Too Many Requests\r\nServer: BaseHTTP/0.3 Python/2.7.14+\r\nContent-type: text/plain\r\nContent-length: 17\r\n\r\nToo many requests' if BLOCKSTACK_TEST: ...
[ "def", "overloaded", "(", "self", ",", "client_addr", ")", ":", "overloaded_txt", "=", "'HTTP/1.0 429 Too Many Requests\\r\\nServer: BaseHTTP/0.3 Python/2.7.14+\\r\\nContent-type: text/plain\\r\\nContent-length: 17\\r\\n\\r\\nToo many requests'", "if", "BLOCKSTACK_TEST", ":", "log", "....
Deflect if we have too many inbound requests
[ "Deflect", "if", "we", "have", "too", "many", "inbound", "requests" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1638-L1646
train
ansible/ansible-container
container/utils/_text.py
to_bytes
def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used...
python
def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used...
[ "def", "to_bytes", "(", "obj", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "None", ",", "nonstring", "=", "'simplerepr'", ")", ":", "if", "isinstance", "(", "obj", ",", "binary_type", ")", ":", "return", "obj", "original_errors", "=", "errors", ...
Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used as a traceback-free version of ``str(obj)``. :kwarg encoding: The en...
[ "Make", "sure", "that", "a", "string", "is", "a", "byte", "string" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/_text.py#L52-L163
train
ansible/ansible-container
container/utils/_text.py
to_text
def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used ...
python
def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used ...
[ "def", "to_text", "(", "obj", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "None", ",", "nonstring", "=", "'simplerepr'", ")", ":", "if", "isinstance", "(", "obj", ",", "text_type", ")", ":", "return", "obj", "if", "errors", "in", "_COMPOSED_ERRO...
Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used as a traceback-free version of ``str(obj)``. :kwarg encoding: The en...
[ "Make", "sure", "that", "a", "string", "is", "a", "text", "string" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/_text.py#L166-L254
train
ansible/ansible-container
container/core.py
push_images
def push_images(base_path, image_namespace, engine_obj, config, **kwargs): """ Pushes images to a Docker registry. Returns dict containing attributes used to push images. """ config_path = kwargs.get('config_path', engine_obj.auth_config_path) username = kwargs.get('username') password = kwargs.get('pas...
python
def push_images(base_path, image_namespace, engine_obj, config, **kwargs): """ Pushes images to a Docker registry. Returns dict containing attributes used to push images. """ config_path = kwargs.get('config_path', engine_obj.auth_config_path) username = kwargs.get('username') password = kwargs.get('pas...
[ "def", "push_images", "(", "base_path", ",", "image_namespace", ",", "engine_obj", ",", "config", ",", "**", "kwargs", ")", ":", "config_path", "=", "kwargs", ".", "get", "(", "'config_path'", ",", "engine_obj", ".", "auth_config_path", ")", "username", "=", ...
Pushes images to a Docker registry. Returns dict containing attributes used to push images.
[ "Pushes", "images", "to", "a", "Docker", "registry", ".", "Returns", "dict", "containing", "attributes", "used", "to", "push", "images", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L394-L467
train
ansible/ansible-container
container/core.py
remove_existing_container
def remove_existing_container(engine_obj, service_name, remove_volumes=False): """ Remove a container for an existing service. Handy for removing an existing conductor. """ conductor_container_id = engine_obj.get_container_id_for_service(service_name) if engine_obj.service_is_running(service_name): ...
python
def remove_existing_container(engine_obj, service_name, remove_volumes=False): """ Remove a container for an existing service. Handy for removing an existing conductor. """ conductor_container_id = engine_obj.get_container_id_for_service(service_name) if engine_obj.service_is_running(service_name): ...
[ "def", "remove_existing_container", "(", "engine_obj", ",", "service_name", ",", "remove_volumes", "=", "False", ")", ":", "conductor_container_id", "=", "engine_obj", ".", "get_container_id_for_service", "(", "service_name", ")", "if", "engine_obj", ".", "service_is_ru...
Remove a container for an existing service. Handy for removing an existing conductor.
[ "Remove", "a", "container", "for", "an", "existing", "service", ".", "Handy", "for", "removing", "an", "existing", "conductor", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L510-L518
train
ansible/ansible-container
container/core.py
resolve_push_to
def resolve_push_to(push_to, default_url, default_namespace): ''' Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, names...
python
def resolve_push_to(push_to, default_url, default_namespace): ''' Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, names...
[ "def", "resolve_push_to", "(", "push_to", ",", "default_url", ",", "default_namespace", ")", ":", "protocol", "=", "'http://'", "if", "push_to", ".", "startswith", "(", "'http://'", ")", "else", "'https://'", "url", "=", "push_to", "=", "REMOVE_HTTP", ".", "su...
Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, namespace
[ "Given", "a", "push", "-", "to", "value", "return", "the", "registry", "and", "namespace", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L522-L546
train
ansible/ansible-container
container/core.py
conductorcmd_push
def conductorcmd_push(engine_name, project_name, services, **kwargs): """ Push images to a registry """ username = kwargs.pop('username') password = kwargs.pop('password') email = kwargs.pop('email') url = kwargs.pop('url') namespace = kwargs.pop('namespace') tag = kwargs.pop('tag') conf...
python
def conductorcmd_push(engine_name, project_name, services, **kwargs): """ Push images to a registry """ username = kwargs.pop('username') password = kwargs.pop('password') email = kwargs.pop('email') url = kwargs.pop('url') namespace = kwargs.pop('namespace') tag = kwargs.pop('tag') conf...
[ "def", "conductorcmd_push", "(", "engine_name", ",", "project_name", ",", "services", ",", "**", "kwargs", ")", ":", "username", "=", "kwargs", ".", "pop", "(", "'username'", ")", "password", "=", "kwargs", ".", "pop", "(", "'password'", ")", "email", "=",...
Push images to a registry
[ "Push", "images", "to", "a", "registry" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L1038-L1069
train
ansible/ansible-container
container/openshift/deploy.py
Deploy.get_route_templates
def get_route_templates(self): """ Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port. """ def _get_published_ports(service_config): result = [] for port in s...
python
def get_route_templates(self): """ Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port. """ def _get_published_ports(service_config): result = [] for port in s...
[ "def", "get_route_templates", "(", "self", ")", ":", "def", "_get_published_ports", "(", "service_config", ")", ":", "result", "=", "[", "]", "for", "port", "in", "service_config", ".", "get", "(", "'ports'", ",", "[", "]", ")", ":", "protocol", "=", "'T...
Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port.
[ "Generate", "Openshift", "route", "templates", "or", "playbook", "tasks", ".", "Each", "port", "on", "a", "service", "definition", "found", "in", "container", ".", "yml", "represents", "an", "externally", "exposed", "port", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/openshift/deploy.py#L56-L117
train
ansible/ansible-container
container/docker/importer.py
DockerfileParser.preparse_iter
def preparse_iter(self): """ Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it. """ to_yield = {} la...
python
def preparse_iter(self): """ Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it. """ to_yield = {} la...
[ "def", "preparse_iter", "(", "self", ")", ":", "to_yield", "=", "{", "}", "last_directive", "=", "None", "lines_processed", "=", "0", "for", "line", "in", "self", ".", "lines_iter", "(", ")", ":", "if", "not", "line", ":", "continue", "if", "line", "."...
Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it.
[ "Comments", "can", "be", "anywhere", ".", "So", "break", "apart", "the", "Dockerfile", "into", "significant", "lines", "and", "any", "comments", "that", "precede", "them", ".", "And", "if", "a", "line", "is", "a", "carryover", "from", "the", "previous", "v...
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/importer.py#L120-L155
train
ansible/ansible-container
container/docker/engine.py
Engine.run_container
def run_container(self, image_id, service_name, **kwargs): """Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.""" run_kwargs = self.run_kwargs_for_service(service_name) run_kwargs.update(kwargs, relax=True) logge...
python
def run_container(self, image_id, service_name, **kwargs): """Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.""" run_kwargs = self.run_kwargs_for_service(service_name) run_kwargs.update(kwargs, relax=True) logge...
[ "def", "run_container", "(", "self", ",", "image_id", ",", "service_name", ",", "**", "kwargs", ")", ":", "run_kwargs", "=", "self", ".", "run_kwargs_for_service", "(", "service_name", ")", "run_kwargs", ".", "update", "(", "kwargs", ",", "relax", "=", "True...
Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.
[ "Run", "a", "particular", "container", ".", "The", "kwargs", "argument", "contains", "individual", "parameter", "overrides", "from", "the", "service", "definition", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L265-L281
train
ansible/ansible-container
container/docker/engine.py
Engine.push
def push(self, image_id, service_name, tag=None, namespace=None, url=None, username=None, password=None, repository_prefix=None, **kwargs): """ Push an image to a remote registry. """ auth_config = { 'username': username, 'password': password ...
python
def push(self, image_id, service_name, tag=None, namespace=None, url=None, username=None, password=None, repository_prefix=None, **kwargs): """ Push an image to a remote registry. """ auth_config = { 'username': username, 'password': password ...
[ "def", "push", "(", "self", ",", "image_id", ",", "service_name", ",", "tag", "=", "None", ",", "namespace", "=", "None", ",", "url", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "repository_prefix", "=", "None", ",", ...
Push an image to a remote registry.
[ "Push", "an", "image", "to", "a", "remote", "registry", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L895-L941
train
ansible/ansible-container
container/docker/engine.py
Engine.login
def login(self, username, password, email, url, config_path): """ If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data. """ if username and password: try: self.client.l...
python
def login(self, username, password, email, url, config_path): """ If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data. """ if username and password: try: self.client.l...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "email", ",", "url", ",", "config_path", ")", ":", "if", "username", "and", "password", ":", "try", ":", "self", ".", "client", ".", "login", "(", "username", "=", "username", ",", "...
If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data.
[ "If", "username", "and", "password", "are", "provided", "authenticate", "with", "the", "registry", ".", "Otherwise", "check", "the", "config", "file", "for", "existing", "authentication", "data", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1186-L1208
train
ansible/ansible-container
container/docker/engine.py
Engine._update_config_file
def _update_config_file(username, password, email, url, config_path): """Update the config file with the authorization.""" try: # read the existing config config = json.load(open(config_path, "r")) except ValueError: config = dict() if not config.get(...
python
def _update_config_file(username, password, email, url, config_path): """Update the config file with the authorization.""" try: # read the existing config config = json.load(open(config_path, "r")) except ValueError: config = dict() if not config.get(...
[ "def", "_update_config_file", "(", "username", ",", "password", ",", "email", ",", "url", ",", "config_path", ")", ":", "try", ":", "config", "=", "json", ".", "load", "(", "open", "(", "config_path", ",", "\"r\"", ")", ")", "except", "ValueError", ":", ...
Update the config file with the authorization.
[ "Update", "the", "config", "file", "with", "the", "authorization", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1212-L1235
train
ansible/ansible-container
container/docker/engine.py
Engine._get_registry_auth
def _get_registry_auth(registry_url, config_path): """ Retrieve from the config file the current authentication for a given URL, and return the username, password """ username = None password = None try: docker_config = json.load(open(config_path)) ...
python
def _get_registry_auth(registry_url, config_path): """ Retrieve from the config file the current authentication for a given URL, and return the username, password """ username = None password = None try: docker_config = json.load(open(config_path)) ...
[ "def", "_get_registry_auth", "(", "registry_url", ",", "config_path", ")", ":", "username", "=", "None", "password", "=", "None", "try", ":", "docker_config", "=", "json", ".", "load", "(", "open", "(", "config_path", ")", ")", "except", "ValueError", ":", ...
Retrieve from the config file the current authentication for a given URL, and return the username, password
[ "Retrieve", "from", "the", "config", "file", "the", "current", "authentication", "for", "a", "given", "URL", "and", "return", "the", "username", "password" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1239-L1256
train
ansible/ansible-container
container/utils/__init__.py
resolve_role_to_path
def resolve_role_to_path(role): """ Given a role definition from a service's list of roles, returns the file path to the role """ loader = DataLoader() try: variable_manager = VariableManager(loader=loader) except TypeError: # If Ansible prior to ansible/ansible@8f97aef1a365 ...
python
def resolve_role_to_path(role): """ Given a role definition from a service's list of roles, returns the file path to the role """ loader = DataLoader() try: variable_manager = VariableManager(loader=loader) except TypeError: # If Ansible prior to ansible/ansible@8f97aef1a365 ...
[ "def", "resolve_role_to_path", "(", "role", ")", ":", "loader", "=", "DataLoader", "(", ")", "try", ":", "variable_manager", "=", "VariableManager", "(", "loader", "=", "loader", ")", "except", "TypeError", ":", "variable_manager", "=", "VariableManager", "(", ...
Given a role definition from a service's list of roles, returns the file path to the role
[ "Given", "a", "role", "definition", "from", "a", "service", "s", "list", "of", "roles", "returns", "the", "file", "path", "to", "the", "role" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/__init__.py#L225-L238
train
ansible/ansible-container
container/utils/__init__.py
get_role_fingerprint
def get_role_fingerprint(role, service_name, config_vars): """ Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency """ def hash_file(hash_obj, file_path): blocksize = 64 * 1024 ...
python
def get_role_fingerprint(role, service_name, config_vars): """ Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency """ def hash_file(hash_obj, file_path): blocksize = 64 * 1024 ...
[ "def", "get_role_fingerprint", "(", "role", ",", "service_name", ",", "config_vars", ")", ":", "def", "hash_file", "(", "hash_obj", ",", "file_path", ")", ":", "blocksize", "=", "64", "*", "1024", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", ...
Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency
[ "Given", "a", "role", "definition", "from", "a", "service", "s", "list", "of", "roles", "returns", "a", "hexdigest", "based", "on", "the", "role", "definition", "the", "role", "contents", "and", "the", "hexdigest", "of", "each", "dependency" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/__init__.py#L256-L323
train
litl/backoff
backoff/_decorator.py
on_predicate
def on_predicate(wait_gen, predicate=operator.not_, max_tries=None, max_time=None, jitter=full_jitter, on_success=None, on_backoff=None, on_giveup=None, logger='backoff', ...
python
def on_predicate(wait_gen, predicate=operator.not_, max_tries=None, max_time=None, jitter=full_jitter, on_success=None, on_backoff=None, on_giveup=None, logger='backoff', ...
[ "def", "on_predicate", "(", "wait_gen", ",", "predicate", "=", "operator", ".", "not_", ",", "max_tries", "=", "None", ",", "max_time", "=", "None", ",", "jitter", "=", "full_jitter", ",", "on_success", "=", "None", ",", "on_backoff", "=", "None", ",", "...
Returns decorator for backoff and retry triggered by predicate. Args: wait_gen: A generator yielding successive wait times in seconds. predicate: A function which when called on the return value of the target function will trigger backoff when considered truthily...
[ "Returns", "decorator", "for", "backoff", "and", "retry", "triggered", "by", "predicate", "." ]
229d30adce4128f093550a1761c49594c78df4b4
https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_decorator.py#L20-L106
train
litl/backoff
backoff/_wait_gen.py
expo
def expo(base=2, factor=1, max_value=None): """Generator for exponential decay. Args: base: The mathematical base of the exponentiation operation factor: Factor to multiply the exponentation by. max_value: The maximum value to yield. Once the value in the true exponential s...
python
def expo(base=2, factor=1, max_value=None): """Generator for exponential decay. Args: base: The mathematical base of the exponentiation operation factor: Factor to multiply the exponentation by. max_value: The maximum value to yield. Once the value in the true exponential s...
[ "def", "expo", "(", "base", "=", "2", ",", "factor", "=", "1", ",", "max_value", "=", "None", ")", ":", "n", "=", "0", "while", "True", ":", "a", "=", "factor", "*", "base", "**", "n", "if", "max_value", "is", "None", "or", "a", "<", "max_value...
Generator for exponential decay. Args: base: The mathematical base of the exponentiation operation factor: Factor to multiply the exponentation by. max_value: The maximum value to yield. Once the value in the true exponential sequence exceeds this, the value of max...
[ "Generator", "for", "exponential", "decay", "." ]
229d30adce4128f093550a1761c49594c78df4b4
https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_wait_gen.py#L6-L23
train
litl/backoff
backoff/_wait_gen.py
fibo
def fibo(max_value=None): """Generator for fibonaccial decay. Args: max_value: The maximum value to yield. Once the value in the true fibonacci sequence exceeds this, the value of max_value will forever after be yielded. """ a = 1 b = 1 while True: if m...
python
def fibo(max_value=None): """Generator for fibonaccial decay. Args: max_value: The maximum value to yield. Once the value in the true fibonacci sequence exceeds this, the value of max_value will forever after be yielded. """ a = 1 b = 1 while True: if m...
[ "def", "fibo", "(", "max_value", "=", "None", ")", ":", "a", "=", "1", "b", "=", "1", "while", "True", ":", "if", "max_value", "is", "None", "or", "a", "<", "max_value", ":", "yield", "a", "a", ",", "b", "=", "b", ",", "a", "+", "b", "else", ...
Generator for fibonaccial decay. Args: max_value: The maximum value to yield. Once the value in the true fibonacci sequence exceeds this, the value of max_value will forever after be yielded.
[ "Generator", "for", "fibonaccial", "decay", "." ]
229d30adce4128f093550a1761c49594c78df4b4
https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_wait_gen.py#L26-L41
train
litl/backoff
backoff/_wait_gen.py
constant
def constant(interval=1): """Generator for constant intervals. Args: interval: A constant value to yield or an iterable of such values. """ try: itr = iter(interval) except TypeError: itr = itertools.repeat(interval) for val in itr: yield val
python
def constant(interval=1): """Generator for constant intervals. Args: interval: A constant value to yield or an iterable of such values. """ try: itr = iter(interval) except TypeError: itr = itertools.repeat(interval) for val in itr: yield val
[ "def", "constant", "(", "interval", "=", "1", ")", ":", "try", ":", "itr", "=", "iter", "(", "interval", ")", "except", "TypeError", ":", "itr", "=", "itertools", ".", "repeat", "(", "interval", ")", "for", "val", "in", "itr", ":", "yield", "val" ]
Generator for constant intervals. Args: interval: A constant value to yield or an iterable of such values.
[ "Generator", "for", "constant", "intervals", "." ]
229d30adce4128f093550a1761c49594c78df4b4
https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_wait_gen.py#L44-L56
train
crytic/slither
slither/detectors/erc20/incorrect_interface.py
IncorrectERC20InterfaceDetection.detect_incorrect_erc20_interface
def detect_incorrect_erc20_interface(contract): """ Detect incorrect ERC20 interface Returns: list(str) : list of incorrect function signatures """ functions = [f for f in contract.functions if f.contract == contract and \ IncorrectERC20InterfaceDetectio...
python
def detect_incorrect_erc20_interface(contract): """ Detect incorrect ERC20 interface Returns: list(str) : list of incorrect function signatures """ functions = [f for f in contract.functions if f.contract == contract and \ IncorrectERC20InterfaceDetectio...
[ "def", "detect_incorrect_erc20_interface", "(", "contract", ")", ":", "functions", "=", "[", "f", "for", "f", "in", "contract", ".", "functions", "if", "f", ".", "contract", "==", "contract", "and", "IncorrectERC20InterfaceDetection", ".", "incorrect_erc20_interface...
Detect incorrect ERC20 interface Returns: list(str) : list of incorrect function signatures
[ "Detect", "incorrect", "ERC20", "interface" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/erc20/incorrect_interface.py#L49-L57
train
crytic/slither
slither/detectors/erc20/incorrect_interface.py
IncorrectERC20InterfaceDetection._detect
def _detect(self): """ Detect incorrect erc20 interface Returns: dict: [contrat name] = set(str) events """ results = [] for c in self.contracts: functions = IncorrectERC20InterfaceDetection.detect_incorrect_erc20_interface(c) if functions: ...
python
def _detect(self): """ Detect incorrect erc20 interface Returns: dict: [contrat name] = set(str) events """ results = [] for c in self.contracts: functions = IncorrectERC20InterfaceDetection.detect_incorrect_erc20_interface(c) if functions: ...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "contracts", ":", "functions", "=", "IncorrectERC20InterfaceDetection", ".", "detect_incorrect_erc20_interface", "(", "c", ")", "if", "functions", ":", "info", ...
Detect incorrect erc20 interface Returns: dict: [contrat name] = set(str) events
[ "Detect", "incorrect", "erc20", "interface" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/erc20/incorrect_interface.py#L59-L78
train
crytic/slither
slither/detectors/shadowing/local.py
LocalShadowing.detect_shadowing_definitions
def detect_shadowing_definitions(self, contract): """ Detects if functions, access modifiers, events, state variables, and local variables are named after reserved keywords. Any such definitions are returned in a list. Returns: list of tuple: (type, contract name, definition)""" ...
python
def detect_shadowing_definitions(self, contract): """ Detects if functions, access modifiers, events, state variables, and local variables are named after reserved keywords. Any such definitions are returned in a list. Returns: list of tuple: (type, contract name, definition)""" ...
[ "def", "detect_shadowing_definitions", "(", "self", ",", "contract", ")", ":", "result", "=", "[", "]", "for", "function", "in", "contract", ".", "functions", "+", "contract", ".", "modifiers", ":", "if", "function", ".", "contract", "!=", "contract", ":", ...
Detects if functions, access modifiers, events, state variables, and local variables are named after reserved keywords. Any such definitions are returned in a list. Returns: list of tuple: (type, contract name, definition)
[ "Detects", "if", "functions", "access", "modifiers", "events", "state", "variables", "and", "local", "variables", "are", "named", "after", "reserved", "keywords", ".", "Any", "such", "definitions", "are", "returned", "in", "a", "list", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/shadowing/local.py#L51-L90
train
crytic/slither
slither/detectors/shadowing/local.py
LocalShadowing._detect
def _detect(self): """ Detect shadowing local variables Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'} """ results = [] for contract in self.contracts: shadows = self.detect_shadowing_definitions(contr...
python
def _detect(self): """ Detect shadowing local variables Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'} """ results = [] for contract in self.contracts: shadows = self.detect_shadowing_definitions(contr...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "contract", "in", "self", ".", "contracts", ":", "shadows", "=", "self", ".", "detect_shadowing_definitions", "(", "contract", ")", "if", "shadows", ":", "for", "shadow", "in", "sh...
Detect shadowing local variables Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'}
[ "Detect", "shadowing", "local", "variables" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/shadowing/local.py#L92-L131
train
crytic/slither
slither/detectors/variables/possible_const_state_variables.py
ConstCandidateStateVars._detect
def _detect(self): """ Detect state variables that could be const """ results = [] all_info = '' all_variables = [c.state_variables for c in self.slither.contracts] all_variables = set([item for sublist in all_variables for item in sublist]) all_non_constant_elem...
python
def _detect(self): """ Detect state variables that could be const """ results = [] all_info = '' all_variables = [c.state_variables for c in self.slither.contracts] all_variables = set([item for sublist in all_variables for item in sublist]) all_non_constant_elem...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "all_info", "=", "''", "all_variables", "=", "[", "c", ".", "state_variables", "for", "c", "in", "self", ".", "slither", ".", "contracts", "]", "all_variables", "=", "set", "(", "[", ...
Detect state variables that could be const
[ "Detect", "state", "variables", "that", "could", "be", "const" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/variables/possible_const_state_variables.py#L66-L96
train
crytic/slither
slither/detectors/functions/suicidal.py
Suicidal.detect_suicidal_func
def detect_suicidal_func(func): """ Detect if the function is suicidal Detect the public functions calling suicide/selfdestruct without protection Returns: (bool): True if the function is suicidal """ if func.is_constructor: return False if func...
python
def detect_suicidal_func(func): """ Detect if the function is suicidal Detect the public functions calling suicide/selfdestruct without protection Returns: (bool): True if the function is suicidal """ if func.is_constructor: return False if func...
[ "def", "detect_suicidal_func", "(", "func", ")", ":", "if", "func", ".", "is_constructor", ":", "return", "False", "if", "func", ".", "visibility", "!=", "'public'", ":", "return", "False", "calls", "=", "[", "c", ".", "name", "for", "c", "in", "func", ...
Detect if the function is suicidal Detect the public functions calling suicide/selfdestruct without protection Returns: (bool): True if the function is suicidal
[ "Detect", "if", "the", "function", "is", "suicidal" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/suicidal.py#L37-L58
train
crytic/slither
slither/detectors/functions/suicidal.py
Suicidal._detect
def _detect(self): """ Detect the suicidal functions """ results = [] for c in self.contracts: functions = self.detect_suicidal(c) for func in functions: txt = "{}.{} ({}) allows anyone to destruct the contract\n" info = txt.format...
python
def _detect(self): """ Detect the suicidal functions """ results = [] for c in self.contracts: functions = self.detect_suicidal(c) for func in functions: txt = "{}.{} ({}) allows anyone to destruct the contract\n" info = txt.format...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "contracts", ":", "functions", "=", "self", ".", "detect_suicidal", "(", "c", ")", "for", "func", "in", "functions", ":", "txt", "=", "\"{}.{} ({}) allows...
Detect the suicidal functions
[ "Detect", "the", "suicidal", "functions" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/suicidal.py#L67-L84
train
crytic/slither
slither/detectors/operations/unused_return_values.py
UnusedReturnValues._detect
def _detect(self): """ Detect high level calls which return a value that are never used """ results = [] for c in self.slither.contracts: for f in c.functions + c.modifiers: if f.contract != c: continue unused_return = self....
python
def _detect(self): """ Detect high level calls which return a value that are never used """ results = [] for c in self.slither.contracts: for f in c.functions + c.modifiers: if f.contract != c: continue unused_return = self....
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "slither", ".", "contracts", ":", "for", "f", "in", "c", ".", "functions", "+", "c", ".", "modifiers", ":", "if", "f", ".", "contract", "!=", "c", ...
Detect high level calls which return a value that are never used
[ "Detect", "high", "level", "calls", "which", "return", "a", "value", "that", "are", "never", "used" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/operations/unused_return_values.py#L61-L83
train
crytic/slither
slither/printers/inheritance/inheritance_graph.py
PrinterInheritanceGraph._summary
def _summary(self, contract): """ Build summary using HTML """ ret = '' # Add arrows (number them if there is more than one path so we know order of declaration for inheritance). if len(contract.immediate_inheritance) == 1: ret += '%s -> %s;\n' % (contrac...
python
def _summary(self, contract): """ Build summary using HTML """ ret = '' # Add arrows (number them if there is more than one path so we know order of declaration for inheritance). if len(contract.immediate_inheritance) == 1: ret += '%s -> %s;\n' % (contrac...
[ "def", "_summary", "(", "self", ",", "contract", ")", ":", "ret", "=", "''", "if", "len", "(", "contract", ".", "immediate_inheritance", ")", "==", "1", ":", "ret", "+=", "'%s -> %s;\\n'", "%", "(", "contract", ".", "name", ",", "contract", ".", "immed...
Build summary using HTML
[ "Build", "summary", "using", "HTML" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/printers/inheritance/inheritance_graph.py#L103-L165
train
crytic/slither
slither/detectors/shadowing/builtin_symbols.py
BuiltinSymbolShadowing.detect_builtin_shadowing_definitions
def detect_builtin_shadowing_definitions(self, contract): """ Detects if functions, access modifiers, events, state variables, or local variables are named after built-in symbols. Any such definitions are returned in a list. Returns: list of tuple: (type, definition, [local vari...
python
def detect_builtin_shadowing_definitions(self, contract): """ Detects if functions, access modifiers, events, state variables, or local variables are named after built-in symbols. Any such definitions are returned in a list. Returns: list of tuple: (type, definition, [local vari...
[ "def", "detect_builtin_shadowing_definitions", "(", "self", ",", "contract", ")", ":", "result", "=", "[", "]", "for", "function", "in", "contract", ".", "functions", ":", "if", "function", ".", "contract", "==", "contract", ":", "if", "self", ".", "is_built...
Detects if functions, access modifiers, events, state variables, or local variables are named after built-in symbols. Any such definitions are returned in a list. Returns: list of tuple: (type, definition, [local variable parent])
[ "Detects", "if", "functions", "access", "modifiers", "events", "state", "variables", "or", "local", "variables", "are", "named", "after", "built", "-", "in", "symbols", ".", "Any", "such", "definitions", "are", "returned", "in", "a", "list", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/shadowing/builtin_symbols.py#L83-L112
train
crytic/slither
slither/detectors/shadowing/builtin_symbols.py
BuiltinSymbolShadowing._detect
def _detect(self): """ Detect shadowing of built-in symbols Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'} """ results = [] for contract in self.contracts: shadows = self.detect_builtin_shadowing_defin...
python
def _detect(self): """ Detect shadowing of built-in symbols Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'} """ results = [] for contract in self.contracts: shadows = self.detect_builtin_shadowing_defin...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "contract", "in", "self", ".", "contracts", ":", "shadows", "=", "self", ".", "detect_builtin_shadowing_definitions", "(", "contract", ")", "if", "shadows", ":", "for", "shadow", "in...
Detect shadowing of built-in symbols Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func', 'shadow'}
[ "Detect", "shadowing", "of", "built", "-", "in", "symbols" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/shadowing/builtin_symbols.py#L114-L152
train
crytic/slither
slither/utils/inheritance_analysis.py
detect_c3_function_shadowing
def detect_c3_function_shadowing(contract): """ Detects and obtains functions which are indirectly shadowed via multiple inheritance by C3 linearization properties, despite not directly inheriting from each other. :param contract: The contract to check for potential C3 linearization shadowing within. ...
python
def detect_c3_function_shadowing(contract): """ Detects and obtains functions which are indirectly shadowed via multiple inheritance by C3 linearization properties, despite not directly inheriting from each other. :param contract: The contract to check for potential C3 linearization shadowing within. ...
[ "def", "detect_c3_function_shadowing", "(", "contract", ")", ":", "results", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "len", "(", "contract", ".", "immediate_inheritance", ")", "-", "1", ")", ":", "inherited_contract1", "=", "contract", "."...
Detects and obtains functions which are indirectly shadowed via multiple inheritance by C3 linearization properties, despite not directly inheriting from each other. :param contract: The contract to check for potential C3 linearization shadowing within. :return: A list of list of tuples: (contract, functio...
[ "Detects", "and", "obtains", "functions", "which", "are", "indirectly", "shadowed", "via", "multiple", "inheritance", "by", "C3", "linearization", "properties", "despite", "not", "directly", "inheriting", "from", "each", "other", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/utils/inheritance_analysis.py#L6-L50
train
crytic/slither
slither/detectors/variables/uninitialized_state_variables.py
UninitializedStateVarsDetection._detect
def _detect(self): """ Detect uninitialized state variables Recursively visit the calls Returns: dict: [contract name] = set(state variable uninitialized) """ results = [] for c in self.slither.contracts_derived: ret = self.detect_uninitialized(c)...
python
def _detect(self): """ Detect uninitialized state variables Recursively visit the calls Returns: dict: [contract name] = set(state variable uninitialized) """ results = [] for c in self.slither.contracts_derived: ret = self.detect_uninitialized(c)...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "slither", ".", "contracts_derived", ":", "ret", "=", "self", ".", "detect_uninitialized", "(", "c", ")", "for", "variable", ",", "functions", "in", "ret"...
Detect uninitialized state variables Recursively visit the calls Returns: dict: [contract name] = set(state variable uninitialized)
[ "Detect", "uninitialized", "state", "variables" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/variables/uninitialized_state_variables.py#L84-L110
train
crytic/slither
slither/detectors/functions/external_function.py
ExternalFunction.detect_functions_called
def detect_functions_called(contract): """ Returns a list of InternallCall, SolidityCall calls made in a function Returns: (list): List of all InternallCall, SolidityCall """ result = [] # Obtain all functions reachable by this contract. for func...
python
def detect_functions_called(contract): """ Returns a list of InternallCall, SolidityCall calls made in a function Returns: (list): List of all InternallCall, SolidityCall """ result = [] # Obtain all functions reachable by this contract. for func...
[ "def", "detect_functions_called", "(", "contract", ")", ":", "result", "=", "[", "]", "for", "func", "in", "contract", ".", "all_functions_called", ":", "for", "node", "in", "func", ".", "nodes", ":", "for", "ir", "in", "node", ".", "irs", ":", "if", "...
Returns a list of InternallCall, SolidityCall calls made in a function Returns: (list): List of all InternallCall, SolidityCall
[ "Returns", "a", "list", "of", "InternallCall", "SolidityCall", "calls", "made", "in", "a", "function" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/external_function.py#L27-L43
train
crytic/slither
slither/detectors/functions/external_function.py
ExternalFunction._contains_internal_dynamic_call
def _contains_internal_dynamic_call(contract): """ Checks if a contract contains a dynamic call either in a direct definition, or through inheritance. Returns: (boolean): True if this contract contains a dynamic call (including through inheritance). """ for func in c...
python
def _contains_internal_dynamic_call(contract): """ Checks if a contract contains a dynamic call either in a direct definition, or through inheritance. Returns: (boolean): True if this contract contains a dynamic call (including through inheritance). """ for func in c...
[ "def", "_contains_internal_dynamic_call", "(", "contract", ")", ":", "for", "func", "in", "contract", ".", "all_functions_called", ":", "for", "node", "in", "func", ".", "nodes", ":", "for", "ir", "in", "node", ".", "irs", ":", "if", "isinstance", "(", "ir...
Checks if a contract contains a dynamic call either in a direct definition, or through inheritance. Returns: (boolean): True if this contract contains a dynamic call (including through inheritance).
[ "Checks", "if", "a", "contract", "contains", "a", "dynamic", "call", "either", "in", "a", "direct", "definition", "or", "through", "inheritance", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/external_function.py#L46-L58
train
crytic/slither
slither/detectors/functions/external_function.py
ExternalFunction.get_base_most_function
def get_base_most_function(function): """ Obtains the base function definition for the provided function. This could be used to obtain the original definition of a function, if the provided function is an override. Returns: (function): Returns the base-most function of a pro...
python
def get_base_most_function(function): """ Obtains the base function definition for the provided function. This could be used to obtain the original definition of a function, if the provided function is an override. Returns: (function): Returns the base-most function of a pro...
[ "def", "get_base_most_function", "(", "function", ")", ":", "for", "contract", "in", "function", ".", "contract", ".", "inheritance", "+", "[", "function", ".", "contract", "]", ":", "for", "f", "in", "contract", ".", "functions_not_inherited", ":", "if", "f...
Obtains the base function definition for the provided function. This could be used to obtain the original definition of a function, if the provided function is an override. Returns: (function): Returns the base-most function of a provided function. (The original definition).
[ "Obtains", "the", "base", "function", "definition", "for", "the", "provided", "function", ".", "This", "could", "be", "used", "to", "obtain", "the", "original", "definition", "of", "a", "function", "if", "the", "provided", "function", "is", "an", "override", ...
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/external_function.py#L61-L82
train
crytic/slither
slither/detectors/functions/external_function.py
ExternalFunction.get_all_function_definitions
def get_all_function_definitions(base_most_function): """ Obtains all function definitions given a base-most function. This includes the provided function, plus any overrides of that function. Returns: (list): Returns any the provided function and any overriding functions de...
python
def get_all_function_definitions(base_most_function): """ Obtains all function definitions given a base-most function. This includes the provided function, plus any overrides of that function. Returns: (list): Returns any the provided function and any overriding functions de...
[ "def", "get_all_function_definitions", "(", "base_most_function", ")", ":", "return", "[", "base_most_function", "]", "+", "[", "function", "for", "derived_contract", "in", "base_most_function", ".", "contract", ".", "derived_contracts", "for", "function", "in", "deri...
Obtains all function definitions given a base-most function. This includes the provided function, plus any overrides of that function. Returns: (list): Returns any the provided function and any overriding functions defined for it.
[ "Obtains", "all", "function", "definitions", "given", "a", "base", "-", "most", "function", ".", "This", "includes", "the", "provided", "function", "plus", "any", "overrides", "of", "that", "function", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/external_function.py#L85-L97
train
crytic/slither
slither/detectors/functions/complex_function.py
ComplexFunction.detect_complex_func
def detect_complex_func(func): """Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7 """ result = [] code_complexity = compute_cyclomatic_complexity(func) if code_complexity > ComplexFunction.MAX_CYCLOMATIC_COMPLEXITY: r...
python
def detect_complex_func(func): """Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7 """ result = [] code_complexity = compute_cyclomatic_complexity(func) if code_complexity > ComplexFunction.MAX_CYCLOMATIC_COMPLEXITY: r...
[ "def", "detect_complex_func", "(", "func", ")", ":", "result", "=", "[", "]", "code_complexity", "=", "compute_cyclomatic_complexity", "(", "func", ")", "if", "code_complexity", ">", "ComplexFunction", ".", "MAX_CYCLOMATIC_COMPLEXITY", ":", "result", ".", "append", ...
Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7
[ "Detect", "the", "cyclomatic", "complexity", "of", "the", "contract", "functions", "shouldn", "t", "be", "greater", "than", "7" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/complex_function.py#L36-L73
train
crytic/slither
slither/detectors/variables/unused_state_variables.py
UnusedStateVars._detect
def _detect(self): """ Detect unused state variables """ results = [] for c in self.slither.contracts_derived: unusedVars = self.detect_unused(c) if unusedVars: info = '' for var in unusedVars: info += "{}.{} ({}...
python
def _detect(self): """ Detect unused state variables """ results = [] for c in self.slither.contracts_derived: unusedVars = self.detect_unused(c) if unusedVars: info = '' for var in unusedVars: info += "{}.{} ({}...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "slither", ".", "contracts_derived", ":", "unusedVars", "=", "self", ".", "detect_unused", "(", "c", ")", "if", "unusedVars", ":", "info", "=", "''", "f...
Detect unused state variables
[ "Detect", "unused", "state", "variables" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/variables/unused_state_variables.py#L51-L70
train
crytic/slither
slither/detectors/variables/uninitialized_local_variables.py
UninitializedLocalVars._detect
def _detect(self): """ Detect uninitialized local variables Recursively visit the calls Returns: dict: [contract name] = set(local variable uninitialized) """ results = [] self.results = [] self.visited_all_paths = {} for contract in self.sl...
python
def _detect(self): """ Detect uninitialized local variables Recursively visit the calls Returns: dict: [contract name] = set(local variable uninitialized) """ results = [] self.results = [] self.visited_all_paths = {} for contract in self.sl...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "self", ".", "results", "=", "[", "]", "self", ".", "visited_all_paths", "=", "{", "}", "for", "contract", "in", "self", ".", "slither", ".", "contracts", ":", "for", "function", "in"...
Detect uninitialized local variables Recursively visit the calls Returns: dict: [contract name] = set(local variable uninitialized)
[ "Detect", "uninitialized", "local", "variables" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/variables/uninitialized_local_variables.py#L79-L116
train
crytic/slither
slither/detectors/erc20/unindexed_event_parameters.py
UnindexedERC20EventParameters._detect
def _detect(self): """ Detect un-indexed ERC20 event parameters in all contracts. """ results = [] for c in self.contracts: unindexed_params = self.detect_erc20_unindexed_event_params(c) if unindexed_params: info = "{} ({}) does not mark im...
python
def _detect(self): """ Detect un-indexed ERC20 event parameters in all contracts. """ results = [] for c in self.contracts: unindexed_params = self.detect_erc20_unindexed_event_params(c) if unindexed_params: info = "{} ({}) does not mark im...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "contracts", ":", "unindexed_params", "=", "self", ".", "detect_erc20_unindexed_event_params", "(", "c", ")", "if", "unindexed_params", ":", "info", "=", "\"{...
Detect un-indexed ERC20 event parameters in all contracts.
[ "Detect", "un", "-", "indexed", "ERC20", "event", "parameters", "in", "all", "contracts", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/erc20/unindexed_event_parameters.py#L67-L85
train
crytic/slither
slither/core/slither_core.py
Slither.print_functions
def print_functions(self, d): """ Export all the functions to dot files """ for c in self.contracts: for f in c.functions: f.cfg_to_dot(os.path.join(d, '{}.{}.dot'.format(c.name, f.name)))
python
def print_functions(self, d): """ Export all the functions to dot files """ for c in self.contracts: for f in c.functions: f.cfg_to_dot(os.path.join(d, '{}.{}.dot'.format(c.name, f.name)))
[ "def", "print_functions", "(", "self", ",", "d", ")", ":", "for", "c", "in", "self", ".", "contracts", ":", "for", "f", "in", "c", ".", "functions", ":", "f", ".", "cfg_to_dot", "(", "os", ".", "path", ".", "join", "(", "d", ",", "'{}.{}.dot'", "...
Export all the functions to dot files
[ "Export", "all", "the", "functions", "to", "dot", "files" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/slither_core.py#L155-L161
train
crytic/slither
slither/printers/inheritance/inheritance.py
PrinterInheritance.output
def output(self, filename): """ Output the inheritance relation _filename is not used Args: _filename(string) """ info = 'Inheritance\n' if not self.contracts: return info += blue('Child_Contract -> ') + green('Im...
python
def output(self, filename): """ Output the inheritance relation _filename is not used Args: _filename(string) """ info = 'Inheritance\n' if not self.contracts: return info += blue('Child_Contract -> ') + green('Im...
[ "def", "output", "(", "self", ",", "filename", ")", ":", "info", "=", "'Inheritance\\n'", "if", "not", "self", ".", "contracts", ":", "return", "info", "+=", "blue", "(", "'Child_Contract -> '", ")", "+", "green", "(", "'Immediate_Base_Contracts'", ")", "inf...
Output the inheritance relation _filename is not used Args: _filename(string)
[ "Output", "the", "inheritance", "relation" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/printers/inheritance/inheritance.py#L23-L58
train
crytic/slither
slither/detectors/variables/uninitialized_storage_variables.py
UninitializedStorageVars._detect
def _detect(self): """ Detect uninitialized storage variables Recursively visit the calls Returns: dict: [contract name] = set(storage variable uninitialized) """ results = [] self.results = [] self.visited_all_paths = {} for contract in sel...
python
def _detect(self): """ Detect uninitialized storage variables Recursively visit the calls Returns: dict: [contract name] = set(storage variable uninitialized) """ results = [] self.results = [] self.visited_all_paths = {} for contract in sel...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "self", ".", "results", "=", "[", "]", "self", ".", "visited_all_paths", "=", "{", "}", "for", "contract", "in", "self", ".", "slither", ".", "contracts", ":", "for", "function", "in"...
Detect uninitialized storage variables Recursively visit the calls Returns: dict: [contract name] = set(storage variable uninitialized)
[ "Detect", "uninitialized", "storage", "variables" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/variables/uninitialized_storage_variables.py#L86-L117
train
crytic/slither
slither/detectors/reentrancy/reentrancy.py
Reentrancy._can_callback
def _can_callback(self, irs): """ Detect if the node contains a call that can be used to re-entrance Consider as valid target: - low level call - high level call Do not consider Send/Transfer as there is not enough gas """ ...
python
def _can_callback(self, irs): """ Detect if the node contains a call that can be used to re-entrance Consider as valid target: - low level call - high level call Do not consider Send/Transfer as there is not enough gas """ ...
[ "def", "_can_callback", "(", "self", ",", "irs", ")", ":", "for", "ir", "in", "irs", ":", "if", "isinstance", "(", "ir", ",", "LowLevelCall", ")", ":", "return", "True", "if", "isinstance", "(", "ir", ",", "HighLevelCall", ")", "and", "not", "isinstanc...
Detect if the node contains a call that can be used to re-entrance Consider as valid target: - low level call - high level call Do not consider Send/Transfer as there is not enough gas
[ "Detect", "if", "the", "node", "contains", "a", "call", "that", "can", "be", "used", "to", "re", "-", "entrance" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/reentrancy/reentrancy.py#L37-L68
train
crytic/slither
slither/detectors/reentrancy/reentrancy.py
Reentrancy._can_send_eth
def _can_send_eth(irs): """ Detect if the node can send eth """ for ir in irs: if isinstance(ir, (HighLevelCall, LowLevelCall, Transfer, Send)): if ir.call_value: return True return False
python
def _can_send_eth(irs): """ Detect if the node can send eth """ for ir in irs: if isinstance(ir, (HighLevelCall, LowLevelCall, Transfer, Send)): if ir.call_value: return True return False
[ "def", "_can_send_eth", "(", "irs", ")", ":", "for", "ir", "in", "irs", ":", "if", "isinstance", "(", "ir", ",", "(", "HighLevelCall", ",", "LowLevelCall", ",", "Transfer", ",", "Send", ")", ")", ":", "if", "ir", ".", "call_value", ":", "return", "Tr...
Detect if the node can send eth
[ "Detect", "if", "the", "node", "can", "send", "eth" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/reentrancy/reentrancy.py#L71-L79
train
crytic/slither
slither/core/cfg/node.py
Node.remove_father
def remove_father(self, father): """ Remove the father node. Do nothing if the node is not a father Args: fathers: list of fathers to add """ self._fathers = [x for x in self._fathers if x.node_id != father.node_id]
python
def remove_father(self, father): """ Remove the father node. Do nothing if the node is not a father Args: fathers: list of fathers to add """ self._fathers = [x for x in self._fathers if x.node_id != father.node_id]
[ "def", "remove_father", "(", "self", ",", "father", ")", ":", "self", ".", "_fathers", "=", "[", "x", "for", "x", "in", "self", ".", "_fathers", "if", "x", ".", "node_id", "!=", "father", ".", "node_id", "]" ]
Remove the father node. Do nothing if the node is not a father Args: fathers: list of fathers to add
[ "Remove", "the", "father", "node", ".", "Do", "nothing", "if", "the", "node", "is", "not", "a", "father" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/cfg/node.py#L485-L491
train
crytic/slither
slither/core/cfg/node.py
Node.remove_son
def remove_son(self, son): """ Remove the son node. Do nothing if the node is not a son Args: fathers: list of fathers to add """ self._sons = [x for x in self._sons if x.node_id != son.node_id]
python
def remove_son(self, son): """ Remove the son node. Do nothing if the node is not a son Args: fathers: list of fathers to add """ self._sons = [x for x in self._sons if x.node_id != son.node_id]
[ "def", "remove_son", "(", "self", ",", "son", ")", ":", "self", ".", "_sons", "=", "[", "x", "for", "x", "in", "self", ".", "_sons", "if", "x", ".", "node_id", "!=", "son", ".", "node_id", "]" ]
Remove the son node. Do nothing if the node is not a son Args: fathers: list of fathers to add
[ "Remove", "the", "son", "node", ".", "Do", "nothing", "if", "the", "node", "is", "not", "a", "son" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/cfg/node.py#L493-L499
train
crytic/slither
slither/detectors/statements/deprecated_calls.py
DeprecatedStandards.detect_deprecated_references_in_node
def detect_deprecated_references_in_node(self, node): """ Detects if a node makes use of any deprecated standards. Returns: list of tuple: (detecting_signature, original_text, recommended_text)""" # Define our results list results = [] # If this node has an expressi...
python
def detect_deprecated_references_in_node(self, node): """ Detects if a node makes use of any deprecated standards. Returns: list of tuple: (detecting_signature, original_text, recommended_text)""" # Define our results list results = [] # If this node has an expressi...
[ "def", "detect_deprecated_references_in_node", "(", "self", ",", "node", ")", ":", "results", "=", "[", "]", "if", "node", ".", "expression", ":", "results", "+=", "self", ".", "detect_deprecation_in_expression", "(", "node", ".", "expression", ")", "for", "de...
Detects if a node makes use of any deprecated standards. Returns: list of tuple: (detecting_signature, original_text, recommended_text)
[ "Detects", "if", "a", "node", "makes", "use", "of", "any", "deprecated", "standards", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/statements/deprecated_calls.py#L88-L105
train
crytic/slither
slither/detectors/statements/deprecated_calls.py
DeprecatedStandards.detect_deprecated_references_in_contract
def detect_deprecated_references_in_contract(self, contract): """ Detects the usage of any deprecated built-in symbols. Returns: list of tuple: (state_variable | node, (detecting_signature, original_text, recommended_text))""" results = [] for state_variable in contract.var...
python
def detect_deprecated_references_in_contract(self, contract): """ Detects the usage of any deprecated built-in symbols. Returns: list of tuple: (state_variable | node, (detecting_signature, original_text, recommended_text))""" results = [] for state_variable in contract.var...
[ "def", "detect_deprecated_references_in_contract", "(", "self", ",", "contract", ")", ":", "results", "=", "[", "]", "for", "state_variable", "in", "contract", ".", "variables", ":", "if", "state_variable", ".", "contract", "!=", "contract", ":", "continue", "if...
Detects the usage of any deprecated built-in symbols. Returns: list of tuple: (state_variable | node, (detecting_signature, original_text, recommended_text))
[ "Detects", "the", "usage", "of", "any", "deprecated", "built", "-", "in", "symbols", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/statements/deprecated_calls.py#L107-L144
train
crytic/slither
slither/__main__.py
process
def process(filename, args, detector_classes, printer_classes): """ The core high-level code for running Slither static analysis. Returns: list(result), int: Result list and number of contracts analyzed """ ast = '--ast-compact-json' if args.legacy_ast: ast = '--ast-json' ar...
python
def process(filename, args, detector_classes, printer_classes): """ The core high-level code for running Slither static analysis. Returns: list(result), int: Result list and number of contracts analyzed """ ast = '--ast-compact-json' if args.legacy_ast: ast = '--ast-json' ar...
[ "def", "process", "(", "filename", ",", "args", ",", "detector_classes", ",", "printer_classes", ")", ":", "ast", "=", "'--ast-compact-json'", "if", "args", ".", "legacy_ast", ":", "ast", "=", "'--ast-json'", "args", ".", "filter_paths", "=", "parse_filter_paths...
The core high-level code for running Slither static analysis. Returns: list(result), int: Result list and number of contracts analyzed
[ "The", "core", "high", "-", "level", "code", "for", "running", "Slither", "static", "analysis", "." ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/__main__.py#L38-L53
train
crytic/slither
slither/detectors/attributes/const_functions.py
ConstantFunctions._detect
def _detect(self): """ Detect the constant function changing the state Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func','#varsWritten'} """ results = [] for c in self.contracts: for f in c.functions: ...
python
def _detect(self): """ Detect the constant function changing the state Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func','#varsWritten'} """ results = [] for c in self.contracts: for f in c.functions: ...
[ "def", "_detect", "(", "self", ")", ":", "results", "=", "[", "]", "for", "c", "in", "self", ".", "contracts", ":", "for", "f", "in", "c", ".", "functions", ":", "if", "f", ".", "contract", "!=", "c", ":", "continue", "if", "f", ".", "view", "o...
Detect the constant function changing the state Recursively visit the calls Returns: list: {'vuln', 'filename,'contract','func','#varsWritten'}
[ "Detect", "the", "constant", "function", "changing", "the", "state" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/attributes/const_functions.py#L44-L84
train
crytic/slither
slither/core/declarations/contract.py
Contract.constructor
def constructor(self): ''' Return the contract's immediate constructor. If there is no immediate constructor, returns the first constructor executed, following the c3 linearization Return None if there is no constructor. ''' cst = self.constructor_...
python
def constructor(self): ''' Return the contract's immediate constructor. If there is no immediate constructor, returns the first constructor executed, following the c3 linearization Return None if there is no constructor. ''' cst = self.constructor_...
[ "def", "constructor", "(", "self", ")", ":", "cst", "=", "self", ".", "constructor_not_inherited", "if", "cst", ":", "return", "cst", "for", "inherited_contract", "in", "self", ".", "inheritance", ":", "cst", "=", "inherited_contract", ".", "constructor_not_inhe...
Return the contract's immediate constructor. If there is no immediate constructor, returns the first constructor executed, following the c3 linearization Return None if there is no constructor.
[ "Return", "the", "contract", "s", "immediate", "constructor", ".", "If", "there", "is", "no", "immediate", "constructor", "returns", "the", "first", "constructor", "executed", "following", "the", "c3", "linearization", "Return", "None", "if", "there", "is", "no"...
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L168-L182
train
crytic/slither
slither/core/declarations/contract.py
Contract.get_functions_reading_from_variable
def get_functions_reading_from_variable(self, variable): ''' Return the functions reading the variable ''' return [f for f in self.functions if f.is_reading(variable)]
python
def get_functions_reading_from_variable(self, variable): ''' Return the functions reading the variable ''' return [f for f in self.functions if f.is_reading(variable)]
[ "def", "get_functions_reading_from_variable", "(", "self", ",", "variable", ")", ":", "return", "[", "f", "for", "f", "in", "self", ".", "functions", "if", "f", ".", "is_reading", "(", "variable", ")", "]" ]
Return the functions reading the variable
[ "Return", "the", "functions", "reading", "the", "variable" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L339-L343
train
crytic/slither
slither/core/declarations/contract.py
Contract.get_functions_writing_to_variable
def get_functions_writing_to_variable(self, variable): ''' Return the functions writting the variable ''' return [f for f in self.functions if f.is_writing(variable)]
python
def get_functions_writing_to_variable(self, variable): ''' Return the functions writting the variable ''' return [f for f in self.functions if f.is_writing(variable)]
[ "def", "get_functions_writing_to_variable", "(", "self", ",", "variable", ")", ":", "return", "[", "f", "for", "f", "in", "self", ".", "functions", "if", "f", ".", "is_writing", "(", "variable", ")", "]" ]
Return the functions writting the variable
[ "Return", "the", "functions", "writting", "the", "variable" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L345-L349
train
crytic/slither
slither/core/declarations/contract.py
Contract.get_source_var_declaration
def get_source_var_declaration(self, var): """ Return the source mapping where the variable is declared Args: var (str): variable name Returns: (dict): sourceMapping """ return next((x.source_mapping for x in self.variables if x.name == var))
python
def get_source_var_declaration(self, var): """ Return the source mapping where the variable is declared Args: var (str): variable name Returns: (dict): sourceMapping """ return next((x.source_mapping for x in self.variables if x.name == var))
[ "def", "get_source_var_declaration", "(", "self", ",", "var", ")", ":", "return", "next", "(", "(", "x", ".", "source_mapping", "for", "x", "in", "self", ".", "variables", "if", "x", ".", "name", "==", "var", ")", ")" ]
Return the source mapping where the variable is declared Args: var (str): variable name Returns: (dict): sourceMapping
[ "Return", "the", "source", "mapping", "where", "the", "variable", "is", "declared" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L351-L359
train
crytic/slither
slither/core/declarations/contract.py
Contract.get_source_event_declaration
def get_source_event_declaration(self, event): """ Return the source mapping where the event is declared Args: event (str): event name Returns: (dict): sourceMapping """ return next((x.source_mapping for x in self.events if x.name == event))
python
def get_source_event_declaration(self, event): """ Return the source mapping where the event is declared Args: event (str): event name Returns: (dict): sourceMapping """ return next((x.source_mapping for x in self.events if x.name == event))
[ "def", "get_source_event_declaration", "(", "self", ",", "event", ")", ":", "return", "next", "(", "(", "x", ".", "source_mapping", "for", "x", "in", "self", ".", "events", "if", "x", ".", "name", "==", "event", ")", ")" ]
Return the source mapping where the event is declared Args: event (str): event name Returns: (dict): sourceMapping
[ "Return", "the", "source", "mapping", "where", "the", "event", "is", "declared" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L361-L369
train
crytic/slither
slither/core/declarations/contract.py
Contract.get_summary
def get_summary(self): """ Return the function summary Returns: (str, list, list, list, list): (name, inheritance, variables, fuction summaries, modifier summaries) """ func_summaries = [f.get_summary() for f in self.functions] modif_summaries = [f.get_summary() for ...
python
def get_summary(self): """ Return the function summary Returns: (str, list, list, list, list): (name, inheritance, variables, fuction summaries, modifier summaries) """ func_summaries = [f.get_summary() for f in self.functions] modif_summaries = [f.get_summary() for ...
[ "def", "get_summary", "(", "self", ")", ":", "func_summaries", "=", "[", "f", ".", "get_summary", "(", ")", "for", "f", "in", "self", ".", "functions", "]", "modif_summaries", "=", "[", "f", ".", "get_summary", "(", ")", "for", "f", "in", "self", "."...
Return the function summary Returns: (str, list, list, list, list): (name, inheritance, variables, fuction summaries, modifier summaries)
[ "Return", "the", "function", "summary" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L512-L520
train
crytic/slither
slither/core/declarations/contract.py
Contract.is_erc20
def is_erc20(self): """ Check if the contract is an erc20 token Note: it does not check for correct return values Returns: bool """ full_names = [f.full_name for f in self.functions] return 'transfer(address,uint256)' in full_names and\ ...
python
def is_erc20(self): """ Check if the contract is an erc20 token Note: it does not check for correct return values Returns: bool """ full_names = [f.full_name for f in self.functions] return 'transfer(address,uint256)' in full_names and\ ...
[ "def", "is_erc20", "(", "self", ")", ":", "full_names", "=", "[", "f", ".", "full_name", "for", "f", "in", "self", ".", "functions", "]", "return", "'transfer(address,uint256)'", "in", "full_names", "and", "'transferFrom(address,address,uint256)'", "in", "full_nam...
Check if the contract is an erc20 token Note: it does not check for correct return values Returns: bool
[ "Check", "if", "the", "contract", "is", "an", "erc20", "token" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/declarations/contract.py#L530-L541
train
crytic/slither
slither/slithir/convert.py
integrate_value_gas
def integrate_value_gas(result): ''' Integrate value and gas temporary arguments to call instruction ''' was_changed = True calls = [] while was_changed: # We loop until we do not find any call to value or gas was_changed = False # Find all the assignments ...
python
def integrate_value_gas(result): ''' Integrate value and gas temporary arguments to call instruction ''' was_changed = True calls = [] while was_changed: # We loop until we do not find any call to value or gas was_changed = False # Find all the assignments ...
[ "def", "integrate_value_gas", "(", "result", ")", ":", "was_changed", "=", "True", "calls", "=", "[", "]", "while", "was_changed", ":", "was_changed", "=", "False", "assigments", "=", "{", "}", "for", "i", "in", "result", ":", "if", "isinstance", "(", "i...
Integrate value and gas temporary arguments to call instruction
[ "Integrate", "value", "and", "gas", "temporary", "arguments", "to", "call", "instruction" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/slithir/convert.py#L144-L213
train
crytic/slither
slither/slithir/convert.py
propagate_type_and_convert_call
def propagate_type_and_convert_call(result, node): ''' Propagate the types variables and convert tmp call to real call operation ''' calls_value = {} calls_gas = {} call_data = [] idx = 0 # use of while len() as result can be modified during the iteration while idx < len(result...
python
def propagate_type_and_convert_call(result, node): ''' Propagate the types variables and convert tmp call to real call operation ''' calls_value = {} calls_gas = {} call_data = [] idx = 0 # use of while len() as result can be modified during the iteration while idx < len(result...
[ "def", "propagate_type_and_convert_call", "(", "result", ",", "node", ")", ":", "calls_value", "=", "{", "}", "calls_gas", "=", "{", "}", "call_data", "=", "[", "]", "idx", "=", "0", "while", "idx", "<", "len", "(", "result", ")", ":", "ins", "=", "r...
Propagate the types variables and convert tmp call to real call operation
[ "Propagate", "the", "types", "variables", "and", "convert", "tmp", "call", "to", "real", "call", "operation" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/slithir/convert.py#L222-L292
train
crytic/slither
slither/slithir/convert.py
convert_to_push
def convert_to_push(ir, node): """ Convert a call to a PUSH operaiton The funciton assume to receive a correct IR The checks must be done by the caller May necessitate to create an intermediate operation (InitArray) Necessitate to return the lenght (see push documentation) As a result, the...
python
def convert_to_push(ir, node): """ Convert a call to a PUSH operaiton The funciton assume to receive a correct IR The checks must be done by the caller May necessitate to create an intermediate operation (InitArray) Necessitate to return the lenght (see push documentation) As a result, the...
[ "def", "convert_to_push", "(", "ir", ",", "node", ")", ":", "lvalue", "=", "ir", ".", "lvalue", "if", "isinstance", "(", "ir", ".", "arguments", "[", "0", "]", ",", "list", ")", ":", "ret", "=", "[", "]", "val", "=", "TemporaryVariable", "(", "node...
Convert a call to a PUSH operaiton The funciton assume to receive a correct IR The checks must be done by the caller May necessitate to create an intermediate operation (InitArray) Necessitate to return the lenght (see push documentation) As a result, the function return may return a list
[ "Convert", "a", "call", "to", "a", "PUSH", "operaiton" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/slithir/convert.py#L579-L626
train
crytic/slither
slither/slithir/convert.py
get_type
def get_type(t): """ Convert a type to a str If the instance is a Contract, return 'address' instead """ if isinstance(t, UserDefinedType): if isinstance(t.type, Contract): return 'address' return str(t)
python
def get_type(t): """ Convert a type to a str If the instance is a Contract, return 'address' instead """ if isinstance(t, UserDefinedType): if isinstance(t.type, Contract): return 'address' return str(t)
[ "def", "get_type", "(", "t", ")", ":", "if", "isinstance", "(", "t", ",", "UserDefinedType", ")", ":", "if", "isinstance", "(", "t", ".", "type", ",", "Contract", ")", ":", "return", "'address'", "return", "str", "(", "t", ")" ]
Convert a type to a str If the instance is a Contract, return 'address' instead
[ "Convert", "a", "type", "to", "a", "str", "If", "the", "instance", "is", "a", "Contract", "return", "address", "instead" ]
04c147f7e50223c6af458ca430befae747ccd259
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/slithir/convert.py#L661-L669
train