partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
get_safe_contract
Get Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract
gnosis/eth/contracts.py
def get_safe_contract(w3: Web3, address=None): """ Get Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract """ return w3.eth.contract(address, ...
def get_safe_contract(w3: Web3, address=None): """ Get Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract """ return w3.eth.contract(address, ...
[ "Get", "Gnosis", "Safe", "Master", "contract", ".", "It", "should", "be", "used", "to", "access", "Safe", "methods", "on", "Proxy", "contracts", ".", ":", "param", "w3", ":", "Web3", "instance", ":", "param", "address", ":", "address", "of", "the", "safe...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/contracts.py#L29-L38
[ "def", "get_safe_contract", "(", "w3", ":", "Web3", ",", "address", "=", "None", ")", ":", "return", "w3", ".", "eth", ".", "contract", "(", "address", ",", "abi", "=", "GNOSIS_SAFE_INTERFACE", "[", "'abi'", "]", ",", "bytecode", "=", "GNOSIS_SAFE_INTERFAC...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
get_old_safe_contract
Get Old Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract
gnosis/eth/contracts.py
def get_old_safe_contract(w3: Web3, address=None): """ Get Old Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract """ return w3.eth.contract(addr...
def get_old_safe_contract(w3: Web3, address=None): """ Get Old Gnosis Safe Master contract. It should be used to access Safe methods on Proxy contracts. :param w3: Web3 instance :param address: address of the safe contract/proxy contract :return: Safe Contract """ return w3.eth.contract(addr...
[ "Get", "Old", "Gnosis", "Safe", "Master", "contract", ".", "It", "should", "be", "used", "to", "access", "Safe", "methods", "on", "Proxy", "contracts", ".", ":", "param", "w3", ":", "Web3", "instance", ":", "param", "address", ":", "address", "of", "the"...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/contracts.py#L41-L50
[ "def", "get_old_safe_contract", "(", "w3", ":", "Web3", ",", "address", "=", "None", ")", ":", "return", "w3", ".", "eth", ".", "contract", "(", "address", ",", "abi", "=", "OLD_GNOSIS_SAFE_INTERFACE", "[", "'abi'", "]", ",", "bytecode", "=", "OLD_GNOSIS_S...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
get_paying_proxy_contract
Get Paying Proxy Contract. This should be used just for contract creation/changing master_copy If you want to call Safe methods you should use `get_safe_contract` with the Proxy address, so you can access every method of the Safe :param w3: Web3 instance :param address: address of the proxy contract ...
gnosis/eth/contracts.py
def get_paying_proxy_contract(w3: Web3, address=None): """ Get Paying Proxy Contract. This should be used just for contract creation/changing master_copy If you want to call Safe methods you should use `get_safe_contract` with the Proxy address, so you can access every method of the Safe :param w3: ...
def get_paying_proxy_contract(w3: Web3, address=None): """ Get Paying Proxy Contract. This should be used just for contract creation/changing master_copy If you want to call Safe methods you should use `get_safe_contract` with the Proxy address, so you can access every method of the Safe :param w3: ...
[ "Get", "Paying", "Proxy", "Contract", ".", "This", "should", "be", "used", "just", "for", "contract", "creation", "/", "changing", "master_copy", "If", "you", "want", "to", "call", "Safe", "methods", "you", "should", "use", "get_safe_contract", "with", "the", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/contracts.py#L53-L64
[ "def", "get_paying_proxy_contract", "(", "w3", ":", "Web3", ",", "address", "=", "None", ")", ":", "return", "w3", ".", "eth", ".", "contract", "(", "address", ",", "abi", "=", "PAYING_PROXY_INTERFACE", "[", "'abi'", "]", ",", "bytecode", "=", "PAYING_PROX...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
get_erc20_contract
Get ERC20 interface :param w3: Web3 instance :param address: address of the proxy contract :return: ERC 20 contract
gnosis/eth/contracts.py
def get_erc20_contract(w3: Web3, address=None): """ Get ERC20 interface :param w3: Web3 instance :param address: address of the proxy contract :return: ERC 20 contract """ return w3.eth.contract(address, abi=ERC20_INTERFACE['abi'], byteco...
def get_erc20_contract(w3: Web3, address=None): """ Get ERC20 interface :param w3: Web3 instance :param address: address of the proxy contract :return: ERC 20 contract """ return w3.eth.contract(address, abi=ERC20_INTERFACE['abi'], byteco...
[ "Get", "ERC20", "interface", ":", "param", "w3", ":", "Web3", "instance", ":", "param", "address", ":", "address", "of", "the", "proxy", "contract", ":", "return", ":", "ERC", "20", "contract" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/contracts.py#L67-L76
[ "def", "get_erc20_contract", "(", "w3", ":", "Web3", ",", "address", "=", "None", ")", ":", "return", "w3", ".", "eth", ".", "contract", "(", "address", ",", "abi", "=", "ERC20_INTERFACE", "[", "'abi'", "]", ",", "bytecode", "=", "ERC20_INTERFACE", "[", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
signature_split
:param signatures: signatures in form of {bytes32 r}{bytes32 s}{uint8 v} :param pos: position of the signature :return: Tuple with v, r, s
gnosis/safe/signatures.py
def signature_split(signatures: bytes, pos: int) -> Tuple[int, int, int]: """ :param signatures: signatures in form of {bytes32 r}{bytes32 s}{uint8 v} :param pos: position of the signature :return: Tuple with v, r, s """ signature_pos = 65 * pos v = signatures[64 + signature_pos] r = int...
def signature_split(signatures: bytes, pos: int) -> Tuple[int, int, int]: """ :param signatures: signatures in form of {bytes32 r}{bytes32 s}{uint8 v} :param pos: position of the signature :return: Tuple with v, r, s """ signature_pos = 65 * pos v = signatures[64 + signature_pos] r = int...
[ ":", "param", "signatures", ":", "signatures", "in", "form", "of", "{", "bytes32", "r", "}", "{", "bytes32", "s", "}", "{", "uint8", "v", "}", ":", "param", "pos", ":", "position", "of", "the", "signature", ":", "return", ":", "Tuple", "with", "v", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/signatures.py#L4-L15
[ "def", "signature_split", "(", "signatures", ":", "bytes", ",", "pos", ":", "int", ")", "->", "Tuple", "[", "int", ",", "int", ",", "int", "]", ":", "signature_pos", "=", "65", "*", "pos", "v", "=", "signatures", "[", "64", "+", "signature_pos", "]",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
signature_to_bytes
Convert signature to bytes :param vrs: tuple of v, r, s :return: signature in form of {bytes32 r}{bytes32 s}{uint8 v}
gnosis/safe/signatures.py
def signature_to_bytes(vrs: Tuple[int, int, int]) -> bytes: """ Convert signature to bytes :param vrs: tuple of v, r, s :return: signature in form of {bytes32 r}{bytes32 s}{uint8 v} """ byte_order = 'big' v, r, s = vrs return (r.to_bytes(32, byteorder=byte_order) + s.to_byt...
def signature_to_bytes(vrs: Tuple[int, int, int]) -> bytes: """ Convert signature to bytes :param vrs: tuple of v, r, s :return: signature in form of {bytes32 r}{bytes32 s}{uint8 v} """ byte_order = 'big' v, r, s = vrs return (r.to_bytes(32, byteorder=byte_order) + s.to_byt...
[ "Convert", "signature", "to", "bytes", ":", "param", "vrs", ":", "tuple", "of", "v", "r", "s", ":", "return", ":", "signature", "in", "form", "of", "{", "bytes32", "r", "}", "{", "bytes32", "s", "}", "{", "uint8", "v", "}" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/signatures.py#L18-L30
[ "def", "signature_to_bytes", "(", "vrs", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "bytes", ":", "byte_order", "=", "'big'", "v", ",", "r", ",", "s", "=", "vrs", "return", "(", "r", ".", "to_bytes", "(", "32", ",", "byteor...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
signatures_to_bytes
Convert signatures to bytes :param signatures: list of tuples(v, r, s) :return: 65 bytes per signature
gnosis/safe/signatures.py
def signatures_to_bytes(signatures: List[Tuple[int, int, int]]) -> bytes: """ Convert signatures to bytes :param signatures: list of tuples(v, r, s) :return: 65 bytes per signature """ return b''.join([signature_to_bytes(vrs) for vrs in signatures])
def signatures_to_bytes(signatures: List[Tuple[int, int, int]]) -> bytes: """ Convert signatures to bytes :param signatures: list of tuples(v, r, s) :return: 65 bytes per signature """ return b''.join([signature_to_bytes(vrs) for vrs in signatures])
[ "Convert", "signatures", "to", "bytes", ":", "param", "signatures", ":", "list", "of", "tuples", "(", "v", "r", "s", ")", ":", "return", ":", "65", "bytes", "per", "signature" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/signatures.py#L33-L39
[ "def", "signatures_to_bytes", "(", "signatures", ":", "List", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", ")", "->", "bytes", ":", "return", "b''", ".", "join", "(", "[", "signature_to_bytes", "(", "vrs", ")", "for", "vrs", "in", "sig...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx.find_valid_random_signature
Find v and r valid values for a given s :param s: random value :return: v, r
gnosis/safe/safe_creation_tx.py
def find_valid_random_signature(s: int) -> Tuple[int, int]: """ Find v and r valid values for a given s :param s: random value :return: v, r """ for _ in range(10000): r = int(os.urandom(31).hex(), 16) v = (r % 2) + 27 if r < secpk1n: ...
def find_valid_random_signature(s: int) -> Tuple[int, int]: """ Find v and r valid values for a given s :param s: random value :return: v, r """ for _ in range(10000): r = int(os.urandom(31).hex(), 16) v = (r % 2) + 27 if r < secpk1n: ...
[ "Find", "v", "and", "r", "valid", "values", "for", "a", "given", "s", ":", "param", "s", ":", "random", "value", ":", "return", ":", "v", "r" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L102-L119
[ "def", "find_valid_random_signature", "(", "s", ":", "int", ")", "->", "Tuple", "[", "int", ",", "int", "]", ":", "for", "_", "in", "range", "(", "10000", ")", ":", "r", "=", "int", "(", "os", ".", "urandom", "(", "31", ")", ".", "hex", "(", ")...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx._build_proxy_contract_creation_constructor
:param master_copy: Master Copy of Gnosis Safe already deployed :param initializer: Data initializer to send to GnosisSafe setup method :param funder: Address that should get the payment (if payment set) :param payment_token: Address if a token is used. If not set, 0x0 will be ether :par...
gnosis/safe/safe_creation_tx.py
def _build_proxy_contract_creation_constructor(self, master_copy: str, initializer: bytes, funder: str, payment_toke...
def _build_proxy_contract_creation_constructor(self, master_copy: str, initializer: bytes, funder: str, payment_toke...
[ ":", "param", "master_copy", ":", "Master", "Copy", "of", "Gnosis", "Safe", "already", "deployed", ":", "param", "initializer", ":", "Data", "initializer", "to", "send", "to", "GnosisSafe", "setup", "method", ":", "param", "funder", ":", "Address", "that", "...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L156-L179
[ "def", "_build_proxy_contract_creation_constructor", "(", "self", ",", "master_copy", ":", "str", ",", "initializer", ":", "bytes", ",", "funder", ":", "str", ",", "payment_token", ":", "str", ",", "payment", ":", "int", ")", "->", "ContractConstructor", ":", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx._build_proxy_contract_creation_tx
:param master_copy: Master Copy of Gnosis Safe already deployed :param initializer: Data initializer to send to GnosisSafe setup method :param funder: Address that should get the payment (if payment set) :param payment_token: Address if a token is used. If not set, 0x0 will be ether :par...
gnosis/safe/safe_creation_tx.py
def _build_proxy_contract_creation_tx(self, master_copy: str, initializer: bytes, funder: str, payment_token: str, ...
def _build_proxy_contract_creation_tx(self, master_copy: str, initializer: bytes, funder: str, payment_token: str, ...
[ ":", "param", "master_copy", ":", "Master", "Copy", "of", "Gnosis", "Safe", "already", "deployed", ":", "param", "initializer", ":", "Data", "initializer", "to", "send", "to", "GnosisSafe", "setup", "method", ":", "param", "funder", ":", "Address", "that", "...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L181-L208
[ "def", "_build_proxy_contract_creation_tx", "(", "self", ",", "master_copy", ":", "str", ",", "initializer", ":", "bytes", ",", "funder", ":", "str", ",", "payment_token", ":", "str", ",", "payment", ":", "int", ",", "gas", ":", "int", ",", "gas_price", ":...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx._build_contract_creation_tx_with_valid_signature
Use pyethereum `Transaction` to generate valid tx using a random signature :param tx_dict: Web3 tx dictionary :param s: Signature s value :return: PyEthereum creation tx for the proxy contract
gnosis/safe/safe_creation_tx.py
def _build_contract_creation_tx_with_valid_signature(self, tx_dict: Dict[str, None], s: int) -> Transaction: """ Use pyethereum `Transaction` to generate valid tx using a random signature :param tx_dict: Web3 tx dictionary :param s: Signature s value :return: PyEthereum creation ...
def _build_contract_creation_tx_with_valid_signature(self, tx_dict: Dict[str, None], s: int) -> Transaction: """ Use pyethereum `Transaction` to generate valid tx using a random signature :param tx_dict: Web3 tx dictionary :param s: Signature s value :return: PyEthereum creation ...
[ "Use", "pyethereum", "Transaction", "to", "generate", "valid", "tx", "using", "a", "random", "signature", ":", "param", "tx_dict", ":", "Web3", "tx", "dictionary", ":", "param", "s", ":", "Signature", "s", "value", ":", "return", ":", "PyEthereum", "creation...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L210-L236
[ "def", "_build_contract_creation_tx_with_valid_signature", "(", "self", ",", "tx_dict", ":", "Dict", "[", "str", ",", "None", "]", ",", "s", ":", "int", ")", "->", "Transaction", ":", "zero_address", "=", "HexBytes", "(", "'0x'", "+", "'0'", "*", "40", ")"...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx._estimate_gas
Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in the address. So we add some gas later. :param master_copy: Master Copy of Gnosis Safe already deployed :param initializer: Data initializer to send to GnosisSafe setup method :param funder:...
gnosis/safe/safe_creation_tx.py
def _estimate_gas(self, master_copy: str, initializer: bytes, funder: str, payment_token: str) -> int: """ Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in th...
def _estimate_gas(self, master_copy: str, initializer: bytes, funder: str, payment_token: str) -> int: """ Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in th...
[ "Gas", "estimation", "done", "using", "web3", "and", "calling", "the", "node", "Payment", "cannot", "be", "estimated", "as", "no", "ether", "is", "in", "the", "address", ".", "So", "we", "add", "some", "gas", "later", ".", ":", "param", "master_copy", ":...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L238-L276
[ "def", "_estimate_gas", "(", "self", ",", "master_copy", ":", "str", ",", "initializer", ":", "bytes", ",", "funder", ":", "str", ",", "payment_token", ":", "str", ")", "->", "int", ":", "# Estimate the contract deployment. We cannot estimate the refunding, as the saf...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreationTx._sign_web3_transaction
Signed transaction that compatible with `w3.eth.sendRawTransaction` Is not used because `pyEthereum` implementation of Transaction was found to be more robust regarding invalid signatures
gnosis/safe/safe_creation_tx.py
def _sign_web3_transaction(tx: Dict[str, any], v: int, r: int, s: int) -> (bytes, HexBytes): """ Signed transaction that compatible with `w3.eth.sendRawTransaction` Is not used because `pyEthereum` implementation of Transaction was found to be more robust regarding invalid signatures ...
def _sign_web3_transaction(tx: Dict[str, any], v: int, r: int, s: int) -> (bytes, HexBytes): """ Signed transaction that compatible with `w3.eth.sendRawTransaction` Is not used because `pyEthereum` implementation of Transaction was found to be more robust regarding invalid signatures ...
[ "Signed", "transaction", "that", "compatible", "with", "w3", ".", "eth", ".", "sendRawTransaction", "Is", "not", "used", "because", "pyEthereum", "implementation", "of", "Transaction", "was", "found", "to", "be", "more", "robust", "regarding", "invalid", "signatur...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_creation_tx.py#L290-L300
[ "def", "_sign_web3_transaction", "(", "tx", ":", "Dict", "[", "str", ",", "any", "]", ",", "v", ":", "int", ",", "r", ":", "int", ",", "s", ":", "int", ")", "->", "(", "bytes", ",", "HexBytes", ")", ":", "unsigned_transaction", "=", "serializable_uns...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.check_proxy_code
Check if proxy is valid :param address: address of the proxy :return: True if proxy is valid, False otherwise
gnosis/safe/safe_service.py
def check_proxy_code(self, address) -> bool: """ Check if proxy is valid :param address: address of the proxy :return: True if proxy is valid, False otherwise """ deployed_proxy_code = self.w3.eth.getCode(address) proxy_code_fns = (get_paying_proxy_deployed_byteco...
def check_proxy_code(self, address) -> bool: """ Check if proxy is valid :param address: address of the proxy :return: True if proxy is valid, False otherwise """ deployed_proxy_code = self.w3.eth.getCode(address) proxy_code_fns = (get_paying_proxy_deployed_byteco...
[ "Check", "if", "proxy", "is", "valid", ":", "param", "address", ":", "address", "of", "the", "proxy", ":", "return", ":", "True", "if", "proxy", "is", "valid", "False", "otherwise" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L198-L211
[ "def", "check_proxy_code", "(", "self", ",", "address", ")", "->", "bool", ":", "deployed_proxy_code", "=", "self", ".", "w3", ".", "eth", ".", "getCode", "(", "address", ")", "proxy_code_fns", "=", "(", "get_paying_proxy_deployed_bytecode", ",", "get_proxy_fact...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.check_funds_for_tx_gas
Check safe has enough funds to pay for a tx :param safe_address: Address of the safe :param safe_tx_gas: Start gas :param data_gas: Data gas :param gas_price: Gas Price :param gas_token: Gas Token, to use token instead of ether for the gas :return: True if enough funds, F...
gnosis/safe/safe_service.py
def check_funds_for_tx_gas(self, safe_address: str, safe_tx_gas: int, data_gas: int, gas_price: int, gas_token: str) -> bool: """ Check safe has enough funds to pay for a tx :param safe_address: Address of the safe :param safe_tx_gas: Start gas :par...
def check_funds_for_tx_gas(self, safe_address: str, safe_tx_gas: int, data_gas: int, gas_price: int, gas_token: str) -> bool: """ Check safe has enough funds to pay for a tx :param safe_address: Address of the safe :param safe_tx_gas: Start gas :par...
[ "Check", "safe", "has", "enough", "funds", "to", "pay", "for", "a", "tx", ":", "param", "safe_address", ":", "Address", "of", "the", "safe", ":", "param", "safe_tx_gas", ":", "Start", "gas", ":", "param", "data_gas", ":", "Data", "gas", ":", "param", "...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L213-L228
[ "def", "check_funds_for_tx_gas", "(", "self", ",", "safe_address", ":", "str", ",", "safe_tx_gas", ":", "int", ",", "data_gas", ":", "int", ",", "gas_price", ":", "int", ",", "gas_token", ":", "str", ")", "->", "bool", ":", "if", "gas_token", "==", "NULL...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.deploy_master_contract
Deploy master contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key of an ethereum account :return: deployed contract address
gnosis/safe/safe_service.py
def deploy_master_contract(self, deployer_account=None, deployer_private_key=None) -> str: """ Deploy master contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key ...
def deploy_master_contract(self, deployer_account=None, deployer_private_key=None) -> str: """ Deploy master contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key ...
[ "Deploy", "master", "contract", ".", "Takes", "deployer_account", "(", "if", "unlocked", "in", "the", "node", ")", "or", "the", "deployer", "private", "key", ":", "param", "deployer_account", ":", "Unlocked", "ethereum", "account", ":", "param", "deployer_privat...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L230-L270
[ "def", "deploy_master_contract", "(", "self", ",", "deployer_account", "=", "None", ",", "deployer_private_key", "=", "None", ")", "->", "str", ":", "assert", "deployer_account", "or", "deployer_private_key", "deployer_address", "=", "deployer_account", "or", "self", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.deploy_paying_proxy_contract
Deploy proxy contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key of an ethereum account :return: deployed contract address
gnosis/safe/safe_service.py
def deploy_paying_proxy_contract(self, initializer=b'', deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :param deployer_account: Unlocked ethe...
def deploy_paying_proxy_contract(self, initializer=b'', deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :param deployer_account: Unlocked ethe...
[ "Deploy", "proxy", "contract", ".", "Takes", "deployer_account", "(", "if", "unlocked", "in", "the", "node", ")", "or", "the", "deployer", "private", "key", ":", "param", "initializer", ":", "Initializer", ":", "param", "deployer_account", ":", "Unlocked", "et...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L311-L331
[ "def", "deploy_paying_proxy_contract", "(", "self", ",", "initializer", "=", "b''", ",", "deployer_account", "=", "None", ",", "deployer_private_key", "=", "None", ")", "->", "str", ":", "assert", "deployer_account", "or", "deployer_private_key", "deployer_address", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.deploy_proxy_contract
Deploy proxy contract using the `Proxy Factory Contract`. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key of an ethereum account ...
gnosis/safe/safe_service.py
def deploy_proxy_contract(self, initializer=b'', deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy contract using the `Proxy Factory Contract`. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :p...
def deploy_proxy_contract(self, initializer=b'', deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy contract using the `Proxy Factory Contract`. Takes deployer_account (if unlocked in the node) or the deployer private key :param initializer: Initializer :p...
[ "Deploy", "proxy", "contract", "using", "the", "Proxy", "Factory", "Contract", ".", "Takes", "deployer_account", "(", "if", "unlocked", "in", "the", "node", ")", "or", "the", "deployer", "private", "key", ":", "param", "initializer", ":", "Initializer", ":", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L333-L354
[ "def", "deploy_proxy_contract", "(", "self", ",", "initializer", "=", "b''", ",", "deployer_account", "=", "None", ",", "deployer_private_key", "=", "None", ")", "->", "str", ":", "assert", "deployer_account", "or", "deployer_private_key", "deployer_address", "=", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.deploy_proxy_contract_with_nonce
Deploy proxy contract using `create2` withthe `Proxy Factory Contract`. Takes `deployer_account` (if unlocked in the node) or the `deployer_private_key` :param salt_nonce: Uint256 for `create2` salt :param initializer: Data for safe creation :param gas: Gas :param gas_price: Gas ...
gnosis/safe/safe_service.py
def deploy_proxy_contract_with_nonce(self, salt_nonce: int, initializer: bytes, gas: int, gas_price: int, deployer_private_key=None) -> Tuple[bytes, Dict[str, any], str]: """ Deploy proxy contract using `create2` withthe `Proxy Factory Contract`. Takes `d...
def deploy_proxy_contract_with_nonce(self, salt_nonce: int, initializer: bytes, gas: int, gas_price: int, deployer_private_key=None) -> Tuple[bytes, Dict[str, any], str]: """ Deploy proxy contract using `create2` withthe `Proxy Factory Contract`. Takes `d...
[ "Deploy", "proxy", "contract", "using", "create2", "withthe", "Proxy", "Factory", "Contract", ".", "Takes", "deployer_account", "(", "if", "unlocked", "in", "the", "node", ")", "or", "the", "deployer_private_key", ":", "param", "salt_nonce", ":", "Uint256", "for...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L356-L382
[ "def", "deploy_proxy_contract_with_nonce", "(", "self", ",", "salt_nonce", ":", "int", ",", "initializer", ":", "bytes", ",", "gas", ":", "int", ",", "gas_price", ":", "int", ",", "deployer_private_key", "=", "None", ")", "->", "Tuple", "[", "bytes", ",", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.deploy_proxy_factory_contract
Deploy proxy factory contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key: Private key of an ethereum account :return: deployed contract address
gnosis/safe/safe_service.py
def deploy_proxy_factory_contract(self, deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy factory contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key...
def deploy_proxy_factory_contract(self, deployer_account=None, deployer_private_key=None) -> str: """ Deploy proxy factory contract. Takes deployer_account (if unlocked in the node) or the deployer private key :param deployer_account: Unlocked ethereum account :param deployer_private_key...
[ "Deploy", "proxy", "factory", "contract", ".", "Takes", "deployer_account", "(", "if", "unlocked", "in", "the", "node", ")", "or", "the", "deployer", "private", "key", ":", "param", "deployer_account", ":", "Unlocked", "ethereum", "account", ":", "param", "dep...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L384-L404
[ "def", "deploy_proxy_factory_contract", "(", "self", ",", "deployer_account", "=", "None", ",", "deployer_private_key", "=", "None", ")", "->", "str", ":", "assert", "deployer_account", "or", "deployer_private_key", "deployer_address", "=", "deployer_account", "or", "...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.estimate_tx_gas_with_safe
Estimate tx gas using safe `requiredTxGas` method :return: int: Estimated gas :raises: CannotEstimateGas: If gas cannot be estimated :raises: ValueError: Cannot decode received data
gnosis/safe/safe_service.py
def estimate_tx_gas_with_safe(self, safe_address: str, to: str, value: int, data: bytes, operation: int, block_identifier='pending') -> int: """ Estimate tx gas using safe `requiredTxGas` method :return: int: Estimated gas :raises: CannotEstimateGas: If ...
def estimate_tx_gas_with_safe(self, safe_address: str, to: str, value: int, data: bytes, operation: int, block_identifier='pending') -> int: """ Estimate tx gas using safe `requiredTxGas` method :return: int: Estimated gas :raises: CannotEstimateGas: If ...
[ "Estimate", "tx", "gas", "using", "safe", "requiredTxGas", "method", ":", "return", ":", "int", ":", "Estimated", "gas", ":", "raises", ":", "CannotEstimateGas", ":", "If", "gas", "cannot", "be", "estimated", ":", "raises", ":", "ValueError", ":", "Cannot", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L471-L542
[ "def", "estimate_tx_gas_with_safe", "(", "self", ",", "safe_address", ":", "str", ",", "to", ":", "str", ",", "value", ":", "int", ",", "data", ":", "bytes", ",", "operation", ":", "int", ",", "block_identifier", "=", "'pending'", ")", "->", "int", ":", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.estimate_tx_gas_with_web3
Estimate tx gas using web3
gnosis/safe/safe_service.py
def estimate_tx_gas_with_web3(self, safe_address: str, to: str, value: int, data: bytes) -> int: """ Estimate tx gas using web3 """ return self.ethereum_client.estimate_gas(safe_address, to, value, data, block_identifier='pending')
def estimate_tx_gas_with_web3(self, safe_address: str, to: str, value: int, data: bytes) -> int: """ Estimate tx gas using web3 """ return self.ethereum_client.estimate_gas(safe_address, to, value, data, block_identifier='pending')
[ "Estimate", "tx", "gas", "using", "web3" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L544-L548
[ "def", "estimate_tx_gas_with_web3", "(", "self", ",", "safe_address", ":", "str", ",", "to", ":", "str", ",", "value", ":", "int", ",", "data", ":", "bytes", ")", "->", "int", ":", "return", "self", ".", "ethereum_client", ".", "estimate_gas", "(", "safe...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.estimate_tx_gas
Estimate tx gas. Use the max of calculation using safe method and web3 if operation == CALL or use just the safe calculation otherwise
gnosis/safe/safe_service.py
def estimate_tx_gas(self, safe_address: str, to: str, value: int, data: bytes, operation: int) -> int: """ Estimate tx gas. Use the max of calculation using safe method and web3 if operation == CALL or use just the safe calculation otherwise """ # Costs to route through the proxy...
def estimate_tx_gas(self, safe_address: str, to: str, value: int, data: bytes, operation: int) -> int: """ Estimate tx gas. Use the max of calculation using safe method and web3 if operation == CALL or use just the safe calculation otherwise """ # Costs to route through the proxy...
[ "Estimate", "tx", "gas", ".", "Use", "the", "max", "of", "calculation", "using", "safe", "method", "and", "web3", "if", "operation", "==", "CALL", "or", "use", "just", "the", "safe", "calculation", "otherwise" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L550-L573
[ "def", "estimate_tx_gas", "(", "self", ",", "safe_address", ":", "str", ",", "to", ":", "str", ",", "value", ":", "int", ",", "data", ":", "bytes", ",", "operation", ":", "int", ")", "->", "int", ":", "# Costs to route through the proxy and nested calls", "p...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.estimate_tx_operational_gas
Estimates the gas for the verification of the signatures and other safe related tasks before and after executing a transaction. Calculation will be the sum of: - Base cost of 15000 gas - 100 of gas per word of `data_bytes` - Validate the signatures 5000 * threshold (ecrecov...
gnosis/safe/safe_service.py
def estimate_tx_operational_gas(self, safe_address: str, data_bytes_length: int): """ Estimates the gas for the verification of the signatures and other safe related tasks before and after executing a transaction. Calculation will be the sum of: - Base cost of 15000 gas ...
def estimate_tx_operational_gas(self, safe_address: str, data_bytes_length: int): """ Estimates the gas for the verification of the signatures and other safe related tasks before and after executing a transaction. Calculation will be the sum of: - Base cost of 15000 gas ...
[ "Estimates", "the", "gas", "for", "the", "verification", "of", "the", "signatures", "and", "other", "safe", "related", "tasks", "before", "and", "after", "executing", "a", "transaction", ".", "Calculation", "will", "be", "the", "sum", "of", ":", "-", "Base",...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L575-L588
[ "def", "estimate_tx_operational_gas", "(", "self", ",", "safe_address", ":", "str", ",", "data_bytes_length", ":", "int", ")", ":", "threshold", "=", "self", ".", "retrieve_threshold", "(", "safe_address", ")", "return", "15000", "+", "data_bytes_length", "//", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeService.send_multisig_tx
Send multisig tx to the Safe :param tx_gas: Gas for the external tx. If not, `(safe_tx_gas + data_gas) * 2` will be used :param tx_gas_price: Gas price of the external tx. If not, `gas_price` will be used :return: Tuple(tx_hash, tx) :raises: InvalidMultisigTx: If user tx cannot go throug...
gnosis/safe/safe_service.py
def send_multisig_tx(self, safe_address: str, to: str, value: int, data: bytes, operation: int, safe_tx_gas: int, data_gas: int, ...
def send_multisig_tx(self, safe_address: str, to: str, value: int, data: bytes, operation: int, safe_tx_gas: int, data_gas: int, ...
[ "Send", "multisig", "tx", "to", "the", "Safe", ":", "param", "tx_gas", ":", "Gas", "for", "the", "external", "tx", ".", "If", "not", "(", "safe_tx_gas", "+", "data_gas", ")", "*", "2", "will", "be", "used", ":", "param", "tx_gas_price", ":", "Gas", "...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_service.py#L656-L698
[ "def", "send_multisig_tx", "(", "self", ",", "safe_address", ":", "str", ",", "to", ":", "str", ",", "value", ":", "int", ",", "data", ":", "bytes", ",", "operation", ":", "int", ",", "safe_tx_gas", ":", "int", ",", "data_gas", ":", "int", ",", "gas_...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreate2TxBuilder.build
Prepare Safe creation :param owners: Owners of the Safe :param threshold: Minimum number of users required to operate the Safe :param salt_nonce: Web3 instance :param gas_price: Gas Price :param payment_receiver: Address to refund when the Safe is created. Address(0) if no need t...
gnosis/safe/safe_create2_tx.py
def build(self, owners: List[str], threshold: int, salt_nonce: int, gas_price: int, payment_receiver: Optional[str] = None, payment_token: Optional[str] = None, payment_token_eth_value: float = 1.0, fixed_creation_cost: Optional[int] = None): """ Prepare Safe cr...
def build(self, owners: List[str], threshold: int, salt_nonce: int, gas_price: int, payment_receiver: Optional[str] = None, payment_token: Optional[str] = None, payment_token_eth_value: float = 1.0, fixed_creation_cost: Optional[int] = None): """ Prepare Safe cr...
[ "Prepare", "Safe", "creation", ":", "param", "owners", ":", "Owners", "of", "the", "Safe", ":", "param", "threshold", ":", "Minimum", "number", "of", "users", "required", "to", "operate", "the", "Safe", ":", "param", "salt_nonce", ":", "Web3", "instance", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_create2_tx.py#L58-L108
[ "def", "build", "(", "self", ",", "owners", ":", "List", "[", "str", "]", ",", "threshold", ":", "int", ",", "salt_nonce", ":", "int", ",", "gas_price", ":", "int", ",", "payment_receiver", ":", "Optional", "[", "str", "]", "=", "None", ",", "payment...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreate2TxBuilder._calculate_gas
Calculate gas manually, based on tests of previosly deployed safes :param owners: Safe owners :param safe_setup_data: Data for proxy setup :param payment_token: If payment token, we will need more gas to transfer and maybe storage if first time :return: total gas needed for deployment
gnosis/safe/safe_create2_tx.py
def _calculate_gas(owners: List[str], safe_setup_data: bytes, payment_token: str) -> int: """ Calculate gas manually, based on tests of previosly deployed safes :param owners: Safe owners :param safe_setup_data: Data for proxy setup :param payment_token: If payment token, we will...
def _calculate_gas(owners: List[str], safe_setup_data: bytes, payment_token: str) -> int: """ Calculate gas manually, based on tests of previosly deployed safes :param owners: Safe owners :param safe_setup_data: Data for proxy setup :param payment_token: If payment token, we will...
[ "Calculate", "gas", "manually", "based", "on", "tests", "of", "previosly", "deployed", "safes", ":", "param", "owners", ":", "Safe", "owners", ":", "param", "safe_setup_data", ":", "Data", "for", "proxy", "setup", ":", "param", "payment_token", ":", "If", "p...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_create2_tx.py#L111-L130
[ "def", "_calculate_gas", "(", "owners", ":", "List", "[", "str", "]", ",", "safe_setup_data", ":", "bytes", ",", "payment_token", ":", "str", ")", "->", "int", ":", "base_gas", "=", "205000", "# Transaction base gas", "# If we already have the token, we don't have t...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeCreate2TxBuilder._estimate_gas
Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in the address. So we add some gas later. :param initializer: Data initializer to send to GnosisSafe setup method :param salt_nonce: Nonce that will be used to generate the salt to calculate t...
gnosis/safe/safe_create2_tx.py
def _estimate_gas(self, initializer: bytes, salt_nonce: int, payment_token: str, payment_receiver: str) -> int: """ Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in the address. So we add some gas later. :param initi...
def _estimate_gas(self, initializer: bytes, salt_nonce: int, payment_token: str, payment_receiver: str) -> int: """ Gas estimation done using web3 and calling the node Payment cannot be estimated, as no ether is in the address. So we add some gas later. :param initi...
[ "Gas", "estimation", "done", "using", "web3", "and", "calling", "the", "node", "Payment", "cannot", "be", "estimated", "as", "no", "ether", "is", "in", "the", "address", ".", "So", "we", "add", "some", "gas", "later", ".", ":", "param", "initializer", ":...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_create2_tx.py#L150-L185
[ "def", "_estimate_gas", "(", "self", ",", "initializer", ":", "bytes", ",", "salt_nonce", ":", "int", ",", "payment_token", ":", "str", ",", "payment_receiver", ":", "str", ")", "->", "int", ":", "# Estimate the contract deployment. We cannot estimate the refunding, a...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeTx.w3_tx
:return: Web3 contract tx prepared for `call`, `transact` or `buildTransaction`
gnosis/safe/safe_tx.py
def w3_tx(self): """ :return: Web3 contract tx prepared for `call`, `transact` or `buildTransaction` """ safe_contract = get_safe_contract(self.w3, address=self.safe_address) return safe_contract.functions.execTransaction( self.to, self.value, ...
def w3_tx(self): """ :return: Web3 contract tx prepared for `call`, `transact` or `buildTransaction` """ safe_contract = get_safe_contract(self.w3, address=self.safe_address) return safe_contract.functions.execTransaction( self.to, self.value, ...
[ ":", "return", ":", "Web3", "contract", "tx", "prepared", "for", "call", "transact", "or", "buildTransaction" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_tx.py#L117-L132
[ "def", "w3_tx", "(", "self", ")", ":", "safe_contract", "=", "get_safe_contract", "(", "self", ".", "w3", ",", "address", "=", "self", ".", "safe_address", ")", "return", "safe_contract", ".", "functions", ".", "execTransaction", "(", "self", ".", "to", ",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeTx.call
:param tx_sender_address: :param tx_gas: Force a gas limit :param block_identifier: :return: `1` if everything ok
gnosis/safe/safe_tx.py
def call(self, tx_sender_address: Optional[str] = None, tx_gas: Optional[int] = None, block_identifier='pending') -> int: """ :param tx_sender_address: :param tx_gas: Force a gas limit :param block_identifier: :return: `1` if everything ok """ paramet...
def call(self, tx_sender_address: Optional[str] = None, tx_gas: Optional[int] = None, block_identifier='pending') -> int: """ :param tx_sender_address: :param tx_gas: Force a gas limit :param block_identifier: :return: `1` if everything ok """ paramet...
[ ":", "param", "tx_sender_address", ":", ":", "param", "tx_gas", ":", "Force", "a", "gas", "limit", ":", "param", "block_identifier", ":", ":", "return", ":", "1", "if", "everything", "ok" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_tx.py#L149-L187
[ "def", "call", "(", "self", ",", "tx_sender_address", ":", "Optional", "[", "str", "]", "=", "None", ",", "tx_gas", ":", "Optional", "[", "int", "]", "=", "None", ",", "block_identifier", "=", "'pending'", ")", "->", "int", ":", "parameters", "=", "{",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
SafeTx.execute
Send multisig tx to the Safe :param tx_sender_private_key: Sender private key :param tx_gas: Gas for the external tx. If not, `(safe_tx_gas + data_gas) * 2` will be used :param tx_gas_price: Gas price of the external tx. If not, `gas_price` will be used :param tx_nonce: Force nonce for `...
gnosis/safe/safe_tx.py
def execute(self, tx_sender_private_key: str, tx_gas: Optional[int] = None, tx_gas_price: Optional[int] = None, tx_nonce: Optional[int] = None, block_identifier='pending') -> Tuple[bytes, Dict[str, any]]: """ Send multisig t...
def execute(self, tx_sender_private_key: str, tx_gas: Optional[int] = None, tx_gas_price: Optional[int] = None, tx_nonce: Optional[int] = None, block_identifier='pending') -> Tuple[bytes, Dict[str, any]]: """ Send multisig t...
[ "Send", "multisig", "tx", "to", "the", "Safe", ":", "param", "tx_sender_private_key", ":", "Sender", "private", "key", ":", "param", "tx_gas", ":", "Gas", "for", "the", "external", "tx", ".", "If", "not", "(", "safe_tx_gas", "+", "data_gas", ")", "*", "2...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/safe/safe_tx.py#L189-L223
[ "def", "execute", "(", "self", ",", "tx_sender_private_key", ":", "str", ",", "tx_gas", ":", "Optional", "[", "int", "]", "=", "None", ",", "tx_gas_price", ":", "Optional", "[", "int", "]", "=", "None", ",", "tx_nonce", ":", "Optional", "[", "int", "]"...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
AbstractAsyncWrapper.write
Appends towrite to the write queue >>> await test.write(b"HELLO") # Returns without wait time >>> await test.write(b"HELLO", await_blocking = True) # Returns when the bufer is flushed :param towrite: Write buffer :param await_blocking: wait for everything to be wr...
asyncserial/abstract_async_wrapper.py
async def write(self, towrite: bytes, await_blocking=False): """ Appends towrite to the write queue >>> await test.write(b"HELLO") # Returns without wait time >>> await test.write(b"HELLO", await_blocking = True) # Returns when the bufer is flushed :param towrit...
async def write(self, towrite: bytes, await_blocking=False): """ Appends towrite to the write queue >>> await test.write(b"HELLO") # Returns without wait time >>> await test.write(b"HELLO", await_blocking = True) # Returns when the bufer is flushed :param towrit...
[ "Appends", "towrite", "to", "the", "write", "queue" ]
xvzf/asyncserial-py
python
https://github.com/xvzf/asyncserial-py/blob/36b5867f44ad78ac3d96debb001e8145afef2366/asyncserial/abstract_async_wrapper.py#L118-L135
[ "async", "def", "write", "(", "self", ",", "towrite", ":", "bytes", ",", "await_blocking", "=", "False", ")", ":", "await", "self", ".", "_write", "(", "towrite", ")", "# Wait for the output buffer to be flushed if requested", "if", "await_blocking", ":", "return"...
36b5867f44ad78ac3d96debb001e8145afef2366
test
AbstractAsyncWrapper.read
Reads a given number of bytes :param bytecount: How many bytes to read, leave it at default to read everything that is available :returns: incoming bytes
asyncserial/abstract_async_wrapper.py
async def read(self, num_bytes=0) -> bytes: """ Reads a given number of bytes :param bytecount: How many bytes to read, leave it at default to read everything that is available :returns: incoming bytes """ if num_bytes < 1: num_bytes...
async def read(self, num_bytes=0) -> bytes: """ Reads a given number of bytes :param bytecount: How many bytes to read, leave it at default to read everything that is available :returns: incoming bytes """ if num_bytes < 1: num_bytes...
[ "Reads", "a", "given", "number", "of", "bytes" ]
xvzf/asyncserial-py
python
https://github.com/xvzf/asyncserial-py/blob/36b5867f44ad78ac3d96debb001e8145afef2366/asyncserial/abstract_async_wrapper.py#L138-L149
[ "async", "def", "read", "(", "self", ",", "num_bytes", "=", "0", ")", "->", "bytes", ":", "if", "num_bytes", "<", "1", ":", "num_bytes", "=", "self", ".", "in_waiting", "or", "1", "return", "await", "self", ".", "_read", "(", "num_bytes", ")" ]
36b5867f44ad78ac3d96debb001e8145afef2366
test
Serial._read
Reads a given number of bytes :param num_bytes: How many bytes to read :returns: incoming bytes
asyncserial/async_serial_wrapper.py
async def _read(self, num_bytes) -> bytes: """ Reads a given number of bytes :param num_bytes: How many bytes to read :returns: incoming bytes """ while True: if self.in_waiting < num_bytes: await asyncio.sleep(self._asyncio_sleep_time) ...
async def _read(self, num_bytes) -> bytes: """ Reads a given number of bytes :param num_bytes: How many bytes to read :returns: incoming bytes """ while True: if self.in_waiting < num_bytes: await asyncio.sleep(self._asyncio_sleep_time) ...
[ "Reads", "a", "given", "number", "of", "bytes" ]
xvzf/asyncserial-py
python
https://github.com/xvzf/asyncserial-py/blob/36b5867f44ad78ac3d96debb001e8145afef2366/asyncserial/async_serial_wrapper.py#L94-L114
[ "async", "def", "_read", "(", "self", ",", "num_bytes", ")", "->", "bytes", ":", "while", "True", ":", "if", "self", ".", "in_waiting", "<", "num_bytes", ":", "await", "asyncio", ".", "sleep", "(", "self", ".", "_asyncio_sleep_time", ")", "else", ":", ...
36b5867f44ad78ac3d96debb001e8145afef2366
test
Serial.readline
Reads one line >>> # Keeps waiting for a linefeed incase there is none in the buffer >>> await test.readline() :returns: bytes forming a line
asyncserial/async_serial_wrapper.py
async def readline(self) -> bytes: """ Reads one line >>> # Keeps waiting for a linefeed incase there is none in the buffer >>> await test.readline() :returns: bytes forming a line """ while True: line = self._serial_instance.readline() i...
async def readline(self) -> bytes: """ Reads one line >>> # Keeps waiting for a linefeed incase there is none in the buffer >>> await test.readline() :returns: bytes forming a line """ while True: line = self._serial_instance.readline() i...
[ "Reads", "one", "line" ]
xvzf/asyncserial-py
python
https://github.com/xvzf/asyncserial-py/blob/36b5867f44ad78ac3d96debb001e8145afef2366/asyncserial/async_serial_wrapper.py#L117-L131
[ "async", "def", "readline", "(", "self", ")", "->", "bytes", ":", "while", "True", ":", "line", "=", "self", ".", "_serial_instance", ".", "readline", "(", ")", "if", "not", "line", ":", "await", "asyncio", ".", "sleep", "(", "self", ".", "_asyncio_sle...
36b5867f44ad78ac3d96debb001e8145afef2366
test
Connection.send
Verifies and sends message. :param message: Message instance. :param envelope_from: Email address to be used in MAIL FROM command.
mailflash.py
def send(self, message): """Verifies and sends message. :param message: Message instance. :param envelope_from: Email address to be used in MAIL FROM command. """ assert message.send_to, "No recipients have been added" if message.has_bad_headers(self.mail.default_sender...
def send(self, message): """Verifies and sends message. :param message: Message instance. :param envelope_from: Email address to be used in MAIL FROM command. """ assert message.send_to, "No recipients have been added" if message.has_bad_headers(self.mail.default_sender...
[ "Verifies", "and", "sends", "message", "." ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L175-L205
[ "def", "send", "(", "self", ",", "message", ")", ":", "assert", "message", ".", "send_to", ",", "\"No recipients have been added\"", "if", "message", ".", "has_bad_headers", "(", "self", ".", "mail", ".", "default_sender", ")", ":", "raise", "BadHeaderError", ...
794598d9df0e343bb1f64b03d09a68a540229774
test
Message._mimetext
Creates a MIMEText object with the given subtype (default: 'plain') If the text is unicode, the utf-8 charset is used.
mailflash.py
def _mimetext(self, text, subtype='plain'): """Creates a MIMEText object with the given subtype (default: 'plain') If the text is unicode, the utf-8 charset is used. """ charset = self.charset or 'utf-8' return MIMEText(text, _subtype=subtype, _charset=charset)
def _mimetext(self, text, subtype='plain'): """Creates a MIMEText object with the given subtype (default: 'plain') If the text is unicode, the utf-8 charset is used. """ charset = self.charset or 'utf-8' return MIMEText(text, _subtype=subtype, _charset=charset)
[ "Creates", "a", "MIMEText", "object", "with", "the", "given", "subtype", "(", "default", ":", "plain", ")", "If", "the", "text", "is", "unicode", "the", "utf", "-", "8", "charset", "is", "used", "." ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L299-L304
[ "def", "_mimetext", "(", "self", ",", "text", ",", "subtype", "=", "'plain'", ")", ":", "charset", "=", "self", ".", "charset", "or", "'utf-8'", "return", "MIMEText", "(", "text", ",", "_subtype", "=", "subtype", ",", "_charset", "=", "charset", ")" ]
794598d9df0e343bb1f64b03d09a68a540229774
test
Message.as_string
Creates the email
mailflash.py
def as_string(self, default_from=None): """Creates the email""" encoding = self.charset or 'utf-8' attachments = self.attachments or [] if len(attachments) == 0 and not self.html: # No html content and zero attachments means plain text msg = self._mimetext(self...
def as_string(self, default_from=None): """Creates the email""" encoding = self.charset or 'utf-8' attachments = self.attachments or [] if len(attachments) == 0 and not self.html: # No html content and zero attachments means plain text msg = self._mimetext(self...
[ "Creates", "the", "email" ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L306-L374
[ "def", "as_string", "(", "self", ",", "default_from", "=", "None", ")", ":", "encoding", "=", "self", ".", "charset", "or", "'utf-8'", "attachments", "=", "self", ".", "attachments", "or", "[", "]", "if", "len", "(", "attachments", ")", "==", "0", "and...
794598d9df0e343bb1f64b03d09a68a540229774
test
Message.has_bad_headers
Checks for bad headers i.e. newlines in subject, sender or recipients.
mailflash.py
def has_bad_headers(self, default_from=None): """Checks for bad headers i.e. newlines in subject, sender or recipients. """ sender = self.sender or default_from reply_to = self.reply_to or '' for val in [self.subject, sender, reply_to] + self.recipients: for c in '\r...
def has_bad_headers(self, default_from=None): """Checks for bad headers i.e. newlines in subject, sender or recipients. """ sender = self.sender or default_from reply_to = self.reply_to or '' for val in [self.subject, sender, reply_to] + self.recipients: for c in '\r...
[ "Checks", "for", "bad", "headers", "i", ".", "e", ".", "newlines", "in", "subject", "sender", "or", "recipients", "." ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L379-L389
[ "def", "has_bad_headers", "(", "self", ",", "default_from", "=", "None", ")", ":", "sender", "=", "self", ".", "sender", "or", "default_from", "reply_to", "=", "self", ".", "reply_to", "or", "''", "for", "val", "in", "[", "self", ".", "subject", ",", "...
794598d9df0e343bb1f64b03d09a68a540229774
test
Message.attach
Adds an attachment to the message. :param filename: filename of attachment :param content_type: file mimetype :param data: the raw file data :param disposition: content-disposition (if any)
mailflash.py
def attach(self, filename=None, content_type=None, data=None, disposition=None, headers=None): """Adds an attachment to the message. :param filename: filename of attachment :param content_type: file mimetype :par...
def attach(self, filename=None, content_type=None, data=None, disposition=None, headers=None): """Adds an attachment to the message. :param filename: filename of attachment :param content_type: file mimetype :par...
[ "Adds", "an", "attachment", "to", "the", "message", "." ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L410-L424
[ "def", "attach", "(", "self", ",", "filename", "=", "None", ",", "content_type", "=", "None", ",", "data", "=", "None", ",", "disposition", "=", "None", ",", "headers", "=", "None", ")", ":", "self", ".", "attachments", ".", "append", "(", "Attachment"...
794598d9df0e343bb1f64b03d09a68a540229774
test
Mail.record_messages
Records all messages. Use in unit tests for example:: with mail.record_messages() as outbox: response = app.test_client.get("/email-sending-view/") assert len(outbox) == 1 assert outbox[0].subject == "testing" You must have blinker installed in order...
mailflash.py
def record_messages(self): """Records all messages. Use in unit tests for example:: with mail.record_messages() as outbox: response = app.test_client.get("/email-sending-view/") assert len(outbox) == 1 assert outbox[0].subject == "testing" Yo...
def record_messages(self): """Records all messages. Use in unit tests for example:: with mail.record_messages() as outbox: response = app.test_client.get("/email-sending-view/") assert len(outbox) == 1 assert outbox[0].subject == "testing" Yo...
[ "Records", "all", "messages", ".", "Use", "in", "unit", "tests", "for", "example", "::" ]
nicolas-van/mailflash
python
https://github.com/nicolas-van/mailflash/blob/794598d9df0e343bb1f64b03d09a68a540229774/mailflash.py#L463-L488
[ "def", "record_messages", "(", "self", ")", ":", "if", "not", "email_dispatched", ":", "raise", "RuntimeError", "(", "\"blinker must be installed\"", ")", "outbox", "=", "[", "]", "def", "_record", "(", "message", ",", "mail", ")", ":", "outbox", ".", "appen...
794598d9df0e343bb1f64b03d09a68a540229774
test
DataAccessLayer.register_services
Register Services that can be accessed by this DAL. Upon registration, the service is set up. :param **services: Keyword arguments where the key is the name to register the Service as and the value is the Service.
src/polydatum/dal.py
def register_services(self, **services): """ Register Services that can be accessed by this DAL. Upon registration, the service is set up. :param **services: Keyword arguments where the key is the name to register the Service as and the value is the Service. """ ...
def register_services(self, **services): """ Register Services that can be accessed by this DAL. Upon registration, the service is set up. :param **services: Keyword arguments where the key is the name to register the Service as and the value is the Service. """ ...
[ "Register", "Services", "that", "can", "be", "accessed", "by", "this", "DAL", ".", "Upon", "registration", "the", "service", "is", "set", "up", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/dal.py#L18-L31
[ "def", "register_services", "(", "self", ",", "*", "*", "services", ")", ":", "for", "key", ",", "service", "in", "services", ".", "items", "(", ")", ":", "if", "key", "in", "self", ".", "_services", ":", "raise", "AlreadyExistsException", "(", "'A Servi...
c98a498f8e7972218903ec027f6de78089726c1d
test
DataManager.register_context_middleware
:param middleware: Middleware in order of execution
src/polydatum/dal.py
def register_context_middleware(self, *middleware): """ :param middleware: Middleware in order of execution """ for m in middleware: if not is_generator(m): raise Exception('Middleware {} must be a Python generator callable.'.format(m)) self._middlewa...
def register_context_middleware(self, *middleware): """ :param middleware: Middleware in order of execution """ for m in middleware: if not is_generator(m): raise Exception('Middleware {} must be a Python generator callable.'.format(m)) self._middlewa...
[ ":", "param", "middleware", ":", "Middleware", "in", "order", "of", "execution" ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/dal.py#L98-L106
[ "def", "register_context_middleware", "(", "self", ",", "*", "middleware", ")", ":", "for", "m", "in", "middleware", ":", "if", "not", "is_generator", "(", "m", ")", ":", "raise", "Exception", "(", "'Middleware {} must be a Python generator callable.'", ".", "form...
c98a498f8e7972218903ec027f6de78089726c1d
test
from_module
Load a configuration module and return a Config
src/polydatum/config.py
def from_module(module_name): """ Load a configuration module and return a Config """ d = importlib.import_module(module_name) config = {} for key in dir(d): if key.isupper(): config[key] = getattr(d, key) return Config(config)
def from_module(module_name): """ Load a configuration module and return a Config """ d = importlib.import_module(module_name) config = {} for key in dir(d): if key.isupper(): config[key] = getattr(d, key) return Config(config)
[ "Load", "a", "configuration", "module", "and", "return", "a", "Config" ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/config.py#L42-L51
[ "def", "from_module", "(", "module_name", ")", ":", "d", "=", "importlib", ".", "import_module", "(", "module_name", ")", "config", "=", "{", "}", "for", "key", "in", "dir", "(", "d", ")", ":", "if", "key", ".", "isupper", "(", ")", ":", "config", ...
c98a498f8e7972218903ec027f6de78089726c1d
test
ResourceManager.register_resources
Register resources with the ResourceManager.
src/polydatum/resources.py
def register_resources(self, **resources): """ Register resources with the ResourceManager. """ for key, resource in resources.items(): if key in self._resources: raise AlreadyExistsException('A Service for {} is already registered.'.format(key)) ...
def register_resources(self, **resources): """ Register resources with the ResourceManager. """ for key, resource in resources.items(): if key in self._resources: raise AlreadyExistsException('A Service for {} is already registered.'.format(key)) ...
[ "Register", "resources", "with", "the", "ResourceManager", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/resources.py#L54-L62
[ "def", "register_resources", "(", "self", ",", "*", "*", "resources", ")", ":", "for", "key", ",", "resource", "in", "resources", ".", "items", "(", ")", ":", "if", "key", "in", "self", ".", "_resources", ":", "raise", "AlreadyExistsException", "(", "'A ...
c98a498f8e7972218903ec027f6de78089726c1d
test
Meta.require
Raises an exception if value for ``key`` is empty.
src/polydatum/context.py
def require(self, key): """ Raises an exception if value for ``key`` is empty. """ value = self.get(key) if not value: raise ValueError('"{}" is empty.'.format(key)) return value
def require(self, key): """ Raises an exception if value for ``key`` is empty. """ value = self.get(key) if not value: raise ValueError('"{}" is empty.'.format(key)) return value
[ "Raises", "an", "exception", "if", "value", "for", "key", "is", "empty", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/context.py#L56-L63
[ "def", "require", "(", "self", ",", "key", ")", ":", "value", "=", "self", ".", "get", "(", "key", ")", "if", "not", "value", ":", "raise", "ValueError", "(", "'\"{}\" is empty.'", ".", "format", "(", "key", ")", ")", "return", "value" ]
c98a498f8e7972218903ec027f6de78089726c1d
test
DataAccessContext._setup
Setup the context. Should only be called by __enter__'ing the context.
src/polydatum/context.py
def _setup(self): """ Setup the context. Should only be called by __enter__'ing the context. """ self.data_manager.ctx_stack.push(self) self._setup_hook() middleware = self.data_manager.get_middleware(self) # Create each middleware generator # Th...
def _setup(self): """ Setup the context. Should only be called by __enter__'ing the context. """ self.data_manager.ctx_stack.push(self) self._setup_hook() middleware = self.data_manager.get_middleware(self) # Create each middleware generator # Th...
[ "Setup", "the", "context", ".", "Should", "only", "be", "called", "by", "__enter__", "ing", "the", "context", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/context.py#L113-L136
[ "def", "_setup", "(", "self", ")", ":", "self", ".", "data_manager", ".", "ctx_stack", ".", "push", "(", "self", ")", "self", ".", "_setup_hook", "(", ")", "middleware", "=", "self", ".", "data_manager", ".", "get_middleware", "(", "self", ")", "# Create...
c98a498f8e7972218903ec027f6de78089726c1d
test
DataAccessContext._exit
Teardown a Resource or Middleware.
src/polydatum/context.py
def _exit(self, obj, type, value, traceback): """ Teardown a Resource or Middleware. """ if type is None: # No in-context exception occurred try: obj.next() except StopIteration: # Resource closed as expected ...
def _exit(self, obj, type, value, traceback): """ Teardown a Resource or Middleware. """ if type is None: # No in-context exception occurred try: obj.next() except StopIteration: # Resource closed as expected ...
[ "Teardown", "a", "Resource", "or", "Middleware", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/context.py#L239-L275
[ "def", "_exit", "(", "self", ",", "obj", ",", "type", ",", "value", ",", "traceback", ")", ":", "if", "type", "is", "None", ":", "# No in-context exception occurred", "try", ":", "obj", ".", "next", "(", ")", "except", "StopIteration", ":", "# Resource clo...
c98a498f8e7972218903ec027f6de78089726c1d
test
Service.setup
Hook to setup this service with a specific DataManager. Will recursively setup sub-services.
src/polydatum/services.py
def setup(self, data_manager): """ Hook to setup this service with a specific DataManager. Will recursively setup sub-services. """ self._data_manager = data_manager if self._data_manager: self._dal = self._data_manager.get_dal() else: sel...
def setup(self, data_manager): """ Hook to setup this service with a specific DataManager. Will recursively setup sub-services. """ self._data_manager = data_manager if self._data_manager: self._dal = self._data_manager.get_dal() else: sel...
[ "Hook", "to", "setup", "this", "service", "with", "a", "specific", "DataManager", "." ]
six8/polydatum
python
https://github.com/six8/polydatum/blob/c98a498f8e7972218903ec027f6de78089726c1d/src/polydatum/services.py#L16-L29
[ "def", "setup", "(", "self", ",", "data_manager", ")", ":", "self", ".", "_data_manager", "=", "data_manager", "if", "self", ".", "_data_manager", ":", "self", ".", "_dal", "=", "self", ".", "_data_manager", ".", "get_dal", "(", ")", "else", ":", "self",...
c98a498f8e7972218903ec027f6de78089726c1d
test
_Material.ng
The group index with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the group index will be evaluated at. Returns: float, list: The group index at the target wavelength(s).
opticalmaterialspy/_material_base.py
def ng(self, wavelength): ''' The group index with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the group index will be evaluated at. Returns: float, list: The group index at the target wavelength(s). '''...
def ng(self, wavelength): ''' The group index with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the group index will be evaluated at. Returns: float, list: The group index at the target wavelength(s). '''...
[ "The", "group", "index", "with", "respect", "to", "wavelength", "." ]
jtambasco/opticalmaterialspy
python
https://github.com/jtambasco/opticalmaterialspy/blob/bfdfacad7fe280a0e63a3eb89de09a5c153595cc/opticalmaterialspy/_material_base.py#L137-L148
[ "def", "ng", "(", "self", ",", "wavelength", ")", ":", "return", "self", ".", "n", "(", "wavelength", ")", "-", "(", "wavelength", "*", "1.e-9", ")", "*", "self", ".", "nDer1", "(", "wavelength", ")" ]
bfdfacad7fe280a0e63a3eb89de09a5c153595cc
test
_Material.gvd
The group velocity dispersion (GVD) with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the GVD will be evaluated at. Returns: float, list: The GVD at the target wavelength(s).
opticalmaterialspy/_material_base.py
def gvd(self, wavelength): ''' The group velocity dispersion (GVD) with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the GVD will be evaluated at. Returns: float, list: The GVD at the target wavelength(s). ...
def gvd(self, wavelength): ''' The group velocity dispersion (GVD) with respect to wavelength. Args: wavelength (float, list, None): The wavelength(s) the GVD will be evaluated at. Returns: float, list: The GVD at the target wavelength(s). ...
[ "The", "group", "velocity", "dispersion", "(", "GVD", ")", "with", "respect", "to", "wavelength", "." ]
jtambasco/opticalmaterialspy
python
https://github.com/jtambasco/opticalmaterialspy/blob/bfdfacad7fe280a0e63a3eb89de09a5c153595cc/opticalmaterialspy/_material_base.py#L167-L179
[ "def", "gvd", "(", "self", ",", "wavelength", ")", ":", "g", "=", "(", "wavelength", "*", "1.e-9", ")", "**", "3.", "/", "(", "2.", "*", "spc", ".", "pi", "*", "spc", ".", "c", "**", "2.", ")", "*", "self", ".", "nDer2", "(", "wavelength", ")...
bfdfacad7fe280a0e63a3eb89de09a5c153595cc
test
_Material._cauchy_equation
Helpful function to evaluate Cauchy equations. Args: wavelength (float, list, None): The wavelength(s) the Cauchy equation will be evaluated at. coefficients (list): A list of the coefficients of the Cauchy equation. Returns: float, l...
opticalmaterialspy/_material_base.py
def _cauchy_equation(wavelength, coefficients): ''' Helpful function to evaluate Cauchy equations. Args: wavelength (float, list, None): The wavelength(s) the Cauchy equation will be evaluated at. coefficients (list): A list of the coefficients of ...
def _cauchy_equation(wavelength, coefficients): ''' Helpful function to evaluate Cauchy equations. Args: wavelength (float, list, None): The wavelength(s) the Cauchy equation will be evaluated at. coefficients (list): A list of the coefficients of ...
[ "Helpful", "function", "to", "evaluate", "Cauchy", "equations", "." ]
jtambasco/opticalmaterialspy
python
https://github.com/jtambasco/opticalmaterialspy/blob/bfdfacad7fe280a0e63a3eb89de09a5c153595cc/opticalmaterialspy/_material_base.py#L238-L255
[ "def", "_cauchy_equation", "(", "wavelength", ",", "coefficients", ")", ":", "n", "=", "0.", "for", "i", ",", "c", "in", "enumerate", "(", "coefficients", ")", ":", "exponent", "=", "2", "*", "i", "n", "+=", "c", "/", "wavelength", "**", "exponent", ...
bfdfacad7fe280a0e63a3eb89de09a5c153595cc
test
main
Main function
alignak_backend_client/backend_client.py
def main(): """ Main function """ bc = BackendUpdate() bc.initialize() logger.info("backend_client, version: %s", __version__) logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~") success = False if bc.item_type and bc.action == 'list': success = bc.get_resource_list(bc.item_type, b...
def main(): """ Main function """ bc = BackendUpdate() bc.initialize() logger.info("backend_client, version: %s", __version__) logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~") success = False if bc.item_type and bc.action == 'list': success = bc.get_resource_list(bc.item_type, b...
[ "Main", "function" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L1085-L1120
[ "def", "main", "(", ")", ":", "bc", "=", "BackendUpdate", "(", ")", "bc", ".", "initialize", "(", ")", "logger", ".", "info", "(", "\"backend_client, version: %s\"", ",", "__version__", ")", "logger", ".", "debug", "(", "\"~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"", ")",...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.initialize
Login on backend with username and password :return: None
alignak_backend_client/backend_client.py
def initialize(self): # pylint: disable=attribute-defined-outside-init """Login on backend with username and password :return: None """ try: logger.info("Authenticating...") self.backend = Backend(self.backend_url) self.backend.login(self.user...
def initialize(self): # pylint: disable=attribute-defined-outside-init """Login on backend with username and password :return: None """ try: logger.info("Authenticating...") self.backend = Backend(self.backend_url) self.backend.login(self.user...
[ "Login", "on", "backend", "with", "username", "and", "password" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L392-L439
[ "def", "initialize", "(", "self", ")", ":", "# pylint: disable=attribute-defined-outside-init", "try", ":", "logger", ".", "info", "(", "\"Authenticating...\"", ")", "self", ".", "backend", "=", "Backend", "(", "self", ".", "backend_url", ")", "self", ".", "back...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.file_dump
Dump the data to a JSON formatted file :param data: data to be dumped :param filename: name of the file to use. Only the file name, not the full path! :return: dumped file absolute file name
alignak_backend_client/backend_client.py
def file_dump(self, data, filename): # pylint: disable=no-self-use """ Dump the data to a JSON formatted file :param data: data to be dumped :param filename: name of the file to use. Only the file name, not the full path! :return: dumped file absolute file name """ ...
def file_dump(self, data, filename): # pylint: disable=no-self-use """ Dump the data to a JSON formatted file :param data: data to be dumped :param filename: name of the file to use. Only the file name, not the full path! :return: dumped file absolute file name """ ...
[ "Dump", "the", "data", "to", "a", "JSON", "formatted", "file", ":", "param", "data", ":", "data", "to", "be", "dumped", ":", "param", "filename", ":", "name", "of", "the", "file", "to", "use", ".", "Only", "the", "file", "name", "not", "the", "full",...
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L441-L458
[ "def", "file_dump", "(", "self", ",", "data", ",", "filename", ")", ":", "# pylint: disable=no-self-use", "dump", "=", "json", ".", "dumps", "(", "data", ",", "indent", "=", "4", ",", "separators", "=", "(", "','", ",", "': '", ")", ",", "sort_keys", "...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.get_resource_list
Get a specific resource list If name is not None, it may be a request to get the list of the services of an host.
alignak_backend_client/backend_client.py
def get_resource_list(self, resource_name, name=''): # pylint: disable=too-many-locals, too-many-nested-blocks """Get a specific resource list If name is not None, it may be a request to get the list of the services of an host. """ try: logger.info("Trying to get %s ...
def get_resource_list(self, resource_name, name=''): # pylint: disable=too-many-locals, too-many-nested-blocks """Get a specific resource list If name is not None, it may be a request to get the list of the services of an host. """ try: logger.info("Trying to get %s ...
[ "Get", "a", "specific", "resource", "list" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L460-L552
[ "def", "get_resource_list", "(", "self", ",", "resource_name", ",", "name", "=", "''", ")", ":", "# pylint: disable=too-many-locals, too-many-nested-blocks", "try", ":", "logger", ".", "info", "(", "\"Trying to get %s list\"", ",", "resource_name", ")", "params", "=",...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.get_resource
Get a specific resource by name
alignak_backend_client/backend_client.py
def get_resource(self, resource_name, name): # pylint: disable=too-many-locals, too-many-nested-blocks """Get a specific resource by name""" try: logger.info("Trying to get %s: '%s'", resource_name, name) services_list = False if resource_name == 'host' and '...
def get_resource(self, resource_name, name): # pylint: disable=too-many-locals, too-many-nested-blocks """Get a specific resource by name""" try: logger.info("Trying to get %s: '%s'", resource_name, name) services_list = False if resource_name == 'host' and '...
[ "Get", "a", "specific", "resource", "by", "name" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L554-L673
[ "def", "get_resource", "(", "self", ",", "resource_name", ",", "name", ")", ":", "# pylint: disable=too-many-locals, too-many-nested-blocks", "try", ":", "logger", ".", "info", "(", "\"Trying to get %s: '%s'\"", ",", "resource_name", ",", "name", ")", "services_list", ...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.delete_resource
Delete a specific resource by name
alignak_backend_client/backend_client.py
def delete_resource(self, resource_name, name): """Delete a specific resource by name""" try: logger.info("Trying to get %s: '%s'", resource_name, name) if name is None: # No name is defined, delete all the resources... if not self.dry_run: ...
def delete_resource(self, resource_name, name): """Delete a specific resource by name""" try: logger.info("Trying to get %s: '%s'", resource_name, name) if name is None: # No name is defined, delete all the resources... if not self.dry_run: ...
[ "Delete", "a", "specific", "resource", "by", "name" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L675-L749
[ "def", "delete_resource", "(", "self", ",", "resource_name", ",", "name", ")", ":", "try", ":", "logger", ".", "info", "(", "\"Trying to get %s: '%s'\"", ",", "resource_name", ",", "name", ")", "if", "name", "is", "None", ":", "# No name is defined, delete all t...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
BackendUpdate.create_update_resource
Create or update a specific resource :param resource_name: backend resource endpoint (eg. host, user, ...) :param name: name of the resource to create/update :param update: True to update an existing resource, else will try to create :return:
alignak_backend_client/backend_client.py
def create_update_resource(self, resource_name, name, update=False): # pylint: disable=too-many-return-statements, too-many-locals # pylint: disable=too-many-nested-blocks """Create or update a specific resource :param resource_name: backend resource endpoint (eg. host, user, ...) ...
def create_update_resource(self, resource_name, name, update=False): # pylint: disable=too-many-return-statements, too-many-locals # pylint: disable=too-many-nested-blocks """Create or update a specific resource :param resource_name: backend resource endpoint (eg. host, user, ...) ...
[ "Create", "or", "update", "a", "specific", "resource" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/backend_client.py#L751-L1082
[ "def", "create_update_resource", "(", "self", ",", "resource_name", ",", "name", ",", "update", "=", "False", ")", ":", "# pylint: disable=too-many-return-statements, too-many-locals", "# pylint: disable=too-many-nested-blocks", "if", "self", ".", "data", "is", "None", ":...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.get_response
Returns the response from the requested endpoint with the requested method :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...) :param endpoint: str. the relative endpoint to access :param params: (optional) Dictionary or bytes to be sent in the query string f...
alignak_backend_client/client.py
def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None): # pylint: disable=too-many-arguments """ Returns the response from the requested endpoint with the requested method :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...) ...
def get_response(self, method, endpoint, headers=None, json=None, params=None, data=None): # pylint: disable=too-many-arguments """ Returns the response from the requested endpoint with the requested method :param method: str. one of the methods accepted by Requests ('POST', 'GET', ...) ...
[ "Returns", "the", "response", "from", "the", "requested", "endpoint", "with", "the", "requested", "method", ":", "param", "method", ":", "str", ".", "one", "of", "the", "methods", "accepted", "by", "Requests", "(", "POST", "GET", "...", ")", ":", "param", ...
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L157-L196
[ "def", "get_response", "(", "self", ",", "method", ",", "endpoint", ",", "headers", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "# pylint: disable=too-many-arguments", "logger", ".", "debug", "(", ...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.decode
Decodes and returns the response as JSON (dict) or raise BackendException :param response: requests.response object :return: dict
alignak_backend_client/client.py
def decode(response): """ Decodes and returns the response as JSON (dict) or raise BackendException :param response: requests.response object :return: dict """ # Second stage. Errors are backend errors (bad login, bad url, ...) try: response.raise_for...
def decode(response): """ Decodes and returns the response as JSON (dict) or raise BackendException :param response: requests.response object :return: dict """ # Second stage. Errors are backend errors (bad login, bad url, ...) try: response.raise_for...
[ "Decodes", "and", "returns", "the", "response", "as", "JSON", "(", "dict", ")", "or", "raise", "BackendException", ":", "param", "response", ":", "requests", ".", "response", "object", ":", "return", ":", "dict" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L199-L221
[ "def", "decode", "(", "response", ")", ":", "# Second stage. Errors are backend errors (bad login, bad url, ...)", "try", ":", "response", ".", "raise_for_status", "(", ")", "except", "requests", ".", "HTTPError", "as", "e", ":", "raise", "BackendException", "(", "cod...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.set_token
Set token in authentification for next requests :param token: str. token to set in auth. If None, reinit auth
alignak_backend_client/client.py
def set_token(self, token): """ Set token in authentification for next requests :param token: str. token to set in auth. If None, reinit auth """ if token: auth = HTTPBasicAuth(token, '') self._token = token self.authenticated = True # TODO: R...
def set_token(self, token): """ Set token in authentification for next requests :param token: str. token to set in auth. If None, reinit auth """ if token: auth = HTTPBasicAuth(token, '') self._token = token self.authenticated = True # TODO: R...
[ "Set", "token", "in", "authentification", "for", "next", "requests", ":", "param", "token", ":", "str", ".", "token", "to", "set", "in", "auth", ".", "If", "None", "reinit", "auth" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L223-L238
[ "def", "set_token", "(", "self", ",", "token", ")", ":", "if", "token", ":", "auth", "=", "HTTPBasicAuth", "(", "token", ",", "''", ")", "self", ".", "_token", "=", "token", "self", ".", "authenticated", "=", "True", "# TODO: Remove this parameter", "self"...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.login
Log into the backend and get the token generate parameter may have following values: - enabled: require current token (default) - force: force new token generation - disabled if login is: - accepted, returns True - refused, returns False In case of any ...
alignak_backend_client/client.py
def login(self, username, password, generate='enabled', proxies=None): """ Log into the backend and get the token generate parameter may have following values: - enabled: require current token (default) - force: force new token generation - disabled if login is:...
def login(self, username, password, generate='enabled', proxies=None): """ Log into the backend and get the token generate parameter may have following values: - enabled: require current token (default) - force: force new token generation - disabled if login is:...
[ "Log", "into", "the", "backend", "and", "get", "the", "token" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L246-L312
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "generate", "=", "'enabled'", ",", "proxies", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"login for: %s with generate: %s\"", ",", "username", ",", "generate", ")", "if", "not", ...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.get_domains
Connect to alignak backend and retrieve all available child endpoints of root If connection is successful, returns a list of all the resources available in the backend: Each resource is identified with its title and provides its endpoint relative to backend root endpoint.:: [ ...
alignak_backend_client/client.py
def get_domains(self): """ Connect to alignak backend and retrieve all available child endpoints of root If connection is successful, returns a list of all the resources available in the backend: Each resource is identified with its title and provides its endpoint relative to backend ...
def get_domains(self): """ Connect to alignak backend and retrieve all available child endpoints of root If connection is successful, returns a list of all the resources available in the backend: Each resource is identified with its title and provides its endpoint relative to backend ...
[ "Connect", "to", "alignak", "backend", "and", "retrieve", "all", "available", "child", "endpoints", "of", "root" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L335-L364
[ "def", "get_domains", "(", "self", ")", ":", "resp", "=", "self", ".", "get", "(", "''", ")", "if", "\"_links\"", "in", "resp", ":", "_links", "=", "resp", "[", "\"_links\"", "]", "if", "\"child\"", "in", "_links", ":", "return", "_links", "[", "\"ch...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.get_all
Get all items in the specified endpoint of alignak backend If an error occurs, a BackendException is raised. If the max_results parameter is not specified in parameters, it is set to BACKEND_PAGINATION_LIMIT (backend maximum value) to limit requests number. This method builds a respon...
alignak_backend_client/client.py
def get_all(self, endpoint, params=None): # pylint: disable=too-many-locals """ Get all items in the specified endpoint of alignak backend If an error occurs, a BackendException is raised. If the max_results parameter is not specified in parameters, it is set to BACKEND...
def get_all(self, endpoint, params=None): # pylint: disable=too-many-locals """ Get all items in the specified endpoint of alignak backend If an error occurs, a BackendException is raised. If the max_results parameter is not specified in parameters, it is set to BACKEND...
[ "Get", "all", "items", "in", "the", "specified", "endpoint", "of", "alignak", "backend" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L396-L504
[ "def", "get_all", "(", "self", ",", "endpoint", ",", "params", "=", "None", ")", ":", "# pylint: disable=too-many-locals", "# Set max results at maximum value supported by the backend to limit requests number", "if", "not", "params", ":", "params", "=", "{", "'max_results'"...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.patch
Method to update an item The headers must include an If-Match containing the object _etag. headers = {'If-Match': contact_etag} The data dictionary contain the fields that must be modified. If the patching fails because the _etag object do not match with the provided one, a ...
alignak_backend_client/client.py
def patch(self, endpoint, data, headers=None, inception=False): """ Method to update an item The headers must include an If-Match containing the object _etag. headers = {'If-Match': contact_etag} The data dictionary contain the fields that must be modified. If the ...
def patch(self, endpoint, data, headers=None, inception=False): """ Method to update an item The headers must include an If-Match containing the object _etag. headers = {'If-Match': contact_etag} The data dictionary contain the fields that must be modified. If the ...
[ "Method", "to", "update", "an", "item" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L550-L610
[ "def", "patch", "(", "self", ",", "endpoint", ",", "data", ",", "headers", "=", "None", ",", "inception", "=", "False", ")", ":", "if", "not", "headers", ":", "raise", "BackendException", "(", "BACKEND_ERROR", ",", "\"Header If-Match required for patching an obj...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
Backend.delete
Method to delete an item or all items headers['If-Match'] must contain the _etag identifier of the element to delete :param endpoint: endpoint (API URL) :type endpoint: str :param headers: headers (example: Content-Type) :type headers: dict :return: response (deletion i...
alignak_backend_client/client.py
def delete(self, endpoint, headers): """ Method to delete an item or all items headers['If-Match'] must contain the _etag identifier of the element to delete :param endpoint: endpoint (API URL) :type endpoint: str :param headers: headers (example: Content-Type) ...
def delete(self, endpoint, headers): """ Method to delete an item or all items headers['If-Match'] must contain the _etag identifier of the element to delete :param endpoint: endpoint (API URL) :type endpoint: str :param headers: headers (example: Content-Type) ...
[ "Method", "to", "delete", "an", "item", "or", "all", "items" ]
Alignak-monitoring-contrib/alignak-backend-client
python
https://github.com/Alignak-monitoring-contrib/alignak-backend-client/blob/1e21f6ce703e66984d1f9b20fe7866460ab50b39/alignak_backend_client/client.py#L674-L694
[ "def", "delete", "(", "self", ",", "endpoint", ",", "headers", ")", ":", "response", "=", "self", ".", "get_response", "(", "method", "=", "'DELETE'", ",", "endpoint", "=", "endpoint", ",", "headers", "=", "headers", ")", "logger", ".", "debug", "(", "...
1e21f6ce703e66984d1f9b20fe7866460ab50b39
test
samefile
Returns True if path1 and path2 refer to the same file.
ntfsutils/hardlink.py
def samefile(path1, path2): """ Returns True if path1 and path2 refer to the same file. """ # Check if both are on the same volume and have the same file ID info1 = fs.getfileinfo(path1) info2 = fs.getfileinfo(path2) return (info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber and ...
def samefile(path1, path2): """ Returns True if path1 and path2 refer to the same file. """ # Check if both are on the same volume and have the same file ID info1 = fs.getfileinfo(path1) info2 = fs.getfileinfo(path2) return (info1.dwVolumeSerialNumber == info2.dwVolumeSerialNumber and ...
[ "Returns", "True", "if", "path1", "and", "path2", "refer", "to", "the", "same", "file", "." ]
sunshowers/ntfs
python
https://github.com/sunshowers/ntfs/blob/33388a514f0a5a032f68dfeb9a40ce7c772e7cf5/ntfsutils/hardlink.py#L25-L34
[ "def", "samefile", "(", "path1", ",", "path2", ")", ":", "# Check if both are on the same volume and have the same file ID", "info1", "=", "fs", ".", "getfileinfo", "(", "path1", ")", "info2", "=", "fs", ".", "getfileinfo", "(", "path2", ")", "return", "(", "inf...
33388a514f0a5a032f68dfeb9a40ce7c772e7cf5
test
new_junction_reparse_buffer
Given a path, return a pair containing a new REPARSE_DATA_BUFFER and the length of the buffer (not necessarily the same as sizeof due to packing issues). If no path is provided, the maximum length is assumed.
ntfsutils/junction.py
def new_junction_reparse_buffer(path=None): """ Given a path, return a pair containing a new REPARSE_DATA_BUFFER and the length of the buffer (not necessarily the same as sizeof due to packing issues). If no path is provided, the maximum length is assumed. """ if path is None: #...
def new_junction_reparse_buffer(path=None): """ Given a path, return a pair containing a new REPARSE_DATA_BUFFER and the length of the buffer (not necessarily the same as sizeof due to packing issues). If no path is provided, the maximum length is assumed. """ if path is None: #...
[ "Given", "a", "path", "return", "a", "pair", "containing", "a", "new", "REPARSE_DATA_BUFFER", "and", "the", "length", "of", "the", "buffer", "(", "not", "necessarily", "the", "same", "as", "sizeof", "due", "to", "packing", "issues", ")", ".", "If", "no", ...
sunshowers/ntfs
python
https://github.com/sunshowers/ntfs/blob/33388a514f0a5a032f68dfeb9a40ce7c772e7cf5/ntfsutils/junction.py#L24-L86
[ "def", "new_junction_reparse_buffer", "(", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "# The maximum reparse point data buffer length is 16384 bytes. We are a", "# bit conservative here and set a length of 16000 bytes (8000", "# characters) + a few more for the hea...
33388a514f0a5a032f68dfeb9a40ce7c772e7cf5
test
create
Create a junction at link_name pointing to source.
ntfsutils/junction.py
def create(source, link_name): """ Create a junction at link_name pointing to source. """ success = False if not os.path.isdir(source): raise Exception("%s is not a directory" % source) if os.path.exists(link_name): raise Exception("%s: junction link name already exists" % link_n...
def create(source, link_name): """ Create a junction at link_name pointing to source. """ success = False if not os.path.isdir(source): raise Exception("%s is not a directory" % source) if os.path.exists(link_name): raise Exception("%s: junction link name already exists" % link_n...
[ "Create", "a", "junction", "at", "link_name", "pointing", "to", "source", "." ]
sunshowers/ntfs
python
https://github.com/sunshowers/ntfs/blob/33388a514f0a5a032f68dfeb9a40ce7c772e7cf5/ntfsutils/junction.py#L110-L153
[ "def", "create", "(", "source", ",", "link_name", ")", ":", "success", "=", "False", "if", "not", "os", ".", "path", ".", "isdir", "(", "source", ")", ":", "raise", "Exception", "(", "\"%s is not a directory\"", "%", "source", ")", "if", "os", ".", "pa...
33388a514f0a5a032f68dfeb9a40ce7c772e7cf5
test
getvolumeinfo
Return information for the volume containing the given path. This is going to be a pair containing (file system, file system flags).
ntfsutils/fs.py
def getvolumeinfo(path): """ Return information for the volume containing the given path. This is going to be a pair containing (file system, file system flags). """ # Add 1 for a trailing backslash if necessary, and 1 for the terminating # null character. volpath = ctypes.create_unicode_bu...
def getvolumeinfo(path): """ Return information for the volume containing the given path. This is going to be a pair containing (file system, file system flags). """ # Add 1 for a trailing backslash if necessary, and 1 for the terminating # null character. volpath = ctypes.create_unicode_bu...
[ "Return", "information", "for", "the", "volume", "containing", "the", "given", "path", ".", "This", "is", "going", "to", "be", "a", "pair", "containing", "(", "file", "system", "file", "system", "flags", ")", "." ]
sunshowers/ntfs
python
https://github.com/sunshowers/ntfs/blob/33388a514f0a5a032f68dfeb9a40ce7c772e7cf5/ntfsutils/fs.py#L113-L133
[ "def", "getvolumeinfo", "(", "path", ")", ":", "# Add 1 for a trailing backslash if necessary, and 1 for the terminating", "# null character.", "volpath", "=", "ctypes", ".", "create_unicode_buffer", "(", "len", "(", "path", ")", "+", "2", ")", "rv", "=", "GetVolumePath...
33388a514f0a5a032f68dfeb9a40ce7c772e7cf5
test
initialize_logger
Sets command name and formatting for subsequent calls to logger
jacquard/utils/logger.py
def initialize_logger(args): """Sets command name and formatting for subsequent calls to logger""" global log_filename log_filename = os.path.join(os.getcwd(), "jacquard.log") if args.log_file: _validate_log_file(args.log_file) log_filename = args.log_file logging.basicConfig(forma...
def initialize_logger(args): """Sets command name and formatting for subsequent calls to logger""" global log_filename log_filename = os.path.join(os.getcwd(), "jacquard.log") if args.log_file: _validate_log_file(args.log_file) log_filename = args.log_file logging.basicConfig(forma...
[ "Sets", "command", "name", "and", "formatting", "for", "subsequent", "calls", "to", "logger" ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/logger.py#L55-L78
[ "def", "initialize_logger", "(", "args", ")", ":", "global", "log_filename", "log_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "\"jacquard.log\"", ")", "if", "args", ".", "log_file", ":", "_validate_log_file", "(...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
_JacquardArgumentParser.error
Suppress default exit behavior
jacquard/jacquard.py
def error(self, message): '''Suppress default exit behavior''' message = self._remessage_invalid_subparser(message) raise utils.UsageError(message)
def error(self, message): '''Suppress default exit behavior''' message = self._remessage_invalid_subparser(message) raise utils.UsageError(message)
[ "Suppress", "default", "exit", "behavior" ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/jacquard.py#L81-L84
[ "def", "error", "(", "self", ",", "message", ")", ":", "message", "=", "self", ".", "_remessage_invalid_subparser", "(", "message", ")", "raise", "utils", ".", "UsageError", "(", "message", ")" ]
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
Mutect.claim
Recognizes and claims MuTect VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed files Returns: A tuple of...
jacquard/variant_caller_transforms/mutect.py
def claim(self, file_readers): """Recognizes and claims MuTect VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed file...
def claim(self, file_readers): """Recognizes and claims MuTect VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed file...
[ "Recognizes", "and", "claims", "MuTect", "VCFs", "form", "the", "set", "of", "all", "input", "VCFs", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/mutect.py#L224-L244
[ "def", "claim", "(", "self", ",", "file_readers", ")", ":", "unclaimed_readers", "=", "[", "]", "vcf_readers", "=", "[", "]", "for", "file_reader", "in", "file_readers", ":", "if", "self", ".", "_is_mutect_vcf", "(", "file_reader", ")", ":", "vcf_reader", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
Mutect._get_new_column_header
Returns a standardized column header. MuTect sample headers include the name of input alignment, which is nice, but doesn't match up with the sample names reported in Strelka or VarScan. To fix this, we replace with NORMAL and TUMOR using the MuTect metadata command line to replace them...
jacquard/variant_caller_transforms/mutect.py
def _get_new_column_header(self, vcf_reader): """Returns a standardized column header. MuTect sample headers include the name of input alignment, which is nice, but doesn't match up with the sample names reported in Strelka or VarScan. To fix this, we replace with NORMAL and TUMOR using...
def _get_new_column_header(self, vcf_reader): """Returns a standardized column header. MuTect sample headers include the name of input alignment, which is nice, but doesn't match up with the sample names reported in Strelka or VarScan. To fix this, we replace with NORMAL and TUMOR using...
[ "Returns", "a", "standardized", "column", "header", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/mutect.py#L253-L278
[ "def", "_get_new_column_header", "(", "self", ",", "vcf_reader", ")", ":", "mutect_dict", "=", "self", ".", "_build_mutect_dict", "(", "vcf_reader", ".", "metaheaders", ")", "new_header_list", "=", "[", "]", "required_keys", "=", "set", "(", "[", "self", ".", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
read
Build a file path from *paths* and return the contents.
setup.py
def read(*paths): """Build a file path from *paths* and return the contents.""" with open(os.path.join(*paths), 'r') as filename: return filename.read()
def read(*paths): """Build a file path from *paths* and return the contents.""" with open(os.path.join(*paths), 'r') as filename: return filename.read()
[ "Build", "a", "file", "path", "from", "*", "paths", "*", "and", "return", "the", "contents", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/setup.py#L23-L26
[ "def", "read", "(", "*", "paths", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "*", "paths", ")", ",", "'r'", ")", "as", "filename", ":", "return", "filename", ".", "read", "(", ")" ]
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
Varscan.claim
Recognizes and claims VarScan VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Since VarScan can claim high-confidence files as well, this process is significantly more complex than for o...
jacquard/variant_caller_transforms/varscan.py
def claim(self, file_readers): """Recognizes and claims VarScan VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Since VarScan can claim high-confidence files as well, this process is sig...
def claim(self, file_readers): """Recognizes and claims VarScan VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Since VarScan can claim high-confidence files as well, this process is sig...
[ "Recognizes", "and", "claims", "VarScan", "VCFs", "form", "the", "set", "of", "all", "input", "VCFs", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/varscan.py#L393-L418
[ "def", "claim", "(", "self", ",", "file_readers", ")", ":", "(", "prefix_to_readers", ",", "filter_files", ",", "unclaimed_set", ")", "=", "self", ".", "_find_varscan_files", "(", "file_readers", ")", "prefix_by_patients", "=", "self", ".", "_split_prefix_by_patie...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
_ZScoreTag._get_dependent_value
Extract (float) value of dependent tag or None if absent.
jacquard/utils/summarize_zscore_transform.py
def _get_dependent_value(tag_values, dependent_tag_id): '''Extract (float) value of dependent tag or None if absent.''' try: values = tag_values[dependent_tag_id].split(",") return max([float(value) for value in values]) except KeyError: return None ex...
def _get_dependent_value(tag_values, dependent_tag_id): '''Extract (float) value of dependent tag or None if absent.''' try: values = tag_values[dependent_tag_id].split(",") return max([float(value) for value in values]) except KeyError: return None ex...
[ "Extract", "(", "float", ")", "value", "of", "dependent", "tag", "or", "None", "if", "absent", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/summarize_zscore_transform.py#L159-L167
[ "def", "_get_dependent_value", "(", "tag_values", ",", "dependent_tag_id", ")", ":", "try", ":", "values", "=", "tag_values", "[", "dependent_tag_id", "]", ".", "split", "(", "\",\"", ")", "return", "max", "(", "[", "float", "(", "value", ")", "for", "valu...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
_ZScoreTag._init_population_stats
Derive mean and stdev. Adapted from online variance algorithm from Knuth, The Art of Computer Programming, volume 2 Returns: mean and stdev when len(values) > 1, otherwise (None, None) Values rounded to _MAX_PRECISION to ameliorate discrepancies between python versions...
jacquard/utils/summarize_zscore_transform.py
def _init_population_stats(self, vcf_reader, dependent_tag_id): '''Derive mean and stdev. Adapted from online variance algorithm from Knuth, The Art of Computer Programming, volume 2 Returns: mean and stdev when len(values) > 1, otherwise (None, None) Values rounded to _MA...
def _init_population_stats(self, vcf_reader, dependent_tag_id): '''Derive mean and stdev. Adapted from online variance algorithm from Knuth, The Art of Computer Programming, volume 2 Returns: mean and stdev when len(values) > 1, otherwise (None, None) Values rounded to _MA...
[ "Derive", "mean", "and", "stdev", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/summarize_zscore_transform.py#L169-L206
[ "def", "_init_population_stats", "(", "self", ",", "vcf_reader", ",", "dependent_tag_id", ")", ":", "#pylint: disable=invalid-name", "n", "=", "0", "mean", "=", "0", "M2", "=", "0", "try", ":", "vcf_reader", ".", "open", "(", ")", "for", "vcf_record", "in", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VariantCallerFactory.claim
Allows each caller to claim incoming files as they are recognized. Args: unclaimed_file_readers: Usually, all files in the input dir. Returns: A tuple of unclaimed file readers and claimed VcfReaders. The presence of any unclaimed file readers could indicate stray f...
jacquard/variant_caller_transforms/variant_caller_factory.py
def claim(self, unclaimed_file_readers): """Allows each caller to claim incoming files as they are recognized. Args: unclaimed_file_readers: Usually, all files in the input dir. Returns: A tuple of unclaimed file readers and claimed VcfReaders. The presence ...
def claim(self, unclaimed_file_readers): """Allows each caller to claim incoming files as they are recognized. Args: unclaimed_file_readers: Usually, all files in the input dir. Returns: A tuple of unclaimed file readers and claimed VcfReaders. The presence ...
[ "Allows", "each", "caller", "to", "claim", "incoming", "files", "as", "they", "are", "recognized", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/variant_caller_factory.py#L25-L42
[ "def", "claim", "(", "self", ",", "unclaimed_file_readers", ")", ":", "claimed_vcf_readers", "=", "[", "]", "for", "caller", "in", "self", ".", "_callers", ":", "(", "unclaimed_file_readers", ",", "translated_vcf_readers", ")", "=", "caller", ".", "claim", "("...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
MergeVcfReader.vcf_records
Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualified: When True, sample names are prefixed with file name Retu...
jacquard/merge.py
def vcf_records(self, format_tags=None, qualified=False): """Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualifi...
def vcf_records(self, format_tags=None, qualified=False): """Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualifi...
[ "Generates", "parsed", "VcfRecord", "objects", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/merge.py#L128-L156
[ "def", "vcf_records", "(", "self", ",", "format_tags", "=", "None", ",", "qualified", "=", "False", ")", ":", "if", "qualified", ":", "sample_names", "=", "self", ".", "qualified_sample_names", "else", ":", "sample_names", "=", "self", ".", "sample_names", "...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
follow_path
Similar to follow, but also looks up if inode of file is changed e.g. if it was re-created. Returned generator yields strings encoded by using encoding. If encoding is not specified, it defaults to locale.getpreferredencoding() >>> import io >>> import os >>> f = io.open('test_follow_path.txt'...
tailhead/__init__.py
def follow_path(file_path, buffering=-1, encoding=None, errors='strict'): """ Similar to follow, but also looks up if inode of file is changed e.g. if it was re-created. Returned generator yields strings encoded by using encoding. If encoding is not specified, it defaults to locale.getpreferredenco...
def follow_path(file_path, buffering=-1, encoding=None, errors='strict'): """ Similar to follow, but also looks up if inode of file is changed e.g. if it was re-created. Returned generator yields strings encoded by using encoding. If encoding is not specified, it defaults to locale.getpreferredenco...
[ "Similar", "to", "follow", "but", "also", "looks", "up", "if", "inode", "of", "file", "is", "changed", "e", ".", "g", ".", "if", "it", "was", "re", "-", "created", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L380-L478
[ "def", "follow_path", "(", "file_path", ",", "buffering", "=", "-", "1", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "encoding", "is", "None", ":", "encoding", "=", "locale", ".", "getpreferredencoding", "(", ")", "class...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.splitlines
Split data into lines where lines are separated by LINE_TERMINATORS. :param data: Any chunk of binary data. :return: List of lines without any characters at LINE_TERMINATORS.
tailhead/__init__.py
def splitlines(self, data): """ Split data into lines where lines are separated by LINE_TERMINATORS. :param data: Any chunk of binary data. :return: List of lines without any characters at LINE_TERMINATORS. """ return re.split(b'|'.join(self.LINE_TERMINATORS), data)
def splitlines(self, data): """ Split data into lines where lines are separated by LINE_TERMINATORS. :param data: Any chunk of binary data. :return: List of lines without any characters at LINE_TERMINATORS. """ return re.split(b'|'.join(self.LINE_TERMINATORS), data)
[ "Split", "data", "into", "lines", "where", "lines", "are", "separated", "by", "LINE_TERMINATORS", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L63-L70
[ "def", "splitlines", "(", "self", ",", "data", ")", ":", "return", "re", ".", "split", "(", "b'|'", ".", "join", "(", "self", ".", "LINE_TERMINATORS", ")", ",", "data", ")" ]
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.read
Read given number of bytes from file. :param read_size: Number of bytes to read. -1 to read all. :return: Number of bytes read and data that was read.
tailhead/__init__.py
def read(self, read_size=-1): """ Read given number of bytes from file. :param read_size: Number of bytes to read. -1 to read all. :return: Number of bytes read and data that was read. """ read_str = self.file.read(read_size) return len(read_str), read_str
def read(self, read_size=-1): """ Read given number of bytes from file. :param read_size: Number of bytes to read. -1 to read all. :return: Number of bytes read and data that was read. """ read_str = self.file.read(read_size) return len(read_str), read_str
[ "Read", "given", "number", "of", "bytes", "from", "file", ".", ":", "param", "read_size", ":", "Number", "of", "bytes", "to", "read", ".", "-", "1", "to", "read", "all", ".", ":", "return", ":", "Number", "of", "bytes", "read", "and", "data", "that",...
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L72-L79
[ "def", "read", "(", "self", ",", "read_size", "=", "-", "1", ")", ":", "read_str", "=", "self", ".", "file", ".", "read", "(", "read_size", ")", "return", "len", "(", "read_str", ")", ",", "read_str" ]
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.prefix_line_terminator
Return line terminator data begins with or None.
tailhead/__init__.py
def prefix_line_terminator(self, data): """ Return line terminator data begins with or None. """ for t in self.LINE_TERMINATORS: if data.startswith(t): return t return None
def prefix_line_terminator(self, data): """ Return line terminator data begins with or None. """ for t in self.LINE_TERMINATORS: if data.startswith(t): return t return None
[ "Return", "line", "terminator", "data", "begins", "with", "or", "None", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L81-L89
[ "def", "prefix_line_terminator", "(", "self", ",", "data", ")", ":", "for", "t", "in", "self", ".", "LINE_TERMINATORS", ":", "if", "data", ".", "startswith", "(", "t", ")", ":", "return", "t", "return", "None" ]
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.suffix_line_terminator
Return line terminator data ends with or None.
tailhead/__init__.py
def suffix_line_terminator(self, data): """ Return line terminator data ends with or None. """ for t in self.LINE_TERMINATORS: if data.endswith(t): return t return None
def suffix_line_terminator(self, data): """ Return line terminator data ends with or None. """ for t in self.LINE_TERMINATORS: if data.endswith(t): return t return None
[ "Return", "line", "terminator", "data", "ends", "with", "or", "None", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L91-L99
[ "def", "suffix_line_terminator", "(", "self", ",", "data", ")", ":", "for", "t", "in", "self", ".", "LINE_TERMINATORS", ":", "if", "data", ".", "endswith", "(", "t", ")", ":", "return", "t", "return", "None" ]
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.seek_next_line
Seek next line relative to the current file position. :return: Position of the line or -1 if next line was not found.
tailhead/__init__.py
def seek_next_line(self): """ Seek next line relative to the current file position. :return: Position of the line or -1 if next line was not found. """ where = self.file.tell() offset = 0 while True: data_len, data = self.read(self.read_size) ...
def seek_next_line(self): """ Seek next line relative to the current file position. :return: Position of the line or -1 if next line was not found. """ where = self.file.tell() offset = 0 while True: data_len, data = self.read(self.read_size) ...
[ "Seek", "next", "line", "relative", "to", "the", "current", "file", "position", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L101-L141
[ "def", "seek_next_line", "(", "self", ")", ":", "where", "=", "self", ".", "file", ".", "tell", "(", ")", "offset", "=", "0", "while", "True", ":", "data_len", ",", "data", "=", "self", ".", "read", "(", "self", ".", "read_size", ")", "data_where", ...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.seek_previous_line
Seek previous line relative to the current file position. :return: Position of the line or -1 if previous line was not found.
tailhead/__init__.py
def seek_previous_line(self): """ Seek previous line relative to the current file position. :return: Position of the line or -1 if previous line was not found. """ where = self.file.tell() offset = 0 while True: if offset == where: br...
def seek_previous_line(self): """ Seek previous line relative to the current file position. :return: Position of the line or -1 if previous line was not found. """ where = self.file.tell() offset = 0 while True: if offset == where: br...
[ "Seek", "previous", "line", "relative", "to", "the", "current", "file", "position", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L143-L196
[ "def", "seek_previous_line", "(", "self", ")", ":", "where", "=", "self", ".", "file", ".", "tell", "(", ")", "offset", "=", "0", "while", "True", ":", "if", "offset", "==", "where", ":", "break", "read_size", "=", "self", ".", "read_size", "if", "se...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.tail
Return the last lines of the file.
tailhead/__init__.py
def tail(self, lines=10): """ Return the last lines of the file. """ self.file.seek(0, SEEK_END) for i in range(lines): if self.seek_previous_line() == -1: break data = self.file.read() for t in self.LINE_TERMINATORS: if ...
def tail(self, lines=10): """ Return the last lines of the file. """ self.file.seek(0, SEEK_END) for i in range(lines): if self.seek_previous_line() == -1: break data = self.file.read() for t in self.LINE_TERMINATORS: if ...
[ "Return", "the", "last", "lines", "of", "the", "file", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L198-L220
[ "def", "tail", "(", "self", ",", "lines", "=", "10", ")", ":", "self", ".", "file", ".", "seek", "(", "0", ",", "SEEK_END", ")", "for", "i", "in", "range", "(", "lines", ")", ":", "if", "self", ".", "seek_previous_line", "(", ")", "==", "-", "1...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.head
Return the top lines of the file.
tailhead/__init__.py
def head(self, lines=10): """ Return the top lines of the file. """ self.file.seek(0) for i in range(lines): if self.seek_next_line() == -1: break end_pos = self.file.tell() self.file.seek(0) data = self.file.read...
def head(self, lines=10): """ Return the top lines of the file. """ self.file.seek(0) for i in range(lines): if self.seek_next_line() == -1: break end_pos = self.file.tell() self.file.seek(0) data = self.file.read...
[ "Return", "the", "top", "lines", "of", "the", "file", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L222-L247
[ "def", "head", "(", "self", ",", "lines", "=", "10", ")", ":", "self", ".", "file", ".", "seek", "(", "0", ")", "for", "i", "in", "range", "(", "lines", ")", ":", "if", "self", ".", "seek_next_line", "(", ")", "==", "-", "1", ":", "break", "e...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Tailer.follow
Iterator generator that returns lines as data is added to the file. None will be yielded if no new line is available. Caller may either wait and re-try or end iteration.
tailhead/__init__.py
def follow(self): """ Iterator generator that returns lines as data is added to the file. None will be yielded if no new line is available. Caller may either wait and re-try or end iteration. """ trailing = True while True: where = sel...
def follow(self): """ Iterator generator that returns lines as data is added to the file. None will be yielded if no new line is available. Caller may either wait and re-try or end iteration. """ trailing = True while True: where = sel...
[ "Iterator", "generator", "that", "returns", "lines", "as", "data", "is", "added", "to", "the", "file", "." ]
GreatFruitOmsk/tailhead
python
https://github.com/GreatFruitOmsk/tailhead/blob/a3b1324a39935f8ffcfda59328a9a458672889d9/tailhead/__init__.py#L249-L284
[ "def", "follow", "(", "self", ")", ":", "trailing", "=", "True", "while", "True", ":", "where", "=", "self", ".", "file", ".", "tell", "(", ")", "if", "where", ">", "os", ".", "fstat", "(", "self", ".", "file", ".", "fileno", "(", ")", ")", "."...
a3b1324a39935f8ffcfda59328a9a458672889d9
test
Strelka.claim
Recognizes and claims Strelka VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed files Returns: A tuple o...
jacquard/variant_caller_transforms/strelka.py
def claim(self, file_readers): """Recognizes and claims Strelka VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed fil...
def claim(self, file_readers): """Recognizes and claims Strelka VCFs form the set of all input VCFs. Each defined caller has a chance to evaluate and claim all the incoming files as something that it can process. Args: file_readers: the collection of currently unclaimed fil...
[ "Recognizes", "and", "claims", "Strelka", "VCFs", "form", "the", "set", "of", "all", "input", "VCFs", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/variant_caller_transforms/strelka.py#L296-L314
[ "def", "claim", "(", "self", ",", "file_readers", ")", ":", "(", "prefix_to_reader", ",", "unclaimed_readers", ")", "=", "self", ".", "_find_strelka_files", "(", "file_readers", ")", "prefix_by_patients", "=", "self", ".", "_split_prefix_by_patient", "(", "prefix_...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfReader.vcf_records
Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualified: When True, sample names are prefixed with file name Retu...
jacquard/utils/vcf.py
def vcf_records(self, qualified=False): """Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualified: When True, sam...
def vcf_records(self, qualified=False): """Generates parsed VcfRecord objects. Typically called in a for loop to process each vcf record in a VcfReader. VcfReader must be opened in advanced and closed when complete. Skips all headers. Args: qualified: When True, sam...
[ "Generates", "parsed", "VcfRecord", "objects", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L101-L126
[ "def", "vcf_records", "(", "self", ",", "qualified", "=", "False", ")", ":", "if", "qualified", ":", "sample_names", "=", "self", ".", "qualified_sample_names", "else", ":", "sample_names", "=", "self", ".", "sample_names", "for", "line", "in", "self", ".", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord.parse_record
Alternative constructor that parses VcfRecord from VCF string. Aspire to parse/represent the data such that it could be reliably round-tripped. (This nicety means INFO fields and FORMAT tags should be treated as ordered to avoid shuffling.) Args: vcf_line: the VCF variant r...
jacquard/utils/vcf.py
def parse_record(cls, vcf_line, sample_names): """Alternative constructor that parses VcfRecord from VCF string. Aspire to parse/represent the data such that it could be reliably round-tripped. (This nicety means INFO fields and FORMAT tags should be treated as ordered to avoid shufflin...
def parse_record(cls, vcf_line, sample_names): """Alternative constructor that parses VcfRecord from VCF string. Aspire to parse/represent the data such that it could be reliably round-tripped. (This nicety means INFO fields and FORMAT tags should be treated as ordered to avoid shufflin...
[ "Alternative", "constructor", "that", "parses", "VcfRecord", "from", "VCF", "string", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L168-L197
[ "def", "parse_record", "(", "cls", ",", "vcf_line", ",", "sample_names", ")", ":", "vcf_fields", "=", "vcf_line", ".", "rstrip", "(", "\"\\r\\n\"", ")", ".", "split", "(", "\"\\t\"", ")", "chrom", ",", "pos", ",", "rid", ",", "ref", ",", "alt", ",", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord._sample_tag_values
Creates a sample dict of tag-value dicts for a single variant record. Args: sample_names: list of sample name strings. rformat: record format string (from VCF record). sample_fields: list of strings where each string is the ';' seperated format values for an ...
jacquard/utils/vcf.py
def _sample_tag_values(cls, sample_names, rformat, sample_fields): """Creates a sample dict of tag-value dicts for a single variant record. Args: sample_names: list of sample name strings. rformat: record format string (from VCF record). sample_fields: list of string...
def _sample_tag_values(cls, sample_names, rformat, sample_fields): """Creates a sample dict of tag-value dicts for a single variant record. Args: sample_names: list of sample name strings. rformat: record format string (from VCF record). sample_fields: list of string...
[ "Creates", "a", "sample", "dict", "of", "tag", "-", "value", "dicts", "for", "a", "single", "variant", "record", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L200-L220
[ "def", "_sample_tag_values", "(", "cls", ",", "sample_names", ",", "rformat", ",", "sample_fields", ")", ":", "sample_tag_values", "=", "OrderedDict", "(", ")", "tag_names", "=", "VcfRecord", ".", "_format_list", "(", "rformat", ")", "for", "i", ",", "sample_f...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord.format_tags
Returns set of format tags.
jacquard/utils/vcf.py
def format_tags(self): """Returns set of format tags.""" tags = VcfRecord._EMPTY_SET if self.sample_tag_values: first_sample = list(self.sample_tag_values.keys())[0] tags = set(self.sample_tag_values[first_sample].keys()) return tags
def format_tags(self): """Returns set of format tags.""" tags = VcfRecord._EMPTY_SET if self.sample_tag_values: first_sample = list(self.sample_tag_values.keys())[0] tags = set(self.sample_tag_values[first_sample].keys()) return tags
[ "Returns", "set", "of", "format", "tags", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L271-L277
[ "def", "format_tags", "(", "self", ")", ":", "tags", "=", "VcfRecord", ".", "_EMPTY_SET", "if", "self", ".", "sample_tag_values", ":", "first_sample", "=", "list", "(", "self", ".", "sample_tag_values", ".", "keys", "(", ")", ")", "[", "0", "]", "tags", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord.add_info_field
Adds new info field (flag or key=value pair). Args: field: String flag (e.g. "SOMATIC") or key-value ("NEW_DP=42") Raises: KeyError: if info field already exists
jacquard/utils/vcf.py
def add_info_field(self, field): """Adds new info field (flag or key=value pair). Args: field: String flag (e.g. "SOMATIC") or key-value ("NEW_DP=42") Raises: KeyError: if info field already exists """ if field in self.info_dict: msg = "New i...
def add_info_field(self, field): """Adds new info field (flag or key=value pair). Args: field: String flag (e.g. "SOMATIC") or key-value ("NEW_DP=42") Raises: KeyError: if info field already exists """ if field in self.info_dict: msg = "New i...
[ "Adds", "new", "info", "field", "(", "flag", "or", "key", "=", "value", "pair", ")", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L291-L310
[ "def", "add_info_field", "(", "self", ",", "field", ")", ":", "if", "field", "in", "self", ".", "info_dict", ":", "msg", "=", "\"New info field [{}] already exists.\"", ".", "format", "(", "field", ")", "raise", "KeyError", "(", "msg", ")", "if", "\"=\"", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord._join_info_fields
Updates info attribute from info dict.
jacquard/utils/vcf.py
def _join_info_fields(self): """Updates info attribute from info dict.""" if self.info_dict: info_fields = [] if len(self.info_dict) > 1: self.info_dict.pop(".", None) for field, value in self.info_dict.items(): if field == value: ...
def _join_info_fields(self): """Updates info attribute from info dict.""" if self.info_dict: info_fields = [] if len(self.info_dict) > 1: self.info_dict.pop(".", None) for field, value in self.info_dict.items(): if field == value: ...
[ "Updates", "info", "attribute", "from", "info", "dict", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L313-L326
[ "def", "_join_info_fields", "(", "self", ")", ":", "if", "self", ".", "info_dict", ":", "info_fields", "=", "[", "]", "if", "len", "(", "self", ".", "info_dict", ")", ">", "1", ":", "self", ".", "info_dict", ".", "pop", "(", "\".\"", ",", "None", "...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord._format_field
Returns string representation of format field.
jacquard/utils/vcf.py
def _format_field(self): """Returns string representation of format field.""" format_field = "." if self.sample_tag_values: first_sample = list(self.sample_tag_values.keys())[0] tag_names = self.sample_tag_values[first_sample].keys() if tag_names: ...
def _format_field(self): """Returns string representation of format field.""" format_field = "." if self.sample_tag_values: first_sample = list(self.sample_tag_values.keys())[0] tag_names = self.sample_tag_values[first_sample].keys() if tag_names: ...
[ "Returns", "string", "representation", "of", "format", "field", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L335-L343
[ "def", "_format_field", "(", "self", ")", ":", "format_field", "=", "\".\"", "if", "self", ".", "sample_tag_values", ":", "first_sample", "=", "list", "(", "self", ".", "sample_tag_values", ".", "keys", "(", ")", ")", "[", "0", "]", "tag_names", "=", "se...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord._sample_field
Returns string representation of sample-format values. Raises: KeyError: if requested sample is not defined.
jacquard/utils/vcf.py
def _sample_field(self, sample): """Returns string representation of sample-format values. Raises: KeyError: if requested sample is not defined. """ tag_values = self.sample_tag_values[sample].values() if tag_values: return ":".join(tag_values) el...
def _sample_field(self, sample): """Returns string representation of sample-format values. Raises: KeyError: if requested sample is not defined. """ tag_values = self.sample_tag_values[sample].values() if tag_values: return ":".join(tag_values) el...
[ "Returns", "string", "representation", "of", "sample", "-", "format", "values", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L345-L355
[ "def", "_sample_field", "(", "self", ",", "sample", ")", ":", "tag_values", "=", "self", ".", "sample_tag_values", "[", "sample", "]", ".", "values", "(", ")", "if", "tag_values", ":", "return", "\":\"", ".", "join", "(", "tag_values", ")", "else", ":", ...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1