id
int32
0
252k
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
229,300
ethereum/pyethereum
ethereum/experimental/pruning_trie.py
Trie._get
def _get(self, node, key): """ get value inside a node :param node: node in form of list, or BLANK_NODE :param key: nibble list without terminator :return: BLANK_NODE if does not exist, otherwise value or hash """ node_type = self._get_node_type(node) ...
python
def _get(self, node, key): """ get value inside a node :param node: node in form of list, or BLANK_NODE :param key: nibble list without terminator :return: BLANK_NODE if does not exist, otherwise value or hash """ node_type = self._get_node_type(node) ...
[ "def", "_get", "(", "self", ",", "node", ",", "key", ")", ":", "node_type", "=", "self", ".", "_get_node_type", "(", "node", ")", "if", "node_type", "==", "NODE_TYPE_BLANK", ":", "return", "BLANK_NODE", "if", "node_type", "==", "NODE_TYPE_BRANCH", ":", "# ...
get value inside a node :param node: node in form of list, or BLANK_NODE :param key: nibble list without terminator :return: BLANK_NODE if does not exist, otherwise value or hash
[ "get", "value", "inside", "a", "node" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L370-L401
229,301
ethereum/pyethereum
ethereum/experimental/pruning_trie.py
Trie._normalize_branch_node
def _normalize_branch_node(self, node): # sys.stderr.write('nbn\n') """node should have only one item changed """ not_blank_items_count = sum(1 for x in range(17) if node[x]) assert not_blank_items_count >= 1 if not_blank_items_count > 1: self._encode_node(no...
python
def _normalize_branch_node(self, node): # sys.stderr.write('nbn\n') """node should have only one item changed """ not_blank_items_count = sum(1 for x in range(17) if node[x]) assert not_blank_items_count >= 1 if not_blank_items_count > 1: self._encode_node(no...
[ "def", "_normalize_branch_node", "(", "self", ",", "node", ")", ":", "# sys.stderr.write('nbn\\n')", "not_blank_items_count", "=", "sum", "(", "1", "for", "x", "in", "range", "(", "17", ")", "if", "node", "[", "x", "]", ")", "assert", "not_blank_items_count", ...
node should have only one item changed
[ "node", "should", "have", "only", "one", "item", "changed" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/experimental/pruning_trie.py#L650-L688
229,302
ethereum/pyethereum
ethereum/slogging.py
DEBUG
def DEBUG(msg, *args, **kwargs): """temporary logger during development that is always on""" logger = getLogger("DEBUG") if len(logger.handlers) == 0: logger.addHandler(StreamHandler()) logger.propagate = False logger.setLevel(logging.DEBUG) logger.DEV(msg, *args, **kwargs)
python
def DEBUG(msg, *args, **kwargs): """temporary logger during development that is always on""" logger = getLogger("DEBUG") if len(logger.handlers) == 0: logger.addHandler(StreamHandler()) logger.propagate = False logger.setLevel(logging.DEBUG) logger.DEV(msg, *args, **kwargs)
[ "def", "DEBUG", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", "=", "getLogger", "(", "\"DEBUG\"", ")", "if", "len", "(", "logger", ".", "handlers", ")", "==", "0", ":", "logger", ".", "addHandler", "(", "StreamHandler", ...
temporary logger during development that is always on
[ "temporary", "logger", "during", "development", "that", "is", "always", "on" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/slogging.py#L349-L356
229,303
ethereum/pyethereum
ethereum/vm.py
vm_trace
def vm_trace(ext, msg, compustate, opcode, pushcache, tracer=log_vm_op): """ This diverges from normal logging, as we use the logging namespace only to decide which features get logged in 'eth.vm.op' i.e. tracing can not be activated by activating a sub like 'eth.vm.op.stack' """ op, in_arg...
python
def vm_trace(ext, msg, compustate, opcode, pushcache, tracer=log_vm_op): """ This diverges from normal logging, as we use the logging namespace only to decide which features get logged in 'eth.vm.op' i.e. tracing can not be activated by activating a sub like 'eth.vm.op.stack' """ op, in_arg...
[ "def", "vm_trace", "(", "ext", ",", "msg", ",", "compustate", ",", "opcode", ",", "pushcache", ",", "tracer", "=", "log_vm_op", ")", ":", "op", ",", "in_args", ",", "out_args", ",", "fee", "=", "opcodes", ".", "opcodes", "[", "opcode", "]", "trace_data...
This diverges from normal logging, as we use the logging namespace only to decide which features get logged in 'eth.vm.op' i.e. tracing can not be activated by activating a sub like 'eth.vm.op.stack'
[ "This", "diverges", "from", "normal", "logging", "as", "we", "use", "the", "logging", "namespace", "only", "to", "decide", "which", "features", "get", "logged", "in", "eth", ".", "vm", ".", "op", "i", ".", "e", ".", "tracing", "can", "not", "be", "acti...
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/vm.py#L202-L242
229,304
ethereum/pyethereum
ethereum/transactions.py
Transaction.sign
def sign(self, key, network_id=None): """Sign this transaction with a private key. A potentially already existing signature would be overridden. """ if network_id is None: rawhash = utils.sha3(rlp.encode(unsigned_tx_from_tx(self), UnsignedTransaction)) else: ...
python
def sign(self, key, network_id=None): """Sign this transaction with a private key. A potentially already existing signature would be overridden. """ if network_id is None: rawhash = utils.sha3(rlp.encode(unsigned_tx_from_tx(self), UnsignedTransaction)) else: ...
[ "def", "sign", "(", "self", ",", "key", ",", "network_id", "=", "None", ")", ":", "if", "network_id", "is", "None", ":", "rawhash", "=", "utils", ".", "sha3", "(", "rlp", ".", "encode", "(", "unsigned_tx_from_tx", "(", "self", ")", ",", "UnsignedTransa...
Sign this transaction with a private key. A potentially already existing signature would be overridden.
[ "Sign", "this", "transaction", "with", "a", "private", "key", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/transactions.py#L118-L141
229,305
ethereum/pyethereum
ethereum/transactions.py
Transaction.creates
def creates(self): "returns the address of a contract created by this tx" if self.to in (b'', '\0' * 20): return mk_contract_address(self.sender, self.nonce)
python
def creates(self): "returns the address of a contract created by this tx" if self.to in (b'', '\0' * 20): return mk_contract_address(self.sender, self.nonce)
[ "def", "creates", "(", "self", ")", ":", "if", "self", ".", "to", "in", "(", "b''", ",", "'\\0'", "*", "20", ")", ":", "return", "mk_contract_address", "(", "self", ".", "sender", ",", "self", ".", "nonce", ")" ]
returns the address of a contract created by this tx
[ "returns", "the", "address", "of", "a", "contract", "created", "by", "this", "tx" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/transactions.py#L167-L170
229,306
ethereum/pyethereum
ethereum/pow/ethpow.py
check_pow
def check_pow(block_number, header_hash, mixhash, nonce, difficulty): """Check if the proof-of-work of the block is valid. :param nonce: if given the proof of work function will be evaluated with this nonce instead of the one already present in the header :returns: `True...
python
def check_pow(block_number, header_hash, mixhash, nonce, difficulty): """Check if the proof-of-work of the block is valid. :param nonce: if given the proof of work function will be evaluated with this nonce instead of the one already present in the header :returns: `True...
[ "def", "check_pow", "(", "block_number", ",", "header_hash", ",", "mixhash", ",", "nonce", ",", "difficulty", ")", ":", "log", ".", "debug", "(", "'checking pow'", ",", "block_number", "=", "block_number", ")", "if", "len", "(", "mixhash", ")", "!=", "32",...
Check if the proof-of-work of the block is valid. :param nonce: if given the proof of work function will be evaluated with this nonce instead of the one already present in the header :returns: `True` or `False`
[ "Check", "if", "the", "proof", "-", "of", "-", "work", "of", "the", "block", "is", "valid", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/ethpow.py#L62-L80
229,307
ethereum/pyethereum
ethereum/block.py
BlockHeader.to_dict
def to_dict(self): """Serialize the header to a readable dictionary.""" d = {} for field in ('prevhash', 'uncles_hash', 'extra_data', 'nonce', 'mixhash'): d[field] = '0x' + encode_hex(getattr(self, field)) for field in ('state_root', 'tx_list_root', 'rec...
python
def to_dict(self): """Serialize the header to a readable dictionary.""" d = {} for field in ('prevhash', 'uncles_hash', 'extra_data', 'nonce', 'mixhash'): d[field] = '0x' + encode_hex(getattr(self, field)) for field in ('state_root', 'tx_list_root', 'rec...
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "{", "}", "for", "field", "in", "(", "'prevhash'", ",", "'uncles_hash'", ",", "'extra_data'", ",", "'nonce'", ",", "'mixhash'", ")", ":", "d", "[", "field", "]", "=", "'0x'", "+", "encode_hex", "(", ...
Serialize the header to a readable dictionary.
[ "Serialize", "the", "header", "to", "a", "readable", "dictionary", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/block.py#L137-L151
229,308
ethereum/pyethereum
ethereum/utils.py
decode_int
def decode_int(v): """decodes and integer from serialization""" if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0): raise Exception("No leading zero bytes allowed for integers") return big_endian_to_int(v)
python
def decode_int(v): """decodes and integer from serialization""" if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0): raise Exception("No leading zero bytes allowed for integers") return big_endian_to_int(v)
[ "def", "decode_int", "(", "v", ")", ":", "if", "len", "(", "v", ")", ">", "0", "and", "(", "v", "[", "0", "]", "==", "b'\\x00'", "or", "v", "[", "0", "]", "==", "0", ")", ":", "raise", "Exception", "(", "\"No leading zero bytes allowed for integers\"...
decodes and integer from serialization
[ "decodes", "and", "integer", "from", "serialization" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L350-L354
229,309
ethereum/pyethereum
ethereum/utils.py
encode_int
def encode_int(v): """encodes an integer into serialization""" if not is_numeric(v) or v < 0 or v >= TT256: raise Exception("Integer invalid or out of range: %r" % v) return int_to_big_endian(v)
python
def encode_int(v): """encodes an integer into serialization""" if not is_numeric(v) or v < 0 or v >= TT256: raise Exception("Integer invalid or out of range: %r" % v) return int_to_big_endian(v)
[ "def", "encode_int", "(", "v", ")", ":", "if", "not", "is_numeric", "(", "v", ")", "or", "v", "<", "0", "or", "v", ">=", "TT256", ":", "raise", "Exception", "(", "\"Integer invalid or out of range: %r\"", "%", "v", ")", "return", "int_to_big_endian", "(", ...
encodes an integer into serialization
[ "encodes", "an", "integer", "into", "serialization" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L371-L375
229,310
ethereum/pyethereum
ethereum/utils.py
print_func_call
def print_func_call(ignore_first_arg=False, max_call_number=100): """ utility function to facilitate debug, it will print input args before function call, and print return value after function call usage: @print_func_call def some_func_to_be_debu(): pass :param ignore_firs...
python
def print_func_call(ignore_first_arg=False, max_call_number=100): """ utility function to facilitate debug, it will print input args before function call, and print return value after function call usage: @print_func_call def some_func_to_be_debu(): pass :param ignore_firs...
[ "def", "print_func_call", "(", "ignore_first_arg", "=", "False", ",", "max_call_number", "=", "100", ")", ":", "from", "functools", "import", "wraps", "def", "display", "(", "x", ")", ":", "x", "=", "to_string", "(", "x", ")", "try", ":", "x", ".", "de...
utility function to facilitate debug, it will print input args before function call, and print return value after function call usage: @print_func_call def some_func_to_be_debu(): pass :param ignore_first_arg: whether print the first arg or not. useful when ignore the `sel...
[ "utility", "function", "to", "facilitate", "debug", "it", "will", "print", "input", "args", "before", "function", "call", "and", "print", "return", "value", "after", "function", "call" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/utils.py#L449-L498
229,311
ethereum/pyethereum
ethereum/tools/_solidity.py
get_compiler_path
def get_compiler_path(): """ Return the path to the solc compiler. This funtion will search for the solc binary in the $PATH and return the path of the first executable occurence. """ # If the user provides a specific solc binary let's use that given_binary = os.environ.get('SOLC_BINARY') i...
python
def get_compiler_path(): """ Return the path to the solc compiler. This funtion will search for the solc binary in the $PATH and return the path of the first executable occurence. """ # If the user provides a specific solc binary let's use that given_binary = os.environ.get('SOLC_BINARY') i...
[ "def", "get_compiler_path", "(", ")", ":", "# If the user provides a specific solc binary let's use that", "given_binary", "=", "os", ".", "environ", ".", "get", "(", "'SOLC_BINARY'", ")", "if", "given_binary", ":", "return", "given_binary", "for", "path", "in", "os",...
Return the path to the solc compiler. This funtion will search for the solc binary in the $PATH and return the path of the first executable occurence.
[ "Return", "the", "path", "to", "the", "solc", "compiler", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L24-L43
229,312
ethereum/pyethereum
ethereum/tools/_solidity.py
solc_arguments
def solc_arguments(libraries=None, combined='bin,abi', optimize=True, extra_args=None): """ Build the arguments to call the solc binary. """ args = [ '--combined-json', combined, ] def str_of(address): """cast address to string. py2/3 compatability. """ try: ...
python
def solc_arguments(libraries=None, combined='bin,abi', optimize=True, extra_args=None): """ Build the arguments to call the solc binary. """ args = [ '--combined-json', combined, ] def str_of(address): """cast address to string. py2/3 compatability. """ try: ...
[ "def", "solc_arguments", "(", "libraries", "=", "None", ",", "combined", "=", "'bin,abi'", ",", "optimize", "=", "True", ",", "extra_args", "=", "None", ")", ":", "args", "=", "[", "'--combined-json'", ",", "combined", ",", "]", "def", "str_of", "(", "ad...
Build the arguments to call the solc binary.
[ "Build", "the", "arguments", "to", "call", "the", "solc", "binary", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L54-L89
229,313
ethereum/pyethereum
ethereum/tools/_solidity.py
solc_parse_output
def solc_parse_output(compiler_output): """ Parses the compiler output. """ # At the moment some solc output like --hashes or -- gas will not output # json at all so if used with those arguments the logic here will break. # Perhaps solidity will slowly switch to a json only output and this comment #...
python
def solc_parse_output(compiler_output): """ Parses the compiler output. """ # At the moment some solc output like --hashes or -- gas will not output # json at all so if used with those arguments the logic here will break. # Perhaps solidity will slowly switch to a json only output and this comment #...
[ "def", "solc_parse_output", "(", "compiler_output", ")", ":", "# At the moment some solc output like --hashes or -- gas will not output", "# json at all so if used with those arguments the logic here will break.", "# Perhaps solidity will slowly switch to a json only output and this comment", "# c...
Parses the compiler output.
[ "Parses", "the", "compiler", "output", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L92-L121
229,314
ethereum/pyethereum
ethereum/tools/_solidity.py
compiler_version
def compiler_version(): """ Return the version of the installed solc. """ version_info = subprocess.check_output(['solc', '--version']) match = re.search(b'^Version: ([0-9a-z.-]+)/', version_info, re.MULTILINE) if match: return match.group(1)
python
def compiler_version(): """ Return the version of the installed solc. """ version_info = subprocess.check_output(['solc', '--version']) match = re.search(b'^Version: ([0-9a-z.-]+)/', version_info, re.MULTILINE) if match: return match.group(1)
[ "def", "compiler_version", "(", ")", ":", "version_info", "=", "subprocess", ".", "check_output", "(", "[", "'solc'", ",", "'--version'", "]", ")", "match", "=", "re", ".", "search", "(", "b'^Version: ([0-9a-z.-]+)/'", ",", "version_info", ",", "re", ".", "M...
Return the version of the installed solc.
[ "Return", "the", "version", "of", "the", "installed", "solc", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L124-L130
229,315
ethereum/pyethereum
ethereum/tools/_solidity.py
solidity_names
def solidity_names(code): # pylint: disable=too-many-branches """ Return the library and contract names in order of appearence. """ names = [] in_string = None backslash = False comment = None # "parse" the code by hand to handle the corner cases: # - the contract or library can be inside...
python
def solidity_names(code): # pylint: disable=too-many-branches """ Return the library and contract names in order of appearence. """ names = [] in_string = None backslash = False comment = None # "parse" the code by hand to handle the corner cases: # - the contract or library can be inside...
[ "def", "solidity_names", "(", "code", ")", ":", "# pylint: disable=too-many-branches", "names", "=", "[", "]", "in_string", "=", "None", "backslash", "=", "False", "comment", "=", "None", "# \"parse\" the code by hand to handle the corner cases:", "# - the contract or libr...
Return the library and contract names in order of appearence.
[ "Return", "the", "library", "and", "contract", "names", "in", "order", "of", "appearence", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L133-L194
229,316
ethereum/pyethereum
ethereum/tools/_solidity.py
compile_file
def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True, extra_args=None): """ Return the compile contract code. Args: filepath (str): The path to the contract source code. libraries (dict): A dictionary mapping library name to it's address. combine...
python
def compile_file(filepath, libraries=None, combined='bin,abi', optimize=True, extra_args=None): """ Return the compile contract code. Args: filepath (str): The path to the contract source code. libraries (dict): A dictionary mapping library name to it's address. combine...
[ "def", "compile_file", "(", "filepath", ",", "libraries", "=", "None", ",", "combined", "=", "'bin,abi'", ",", "optimize", "=", "True", ",", "extra_args", "=", "None", ")", ":", "workdir", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "fi...
Return the compile contract code. Args: filepath (str): The path to the contract source code. libraries (dict): A dictionary mapping library name to it's address. combined (str): The argument for solc's --combined-json. optimize (bool): Enable/disables compiler optimization. Re...
[ "Return", "the", "compile", "contract", "code", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L265-L291
229,317
ethereum/pyethereum
ethereum/tools/_solidity.py
solidity_get_contract_key
def solidity_get_contract_key(all_contracts, filepath, contract_name): """ A backwards compatible method of getting the key to the all_contracts dictionary for a particular contract""" if contract_name in all_contracts: return contract_name else: if filepath is None: filename...
python
def solidity_get_contract_key(all_contracts, filepath, contract_name): """ A backwards compatible method of getting the key to the all_contracts dictionary for a particular contract""" if contract_name in all_contracts: return contract_name else: if filepath is None: filename...
[ "def", "solidity_get_contract_key", "(", "all_contracts", ",", "filepath", ",", "contract_name", ")", ":", "if", "contract_name", "in", "all_contracts", ":", "return", "contract_name", "else", ":", "if", "filepath", "is", "None", ":", "filename", "=", "'<stdin>'",...
A backwards compatible method of getting the key to the all_contracts dictionary for a particular contract
[ "A", "backwards", "compatible", "method", "of", "getting", "the", "key", "to", "the", "all_contracts", "dictionary", "for", "a", "particular", "contract" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L308-L319
229,318
ethereum/pyethereum
ethereum/tools/_solidity.py
Solc.compile
def compile(cls, code, path=None, libraries=None, contract_name='', extra_args=None): """ Return the binary of last contract in code. """ result = cls._code_or_path( code, path, contract_name, libraries, 'bin', extra...
python
def compile(cls, code, path=None, libraries=None, contract_name='', extra_args=None): """ Return the binary of last contract in code. """ result = cls._code_or_path( code, path, contract_name, libraries, 'bin', extra...
[ "def", "compile", "(", "cls", ",", "code", ",", "path", "=", "None", ",", "libraries", "=", "None", ",", "contract_name", "=", "''", ",", "extra_args", "=", "None", ")", ":", "result", "=", "cls", ".", "_code_or_path", "(", "code", ",", "path", ",", ...
Return the binary of last contract in code.
[ "Return", "the", "binary", "of", "last", "contract", "in", "code", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L420-L430
229,319
ethereum/pyethereum
ethereum/tools/_solidity.py
Solc.combined
def combined(cls, code, path=None, extra_args=None): """ Compile combined-json with abi,bin,devdoc,userdoc. @param code: literal solidity code as a string. @param path: absolute path to solidity-file. Note: code & path are mutually exclusive! @param extra_args: Eith...
python
def combined(cls, code, path=None, extra_args=None): """ Compile combined-json with abi,bin,devdoc,userdoc. @param code: literal solidity code as a string. @param path: absolute path to solidity-file. Note: code & path are mutually exclusive! @param extra_args: Eith...
[ "def", "combined", "(", "cls", ",", "code", ",", "path", "=", "None", ",", "extra_args", "=", "None", ")", ":", "if", "code", "and", "path", ":", "raise", "ValueError", "(", "'sourcecode and path are mutually exclusive.'", ")", "if", "path", ":", "contracts"...
Compile combined-json with abi,bin,devdoc,userdoc. @param code: literal solidity code as a string. @param path: absolute path to solidity-file. Note: code & path are mutually exclusive! @param extra_args: Either a space separated string or a list of extra ...
[ "Compile", "combined", "-", "json", "with", "abi", "bin", "devdoc", "userdoc", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L447-L480
229,320
ethereum/pyethereum
ethereum/tools/_solidity.py
Solc.compile_rich
def compile_rich(cls, code, path=None, extra_args=None): """full format as returned by jsonrpc""" return { contract_name: { 'code': '0x' + contract.get('bin_hex'), 'info': { 'abiDefinition': contract.get('abi'), 'compil...
python
def compile_rich(cls, code, path=None, extra_args=None): """full format as returned by jsonrpc""" return { contract_name: { 'code': '0x' + contract.get('bin_hex'), 'info': { 'abiDefinition': contract.get('abi'), 'compil...
[ "def", "compile_rich", "(", "cls", ",", "code", ",", "path", "=", "None", ",", "extra_args", "=", "None", ")", ":", "return", "{", "contract_name", ":", "{", "'code'", ":", "'0x'", "+", "contract", ".", "get", "(", "'bin_hex'", ")", ",", "'info'", ":...
full format as returned by jsonrpc
[ "full", "format", "as", "returned", "by", "jsonrpc" ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/tools/_solidity.py#L483-L501
229,321
ethereum/pyethereum
ethereum/pow/consensus.py
validate_uncles
def validate_uncles(state, block): """Validate the uncles of this block.""" # Make sure hash matches up if utils.sha3(rlp.encode(block.uncles)) != block.header.uncles_hash: raise VerificationFailed("Uncle hash mismatch") # Enforce maximum number of uncles if len(block.uncles) > state.config[...
python
def validate_uncles(state, block): """Validate the uncles of this block.""" # Make sure hash matches up if utils.sha3(rlp.encode(block.uncles)) != block.header.uncles_hash: raise VerificationFailed("Uncle hash mismatch") # Enforce maximum number of uncles if len(block.uncles) > state.config[...
[ "def", "validate_uncles", "(", "state", ",", "block", ")", ":", "# Make sure hash matches up", "if", "utils", ".", "sha3", "(", "rlp", ".", "encode", "(", "block", ".", "uncles", ")", ")", "!=", "block", ".", "header", ".", "uncles_hash", ":", "raise", "...
Validate the uncles of this block.
[ "Validate", "the", "uncles", "of", "this", "block", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/consensus.py#L63-L106
229,322
ethereum/pyethereum
ethereum/pow/consensus.py
finalize
def finalize(state, block): """Apply rewards and commit.""" if state.is_METROPOLIS(): br = state.config['BYZANTIUM_BLOCK_REWARD'] nr = state.config['BYZANTIUM_NEPHEW_REWARD'] else: br = state.config['BLOCK_REWARD'] nr = state.config['NEPHEW_REWARD'] delta = int(...
python
def finalize(state, block): """Apply rewards and commit.""" if state.is_METROPOLIS(): br = state.config['BYZANTIUM_BLOCK_REWARD'] nr = state.config['BYZANTIUM_NEPHEW_REWARD'] else: br = state.config['BLOCK_REWARD'] nr = state.config['NEPHEW_REWARD'] delta = int(...
[ "def", "finalize", "(", "state", ",", "block", ")", ":", "if", "state", ".", "is_METROPOLIS", "(", ")", ":", "br", "=", "state", ".", "config", "[", "'BYZANTIUM_BLOCK_REWARD'", "]", "nr", "=", "state", ".", "config", "[", "'BYZANTIUM_NEPHEW_REWARD'", "]", ...
Apply rewards and commit.
[ "Apply", "rewards", "and", "commit", "." ]
b704a5c6577863edc539a1ec3d2620a443b950fb
https://github.com/ethereum/pyethereum/blob/b704a5c6577863edc539a1ec3d2620a443b950fb/ethereum/pow/consensus.py#L110-L132
229,323
Microsoft/knack
knack/deprecation.py
Deprecated.ensure_new_style_deprecation
def ensure_new_style_deprecation(cli_ctx, kwargs, object_type): """ Helper method to make the previous string-based deprecate_info kwarg work with the new style. """ deprecate_info = kwargs.get('deprecate_info', None) if isinstance(deprecate_info, Deprecated): deprecate_i...
python
def ensure_new_style_deprecation(cli_ctx, kwargs, object_type): """ Helper method to make the previous string-based deprecate_info kwarg work with the new style. """ deprecate_info = kwargs.get('deprecate_info', None) if isinstance(deprecate_info, Deprecated): deprecate_i...
[ "def", "ensure_new_style_deprecation", "(", "cli_ctx", ",", "kwargs", ",", "object_type", ")", ":", "deprecate_info", "=", "kwargs", ".", "get", "(", "'deprecate_info'", ",", "None", ")", "if", "isinstance", "(", "deprecate_info", ",", "Deprecated", ")", ":", ...
Helper method to make the previous string-based deprecate_info kwarg work with the new style.
[ "Helper", "method", "to", "make", "the", "previous", "string", "-", "based", "deprecate_info", "kwarg", "work", "with", "the", "new", "style", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/deprecation.py#L53-L62
229,324
Microsoft/knack
knack/deprecation.py
Deprecated._version_less_than_or_equal_to
def _version_less_than_or_equal_to(self, v1, v2): """ Returns true if v1 <= v2. """ # pylint: disable=no-name-in-module, import-error from distutils.version import LooseVersion return LooseVersion(v1) <= LooseVersion(v2)
python
def _version_less_than_or_equal_to(self, v1, v2): """ Returns true if v1 <= v2. """ # pylint: disable=no-name-in-module, import-error from distutils.version import LooseVersion return LooseVersion(v1) <= LooseVersion(v2)
[ "def", "_version_less_than_or_equal_to", "(", "self", ",", "v1", ",", "v2", ")", ":", "# pylint: disable=no-name-in-module, import-error", "from", "distutils", ".", "version", "import", "LooseVersion", "return", "LooseVersion", "(", "v1", ")", "<=", "LooseVersion", "(...
Returns true if v1 <= v2.
[ "Returns", "true", "if", "v1", "<", "=", "v2", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/deprecation.py#L127-L131
229,325
Microsoft/knack
knack/prompting.py
prompt_choice_list
def prompt_choice_list(msg, a_list, default=1, help_string=None): """Prompt user to select from a list of possible choices. :param msg:A message displayed to the user before the choice list :type msg: str :param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc') "typ...
python
def prompt_choice_list(msg, a_list, default=1, help_string=None): """Prompt user to select from a list of possible choices. :param msg:A message displayed to the user before the choice list :type msg: str :param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc') "typ...
[ "def", "prompt_choice_list", "(", "msg", ",", "a_list", ",", "default", "=", "1", ",", "help_string", "=", "None", ")", ":", "verify_is_a_tty", "(", ")", "options", "=", "'\\n'", ".", "join", "(", "[", "' [{}] {}{}'", ".", "format", "(", "i", "+", "1",...
Prompt user to select from a list of possible choices. :param msg:A message displayed to the user before the choice list :type msg: str :param a_list:The list of choices (list of strings or list of dicts with 'name' & 'desc') "type a_list: list :param default:The default option that should be chose...
[ "Prompt", "user", "to", "select", "from", "a", "list", "of", "possible", "choices", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/prompting.py#L99-L131
229,326
Microsoft/knack
knack/parser.py
CLICommandParser._add_argument
def _add_argument(obj, arg): """ Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument """ argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS} if arg.options_list: scrubbed_options_list = [] for it...
python
def _add_argument(obj, arg): """ Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument """ argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS} if arg.options_list: scrubbed_options_list = [] for it...
[ "def", "_add_argument", "(", "obj", ",", "arg", ")", ":", "argparse_options", "=", "{", "name", ":", "value", "for", "name", ",", "value", "in", "arg", ".", "options", ".", "items", "(", ")", "if", "name", "in", "ARGPARSE_SUPPORTED_KWARGS", "}", "if", ...
Only pass valid argparse kwargs to argparse.ArgumentParser.add_argument
[ "Only", "pass", "valid", "argparse", "kwargs", "to", "argparse", ".", "ArgumentParser", ".", "add_argument" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L42-L69
229,327
Microsoft/knack
knack/parser.py
CLICommandParser.load_command_table
def load_command_table(self, command_loader): """ Process the command table and load it into the parser :param cmd_tbl: A dictionary containing the commands :type cmd_tbl: dict """ cmd_tbl = command_loader.command_table grp_tbl = command_loader.command_group_table ...
python
def load_command_table(self, command_loader): """ Process the command table and load it into the parser :param cmd_tbl: A dictionary containing the commands :type cmd_tbl: dict """ cmd_tbl = command_loader.command_table grp_tbl = command_loader.command_group_table ...
[ "def", "load_command_table", "(", "self", ",", "command_loader", ")", ":", "cmd_tbl", "=", "command_loader", ".", "command_table", "grp_tbl", "=", "command_loader", ".", "command_group_table", "if", "not", "cmd_tbl", ":", "raise", "ValueError", "(", "'The command ta...
Process the command table and load it into the parser :param cmd_tbl: A dictionary containing the commands :type cmd_tbl: dict
[ "Process", "the", "command", "table", "and", "load", "it", "into", "the", "parser" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L111-L178
229,328
Microsoft/knack
knack/parser.py
CLICommandParser._get_subparser
def _get_subparser(self, path, group_table=None): """For each part of the path, walk down the tree of subparsers, creating new ones if one doesn't already exist. """ group_table = group_table or {} for length in range(0, len(path)): parent_path = path[:length] ...
python
def _get_subparser(self, path, group_table=None): """For each part of the path, walk down the tree of subparsers, creating new ones if one doesn't already exist. """ group_table = group_table or {} for length in range(0, len(path)): parent_path = path[:length] ...
[ "def", "_get_subparser", "(", "self", ",", "path", ",", "group_table", "=", "None", ")", ":", "group_table", "=", "group_table", "or", "{", "}", "for", "length", "in", "range", "(", "0", ",", "len", "(", "path", ")", ")", ":", "parent_path", "=", "pa...
For each part of the path, walk down the tree of subparsers, creating new ones if one doesn't already exist.
[ "For", "each", "part", "of", "the", "path", "walk", "down", "the", "tree", "of", "subparsers", "creating", "new", "ones", "if", "one", "doesn", "t", "already", "exist", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L180-L217
229,329
Microsoft/knack
knack/parser.py
CLICommandParser.parse_args
def parse_args(self, args=None, namespace=None): """ Overrides argparse.ArgumentParser.parse_args Enables '@'-prefixed files to be expanded before arguments are processed by ArgumentParser.parse_args as usual """ self._expand_prefixed_files(args) return super(CLICommandP...
python
def parse_args(self, args=None, namespace=None): """ Overrides argparse.ArgumentParser.parse_args Enables '@'-prefixed files to be expanded before arguments are processed by ArgumentParser.parse_args as usual """ self._expand_prefixed_files(args) return super(CLICommandP...
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ",", "namespace", "=", "None", ")", ":", "self", ".", "_expand_prefixed_files", "(", "args", ")", "return", "super", "(", "CLICommandParser", ",", "self", ")", ".", "parse_args", "(", "args", ")...
Overrides argparse.ArgumentParser.parse_args Enables '@'-prefixed files to be expanded before arguments are processed by ArgumentParser.parse_args as usual
[ "Overrides", "argparse", ".", "ArgumentParser", ".", "parse_args" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/parser.py#L249-L256
229,330
Microsoft/knack
knack/introspection.py
extract_full_summary_from_signature
def extract_full_summary_from_signature(operation): """ Extract the summary from the docstring of the command. """ lines = inspect.getdoc(operation) regex = r'\s*(:param)\s+(.+?)\s*:(.*)' summary = '' if lines: match = re.search(regex, lines) summary = lines[:match.regs[0][0]] if mat...
python
def extract_full_summary_from_signature(operation): """ Extract the summary from the docstring of the command. """ lines = inspect.getdoc(operation) regex = r'\s*(:param)\s+(.+?)\s*:(.*)' summary = '' if lines: match = re.search(regex, lines) summary = lines[:match.regs[0][0]] if mat...
[ "def", "extract_full_summary_from_signature", "(", "operation", ")", ":", "lines", "=", "inspect", ".", "getdoc", "(", "operation", ")", "regex", "=", "r'\\s*(:param)\\s+(.+?)\\s*:(.*)'", "summary", "=", "''", "if", "lines", ":", "match", "=", "re", ".", "search...
Extract the summary from the docstring of the command.
[ "Extract", "the", "summary", "from", "the", "docstring", "of", "the", "command", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/introspection.py#L15-L25
229,331
Microsoft/knack
knack/cli.py
CLI.get_runtime_version
def get_runtime_version(self): # pylint: disable=no-self-use """ Get the runtime information. :return: Runtime information :rtype: str """ import platform version_info = '\n\n' version_info += 'Python ({}) {}'.format(platform.system(), sys.version) vers...
python
def get_runtime_version(self): # pylint: disable=no-self-use """ Get the runtime information. :return: Runtime information :rtype: str """ import platform version_info = '\n\n' version_info += 'Python ({}) {}'.format(platform.system(), sys.version) vers...
[ "def", "get_runtime_version", "(", "self", ")", ":", "# pylint: disable=no-self-use", "import", "platform", "version_info", "=", "'\\n\\n'", "version_info", "+=", "'Python ({}) {}'", ".", "format", "(", "platform", ".", "system", "(", ")", ",", "sys", ".", "versio...
Get the runtime information. :return: Runtime information :rtype: str
[ "Get", "the", "runtime", "information", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L107-L120
229,332
Microsoft/knack
knack/cli.py
CLI.show_version
def show_version(self): """ Print version information to the out file. """ version_info = self.get_cli_version() version_info += self.get_runtime_version() print(version_info, file=self.out_file)
python
def show_version(self): """ Print version information to the out file. """ version_info = self.get_cli_version() version_info += self.get_runtime_version() print(version_info, file=self.out_file)
[ "def", "show_version", "(", "self", ")", ":", "version_info", "=", "self", ".", "get_cli_version", "(", ")", "version_info", "+=", "self", ".", "get_runtime_version", "(", ")", "print", "(", "version_info", ",", "file", "=", "self", ".", "out_file", ")" ]
Print version information to the out file.
[ "Print", "version", "information", "to", "the", "out", "file", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L122-L126
229,333
Microsoft/knack
knack/cli.py
CLI.unregister_event
def unregister_event(self, event_name, handler): """ Unregister a callable that will be called when event is raised. :param event_name: The name of the event (see knack.events for in-built events) :type event_name: str :param handler: The callback that was used to register the event ...
python
def unregister_event(self, event_name, handler): """ Unregister a callable that will be called when event is raised. :param event_name: The name of the event (see knack.events for in-built events) :type event_name: str :param handler: The callback that was used to register the event ...
[ "def", "unregister_event", "(", "self", ",", "event_name", ",", "handler", ")", ":", "try", ":", "self", ".", "_event_handlers", "[", "event_name", "]", ".", "remove", "(", "handler", ")", "except", "ValueError", ":", "pass" ]
Unregister a callable that will be called when event is raised. :param event_name: The name of the event (see knack.events for in-built events) :type event_name: str :param handler: The callback that was used to register the event :type handler: function
[ "Unregister", "a", "callable", "that", "will", "be", "called", "when", "event", "is", "raised", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L139-L150
229,334
Microsoft/knack
knack/cli.py
CLI.raise_event
def raise_event(self, event_name, **kwargs): """ Raise an event. Calls each handler in turn with kwargs :param event_name: The name of the event to raise :type event_name: str :param kwargs: Kwargs to be passed to all event handlers """ handlers = list(self._event_handle...
python
def raise_event(self, event_name, **kwargs): """ Raise an event. Calls each handler in turn with kwargs :param event_name: The name of the event to raise :type event_name: str :param kwargs: Kwargs to be passed to all event handlers """ handlers = list(self._event_handle...
[ "def", "raise_event", "(", "self", ",", "event_name", ",", "*", "*", "kwargs", ")", ":", "handlers", "=", "list", "(", "self", ".", "_event_handlers", "[", "event_name", "]", ")", "logger", ".", "debug", "(", "'Event: %s %s'", ",", "event_name", ",", "ha...
Raise an event. Calls each handler in turn with kwargs :param event_name: The name of the event to raise :type event_name: str :param kwargs: Kwargs to be passed to all event handlers
[ "Raise", "an", "event", ".", "Calls", "each", "handler", "in", "turn", "with", "kwargs" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L152-L162
229,335
Microsoft/knack
knack/cli.py
CLI.exception_handler
def exception_handler(self, ex): # pylint: disable=no-self-use """ The default exception handler """ if isinstance(ex, CLIError): logger.error(ex) else: logger.exception(ex) return 1
python
def exception_handler(self, ex): # pylint: disable=no-self-use """ The default exception handler """ if isinstance(ex, CLIError): logger.error(ex) else: logger.exception(ex) return 1
[ "def", "exception_handler", "(", "self", ",", "ex", ")", ":", "# pylint: disable=no-self-use", "if", "isinstance", "(", "ex", ",", "CLIError", ")", ":", "logger", ".", "error", "(", "ex", ")", "else", ":", "logger", ".", "exception", "(", "ex", ")", "ret...
The default exception handler
[ "The", "default", "exception", "handler" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L164-L170
229,336
Microsoft/knack
knack/cli.py
CLI.invoke
def invoke(self, args, initial_invocation_data=None, out_file=None): """ Invoke a command. :param args: The arguments that represent the command :type args: list, tuple :param initial_invocation_data: Prime the in memory collection of key-value data for this invocation. :type in...
python
def invoke(self, args, initial_invocation_data=None, out_file=None): """ Invoke a command. :param args: The arguments that represent the command :type args: list, tuple :param initial_invocation_data: Prime the in memory collection of key-value data for this invocation. :type in...
[ "def", "invoke", "(", "self", ",", "args", ",", "initial_invocation_data", "=", "None", ",", "out_file", "=", "None", ")", ":", "from", ".", "util", "import", "CommandResultItem", "if", "not", "isinstance", "(", "args", ",", "(", "list", ",", "tuple", ")...
Invoke a command. :param args: The arguments that represent the command :type args: list, tuple :param initial_invocation_data: Prime the in memory collection of key-value data for this invocation. :type initial_invocation_data: dict :param out_file: The file to send output to. ...
[ "Invoke", "a", "command", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L172-L223
229,337
Microsoft/knack
knack/log.py
get_logger
def get_logger(module_name=None): """ Get the logger for a module. If no module name is given, the current CLI logger is returned. Example: get_logger(__name__) :param module_name: The module to get the logger for :type module_name: str :return: The logger :rtype: logger """ if...
python
def get_logger(module_name=None): """ Get the logger for a module. If no module name is given, the current CLI logger is returned. Example: get_logger(__name__) :param module_name: The module to get the logger for :type module_name: str :return: The logger :rtype: logger """ if...
[ "def", "get_logger", "(", "module_name", "=", "None", ")", ":", "if", "module_name", ":", "logger_name", "=", "'{}.{}'", ".", "format", "(", "CLI_LOGGER_NAME", ",", "module_name", ")", "else", ":", "logger_name", "=", "CLI_LOGGER_NAME", "return", "logging", "....
Get the logger for a module. If no module name is given, the current CLI logger is returned. Example: get_logger(__name__) :param module_name: The module to get the logger for :type module_name: str :return: The logger :rtype: logger
[ "Get", "the", "logger", "for", "a", "module", ".", "If", "no", "module", "name", "is", "given", "the", "current", "CLI", "logger", "is", "returned", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L16-L31
229,338
Microsoft/knack
knack/log.py
CLILogging.configure
def configure(self, args): """ Configure the loggers with the appropriate log level etc. :param args: The arguments from the command line :type args: list """ verbose_level = self._determine_verbose_level(args) log_level_config = self.console_log_configs[verbose_level] ...
python
def configure(self, args): """ Configure the loggers with the appropriate log level etc. :param args: The arguments from the command line :type args: list """ verbose_level = self._determine_verbose_level(args) log_level_config = self.console_log_configs[verbose_level] ...
[ "def", "configure", "(", "self", ",", "args", ")", ":", "verbose_level", "=", "self", ".", "_determine_verbose_level", "(", "args", ")", "log_level_config", "=", "self", ".", "console_log_configs", "[", "verbose_level", "]", "root_logger", "=", "logging", ".", ...
Configure the loggers with the appropriate log level etc. :param args: The arguments from the command line :type args: list
[ "Configure", "the", "loggers", "with", "the", "appropriate", "log", "level", "etc", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L120-L141
229,339
Microsoft/knack
knack/log.py
CLILogging._determine_verbose_level
def _determine_verbose_level(self, args): """ Get verbose level by reading the arguments. """ verbose_level = 0 for arg in args: if arg == CLILogging.VERBOSE_FLAG: verbose_level += 1 elif arg == CLILogging.DEBUG_FLAG: verbose_level += 2 ...
python
def _determine_verbose_level(self, args): """ Get verbose level by reading the arguments. """ verbose_level = 0 for arg in args: if arg == CLILogging.VERBOSE_FLAG: verbose_level += 1 elif arg == CLILogging.DEBUG_FLAG: verbose_level += 2 ...
[ "def", "_determine_verbose_level", "(", "self", ",", "args", ")", ":", "verbose_level", "=", "0", "for", "arg", "in", "args", ":", "if", "arg", "==", "CLILogging", ".", "VERBOSE_FLAG", ":", "verbose_level", "+=", "1", "elif", "arg", "==", "CLILogging", "."...
Get verbose level by reading the arguments.
[ "Get", "verbose", "level", "by", "reading", "the", "arguments", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/log.py#L143-L152
229,340
Microsoft/knack
knack/arguments.py
enum_choice_list
def enum_choice_list(data): """ Creates the argparse choices and type kwargs for a supplied enum type or list of strings """ # transform enum types, otherwise assume list of string choices if not data: return {} try: choices = [x.value for x in data] except AttributeError: c...
python
def enum_choice_list(data): """ Creates the argparse choices and type kwargs for a supplied enum type or list of strings """ # transform enum types, otherwise assume list of string choices if not data: return {} try: choices = [x.value for x in data] except AttributeError: c...
[ "def", "enum_choice_list", "(", "data", ")", ":", "# transform enum types, otherwise assume list of string choices", "if", "not", "data", ":", "return", "{", "}", "try", ":", "choices", "=", "[", "x", ".", "value", "for", "x", "in", "data", "]", "except", "Att...
Creates the argparse choices and type kwargs for a supplied enum type or list of strings
[ "Creates", "the", "argparse", "choices", "and", "type", "kwargs", "for", "a", "supplied", "enum", "type", "or", "list", "of", "strings" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L359-L376
229,341
Microsoft/knack
knack/arguments.py
ArgumentRegistry.register_cli_argument
def register_cli_argument(self, scope, dest, argtype, **kwargs): """ Add an argument to the argument registry :param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand') :type scope: str :param dest: The parameter/destination that this argument is for ...
python
def register_cli_argument(self, scope, dest, argtype, **kwargs): """ Add an argument to the argument registry :param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand') :type scope: str :param dest: The parameter/destination that this argument is for ...
[ "def", "register_cli_argument", "(", "self", ",", "scope", ",", "dest", ",", "argtype", ",", "*", "*", "kwargs", ")", ":", "argument", "=", "CLIArgumentType", "(", "overrides", "=", "argtype", ",", "*", "*", "kwargs", ")", "self", ".", "arguments", "[", ...
Add an argument to the argument registry :param scope: The command level to apply the argument registration (e.g. 'mygroup mycommand') :type scope: str :param dest: The parameter/destination that this argument is for :type dest: str :param argtype: The argument type for this com...
[ "Add", "an", "argument", "to", "the", "argument", "registry" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L93-L105
229,342
Microsoft/knack
knack/arguments.py
ArgumentRegistry.get_cli_argument
def get_cli_argument(self, command, name): """ Get the argument for the command after applying the scope hierarchy :param command: The command that we want the argument for :type command: str :param name: The name of the argument :type name: str :return: The CLI command ...
python
def get_cli_argument(self, command, name): """ Get the argument for the command after applying the scope hierarchy :param command: The command that we want the argument for :type command: str :param name: The name of the argument :type name: str :return: The CLI command ...
[ "def", "get_cli_argument", "(", "self", ",", "command", ",", "name", ")", ":", "parts", "=", "command", ".", "split", "(", ")", "result", "=", "CLIArgumentType", "(", ")", "for", "index", "in", "range", "(", "0", ",", "len", "(", "parts", ")", "+", ...
Get the argument for the command after applying the scope hierarchy :param command: The command that we want the argument for :type command: str :param name: The name of the argument :type name: str :return: The CLI command after all overrides in the scope hierarchy have been ap...
[ "Get", "the", "argument", "for", "the", "command", "after", "applying", "the", "scope", "hierarchy" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L107-L124
229,343
Microsoft/knack
knack/arguments.py
ArgumentsContext.argument
def argument(self, argument_dest, arg_type=None, **kwargs): """ Register an argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Predefined CLIAr...
python
def argument(self, argument_dest, arg_type=None, **kwargs): """ Register an argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Predefined CLIAr...
[ "def", "argument", "(", "self", ",", "argument_dest", ",", "arg_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_stale", "(", ")", "if", "not", "self", ".", "_applicable", "(", ")", ":", "return", "deprecate_action", "=", "se...
Register an argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Predefined CLIArgumentType definition to register, as modified by any provided kwargs. ...
[ "Register", "an", "argument", "for", "the", "given", "command", "scope", "using", "a", "knack", ".", "arguments", ".", "CLIArgumentType" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L247-L267
229,344
Microsoft/knack
knack/arguments.py
ArgumentsContext.positional
def positional(self, argument_dest, arg_type=None, **kwargs): """ Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Pred...
python
def positional(self, argument_dest, arg_type=None, **kwargs): """ Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Pred...
[ "def", "positional", "(", "self", ",", "argument_dest", ",", "arg_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_stale", "(", ")", "if", "not", "self", ".", "_applicable", "(", ")", ":", "return", "if", "self", ".", "comm...
Register a positional argument for the given command scope using a knack.arguments.CLIArgumentType :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param arg_type: Predefined CLIArgumentType definition to register, as modified by any provided...
[ "Register", "a", "positional", "argument", "for", "the", "given", "command", "scope", "using", "a", "knack", ".", "arguments", ".", "CLIArgumentType" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L269-L304
229,345
Microsoft/knack
knack/arguments.py
ArgumentsContext.extra
def extra(self, argument_dest, **kwargs): """Register extra parameters for the given command. Typically used to augment auto-command built commands to add more parameters than the specific SDK method introspected. :param argument_dest: The destination argument to add this argument type to ...
python
def extra(self, argument_dest, **kwargs): """Register extra parameters for the given command. Typically used to augment auto-command built commands to add more parameters than the specific SDK method introspected. :param argument_dest: The destination argument to add this argument type to ...
[ "def", "extra", "(", "self", ",", "argument_dest", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_stale", "(", ")", "if", "not", "self", ".", "_applicable", "(", ")", ":", "return", "if", "self", ".", "command_scope", "in", "self", ".", "com...
Register extra parameters for the given command. Typically used to augment auto-command built commands to add more parameters than the specific SDK method introspected. :param argument_dest: The destination argument to add this argument type to :type argument_dest: str :param kwargs: Po...
[ "Register", "extra", "parameters", "for", "the", "given", "command", ".", "Typically", "used", "to", "augment", "auto", "-", "command", "built", "commands", "to", "add", "more", "parameters", "than", "the", "specific", "SDK", "method", "introspected", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/arguments.py#L319-L341
229,346
Microsoft/knack
knack/commands.py
CLICommandsLoader.load_command_table
def load_command_table(self, args): # pylint: disable=unused-argument """ Load commands into the command table :param args: List of the arguments from the command line :type args: list :return: The ordered command table :rtype: collections.OrderedDict """ self.c...
python
def load_command_table(self, args): # pylint: disable=unused-argument """ Load commands into the command table :param args: List of the arguments from the command line :type args: list :return: The ordered command table :rtype: collections.OrderedDict """ self.c...
[ "def", "load_command_table", "(", "self", ",", "args", ")", ":", "# pylint: disable=unused-argument", "self", ".", "cli_ctx", ".", "raise_event", "(", "EVENT_CMDLOADER_LOAD_COMMAND_TABLE", ",", "cmd_tbl", "=", "self", ".", "command_table", ")", "return", "OrderedDict"...
Load commands into the command table :param args: List of the arguments from the command line :type args: list :return: The ordered command table :rtype: collections.OrderedDict
[ "Load", "commands", "into", "the", "command", "table" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L189-L198
229,347
Microsoft/knack
knack/commands.py
CLICommandsLoader.load_arguments
def load_arguments(self, command): """ Load the arguments for the specified command :param command: The command to load arguments for :type command: str """ from knack.arguments import ArgumentsContext self.cli_ctx.raise_event(EVENT_CMDLOADER_LOAD_ARGUMENTS, cmd_tbl=sel...
python
def load_arguments(self, command): """ Load the arguments for the specified command :param command: The command to load arguments for :type command: str """ from knack.arguments import ArgumentsContext self.cli_ctx.raise_event(EVENT_CMDLOADER_LOAD_ARGUMENTS, cmd_tbl=sel...
[ "def", "load_arguments", "(", "self", ",", "command", ")", ":", "from", "knack", ".", "arguments", "import", "ArgumentsContext", "self", ".", "cli_ctx", ".", "raise_event", "(", "EVENT_CMDLOADER_LOAD_ARGUMENTS", ",", "cmd_tbl", "=", "self", ".", "command_table", ...
Load the arguments for the specified command :param command: The command to load arguments for :type command: str
[ "Load", "the", "arguments", "for", "the", "specified", "command" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L200-L218
229,348
Microsoft/knack
knack/commands.py
CLICommandsLoader.create_command
def create_command(self, name, operation, **kwargs): """ Constructs the command object that can then be added to the command table """ if not isinstance(operation, six.string_types): raise ValueError("Operation must be a string. Got '{}'".format(operation)) name = ' '.join(name.spli...
python
def create_command(self, name, operation, **kwargs): """ Constructs the command object that can then be added to the command table """ if not isinstance(operation, six.string_types): raise ValueError("Operation must be a string. Got '{}'".format(operation)) name = ' '.join(name.spli...
[ "def", "create_command", "(", "self", ",", "name", ",", "operation", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "operation", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"Operation must be a string. Got '{}'\...
Constructs the command object that can then be added to the command table
[ "Constructs", "the", "command", "object", "that", "can", "then", "be", "added", "to", "the", "command", "table" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L229-L255
229,349
Microsoft/knack
knack/commands.py
CLICommandsLoader._get_op_handler
def _get_op_handler(operation): """ Import and load the operation handler """ try: mod_to_import, attr_path = operation.split('#') op = import_module(mod_to_import) for part in attr_path.split('.'): op = getattr(op, part) if isinstance(op, ...
python
def _get_op_handler(operation): """ Import and load the operation handler """ try: mod_to_import, attr_path = operation.split('#') op = import_module(mod_to_import) for part in attr_path.split('.'): op = getattr(op, part) if isinstance(op, ...
[ "def", "_get_op_handler", "(", "operation", ")", ":", "try", ":", "mod_to_import", ",", "attr_path", "=", "operation", ".", "split", "(", "'#'", ")", "op", "=", "import_module", "(", "mod_to_import", ")", "for", "part", "in", "attr_path", ".", "split", "("...
Import and load the operation handler
[ "Import", "and", "load", "the", "operation", "handler" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L258-L269
229,350
Microsoft/knack
knack/commands.py
CommandGroup.command
def command(self, name, handler_name, **kwargs): """ Register a command into the command table :param name: The name of the command :type name: str :param handler_name: The name of the handler that will be applied to the operations template :type handler_name: str :param...
python
def command(self, name, handler_name, **kwargs): """ Register a command into the command table :param name: The name of the command :type name: str :param handler_name: The name of the handler that will be applied to the operations template :type handler_name: str :param...
[ "def", "command", "(", "self", ",", "name", ",", "handler_name", ",", "*", "*", "kwargs", ")", ":", "import", "copy", "command_name", "=", "'{} {}'", ".", "format", "(", "self", ".", "group_name", ",", "name", ")", "if", "self", ".", "group_name", "els...
Register a command into the command table :param name: The name of the command :type name: str :param handler_name: The name of the handler that will be applied to the operations template :type handler_name: str :param kwargs: Kwargs to apply to the command. ...
[ "Register", "a", "command", "into", "the", "command", "table" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/commands.py#L307-L330
229,351
Microsoft/knack
knack/invocation.py
CommandInvoker._rudimentary_get_command
def _rudimentary_get_command(self, args): """ Rudimentary parsing to get the command """ nouns = [] command_names = self.commands_loader.command_table.keys() for arg in args: if arg and arg[0] != '-': nouns.append(arg) else: break ...
python
def _rudimentary_get_command(self, args): """ Rudimentary parsing to get the command """ nouns = [] command_names = self.commands_loader.command_table.keys() for arg in args: if arg and arg[0] != '-': nouns.append(arg) else: break ...
[ "def", "_rudimentary_get_command", "(", "self", ",", "args", ")", ":", "nouns", "=", "[", "]", "command_names", "=", "self", ".", "commands_loader", ".", "command_table", ".", "keys", "(", ")", "for", "arg", "in", "args", ":", "if", "arg", "and", "arg", ...
Rudimentary parsing to get the command
[ "Rudimentary", "parsing", "to", "get", "the", "command" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/invocation.py#L67-L89
229,352
Microsoft/knack
knack/invocation.py
CommandInvoker.execute
def execute(self, args): """ Executes the command invocation :param args: The command arguments for this invocation :type args: list :return: The command result :rtype: knack.util.CommandResultItem """ import colorama self.cli_ctx.raise_event(EVENT_INVOK...
python
def execute(self, args): """ Executes the command invocation :param args: The command arguments for this invocation :type args: list :return: The command result :rtype: knack.util.CommandResultItem """ import colorama self.cli_ctx.raise_event(EVENT_INVOK...
[ "def", "execute", "(", "self", ",", "args", ")", ":", "import", "colorama", "self", ".", "cli_ctx", ".", "raise_event", "(", "EVENT_INVOKER_PRE_CMD_TBL_CREATE", ",", "args", "=", "args", ")", "cmd_tbl", "=", "self", ".", "commands_loader", ".", "load_command_t...
Executes the command invocation :param args: The command arguments for this invocation :type args: list :return: The command result :rtype: knack.util.CommandResultItem
[ "Executes", "the", "command", "invocation" ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/invocation.py#L120-L198
229,353
Microsoft/knack
knack/completion.py
CLICompletion.get_completion_args
def get_completion_args(self, is_completion=False, comp_line=None): # pylint: disable=no-self-use """ Get the args that will be used to tab completion if completion is active. """ is_completion = is_completion or os.environ.get(ARGCOMPLETE_ENV_NAME) comp_line = comp_line or os.environ.get('COMP...
python
def get_completion_args(self, is_completion=False, comp_line=None): # pylint: disable=no-self-use """ Get the args that will be used to tab completion if completion is active. """ is_completion = is_completion or os.environ.get(ARGCOMPLETE_ENV_NAME) comp_line = comp_line or os.environ.get('COMP...
[ "def", "get_completion_args", "(", "self", ",", "is_completion", "=", "False", ",", "comp_line", "=", "None", ")", ":", "# pylint: disable=no-self-use", "is_completion", "=", "is_completion", "or", "os", ".", "environ", ".", "get", "(", "ARGCOMPLETE_ENV_NAME", ")"...
Get the args that will be used to tab completion if completion is active.
[ "Get", "the", "args", "that", "will", "be", "used", "to", "tab", "completion", "if", "completion", "is", "active", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/completion.py#L37-L42
229,354
Microsoft/knack
knack/output.py
OutputProducer.out
def out(self, obj, formatter=None, out_file=None): # pylint: disable=no-self-use """ Produces the output using the command result. The method does not return a result as the output is written straight to the output file. :param obj: The command result :type obj: knack.util.CommandR...
python
def out(self, obj, formatter=None, out_file=None): # pylint: disable=no-self-use """ Produces the output using the command result. The method does not return a result as the output is written straight to the output file. :param obj: The command result :type obj: knack.util.CommandR...
[ "def", "out", "(", "self", ",", "obj", ",", "formatter", "=", "None", ",", "out_file", "=", "None", ")", ":", "# pylint: disable=no-self-use", "if", "not", "isinstance", "(", "obj", ",", "CommandResultItem", ")", ":", "raise", "TypeError", "(", "'Expected {}...
Produces the output using the command result. The method does not return a result as the output is written straight to the output file. :param obj: The command result :type obj: knack.util.CommandResultItem :param formatter: The formatter we should use for the command result ...
[ "Produces", "the", "output", "using", "the", "command", "result", ".", "The", "method", "does", "not", "return", "a", "result", "as", "the", "output", "is", "written", "straight", "to", "the", "output", "file", "." ]
5f1a480a33f103e2688c46eef59fb2d9eaf2baad
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/output.py#L113-L142
229,355
ryanmcgrath/twython
twython/endpoints.py
EndpointsMixin.update_status_with_media
def update_status_with_media(self, **params): # pragma: no cover """Updates the authenticating user's current status and attaches media for upload. In other words, it creates a Tweet with a picture attached. Docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-referen...
python
def update_status_with_media(self, **params): # pragma: no cover """Updates the authenticating user's current status and attaches media for upload. In other words, it creates a Tweet with a picture attached. Docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-referen...
[ "def", "update_status_with_media", "(", "self", ",", "*", "*", "params", ")", ":", "# pragma: no cover", "warnings", ".", "warn", "(", "'This method is deprecated. You should use Twython.upload_media instead.'", ",", "TwythonDeprecationWarning", ",", "stacklevel", "=", "2",...
Updates the authenticating user's current status and attaches media for upload. In other words, it creates a Tweet with a picture attached. Docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update_with_media
[ "Updates", "the", "authenticating", "user", "s", "current", "status", "and", "attaches", "media", "for", "upload", ".", "In", "other", "words", "it", "creates", "a", "Tweet", "with", "a", "picture", "attached", "." ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/endpoints.py#L134-L147
229,356
ryanmcgrath/twython
twython/endpoints.py
EndpointsMixin.create_metadata
def create_metadata(self, **params): """ Adds metadata to a media element, such as image descriptions for visually impaired. Docs: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create """ params = json.dumps(params) return se...
python
def create_metadata(self, **params): """ Adds metadata to a media element, such as image descriptions for visually impaired. Docs: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create """ params = json.dumps(params) return se...
[ "def", "create_metadata", "(", "self", ",", "*", "*", "params", ")", ":", "params", "=", "json", ".", "dumps", "(", "params", ")", "return", "self", ".", "post", "(", "\"https://upload.twitter.com/1.1/media/metadata/create.json\"", ",", "params", "=", "params", ...
Adds metadata to a media element, such as image descriptions for visually impaired. Docs: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create
[ "Adds", "metadata", "to", "a", "media", "element", "such", "as", "image", "descriptions", "for", "visually", "impaired", "." ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/endpoints.py#L164-L172
229,357
ryanmcgrath/twython
twython/api.py
Twython._get_error_message
def _get_error_message(self, response): """Parse and return the first error message""" error_message = 'An error occurred processing your request.' try: content = response.json() # {"errors":[{"code":34,"message":"Sorry, # that page does not exist"}]} ...
python
def _get_error_message(self, response): """Parse and return the first error message""" error_message = 'An error occurred processing your request.' try: content = response.json() # {"errors":[{"code":34,"message":"Sorry, # that page does not exist"}]} ...
[ "def", "_get_error_message", "(", "self", ",", "response", ")", ":", "error_message", "=", "'An error occurred processing your request.'", "try", ":", "content", "=", "response", ".", "json", "(", ")", "# {\"errors\":[{\"code\":34,\"message\":\"Sorry,", "# that page does no...
Parse and return the first error message
[ "Parse", "and", "return", "the", "first", "error", "message" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L218-L236
229,358
ryanmcgrath/twython
twython/api.py
Twython.request
def request(self, endpoint, method='GET', params=None, version='1.1', json_encoded=False): """Return dict of response received from Twitter's API :param endpoint: (required) Full url or Twitter API endpoint (e.g. search/tweets) :type endpoint: string :param meth...
python
def request(self, endpoint, method='GET', params=None, version='1.1', json_encoded=False): """Return dict of response received from Twitter's API :param endpoint: (required) Full url or Twitter API endpoint (e.g. search/tweets) :type endpoint: string :param meth...
[ "def", "request", "(", "self", ",", "endpoint", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "version", "=", "'1.1'", ",", "json_encoded", "=", "False", ")", ":", "if", "endpoint", ".", "startswith", "(", "'http://'", ")", ":", "raise"...
Return dict of response received from Twitter's API :param endpoint: (required) Full url or Twitter API endpoint (e.g. search/tweets) :type endpoint: string :param method: (optional) Method of accessing data, either GET, POST or DELETE. (default G...
[ "Return", "dict", "of", "response", "received", "from", "Twitter", "s", "API" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L238-L274
229,359
ryanmcgrath/twython
twython/api.py
Twython.get_lastfunction_header
def get_lastfunction_header(self, header, default_return_value=None): """Returns a specific header from the last API call This will return None if the header is not present :param header: (required) The name of the header you want to get the value of Most useful ...
python
def get_lastfunction_header(self, header, default_return_value=None): """Returns a specific header from the last API call This will return None if the header is not present :param header: (required) The name of the header you want to get the value of Most useful ...
[ "def", "get_lastfunction_header", "(", "self", ",", "header", ",", "default_return_value", "=", "None", ")", ":", "if", "self", ".", "_last_call", "is", "None", ":", "raise", "TwythonError", "(", "'This function must be called after an API call. \\\n ...
Returns a specific header from the last API call This will return None if the header is not present :param header: (required) The name of the header you want to get the value of Most useful for the following header information: x-rate-limit-limit, ...
[ "Returns", "a", "specific", "header", "from", "the", "last", "API", "call", "This", "will", "return", "None", "if", "the", "header", "is", "not", "present" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L288-L306
229,360
ryanmcgrath/twython
twython/api.py
Twython.get_authentication_tokens
def get_authentication_tokens(self, callback_url=None, force_login=False, screen_name=''): """Returns a dict including an authorization URL, ``auth_url``, to direct a user to :param callback_url: (optional) Url the user is returned to after ...
python
def get_authentication_tokens(self, callback_url=None, force_login=False, screen_name=''): """Returns a dict including an authorization URL, ``auth_url``, to direct a user to :param callback_url: (optional) Url the user is returned to after ...
[ "def", "get_authentication_tokens", "(", "self", ",", "callback_url", "=", "None", ",", "force_login", "=", "False", ",", "screen_name", "=", "''", ")", ":", "if", "self", ".", "oauth_version", "!=", "1", ":", "raise", "TwythonError", "(", "'This method can on...
Returns a dict including an authorization URL, ``auth_url``, to direct a user to :param callback_url: (optional) Url the user is returned to after they authorize your app (web clients only) :param force_login: (optional) Forces the user to enter their ...
[ "Returns", "a", "dict", "including", "an", "authorization", "URL", "auth_url", "to", "direct", "a", "user", "to" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L308-L365
229,361
ryanmcgrath/twython
twython/api.py
Twython.obtain_access_token
def obtain_access_token(self): """Returns an OAuth 2 access token to make OAuth 2 authenticated read-only calls. :rtype: string """ if self.oauth_version != 2: raise TwythonError('This method can only be called when your \ OAuth version...
python
def obtain_access_token(self): """Returns an OAuth 2 access token to make OAuth 2 authenticated read-only calls. :rtype: string """ if self.oauth_version != 2: raise TwythonError('This method can only be called when your \ OAuth version...
[ "def", "obtain_access_token", "(", "self", ")", ":", "if", "self", ".", "oauth_version", "!=", "2", ":", "raise", "TwythonError", "(", "'This method can only be called when your \\\n OAuth version is 2.0.'", ")", "data", "=", "{", "'grant_type'...
Returns an OAuth 2 access token to make OAuth 2 authenticated read-only calls. :rtype: string
[ "Returns", "an", "OAuth", "2", "access", "token", "to", "make", "OAuth", "2", "authenticated", "read", "-", "only", "calls", "." ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L405-L429
229,362
ryanmcgrath/twython
twython/api.py
Twython.construct_api_url
def construct_api_url(api_url, **params): """Construct a Twitter API url, encoded, with parameters :param api_url: URL of the Twitter API endpoint you are attempting to construct :param \*\*params: Parameters that are accepted by Twitter for the endpoint you're requesting ...
python
def construct_api_url(api_url, **params): """Construct a Twitter API url, encoded, with parameters :param api_url: URL of the Twitter API endpoint you are attempting to construct :param \*\*params: Parameters that are accepted by Twitter for the endpoint you're requesting ...
[ "def", "construct_api_url", "(", "api_url", ",", "*", "*", "params", ")", ":", "querystring", "=", "[", "]", "params", ",", "_", "=", "_transparent_params", "(", "params", "or", "{", "}", ")", "params", "=", "requests", ".", "utils", ".", "to_key_val_lis...
Construct a Twitter API url, encoded, with parameters :param api_url: URL of the Twitter API endpoint you are attempting to construct :param \*\*params: Parameters that are accepted by Twitter for the endpoint you're requesting :rtype: string Usage:: >>> from...
[ "Construct", "a", "Twitter", "API", "url", "encoded", "with", "parameters" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L432-L460
229,363
ryanmcgrath/twython
twython/api.py
Twython.cursor
def cursor(self, function, return_pages=False, **params): """Returns a generator for results that match a specified query. :param function: Instance of a Twython function (Twython.get_home_timeline, Twython.search) :param \*\*params: Extra parameters to send with your request (u...
python
def cursor(self, function, return_pages=False, **params): """Returns a generator for results that match a specified query. :param function: Instance of a Twython function (Twython.get_home_timeline, Twython.search) :param \*\*params: Extra parameters to send with your request (u...
[ "def", "cursor", "(", "self", ",", "function", ",", "return_pages", "=", "False", ",", "*", "*", "params", ")", ":", "if", "not", "callable", "(", "function", ")", ":", "raise", "TypeError", "(", "'.cursor() takes a Twython function as its first \\\n ...
Returns a generator for results that match a specified query. :param function: Instance of a Twython function (Twython.get_home_timeline, Twython.search) :param \*\*params: Extra parameters to send with your request (usually parameters accepted by the Twitter API endpoint) :rtyp...
[ "Returns", "a", "generator", "for", "results", "that", "match", "a", "specified", "query", "." ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/api.py#L471-L543
229,364
ryanmcgrath/twython
twython/streaming/api.py
TwythonStreamer._request
def _request(self, url, method='GET', params=None): """Internal stream request handling""" self.connected = True retry_counter = 0 method = method.lower() func = getattr(self.client, method) params, _ = _transparent_params(params) def _send(retry_counter): ...
python
def _request(self, url, method='GET', params=None): """Internal stream request handling""" self.connected = True retry_counter = 0 method = method.lower() func = getattr(self.client, method) params, _ = _transparent_params(params) def _send(retry_counter): ...
[ "def", "_request", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "params", "=", "None", ")", ":", "self", ".", "connected", "=", "True", "retry_counter", "=", "0", "method", "=", "method", ".", "lower", "(", ")", "func", "=", "getattr", ...
Internal stream request handling
[ "Internal", "stream", "request", "handling" ]
7366de80efcbbdfaf615d3f1fea72546196916fc
https://github.com/ryanmcgrath/twython/blob/7366de80efcbbdfaf615d3f1fea72546196916fc/twython/streaming/api.py#L99-L165
229,365
orsinium/textdistance
textdistance/libraries.py
LibrariesManager.optimize
def optimize(self): """Sort algorithm implementations by speed. """ # load benchmarks results with open(LIBRARIES_FILE, 'r') as f: libs_data = json.load(f) # optimize for alg, libs_names in libs_data.items(): libs = self.get_libs(alg) i...
python
def optimize(self): """Sort algorithm implementations by speed. """ # load benchmarks results with open(LIBRARIES_FILE, 'r') as f: libs_data = json.load(f) # optimize for alg, libs_names in libs_data.items(): libs = self.get_libs(alg) i...
[ "def", "optimize", "(", "self", ")", ":", "# load benchmarks results", "with", "open", "(", "LIBRARIES_FILE", ",", "'r'", ")", "as", "f", ":", "libs_data", "=", "json", ".", "load", "(", "f", ")", "# optimize", "for", "alg", ",", "libs_names", "in", "lib...
Sort algorithm implementations by speed.
[ "Sort", "algorithm", "implementations", "by", "speed", "." ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/libraries.py#L23-L37
229,366
orsinium/textdistance
textdistance/libraries.py
LibrariesManager.clone
def clone(self): """Clone library manager prototype """ obj = self.__class__() obj.libs = deepcopy(self.libs) return obj
python
def clone(self): """Clone library manager prototype """ obj = self.__class__() obj.libs = deepcopy(self.libs) return obj
[ "def", "clone", "(", "self", ")", ":", "obj", "=", "self", ".", "__class__", "(", ")", "obj", ".", "libs", "=", "deepcopy", "(", "self", ".", "libs", ")", "return", "obj" ]
Clone library manager prototype
[ "Clone", "library", "manager", "prototype" ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/libraries.py#L51-L56
229,367
orsinium/textdistance
textdistance/algorithms/base.py
Base.normalized_distance
def normalized_distance(self, *sequences): """Get distance from 0 to 1 """ return float(self.distance(*sequences)) / self.maximum(*sequences)
python
def normalized_distance(self, *sequences): """Get distance from 0 to 1 """ return float(self.distance(*sequences)) / self.maximum(*sequences)
[ "def", "normalized_distance", "(", "self", ",", "*", "sequences", ")", ":", "return", "float", "(", "self", ".", "distance", "(", "*", "sequences", ")", ")", "/", "self", ".", "maximum", "(", "*", "sequences", ")" ]
Get distance from 0 to 1
[ "Get", "distance", "from", "0", "to", "1" ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L39-L42
229,368
orsinium/textdistance
textdistance/algorithms/base.py
Base.external_answer
def external_answer(self, *sequences): """Try to get answer from known external libraries. """ # if this feature disabled if not getattr(self, 'external', False): return # all external libs doesn't support test_func if hasattr(self, 'test_func') and self.test_...
python
def external_answer(self, *sequences): """Try to get answer from known external libraries. """ # if this feature disabled if not getattr(self, 'external', False): return # all external libs doesn't support test_func if hasattr(self, 'test_func') and self.test_...
[ "def", "external_answer", "(", "self", ",", "*", "sequences", ")", ":", "# if this feature disabled", "if", "not", "getattr", "(", "self", ",", "'external'", ",", "False", ")", ":", "return", "# all external libs doesn't support test_func", "if", "hasattr", "(", "...
Try to get answer from known external libraries.
[ "Try", "to", "get", "answer", "from", "known", "external", "libraries", "." ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L51-L75
229,369
orsinium/textdistance
textdistance/algorithms/base.py
Base._ident
def _ident(*elements): """Return True if all sequences are equal. """ try: # for hashable elements return len(set(elements)) == 1 except TypeError: # for unhashable elements for e1, e2 in zip(elements, elements[1:]): if e1 !...
python
def _ident(*elements): """Return True if all sequences are equal. """ try: # for hashable elements return len(set(elements)) == 1 except TypeError: # for unhashable elements for e1, e2 in zip(elements, elements[1:]): if e1 !...
[ "def", "_ident", "(", "*", "elements", ")", ":", "try", ":", "# for hashable elements", "return", "len", "(", "set", "(", "elements", ")", ")", "==", "1", "except", "TypeError", ":", "# for unhashable elements", "for", "e1", ",", "e2", "in", "zip", "(", ...
Return True if all sequences are equal.
[ "Return", "True", "if", "all", "sequences", "are", "equal", "." ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L98-L109
229,370
orsinium/textdistance
textdistance/algorithms/base.py
Base._get_sequences
def _get_sequences(self, *sequences): """Prepare sequences. qval=None: split text by words qval=1: do not split sequences. For text this is mean comparing by letters. qval>1: split sequences by q-grams """ # by words if not self.qval: return [s.split(...
python
def _get_sequences(self, *sequences): """Prepare sequences. qval=None: split text by words qval=1: do not split sequences. For text this is mean comparing by letters. qval>1: split sequences by q-grams """ # by words if not self.qval: return [s.split(...
[ "def", "_get_sequences", "(", "self", ",", "*", "sequences", ")", ":", "# by words", "if", "not", "self", ".", "qval", ":", "return", "[", "s", ".", "split", "(", ")", "for", "s", "in", "sequences", "]", "# by chars", "if", "self", ".", "qval", "==",...
Prepare sequences. qval=None: split text by words qval=1: do not split sequences. For text this is mean comparing by letters. qval>1: split sequences by q-grams
[ "Prepare", "sequences", "." ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L111-L125
229,371
orsinium/textdistance
textdistance/algorithms/base.py
Base._get_counters
def _get_counters(self, *sequences): """Prepare sequences and convert it to Counters. """ # already Counters if all(isinstance(s, Counter) for s in sequences): return sequences return [Counter(s) for s in self._get_sequences(*sequences)]
python
def _get_counters(self, *sequences): """Prepare sequences and convert it to Counters. """ # already Counters if all(isinstance(s, Counter) for s in sequences): return sequences return [Counter(s) for s in self._get_sequences(*sequences)]
[ "def", "_get_counters", "(", "self", ",", "*", "sequences", ")", ":", "# already Counters", "if", "all", "(", "isinstance", "(", "s", ",", "Counter", ")", "for", "s", "in", "sequences", ")", ":", "return", "sequences", "return", "[", "Counter", "(", "s",...
Prepare sequences and convert it to Counters.
[ "Prepare", "sequences", "and", "convert", "it", "to", "Counters", "." ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L127-L133
229,372
orsinium/textdistance
textdistance/algorithms/base.py
Base._count_counters
def _count_counters(self, counter): """Return all elements count from Counter """ if getattr(self, 'as_set', False): return len(set(counter)) else: return sum(counter.values())
python
def _count_counters(self, counter): """Return all elements count from Counter """ if getattr(self, 'as_set', False): return len(set(counter)) else: return sum(counter.values())
[ "def", "_count_counters", "(", "self", ",", "counter", ")", ":", "if", "getattr", "(", "self", ",", "'as_set'", ",", "False", ")", ":", "return", "len", "(", "set", "(", "counter", ")", ")", "else", ":", "return", "sum", "(", "counter", ".", "values"...
Return all elements count from Counter
[ "Return", "all", "elements", "count", "from", "Counter" ]
34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7
https://github.com/orsinium/textdistance/blob/34d2e40bb0b26efc03da80b63fd58ebbd3f2cdd7/textdistance/algorithms/base.py#L153-L159
229,373
SCIP-Interfaces/PySCIPOpt
examples/finished/transp.py
make_inst2
def make_inst2(): """creates example data set 2""" I,d = multidict({1:45, 2:20, 3:30 , 4:30}) # demand J,M = multidict({1:35, 2:50, 3:40}) # capacity c = {(1,1):8, (1,2):9, (1,3):14 , # {(customer,factory) : cost<float>} (2,1):6, (2,2):12, (2,3):9 , (3,1):10, (...
python
def make_inst2(): """creates example data set 2""" I,d = multidict({1:45, 2:20, 3:30 , 4:30}) # demand J,M = multidict({1:35, 2:50, 3:40}) # capacity c = {(1,1):8, (1,2):9, (1,3):14 , # {(customer,factory) : cost<float>} (2,1):6, (2,2):12, (2,3):9 , (3,1):10, (...
[ "def", "make_inst2", "(", ")", ":", "I", ",", "d", "=", "multidict", "(", "{", "1", ":", "45", ",", "2", ":", "20", ",", "3", ":", "30", ",", "4", ":", "30", "}", ")", "# demand", "J", ",", "M", "=", "multidict", "(", "{", "1", ":", "35",...
creates example data set 2
[ "creates", "example", "data", "set", "2" ]
9c960b40d94a48b0304d73dbe28b467b9c065abe
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/transp.py#L62-L71
229,374
SCIP-Interfaces/PySCIPOpt
examples/unfinished/vrp_lazy.py
VRPconshdlr.addCuts
def addCuts(self, checkonly): """add cuts if necessary and return whether model is feasible""" cutsadded = False edges = [] x = self.model.data for (i, j) in x: if self.model.getVal(x[i, j]) > .5: if i != V[0] and j != V[0]: edges.a...
python
def addCuts(self, checkonly): """add cuts if necessary and return whether model is feasible""" cutsadded = False edges = [] x = self.model.data for (i, j) in x: if self.model.getVal(x[i, j]) > .5: if i != V[0] and j != V[0]: edges.a...
[ "def", "addCuts", "(", "self", ",", "checkonly", ")", ":", "cutsadded", "=", "False", "edges", "=", "[", "]", "x", "=", "self", ".", "model", ".", "data", "for", "(", "i", ",", "j", ")", "in", "x", ":", "if", "self", ".", "model", ".", "getVal"...
add cuts if necessary and return whether model is feasible
[ "add", "cuts", "if", "necessary", "and", "return", "whether", "model", "is", "feasible" ]
9c960b40d94a48b0304d73dbe28b467b9c065abe
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/unfinished/vrp_lazy.py#L17-L42
229,375
SCIP-Interfaces/PySCIPOpt
examples/finished/read_tsplib.py
distCEIL2D
def distCEIL2D(x1,y1,x2,y2): """returns smallest integer not less than the distance of two points""" xdiff = x2 - x1 ydiff = y2 - y1 return int(math.ceil(math.sqrt(xdiff*xdiff + ydiff*ydiff)))
python
def distCEIL2D(x1,y1,x2,y2): """returns smallest integer not less than the distance of two points""" xdiff = x2 - x1 ydiff = y2 - y1 return int(math.ceil(math.sqrt(xdiff*xdiff + ydiff*ydiff)))
[ "def", "distCEIL2D", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "xdiff", "=", "x2", "-", "x1", "ydiff", "=", "y2", "-", "y1", "return", "int", "(", "math", ".", "ceil", "(", "math", ".", "sqrt", "(", "xdiff", "*", "xdiff", "+", "yd...
returns smallest integer not less than the distance of two points
[ "returns", "smallest", "integer", "not", "less", "than", "the", "distance", "of", "two", "points" ]
9c960b40d94a48b0304d73dbe28b467b9c065abe
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/read_tsplib.py#L53-L57
229,376
SCIP-Interfaces/PySCIPOpt
examples/finished/read_tsplib.py
read_atsplib
def read_atsplib(filename): "basic function for reading a ATSP problem on the TSPLIB format" "NOTE: only works for explicit matrices" if filename[-3:] == ".gz": f = gzip.open(filename, 'r') data = f.readlines() else: f = open(filename, 'r') data = f.readlines() for ...
python
def read_atsplib(filename): "basic function for reading a ATSP problem on the TSPLIB format" "NOTE: only works for explicit matrices" if filename[-3:] == ".gz": f = gzip.open(filename, 'r') data = f.readlines() else: f = open(filename, 'r') data = f.readlines() for ...
[ "def", "read_atsplib", "(", "filename", ")", ":", "\"NOTE: only works for explicit matrices\"", "if", "filename", "[", "-", "3", ":", "]", "==", "\".gz\"", ":", "f", "=", "gzip", ".", "open", "(", "filename", ",", "'r'", ")", "data", "=", "f", ".", "read...
basic function for reading a ATSP problem on the TSPLIB format
[ "basic", "function", "for", "reading", "a", "ATSP", "problem", "on", "the", "TSPLIB", "format" ]
9c960b40d94a48b0304d73dbe28b467b9c065abe
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/read_tsplib.py#L216-L262
229,377
SCIP-Interfaces/PySCIPOpt
src/pyscipopt/Multidict.py
multidict
def multidict(D): '''creates a multidictionary''' keys = list(D.keys()) if len(keys) == 0: return [[]] try: N = len(D[keys[0]]) islist = True except: N = 1 islist = False dlist = [dict() for d in range(N)] for k in keys: if islist: ...
python
def multidict(D): '''creates a multidictionary''' keys = list(D.keys()) if len(keys) == 0: return [[]] try: N = len(D[keys[0]]) islist = True except: N = 1 islist = False dlist = [dict() for d in range(N)] for k in keys: if islist: ...
[ "def", "multidict", "(", "D", ")", ":", "keys", "=", "list", "(", "D", ".", "keys", "(", ")", ")", "if", "len", "(", "keys", ")", "==", "0", ":", "return", "[", "[", "]", "]", "try", ":", "N", "=", "len", "(", "D", "[", "keys", "[", "0", ...
creates a multidictionary
[ "creates", "a", "multidictionary" ]
9c960b40d94a48b0304d73dbe28b467b9c065abe
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/src/pyscipopt/Multidict.py#L3-L21
229,378
intake/intake
intake/catalog/local.py
register_plugin_module
def register_plugin_module(mod): """Find plugins in given module""" for k, v in load_plugins_from_module(mod).items(): if k: if isinstance(k, (list, tuple)): k = k[0] global_registry[k] = v
python
def register_plugin_module(mod): """Find plugins in given module""" for k, v in load_plugins_from_module(mod).items(): if k: if isinstance(k, (list, tuple)): k = k[0] global_registry[k] = v
[ "def", "register_plugin_module", "(", "mod", ")", ":", "for", "k", ",", "v", "in", "load_plugins_from_module", "(", "mod", ")", ".", "items", "(", ")", ":", "if", "k", ":", "if", "isinstance", "(", "k", ",", "(", "list", ",", "tuple", ")", ")", ":"...
Find plugins in given module
[ "Find", "plugins", "in", "given", "module" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L494-L500
229,379
intake/intake
intake/catalog/local.py
register_plugin_dir
def register_plugin_dir(path): """Find plugins in given directory""" import glob for f in glob.glob(path + '/*.py'): for k, v in load_plugins_from_module(f).items(): if k: global_registry[k] = v
python
def register_plugin_dir(path): """Find plugins in given directory""" import glob for f in glob.glob(path + '/*.py'): for k, v in load_plugins_from_module(f).items(): if k: global_registry[k] = v
[ "def", "register_plugin_dir", "(", "path", ")", ":", "import", "glob", "for", "f", "in", "glob", ".", "glob", "(", "path", "+", "'/*.py'", ")", ":", "for", "k", ",", "v", "in", "load_plugins_from_module", "(", "f", ")", ".", "items", "(", ")", ":", ...
Find plugins in given directory
[ "Find", "plugins", "in", "given", "directory" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L503-L509
229,380
intake/intake
intake/catalog/local.py
UserParameter.describe
def describe(self): """Information about this parameter""" desc = { 'name': self.name, 'description': self.description, # the Parameter might not have a type at all 'type': self.type or 'unknown', } for attr in ['min', 'max', 'allowed', 'de...
python
def describe(self): """Information about this parameter""" desc = { 'name': self.name, 'description': self.description, # the Parameter might not have a type at all 'type': self.type or 'unknown', } for attr in ['min', 'max', 'allowed', 'de...
[ "def", "describe", "(", "self", ")", ":", "desc", "=", "{", "'name'", ":", "self", ".", "name", ",", "'description'", ":", "self", ".", "description", ",", "# the Parameter might not have a type at all", "'type'", ":", "self", ".", "type", "or", "'unknown'", ...
Information about this parameter
[ "Information", "about", "this", "parameter" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L88-L100
229,381
intake/intake
intake/catalog/local.py
UserParameter.validate
def validate(self, value): """Does value meet parameter requirements?""" if self.type is not None: value = coerce(self.type, value) if self.min is not None and value < self.min: raise ValueError('%s=%s is less than %s' % (self.name, value, ...
python
def validate(self, value): """Does value meet parameter requirements?""" if self.type is not None: value = coerce(self.type, value) if self.min is not None and value < self.min: raise ValueError('%s=%s is less than %s' % (self.name, value, ...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "type", "is", "not", "None", ":", "value", "=", "coerce", "(", "self", ".", "type", ",", "value", ")", "if", "self", ".", "min", "is", "not", "None", "and", "value", "<", ...
Does value meet parameter requirements?
[ "Does", "value", "meet", "parameter", "requirements?" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L111-L126
229,382
intake/intake
intake/catalog/local.py
LocalCatalogEntry.describe
def describe(self): """Basic information about this entry""" if isinstance(self._plugin, list): pl = [p.name for p in self._plugin] elif isinstance(self._plugin, dict): pl = {k: classname(v) for k, v in self._plugin.items()} else: pl = self._plugin if ...
python
def describe(self): """Basic information about this entry""" if isinstance(self._plugin, list): pl = [p.name for p in self._plugin] elif isinstance(self._plugin, dict): pl = {k: classname(v) for k, v in self._plugin.items()} else: pl = self._plugin if ...
[ "def", "describe", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_plugin", ",", "list", ")", ":", "pl", "=", "[", "p", ".", "name", "for", "p", "in", "self", ".", "_plugin", "]", "elif", "isinstance", "(", "self", ".", "_plugin", ...
Basic information about this entry
[ "Basic", "information", "about", "this", "entry" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L207-L224
229,383
intake/intake
intake/catalog/local.py
LocalCatalogEntry.get
def get(self, **user_parameters): """Instantiate the DataSource for the given parameters""" plugin, open_args = self._create_open_args(user_parameters) data_source = plugin(**open_args) data_source.catalog_object = self._catalog data_source.name = self.name data_source.de...
python
def get(self, **user_parameters): """Instantiate the DataSource for the given parameters""" plugin, open_args = self._create_open_args(user_parameters) data_source = plugin(**open_args) data_source.catalog_object = self._catalog data_source.name = self.name data_source.de...
[ "def", "get", "(", "self", ",", "*", "*", "user_parameters", ")", ":", "plugin", ",", "open_args", "=", "self", ".", "_create_open_args", "(", "user_parameters", ")", "data_source", "=", "plugin", "(", "*", "*", "open_args", ")", "data_source", ".", "catal...
Instantiate the DataSource for the given parameters
[ "Instantiate", "the", "DataSource", "for", "the", "given", "parameters" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L263-L272
229,384
intake/intake
intake/catalog/local.py
YAMLFileCatalog._load
def _load(self, reload=False): """Load text of fcatalog file and pass to parse Will do nothing if autoreload is off and reload is not explicitly requested """ if self.autoreload or reload: # First, we load from YAML, failing if syntax errors are found opt...
python
def _load(self, reload=False): """Load text of fcatalog file and pass to parse Will do nothing if autoreload is off and reload is not explicitly requested """ if self.autoreload or reload: # First, we load from YAML, failing if syntax errors are found opt...
[ "def", "_load", "(", "self", ",", "reload", "=", "False", ")", ":", "if", "self", ".", "autoreload", "or", "reload", ":", "# First, we load from YAML, failing if syntax errors are found", "options", "=", "self", ".", "storage_options", "or", "{", "}", "if", "has...
Load text of fcatalog file and pass to parse Will do nothing if autoreload is off and reload is not explicitly requested
[ "Load", "text", "of", "fcatalog", "file", "and", "pass", "to", "parse" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L544-L569
229,385
intake/intake
intake/catalog/local.py
YAMLFileCatalog.parse
def parse(self, text): """Create entries from catalog text Normally the text comes from the file at self.path via the ``_load()`` method, but could be explicitly set instead. A copy of the text is kept in attribute ``.text`` . Parameters ---------- text : str ...
python
def parse(self, text): """Create entries from catalog text Normally the text comes from the file at self.path via the ``_load()`` method, but could be explicitly set instead. A copy of the text is kept in attribute ``.text`` . Parameters ---------- text : str ...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "self", ".", "text", "=", "text", "data", "=", "yaml_load", "(", "self", ".", "text", ")", "if", "data", "is", "None", ":", "raise", "exceptions", ".", "CatalogException", "(", "'No YAML data in file'",...
Create entries from catalog text Normally the text comes from the file at self.path via the ``_load()`` method, but could be explicitly set instead. A copy of the text is kept in attribute ``.text`` . Parameters ---------- text : str YAML formatted catalog s...
[ "Create", "entries", "from", "catalog", "text" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L571-L607
229,386
intake/intake
intake/catalog/local.py
YAMLFileCatalog.name_from_path
def name_from_path(self): """If catalog is named 'catalog' take name from parent directory""" name = os.path.splitext(os.path.basename(self.path))[0] if name == 'catalog': name = os.path.basename(os.path.dirname(self.path)) return name.replace('.', '_')
python
def name_from_path(self): """If catalog is named 'catalog' take name from parent directory""" name = os.path.splitext(os.path.basename(self.path))[0] if name == 'catalog': name = os.path.basename(os.path.dirname(self.path)) return name.replace('.', '_')
[ "def", "name_from_path", "(", "self", ")", ":", "name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "path", ")", ")", "[", "0", "]", "if", "name", "==", "'catalog'", ":", "name", "=", "os", ...
If catalog is named 'catalog' take name from parent directory
[ "If", "catalog", "is", "named", "catalog", "take", "name", "from", "parent", "directory" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/local.py#L610-L615
229,387
intake/intake
intake/cli/server/server.py
ServerSourceHandler.get
def get(self): """ Access one source's info. This is for direct access to an entry by name for random access, which is useful to the client when the whole catalog has not first been listed and pulled locally (e.g., in the case of pagination). """ head = self.requ...
python
def get(self): """ Access one source's info. This is for direct access to an entry by name for random access, which is useful to the client when the whole catalog has not first been listed and pulled locally (e.g., in the case of pagination). """ head = self.requ...
[ "def", "get", "(", "self", ")", ":", "head", "=", "self", ".", "request", ".", "headers", "name", "=", "self", ".", "get_argument", "(", "'name'", ")", "if", "self", ".", "auth", ".", "allow_connect", "(", "head", ")", ":", "if", "'source_id'", "in",...
Access one source's info. This is for direct access to an entry by name for random access, which is useful to the client when the whole catalog has not first been listed and pulled locally (e.g., in the case of pagination).
[ "Access", "one", "source", "s", "info", "." ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/cli/server/server.py#L186-L216
229,388
intake/intake
intake/gui/catalog/select.py
CatSelector.preprocess
def preprocess(cls, cat): """Function to run on each cat input""" if isinstance(cat, str): cat = intake.open_catalog(cat) return cat
python
def preprocess(cls, cat): """Function to run on each cat input""" if isinstance(cat, str): cat = intake.open_catalog(cat) return cat
[ "def", "preprocess", "(", "cls", ",", "cat", ")", ":", "if", "isinstance", "(", "cat", ",", "str", ")", ":", "cat", "=", "intake", ".", "open_catalog", "(", "cat", ")", "return", "cat" ]
Function to run on each cat input
[ "Function", "to", "run", "on", "each", "cat", "input" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/catalog/select.py#L57-L61
229,389
intake/intake
intake/gui/catalog/select.py
CatSelector.expand_nested
def expand_nested(self, cats): """Populate widget with nested catalogs""" down = '│' right = '└──' def get_children(parent): return [e() for e in parent._entries.values() if e._container == 'catalog'] if len(cats) == 0: return cat = cats[0] ...
python
def expand_nested(self, cats): """Populate widget with nested catalogs""" down = '│' right = '└──' def get_children(parent): return [e() for e in parent._entries.values() if e._container == 'catalog'] if len(cats) == 0: return cat = cats[0] ...
[ "def", "expand_nested", "(", "self", ",", "cats", ")", ":", "down", "=", "'│'", "right", "=", "'└──'", "def", "get_children", "(", "parent", ")", ":", "return", "[", "e", "(", ")", "for", "e", "in", "parent", ".", "_entries", ".", "values", "(", ")...
Populate widget with nested catalogs
[ "Populate", "widget", "with", "nested", "catalogs" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/catalog/select.py#L91-L114
229,390
intake/intake
intake/gui/catalog/select.py
CatSelector.collapse_nested
def collapse_nested(self, cats, max_nestedness=10): """ Collapse any items that are nested under cats. `max_nestedness` acts as a fail-safe to prevent infinite looping. """ children = [] removed = set() nestedness = max_nestedness old = list(self.widget.o...
python
def collapse_nested(self, cats, max_nestedness=10): """ Collapse any items that are nested under cats. `max_nestedness` acts as a fail-safe to prevent infinite looping. """ children = [] removed = set() nestedness = max_nestedness old = list(self.widget.o...
[ "def", "collapse_nested", "(", "self", ",", "cats", ",", "max_nestedness", "=", "10", ")", ":", "children", "=", "[", "]", "removed", "=", "set", "(", ")", "nestedness", "=", "max_nestedness", "old", "=", "list", "(", "self", ".", "widget", ".", "optio...
Collapse any items that are nested under cats. `max_nestedness` acts as a fail-safe to prevent infinite looping.
[ "Collapse", "any", "items", "that", "are", "nested", "under", "cats", ".", "max_nestedness", "acts", "as", "a", "fail", "-", "safe", "to", "prevent", "infinite", "looping", "." ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/catalog/select.py#L116-L137
229,391
intake/intake
intake/gui/catalog/select.py
CatSelector.remove_selected
def remove_selected(self, *args): """Remove the selected catalog - allow the passing of arbitrary args so that buttons work. Also remove any nested catalogs.""" self.collapse_nested(self.selected) self.remove(self.selected)
python
def remove_selected(self, *args): """Remove the selected catalog - allow the passing of arbitrary args so that buttons work. Also remove any nested catalogs.""" self.collapse_nested(self.selected) self.remove(self.selected)
[ "def", "remove_selected", "(", "self", ",", "*", "args", ")", ":", "self", ".", "collapse_nested", "(", "self", ".", "selected", ")", "self", ".", "remove", "(", "self", ".", "selected", ")" ]
Remove the selected catalog - allow the passing of arbitrary args so that buttons work. Also remove any nested catalogs.
[ "Remove", "the", "selected", "catalog", "-", "allow", "the", "passing", "of", "arbitrary", "args", "so", "that", "buttons", "work", ".", "Also", "remove", "any", "nested", "catalogs", "." ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/catalog/select.py#L139-L143
229,392
intake/intake
intake/container/persist.py
PersistStore.add
def add(self, key, source): """Add the persisted source to the store under the given key key : str The unique token of the un-persisted, original source source : DataSource instance The thing to add to the persisted catalogue, referring to persisted data ...
python
def add(self, key, source): """Add the persisted source to the store under the given key key : str The unique token of the un-persisted, original source source : DataSource instance The thing to add to the persisted catalogue, referring to persisted data ...
[ "def", "add", "(", "self", ",", "key", ",", "source", ")", ":", "from", "intake", ".", "catalog", ".", "local", "import", "LocalCatalogEntry", "try", ":", "with", "self", ".", "fs", ".", "open", "(", "self", ".", "path", ",", "'rb'", ")", "as", "f"...
Add the persisted source to the store under the given key key : str The unique token of the un-persisted, original source source : DataSource instance The thing to add to the persisted catalogue, referring to persisted data
[ "Add", "the", "persisted", "source", "to", "the", "store", "under", "the", "given", "key" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/container/persist.py#L84-L109
229,393
intake/intake
intake/container/persist.py
PersistStore.get_tok
def get_tok(self, source): """Get string token from object Strings are assumed to already be a token; if source or entry, see if it is a persisted thing ("original_tok" is in its metadata), else generate its own token. """ if isinstance(source, str): return s...
python
def get_tok(self, source): """Get string token from object Strings are assumed to already be a token; if source or entry, see if it is a persisted thing ("original_tok" is in its metadata), else generate its own token. """ if isinstance(source, str): return s...
[ "def", "get_tok", "(", "self", ",", "source", ")", ":", "if", "isinstance", "(", "source", ",", "str", ")", ":", "return", "source", "if", "isinstance", "(", "source", ",", "CatalogEntry", ")", ":", "return", "source", ".", "_metadata", ".", "get", "("...
Get string token from object Strings are assumed to already be a token; if source or entry, see if it is a persisted thing ("original_tok" is in its metadata), else generate its own token.
[ "Get", "string", "token", "from", "object" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/container/persist.py#L111-L126
229,394
intake/intake
intake/container/persist.py
PersistStore.remove
def remove(self, source, delfiles=True): """Remove a dataset from the persist store source : str or DataSource or Lo If a str, this is the unique ID of the original source, which is the key of the persisted dataset within the store. If a source, can be either the ori...
python
def remove(self, source, delfiles=True): """Remove a dataset from the persist store source : str or DataSource or Lo If a str, this is the unique ID of the original source, which is the key of the persisted dataset within the store. If a source, can be either the ori...
[ "def", "remove", "(", "self", ",", "source", ",", "delfiles", "=", "True", ")", ":", "source", "=", "self", ".", "get_tok", "(", "source", ")", "with", "self", ".", "fs", ".", "open", "(", "self", ".", "path", ",", "'rb'", ")", "as", "f", ":", ...
Remove a dataset from the persist store source : str or DataSource or Lo If a str, this is the unique ID of the original source, which is the key of the persisted dataset within the store. If a source, can be either the original or the persisted source. delfiles : bo...
[ "Remove", "a", "dataset", "from", "the", "persist", "store" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/container/persist.py#L128-L150
229,395
intake/intake
intake/container/persist.py
PersistStore.backtrack
def backtrack(self, source): """Given a unique key in the store, recreate original source""" key = self.get_tok(source) s = self[key]() meta = s.metadata['original_source'] cls = meta['cls'] args = meta['args'] kwargs = meta['kwargs'] cls = import_name(cls...
python
def backtrack(self, source): """Given a unique key in the store, recreate original source""" key = self.get_tok(source) s = self[key]() meta = s.metadata['original_source'] cls = meta['cls'] args = meta['args'] kwargs = meta['kwargs'] cls = import_name(cls...
[ "def", "backtrack", "(", "self", ",", "source", ")", ":", "key", "=", "self", ".", "get_tok", "(", "source", ")", "s", "=", "self", "[", "key", "]", "(", ")", "meta", "=", "s", ".", "metadata", "[", "'original_source'", "]", "cls", "=", "meta", "...
Given a unique key in the store, recreate original source
[ "Given", "a", "unique", "key", "in", "the", "store", "recreate", "original", "source" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/container/persist.py#L156-L168
229,396
intake/intake
intake/container/persist.py
PersistStore.refresh
def refresh(self, key): """Recreate and re-persist the source for the given unique ID""" s0 = self[key] s = self.backtrack(key) s.persist(**s0.metadata['persist_kwargs'])
python
def refresh(self, key): """Recreate and re-persist the source for the given unique ID""" s0 = self[key] s = self.backtrack(key) s.persist(**s0.metadata['persist_kwargs'])
[ "def", "refresh", "(", "self", ",", "key", ")", ":", "s0", "=", "self", "[", "key", "]", "s", "=", "self", ".", "backtrack", "(", "key", ")", "s", ".", "persist", "(", "*", "*", "s0", ".", "metadata", "[", "'persist_kwargs'", "]", ")" ]
Recreate and re-persist the source for the given unique ID
[ "Recreate", "and", "re", "-", "persist", "the", "source", "for", "the", "given", "unique", "ID" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/container/persist.py#L170-L174
229,397
intake/intake
intake/gui/source/select.py
SourceSelector.cats
def cats(self, cats): """Set sources from a list of cats""" sources = [] for cat in coerce_to_list(cats): sources.extend([entry for entry in cat._entries.values() if entry._container != 'catalog']) self.items = sources
python
def cats(self, cats): """Set sources from a list of cats""" sources = [] for cat in coerce_to_list(cats): sources.extend([entry for entry in cat._entries.values() if entry._container != 'catalog']) self.items = sources
[ "def", "cats", "(", "self", ",", "cats", ")", ":", "sources", "=", "[", "]", "for", "cat", "in", "coerce_to_list", "(", "cats", ")", ":", "sources", ".", "extend", "(", "[", "entry", "for", "entry", "in", "cat", ".", "_entries", ".", "values", "(",...
Set sources from a list of cats
[ "Set", "sources", "from", "a", "list", "of", "cats" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/source/select.py#L88-L93
229,398
intake/intake
intake/cli/client/__main__.py
main
def main(argv=None): ''' Execute the "intake" command line program. ''' from intake.cli.bootstrap import main as _main return _main('Intake Catalog CLI', subcommands.all, argv or sys.argv)
python
def main(argv=None): ''' Execute the "intake" command line program. ''' from intake.cli.bootstrap import main as _main return _main('Intake Catalog CLI', subcommands.all, argv or sys.argv)
[ "def", "main", "(", "argv", "=", "None", ")", ":", "from", "intake", ".", "cli", ".", "bootstrap", "import", "main", "as", "_main", "return", "_main", "(", "'Intake Catalog CLI'", ",", "subcommands", ".", "all", ",", "argv", "or", "sys", ".", "argv", "...
Execute the "intake" command line program.
[ "Execute", "the", "intake", "command", "line", "program", "." ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/cli/client/__main__.py#L27-L33
229,399
intake/intake
intake/source/base.py
DataSource._load_metadata
def _load_metadata(self): """load metadata only if needed""" if self._schema is None: self._schema = self._get_schema() self.datashape = self._schema.datashape self.dtype = self._schema.dtype self.shape = self._schema.shape self.npartitions = s...
python
def _load_metadata(self): """load metadata only if needed""" if self._schema is None: self._schema = self._get_schema() self.datashape = self._schema.datashape self.dtype = self._schema.dtype self.shape = self._schema.shape self.npartitions = s...
[ "def", "_load_metadata", "(", "self", ")", ":", "if", "self", ".", "_schema", "is", "None", ":", "self", ".", "_schema", "=", "self", ".", "_get_schema", "(", ")", "self", ".", "datashape", "=", "self", ".", "_schema", ".", "datashape", "self", ".", ...
load metadata only if needed
[ "load", "metadata", "only", "if", "needed" ]
277b96bfdee39d8a3048ea5408c6d6716d568336
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/source/base.py#L114-L122