repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig
def is_multisig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a multisig bundle? """ if blockchain == 'bitcoin': return btc_is_multisig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a multisig bundle? """ if blockchain == 'bitcoin': return btc_is_multisig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig", "(", "privkey_info", ",", "*", "*", "blockchain_opts", ")", "el...
Is the given private key bundle a multisig bundle?
[ "Is", "the", "given", "private", "key", "bundle", "a", "multisig", "bundle?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L28-L35
train
64,000
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig_address
def is_multisig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a multisig address? """ if blockchain == 'bitcoin': return btc_is_multisig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a multisig address? """ if blockchain == 'bitcoin': return btc_is_multisig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig_address", "(", "addr", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig_address", "(", "addr", ",", "*", "*", "blockchain_opts", ")", "el...
Is the given address a multisig address?
[ "Is", "the", "given", "address", "a", "multisig", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L38-L45
train
64,001
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_multisig_script
def is_multisig_script(script, blockchain='bitcoin', **blockchain_opts): """ Is the given script a multisig script? """ if blockchain == 'bitcoin': return btc_is_multisig_script(script, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_multisig_script(script, blockchain='bitcoin', **blockchain_opts): """ Is the given script a multisig script? """ if blockchain == 'bitcoin': return btc_is_multisig_script(script, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_multisig_script", "(", "script", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_multisig_script", "(", "script", ",", "*", "*", "blockchain_opts", ")", "...
Is the given script a multisig script?
[ "Is", "the", "given", "script", "a", "multisig", "script?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L48-L55
train
64,002
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_singlesig
def is_singlesig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a single-sig key bundle? """ if blockchain == 'bitcoin': return btc_is_singlesig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(block...
python
def is_singlesig(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Is the given private key bundle a single-sig key bundle? """ if blockchain == 'bitcoin': return btc_is_singlesig(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(block...
[ "def", "is_singlesig", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_singlesig", "(", "privkey_info", ",", "*", "*", "blockchain_opts", ")", "...
Is the given private key bundle a single-sig key bundle?
[ "Is", "the", "given", "private", "key", "bundle", "a", "single", "-", "sig", "key", "bundle?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L58-L65
train
64,003
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
is_singlesig_address
def is_singlesig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a single-sig address? """ if blockchain == 'bitcoin': return btc_is_singlesig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
python
def is_singlesig_address(addr, blockchain='bitcoin', **blockchain_opts): """ Is the given address a single-sig address? """ if blockchain == 'bitcoin': return btc_is_singlesig_address(addr, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockchain))
[ "def", "is_singlesig_address", "(", "addr", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_is_singlesig_address", "(", "addr", ",", "*", "*", "blockchain_opts", ")", "...
Is the given address a single-sig address?
[ "Is", "the", "given", "address", "a", "single", "-", "sig", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L78-L85
train
64,004
blockstack/virtualchain
virtualchain/lib/blockchain/keys.py
get_privkey_address
def get_privkey_address(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Get the address from a private key bundle """ if blockchain == 'bitcoin': return btc_get_privkey_address(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockc...
python
def get_privkey_address(privkey_info, blockchain='bitcoin', **blockchain_opts): """ Get the address from a private key bundle """ if blockchain == 'bitcoin': return btc_get_privkey_address(privkey_info, **blockchain_opts) else: raise ValueError('Unknown blockchain "{}"'.format(blockc...
[ "def", "get_privkey_address", "(", "privkey_info", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_get_privkey_address", "(", "privkey_info", ",", "*", "*", "blockchain_opt...
Get the address from a private key bundle
[ "Get", "the", "address", "from", "a", "private", "key", "bundle" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/keys.py#L88-L95
train
64,005
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/zmat_functions.py
apply_grad_cartesian_tensor
def apply_grad_cartesian_tensor(grad_X, zmat_dist): """Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesi...
python
def apply_grad_cartesian_tensor(grad_X, zmat_dist): """Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesi...
[ "def", "apply_grad_cartesian_tensor", "(", "grad_X", ",", "zmat_dist", ")", ":", "columns", "=", "[", "'bond'", ",", "'angle'", ",", "'dihedral'", "]", "C_dist", "=", "zmat_dist", ".", "loc", "[", ":", ",", "columns", "]", ".", "values", ".", "T", "try",...
Apply the gradient for transformation to cartesian space onto zmat_dist. Args: grad_X (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array. The mathematical details of the index layout is explained in :meth:`~chemcoord.Cartesian.get_grad_zmat()`. zmat_dist (:class:`~chemcoord....
[ "Apply", "the", "gradient", "for", "transformation", "to", "cartesian", "space", "onto", "zmat_dist", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/zmat_functions.py#L75-L98
train
64,006
anjianshi/flask-restful-extend
flask_restful_extend/model_converter.py
register_model_converter
def register_model_converter(model, app): """Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def ...
python
def register_model_converter(model, app): """Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def ...
[ "def", "register_model_converter", "(", "model", ",", "app", ")", ":", "if", "hasattr", "(", "model", ",", "'id'", ")", ":", "class", "Converter", "(", "_ModelConverter", ")", ":", "_model", "=", "model", "app", ".", "url_map", ".", "converters", "[", "m...
Add url converter for model Example: class Student(db.model): id = Column(Integer, primary_key=True) name = Column(String(50)) register_model_converter(Student) @route('/classmates/<Student:classmate>') def get_classmate_info(classmate): pass ...
[ "Add", "url", "converter", "for", "model" ]
cc168729bf341d4f9c0f6938be30463acbf770f1
https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/model_converter.py#L6-L26
train
64,007
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.iupacify
def iupacify(self): """Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dih...
python
def iupacify(self): """Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dih...
[ "def", "iupacify", "(", "self", ")", ":", "def", "convert_d", "(", "d", ")", ":", "r", "=", "d", "%", "360", "return", "r", "-", "(", "r", "//", "180", ")", "*", "360", "new", "=", "self", ".", "copy", "(", ")", "new", ".", "unsafe_loc", "[",...
Give the IUPAC conform representation. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\\sim` and use :math:`\\alpha` for an angle and :math:`\\delta` for a dihedral angle. Then the f...
[ "Give", "the", "IUPAC", "conform", "representation", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L280-L321
train
64,008
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.minimize_dihedrals
def minimize_dihedrals(self): r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for...
python
def minimize_dihedrals(self): r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for...
[ "def", "minimize_dihedrals", "(", "self", ")", ":", "new", "=", "self", ".", "copy", "(", ")", "def", "convert_d", "(", "d", ")", ":", "r", "=", "d", "%", "360", "return", "r", "-", "(", "r", "//", "180", ")", "*", "360", "new", ".", "unsafe_lo...
r"""Give a representation of the dihedral with minimized absolute value. Mathematically speaking the angles in a zmatrix are representations of an equivalence class. We will denote an equivalence relation with :math:`\sim` and use :math:`\alpha` for an angle and :math:`\delta` for a dih...
[ "r", "Give", "a", "representation", "of", "the", "dihedral", "with", "minimized", "absolute", "value", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L323-L372
train
64,009
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.change_numbering
def change_numbering(self, new_index=None): """Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: ...
python
def change_numbering(self, new_index=None): """Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: ...
[ "def", "change_numbering", "(", "self", ",", "new_index", "=", "None", ")", ":", "if", "(", "new_index", "is", "None", ")", ":", "new_index", "=", "range", "(", "len", "(", "self", ")", ")", "elif", "len", "(", "new_index", ")", "!=", "len", "(", "...
Change numbering to a new index. Changes the numbering of index and all dependent numbering (bond_with...) to a new_index. The user has to make sure that the new_index consists of distinct elements. Args: new_index (list): If None the new_index is taken from...
[ "Change", "numbering", "to", "a", "new", "index", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L445-L491
train
64,010
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore._insert_dummy_cart
def _insert_dummy_cart(self, exception, last_valid_cartesian=None): """Insert dummy atom into the already built cartesian of exception """ def get_normal_vec(cartesian, reference_labels): b_pos, a_pos, d_pos = cartesian._get_positions(reference_labels) BA = a_pos - b_pos ...
python
def _insert_dummy_cart(self, exception, last_valid_cartesian=None): """Insert dummy atom into the already built cartesian of exception """ def get_normal_vec(cartesian, reference_labels): b_pos, a_pos, d_pos = cartesian._get_positions(reference_labels) BA = a_pos - b_pos ...
[ "def", "_insert_dummy_cart", "(", "self", ",", "exception", ",", "last_valid_cartesian", "=", "None", ")", ":", "def", "get_normal_vec", "(", "cartesian", ",", "reference_labels", ")", ":", "b_pos", ",", "a_pos", ",", "d_pos", "=", "cartesian", ".", "_get_posi...
Insert dummy atom into the already built cartesian of exception
[ "Insert", "dummy", "atom", "into", "the", "already", "built", "cartesian", "of", "exception" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L493-L519
train
64,011
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.get_cartesian
def get_cartesian(self): """Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix. ...
python
def get_cartesian(self): """Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix. ...
[ "def", "get_cartesian", "(", "self", ")", ":", "def", "create_cartesian", "(", "positions", ",", "row", ")", ":", "xyz_frame", "=", "pd", ".", "DataFrame", "(", "columns", "=", "[", "'atom'", ",", "'x'", ",", "'y'", ",", "'z'", "]", ",", "index", "="...
Return the molecule in cartesian coordinates. Raises an :class:`~exceptions.InvalidReference` exception, if the reference of the i-th atom is undefined. Args: None Returns: Cartesian: Reindexed version of the zmatrix.
[ "Return", "the", "molecule", "in", "cartesian", "coordinates", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L620-L661
train
64,012
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_core.py
ZmatCore.get_grad_cartesian
def get_grad_cartesian(self, as_function=True, chain=True, drop_auto_dummies=True): r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which c...
python
def get_grad_cartesian(self, as_function=True, chain=True, drop_auto_dummies=True): r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which c...
[ "def", "get_grad_cartesian", "(", "self", ",", "as_function", "=", "True", ",", "chain", "=", "True", ",", "drop_auto_dummies", "=", "True", ")", ":", "zmat", "=", "self", ".", "change_numbering", "(", ")", "c_table", "=", "zmat", ".", "loc", "[", ":", ...
r"""Return the gradient for the transformation to a Cartesian. If ``as_function`` is True, a function is returned that can be directly applied onto instances of :class:`~Zmat`, which contain the applied distortions in Zmatrix space. In this case the user does not have to worry about ind...
[ "r", "Return", "the", "gradient", "for", "the", "transformation", "to", "a", "Cartesian", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_core.py#L663-L778
train
64,013
blockstack/virtualchain
virtualchain/lib/blockchain/transactions.py
tx_extend
def tx_extend(partial_tx_hex, new_inputs, new_outputs, blockchain='bitcoin', **blockchain_opts): """ Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error """ if blockchain == 'bitcoin': return btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockc...
python
def tx_extend(partial_tx_hex, new_inputs, new_outputs, blockchain='bitcoin', **blockchain_opts): """ Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error """ if blockchain == 'bitcoin': return btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockc...
[ "def", "tx_extend", "(", "partial_tx_hex", ",", "new_inputs", ",", "new_outputs", ",", "blockchain", "=", "'bitcoin'", ",", "*", "*", "blockchain_opts", ")", ":", "if", "blockchain", "==", "'bitcoin'", ":", "return", "btc_tx_extend", "(", "partial_tx_hex", ",", ...
Add a set of inputs and outputs to a tx. Return the new tx on success Raise on error
[ "Add", "a", "set", "of", "inputs", "and", "outputs", "to", "a", "tx", ".", "Return", "the", "new", "tx", "on", "success", "Raise", "on", "error" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/transactions.py#L110-L119
train
64,014
mdickinson/bigfloat
bigfloat/context.py
setcontext
def setcontext(context, _local=local): """ Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through. """ oldcontext = getcont...
python
def setcontext(context, _local=local): """ Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through. """ oldcontext = getcont...
[ "def", "setcontext", "(", "context", ",", "_local", "=", "local", ")", ":", "oldcontext", "=", "getcontext", "(", ")", "_local", ".", "__bigfloat_context__", "=", "oldcontext", "+", "context" ]
Set the current context to that given. Attributes provided by ``context`` override those in the current context. If ``context`` doesn't specify a particular attribute, the attribute from the current context shows through.
[ "Set", "the", "current", "context", "to", "that", "given", "." ]
e5fdd1048615191ed32a2b7460e14b3b3ff24662
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/context.py#L217-L227
train
64,015
mdickinson/bigfloat
bigfloat/context.py
_apply_function_in_context
def _apply_function_in_context(cls, f, args, context): """ Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context. """ rounding = context.rounding bf = mpfr.Mpfr_t.__new__(cls) mpfr.mp...
python
def _apply_function_in_context(cls, f, args, context): """ Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context. """ rounding = context.rounding bf = mpfr.Mpfr_t.__new__(cls) mpfr.mp...
[ "def", "_apply_function_in_context", "(", "cls", ",", "f", ",", "args", ",", "context", ")", ":", "rounding", "=", "context", ".", "rounding", "bf", "=", "mpfr", ".", "Mpfr_t", ".", "__new__", "(", "cls", ")", "mpfr", ".", "mpfr_init2", "(", "bf", ",",...
Apply an MPFR function 'f' to the given arguments 'args', rounding to the given context. Returns a new Mpfr object with precision taken from the current context.
[ "Apply", "an", "MPFR", "function", "f", "to", "the", "given", "arguments", "args", "rounding", "to", "the", "given", "context", ".", "Returns", "a", "new", "Mpfr", "object", "with", "precision", "taken", "from", "the", "current", "context", "." ]
e5fdd1048615191ed32a2b7460e14b3b3ff24662
https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/context.py#L296-L327
train
64,016
blockstack/virtualchain
virtualchain/lib/config.py
get_logger
def get_logger(name=None): """ Get virtualchain's logger """ level = logging.CRITICAL if DEBUG: logging.disable(logging.NOTSET) level = logging.DEBUG if name is None: name = "<unknown>" log = logging.getLogger(name=name) log.setLevel( level ) console = logg...
python
def get_logger(name=None): """ Get virtualchain's logger """ level = logging.CRITICAL if DEBUG: logging.disable(logging.NOTSET) level = logging.DEBUG if name is None: name = "<unknown>" log = logging.getLogger(name=name) log.setLevel( level ) console = logg...
[ "def", "get_logger", "(", "name", "=", "None", ")", ":", "level", "=", "logging", ".", "CRITICAL", "if", "DEBUG", ":", "logging", ".", "disable", "(", "logging", ".", "NOTSET", ")", "level", "=", "logging", ".", "DEBUG", "if", "name", "is", "None", "...
Get virtualchain's logger
[ "Get", "virtualchain", "s", "logger" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L64-L91
train
64,017
blockstack/virtualchain
virtualchain/lib/config.py
get_config_filename
def get_config_filename(impl, working_dir): """ Get the absolute path to the config file. """ config_filename = impl.get_virtual_chain_name() + ".ini" return os.path.join(working_dir, config_filename)
python
def get_config_filename(impl, working_dir): """ Get the absolute path to the config file. """ config_filename = impl.get_virtual_chain_name() + ".ini" return os.path.join(working_dir, config_filename)
[ "def", "get_config_filename", "(", "impl", ",", "working_dir", ")", ":", "config_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".ini\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "config_filename", ")" ]
Get the absolute path to the config file.
[ "Get", "the", "absolute", "path", "to", "the", "config", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L107-L112
train
64,018
blockstack/virtualchain
virtualchain/lib/config.py
get_db_filename
def get_db_filename(impl, working_dir): """ Get the absolute path to the last-block file. """ db_filename = impl.get_virtual_chain_name() + ".db" return os.path.join(working_dir, db_filename)
python
def get_db_filename(impl, working_dir): """ Get the absolute path to the last-block file. """ db_filename = impl.get_virtual_chain_name() + ".db" return os.path.join(working_dir, db_filename)
[ "def", "get_db_filename", "(", "impl", ",", "working_dir", ")", ":", "db_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".db\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "db_filename", ")" ]
Get the absolute path to the last-block file.
[ "Get", "the", "absolute", "path", "to", "the", "last", "-", "block", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L115-L120
train
64,019
blockstack/virtualchain
virtualchain/lib/config.py
get_snapshots_filename
def get_snapshots_filename(impl, working_dir): """ Get the absolute path to the chain's consensus snapshots file. """ snapshots_filename = impl.get_virtual_chain_name() + ".snapshots" return os.path.join(working_dir, snapshots_filename)
python
def get_snapshots_filename(impl, working_dir): """ Get the absolute path to the chain's consensus snapshots file. """ snapshots_filename = impl.get_virtual_chain_name() + ".snapshots" return os.path.join(working_dir, snapshots_filename)
[ "def", "get_snapshots_filename", "(", "impl", ",", "working_dir", ")", ":", "snapshots_filename", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".snapshots\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "snapshots_filename", ...
Get the absolute path to the chain's consensus snapshots file.
[ "Get", "the", "absolute", "path", "to", "the", "chain", "s", "consensus", "snapshots", "file", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L123-L128
train
64,020
blockstack/virtualchain
virtualchain/lib/config.py
get_lockfile_filename
def get_lockfile_filename(impl, working_dir): """ Get the absolute path to the chain's indexing lockfile """ lockfile_name = impl.get_virtual_chain_name() + ".lock" return os.path.join(working_dir, lockfile_name)
python
def get_lockfile_filename(impl, working_dir): """ Get the absolute path to the chain's indexing lockfile """ lockfile_name = impl.get_virtual_chain_name() + ".lock" return os.path.join(working_dir, lockfile_name)
[ "def", "get_lockfile_filename", "(", "impl", ",", "working_dir", ")", ":", "lockfile_name", "=", "impl", ".", "get_virtual_chain_name", "(", ")", "+", "\".lock\"", "return", "os", ".", "path", ".", "join", "(", "working_dir", ",", "lockfile_name", ")" ]
Get the absolute path to the chain's indexing lockfile
[ "Get", "the", "absolute", "path", "to", "the", "chain", "s", "indexing", "lockfile" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L139-L144
train
64,021
blockstack/virtualchain
virtualchain/lib/config.py
get_bitcoind_config
def get_bitcoind_config(config_file=None, impl=None): """ Set bitcoind options globally. Call this before trying to talk to bitcoind. """ loaded = False bitcoind_server = None bitcoind_port = None bitcoind_user = None bitcoind_passwd = None bitcoind_timeout = None bitcoind_...
python
def get_bitcoind_config(config_file=None, impl=None): """ Set bitcoind options globally. Call this before trying to talk to bitcoind. """ loaded = False bitcoind_server = None bitcoind_port = None bitcoind_user = None bitcoind_passwd = None bitcoind_timeout = None bitcoind_...
[ "def", "get_bitcoind_config", "(", "config_file", "=", "None", ",", "impl", "=", "None", ")", ":", "loaded", "=", "False", "bitcoind_server", "=", "None", "bitcoind_port", "=", "None", "bitcoind_user", "=", "None", "bitcoind_passwd", "=", "None", "bitcoind_timeo...
Set bitcoind options globally. Call this before trying to talk to bitcoind.
[ "Set", "bitcoind", "options", "globally", ".", "Call", "this", "before", "trying", "to", "talk", "to", "bitcoind", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/config.py#L147-L228
train
64,022
emory-libraries/eulxml
eulxml/xmlmap/mods.py
OriginInfo.is_empty
def is_empty(self): """Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.""" return all(date.is_empty() for date in [self.created, self.issued]) \ and not se...
python
def is_empty(self): """Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.""" return all(date.is_empty() for date in [self.created, self.issued]) \ and not se...
[ "def", "is_empty", "(", "self", ")", ":", "return", "all", "(", "date", ".", "is_empty", "(", ")", "for", "date", "in", "[", "self", ".", "created", ",", "self", ".", "issued", "]", ")", "and", "not", "self", ".", "publisher" ]
Returns True if all child date elements present are empty and other nodes are not set. Returns False if any child date elements are not empty or other nodes are set.
[ "Returns", "True", "if", "all", "child", "date", "elements", "present", "are", "empty", "and", "other", "nodes", "are", "not", "set", ".", "Returns", "False", "if", "any", "child", "date", "elements", "are", "not", "empty", "or", "other", "nodes", "are", ...
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L116-L121
train
64,023
emory-libraries/eulxml
eulxml/xmlmap/mods.py
TitleInfo.is_empty
def is_empty(self): '''Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.''' return not bool(self.title or self.subtitle or self.part_number \ or self.part_name or self.non_sort or self.type)
python
def is_empty(self): '''Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.''' return not bool(self.title or self.subtitle or self.part_number \ or self.part_name or self.non_sort or self.type)
[ "def", "is_empty", "(", "self", ")", ":", "return", "not", "bool", "(", "self", ".", "title", "or", "self", ".", "subtitle", "or", "self", ".", "part_number", "or", "self", ".", "part_name", "or", "self", ".", "non_sort", "or", "self", ".", "type", "...
Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.
[ "Returns", "True", "if", "all", "titleInfo", "subfields", "are", "not", "set", "or", "empty", ";", "returns", "False", "if", "any", "of", "the", "fields", "are", "not", "empty", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L242-L246
train
64,024
emory-libraries/eulxml
eulxml/xmlmap/mods.py
Part.is_empty
def is_empty(self): '''Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.''' return all(field.is_empty() for field in [self.details, self.extent] if field is not None) \ ...
python
def is_empty(self): '''Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.''' return all(field.is_empty() for field in [self.details, self.extent] if field is not None) \ ...
[ "def", "is_empty", "(", "self", ")", ":", "return", "all", "(", "field", ".", "is_empty", "(", ")", "for", "field", "in", "[", "self", ".", "details", ",", "self", ".", "extent", "]", "if", "field", "is", "not", "None", ")", "and", "not", "self", ...
Returns True if details, extent, and type are not set or return True for ``is_empty``; returns False if any of the fields are not empty.
[ "Returns", "True", "if", "details", "extent", "and", "type", "are", "not", "set", "or", "return", "True", "for", "is_empty", ";", "returns", "False", "if", "any", "of", "the", "fields", "are", "not", "empty", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L294-L300
train
64,025
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py
AuthServiceProxy.getinfo
def getinfo(self): """ Backwards-compatibility for 0.14 and later """ try: old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True) res = old_getinfo() if 'error' not in res: # 0.13 and earlier ...
python
def getinfo(self): """ Backwards-compatibility for 0.14 and later """ try: old_getinfo = AuthServiceProxy(self.__service_url, 'getinfo', self.__timeout, self.__conn, True) res = old_getinfo() if 'error' not in res: # 0.13 and earlier ...
[ "def", "getinfo", "(", "self", ")", ":", "try", ":", "old_getinfo", "=", "AuthServiceProxy", "(", "self", ".", "__service_url", ",", "'getinfo'", ",", "self", ".", "__timeout", ",", "self", ".", "__conn", ",", "True", ")", "res", "=", "old_getinfo", "(",...
Backwards-compatibility for 0.14 and later
[ "Backwards", "-", "compatibility", "for", "0", ".", "14", "and", "later" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/authproxy.py#L203-L251
train
64,026
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_payment_script
def btc_make_payment_script( address, segwit=None, **ignored ): """ Make a pay-to-address script. """ if segwit is None: segwit = get_features('segwit') # is address bech32-encoded? witver, withash = segwit_addr_decode(address) if witver is not None and withash is not None: ...
python
def btc_make_payment_script( address, segwit=None, **ignored ): """ Make a pay-to-address script. """ if segwit is None: segwit = get_features('segwit') # is address bech32-encoded? witver, withash = segwit_addr_decode(address) if witver is not None and withash is not None: ...
[ "def", "btc_make_payment_script", "(", "address", ",", "segwit", "=", "None", ",", "*", "*", "ignored", ")", ":", "if", "segwit", "is", "None", ":", "segwit", "=", "get_features", "(", "'segwit'", ")", "# is address bech32-encoded?", "witver", ",", "withash", ...
Make a pay-to-address script.
[ "Make", "a", "pay", "-", "to", "-", "address", "script", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L281-L327
train
64,027
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_data_script
def btc_make_data_script( data, **ignored ): """ Make a data-bearing transaction output. Data must be a hex string Returns a hex string. """ if len(data) >= MAX_DATA_LEN * 2: raise ValueError("Data hex string is too long") # note: data is a hex string if len(data) % 2 != 0: ...
python
def btc_make_data_script( data, **ignored ): """ Make a data-bearing transaction output. Data must be a hex string Returns a hex string. """ if len(data) >= MAX_DATA_LEN * 2: raise ValueError("Data hex string is too long") # note: data is a hex string if len(data) % 2 != 0: ...
[ "def", "btc_make_data_script", "(", "data", ",", "*", "*", "ignored", ")", ":", "if", "len", "(", "data", ")", ">=", "MAX_DATA_LEN", "*", "2", ":", "raise", "ValueError", "(", "\"Data hex string is too long\"", ")", "# note: data is a hex string", "if", "len", ...
Make a data-bearing transaction output. Data must be a hex string Returns a hex string.
[ "Make", "a", "data", "-", "bearing", "transaction", "output", ".", "Data", "must", "be", "a", "hex", "string", "Returns", "a", "hex", "string", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L330-L342
train
64,028
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_address
def btc_make_p2sh_address( script_hex ): """ Make a P2SH address from a hex script """ h = hashing.bin_hash160(binascii.unhexlify(script_hex)) addr = bin_hash160_to_address(h, version_byte=multisig_version_byte) return addr
python
def btc_make_p2sh_address( script_hex ): """ Make a P2SH address from a hex script """ h = hashing.bin_hash160(binascii.unhexlify(script_hex)) addr = bin_hash160_to_address(h, version_byte=multisig_version_byte) return addr
[ "def", "btc_make_p2sh_address", "(", "script_hex", ")", ":", "h", "=", "hashing", ".", "bin_hash160", "(", "binascii", ".", "unhexlify", "(", "script_hex", ")", ")", "addr", "=", "bin_hash160_to_address", "(", "h", ",", "version_byte", "=", "multisig_version_byt...
Make a P2SH address from a hex script
[ "Make", "a", "P2SH", "address", "from", "a", "hex", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L375-L381
train
64,029
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2wpkh_address
def btc_make_p2wpkh_address( pubkey_hex ): """ Make a p2wpkh address from a hex pubkey """ pubkey_hex = keylib.key_formatting.compress(pubkey_hex) hash160_bin = hashing.bin_hash160(pubkey_hex.decode('hex')) return segwit_addr_encode(hash160_bin)
python
def btc_make_p2wpkh_address( pubkey_hex ): """ Make a p2wpkh address from a hex pubkey """ pubkey_hex = keylib.key_formatting.compress(pubkey_hex) hash160_bin = hashing.bin_hash160(pubkey_hex.decode('hex')) return segwit_addr_encode(hash160_bin)
[ "def", "btc_make_p2wpkh_address", "(", "pubkey_hex", ")", ":", "pubkey_hex", "=", "keylib", ".", "key_formatting", ".", "compress", "(", "pubkey_hex", ")", "hash160_bin", "=", "hashing", ".", "bin_hash160", "(", "pubkey_hex", ".", "decode", "(", "'hex'", ")", ...
Make a p2wpkh address from a hex pubkey
[ "Make", "a", "p2wpkh", "address", "from", "a", "hex", "pubkey" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L384-L390
train
64,030
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_p2wpkh_redeem_script
def btc_make_p2sh_p2wpkh_redeem_script( pubkey_hex ): """ Make the redeem script for a p2sh-p2wpkh witness script """ pubkey_hash = hashing.bin_hash160(pubkey_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0014' + pubkey_hash]) return redeem_script
python
def btc_make_p2sh_p2wpkh_redeem_script( pubkey_hex ): """ Make the redeem script for a p2sh-p2wpkh witness script """ pubkey_hash = hashing.bin_hash160(pubkey_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0014' + pubkey_hash]) return redeem_script
[ "def", "btc_make_p2sh_p2wpkh_redeem_script", "(", "pubkey_hex", ")", ":", "pubkey_hash", "=", "hashing", ".", "bin_hash160", "(", "pubkey_hex", ".", "decode", "(", "'hex'", ")", ")", ".", "encode", "(", "'hex'", ")", "redeem_script", "=", "btc_script_serialize", ...
Make the redeem script for a p2sh-p2wpkh witness script
[ "Make", "the", "redeem", "script", "for", "a", "p2sh", "-", "p2wpkh", "witness", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L393-L399
train
64,031
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_make_p2sh_p2wsh_redeem_script
def btc_make_p2sh_p2wsh_redeem_script( witness_script_hex ): """ Make the redeem script for a p2sh-p2wsh witness script """ witness_script_hash = hashing.bin_sha256(witness_script_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0020' + witness_script_hash]) return redeem_...
python
def btc_make_p2sh_p2wsh_redeem_script( witness_script_hex ): """ Make the redeem script for a p2sh-p2wsh witness script """ witness_script_hash = hashing.bin_sha256(witness_script_hex.decode('hex')).encode('hex') redeem_script = btc_script_serialize(['0020' + witness_script_hash]) return redeem_...
[ "def", "btc_make_p2sh_p2wsh_redeem_script", "(", "witness_script_hex", ")", ":", "witness_script_hash", "=", "hashing", ".", "bin_sha256", "(", "witness_script_hex", ".", "decode", "(", "'hex'", ")", ")", ".", "encode", "(", "'hex'", ")", "redeem_script", "=", "bt...
Make the redeem script for a p2sh-p2wsh witness script
[ "Make", "the", "redeem", "script", "for", "a", "p2sh", "-", "p2wsh", "witness", "script" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L419-L425
train
64,032
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2sh_address
def btc_is_p2sh_address( address ): """ Is the given address a p2sh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == multisig_version_byte: return True else: return False
python
def btc_is_p2sh_address( address ): """ Is the given address a p2sh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == multisig_version_byte: return True else: return False
[ "def", "btc_is_p2sh_address", "(", "address", ")", ":", "vb", "=", "keylib", ".", "b58check", ".", "b58check_version_byte", "(", "address", ")", "if", "vb", "==", "multisig_version_byte", ":", "return", "True", "else", ":", "return", "False" ]
Is the given address a p2sh address?
[ "Is", "the", "given", "address", "a", "p2sh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L437-L445
train
64,033
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2pkh_address
def btc_is_p2pkh_address( address ): """ Is the given address a p2pkh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == version_byte: return True else: return False
python
def btc_is_p2pkh_address( address ): """ Is the given address a p2pkh address? """ vb = keylib.b58check.b58check_version_byte( address ) if vb == version_byte: return True else: return False
[ "def", "btc_is_p2pkh_address", "(", "address", ")", ":", "vb", "=", "keylib", ".", "b58check", ".", "b58check_version_byte", "(", "address", ")", "if", "vb", "==", "version_byte", ":", "return", "True", "else", ":", "return", "False" ]
Is the given address a p2pkh address?
[ "Is", "the", "given", "address", "a", "p2pkh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L448-L456
train
64,034
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2wpkh_address
def btc_is_p2wpkh_address( address ): """ Is the given address a p2wpkh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 20: return False return True
python
def btc_is_p2wpkh_address( address ): """ Is the given address a p2wpkh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 20: return False return True
[ "def", "btc_is_p2wpkh_address", "(", "address", ")", ":", "wver", ",", "whash", "=", "segwit_addr_decode", "(", "address", ")", "if", "whash", "is", "None", ":", "return", "False", "if", "len", "(", "whash", ")", "!=", "20", ":", "return", "False", "retu...
Is the given address a p2wpkh address?
[ "Is", "the", "given", "address", "a", "p2wpkh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L459-L470
train
64,035
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2wsh_address
def btc_is_p2wsh_address( address ): """ Is the given address a p2wsh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 32: return False return True
python
def btc_is_p2wsh_address( address ): """ Is the given address a p2wsh address? """ wver, whash = segwit_addr_decode(address) if whash is None: return False if len(whash) != 32: return False return True
[ "def", "btc_is_p2wsh_address", "(", "address", ")", ":", "wver", ",", "whash", "=", "segwit_addr_decode", "(", "address", ")", "if", "whash", "is", "None", ":", "return", "False", "if", "len", "(", "whash", ")", "!=", "32", ":", "return", "False", "retur...
Is the given address a p2wsh address?
[ "Is", "the", "given", "address", "a", "p2wsh", "address?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L473-L484
train
64,036
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_p2sh_script
def btc_is_p2sh_script( script_hex ): """ Is the given scriptpubkey a p2sh script? """ if script_hex.startswith("a914") and script_hex.endswith("87") and len(script_hex) == 46: return True else: return False
python
def btc_is_p2sh_script( script_hex ): """ Is the given scriptpubkey a p2sh script? """ if script_hex.startswith("a914") and script_hex.endswith("87") and len(script_hex) == 46: return True else: return False
[ "def", "btc_is_p2sh_script", "(", "script_hex", ")", ":", "if", "script_hex", ".", "startswith", "(", "\"a914\"", ")", "and", "script_hex", ".", "endswith", "(", "\"87\"", ")", "and", "len", "(", "script_hex", ")", "==", "46", ":", "return", "True", "else"...
Is the given scriptpubkey a p2sh script?
[ "Is", "the", "given", "scriptpubkey", "a", "p2sh", "script?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L494-L501
train
64,037
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_address_reencode
def btc_address_reencode( address, **blockchain_opts ): """ Depending on whether or not we're in testnet or mainnet, re-encode an address accordingly. """ # re-encode bitcoin address network = blockchain_opts.get('network', None) opt_version_byte = blockchain_opts.get('version_byte', None) ...
python
def btc_address_reencode( address, **blockchain_opts ): """ Depending on whether or not we're in testnet or mainnet, re-encode an address accordingly. """ # re-encode bitcoin address network = blockchain_opts.get('network', None) opt_version_byte = blockchain_opts.get('version_byte', None) ...
[ "def", "btc_address_reencode", "(", "address", ",", "*", "*", "blockchain_opts", ")", ":", "# re-encode bitcoin address", "network", "=", "blockchain_opts", ".", "get", "(", "'network'", ",", "None", ")", "opt_version_byte", "=", "blockchain_opts", ".", "get", "("...
Depending on whether or not we're in testnet or mainnet, re-encode an address accordingly.
[ "Depending", "on", "whether", "or", "not", "we", "re", "in", "testnet", "or", "mainnet", "re", "-", "encode", "an", "address", "accordingly", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L514-L594
train
64,038
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/keys.py
btc_is_singlesig_segwit
def btc_is_singlesig_segwit(privkey_info): """ Is the given key bundle a p2sh-p2wpkh key bundle? """ try: jsonschema.validate(privkey_info, PRIVKEY_MULTISIG_SCHEMA) if len(privkey_info['private_keys']) > 1: return False return privkey_info.get('segwit', False) ex...
python
def btc_is_singlesig_segwit(privkey_info): """ Is the given key bundle a p2sh-p2wpkh key bundle? """ try: jsonschema.validate(privkey_info, PRIVKEY_MULTISIG_SCHEMA) if len(privkey_info['private_keys']) > 1: return False return privkey_info.get('segwit', False) ex...
[ "def", "btc_is_singlesig_segwit", "(", "privkey_info", ")", ":", "try", ":", "jsonschema", ".", "validate", "(", "privkey_info", ",", "PRIVKEY_MULTISIG_SCHEMA", ")", "if", "len", "(", "privkey_info", "[", "'private_keys'", "]", ")", ">", "1", ":", "return", "F...
Is the given key bundle a p2sh-p2wpkh key bundle?
[ "Is", "the", "given", "key", "bundle", "a", "p2sh", "-", "p2wpkh", "key", "bundle?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/keys.py#L676-L687
train
64,039
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bech32.py
segwit_addr_encode
def segwit_addr_encode(witprog_bin, hrp=bech32_prefix, witver=bech32_witver): """ Encode a segwit script hash to a bech32 address. Returns the bech32-encoded string on success """ witprog_bytes = [ord(c) for c in witprog_bin] ret = bech32_encode(hrp, [int(witver)] + convertbits(witprog_bytes, 8,...
python
def segwit_addr_encode(witprog_bin, hrp=bech32_prefix, witver=bech32_witver): """ Encode a segwit script hash to a bech32 address. Returns the bech32-encoded string on success """ witprog_bytes = [ord(c) for c in witprog_bin] ret = bech32_encode(hrp, [int(witver)] + convertbits(witprog_bytes, 8,...
[ "def", "segwit_addr_encode", "(", "witprog_bin", ",", "hrp", "=", "bech32_prefix", ",", "witver", "=", "bech32_witver", ")", ":", "witprog_bytes", "=", "[", "ord", "(", "c", ")", "for", "c", "in", "witprog_bin", "]", "ret", "=", "bech32_encode", "(", "hrp"...
Encode a segwit script hash to a bech32 address. Returns the bech32-encoded string on success
[ "Encode", "a", "segwit", "script", "hash", "to", "a", "bech32", "address", ".", "Returns", "the", "bech32", "-", "encoded", "string", "on", "success" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bech32.py#L139-L147
train
64,040
mcocdawc/chemcoord
version.py
format_git_describe
def format_git_describe(git_str, pep440=False): """format the result of calling 'git describe' as a python version""" if git_str is None: return None if "-" not in git_str: # currently at a tag return git_str else: # formatted as version-N-githash # want to convert to ve...
python
def format_git_describe(git_str, pep440=False): """format the result of calling 'git describe' as a python version""" if git_str is None: return None if "-" not in git_str: # currently at a tag return git_str else: # formatted as version-N-githash # want to convert to ve...
[ "def", "format_git_describe", "(", "git_str", ",", "pep440", "=", "False", ")", ":", "if", "git_str", "is", "None", ":", "return", "None", "if", "\"-\"", "not", "in", "git_str", ":", "# currently at a tag", "return", "git_str", "else", ":", "# formatted as ver...
format the result of calling 'git describe' as a python version
[ "format", "the", "result", "of", "calling", "git", "describe", "as", "a", "python", "version" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/version.py#L100-L113
train
64,041
mcocdawc/chemcoord
version.py
update_release_version
def update_release_version(): """Update VERSION file""" version = get_version(pep440=True) with open(VERSION_FILE, "w") as outfile: outfile.write(version) outfile.write("\n")
python
def update_release_version(): """Update VERSION file""" version = get_version(pep440=True) with open(VERSION_FILE, "w") as outfile: outfile.write(version) outfile.write("\n")
[ "def", "update_release_version", "(", ")", ":", "version", "=", "get_version", "(", "pep440", "=", "True", ")", "with", "open", "(", "VERSION_FILE", ",", "\"w\"", ")", "as", "outfile", ":", "outfile", ".", "write", "(", "version", ")", "outfile", ".", "w...
Update VERSION file
[ "Update", "VERSION", "file" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/version.py#L128-L133
train
64,042
mcocdawc/chemcoord
version.py
get_version
def get_version(pep440=False): """Tracks the version number. pep440: bool When True, this function returns a version string suitable for a release as defined by PEP 440. When False, the githash (if available) will be appended to the version string. The file VERSION holds the versio...
python
def get_version(pep440=False): """Tracks the version number. pep440: bool When True, this function returns a version string suitable for a release as defined by PEP 440. When False, the githash (if available) will be appended to the version string. The file VERSION holds the versio...
[ "def", "get_version", "(", "pep440", "=", "False", ")", ":", "git_version", "=", "format_git_describe", "(", "call_git_describe", "(", ")", ",", "pep440", "=", "pep440", ")", "if", "git_version", "is", "None", ":", "# not a git repository", "return", "read_relea...
Tracks the version number. pep440: bool When True, this function returns a version string suitable for a release as defined by PEP 440. When False, the githash (if available) will be appended to the version string. The file VERSION holds the version information. If this is not a git ...
[ "Tracks", "the", "version", "number", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/version.py#L136-L160
train
64,043
mcocdawc/chemcoord
version.py
call_git_branch
def call_git_branch(): """return the string output of git desribe""" try: with open(devnull, "w") as fnull: arguments = [GIT_COMMAND, 'rev-parse', '--abbrev-ref', 'HEAD'] return check_output(arguments, cwd=CURRENT_DIRECTORY, stderr=fnull).decode("a...
python
def call_git_branch(): """return the string output of git desribe""" try: with open(devnull, "w") as fnull: arguments = [GIT_COMMAND, 'rev-parse', '--abbrev-ref', 'HEAD'] return check_output(arguments, cwd=CURRENT_DIRECTORY, stderr=fnull).decode("a...
[ "def", "call_git_branch", "(", ")", ":", "try", ":", "with", "open", "(", "devnull", ",", "\"w\"", ")", "as", "fnull", ":", "arguments", "=", "[", "GIT_COMMAND", ",", "'rev-parse'", ",", "'--abbrev-ref'", ",", "'HEAD'", "]", "return", "check_output", "(", ...
return the string output of git desribe
[ "return", "the", "string", "output", "of", "git", "desribe" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/version.py#L208-L216
train
64,044
emory-libraries/eulxml
eulxml/xmlmap/core.py
load_xmlobject_from_string
def load_xmlobject_from_string(string, xmlclass=XmlObject, validate=False, resolver=None): """Initialize an XmlObject from a string. If an xmlclass is specified, construct an instance of that class instead of :class:`~eulxml.xmlmap.XmlObject`. It should be a subclass of XmlObject. The construct...
python
def load_xmlobject_from_string(string, xmlclass=XmlObject, validate=False, resolver=None): """Initialize an XmlObject from a string. If an xmlclass is specified, construct an instance of that class instead of :class:`~eulxml.xmlmap.XmlObject`. It should be a subclass of XmlObject. The construct...
[ "def", "load_xmlobject_from_string", "(", "string", ",", "xmlclass", "=", "XmlObject", ",", "validate", "=", "False", ",", "resolver", "=", "None", ")", ":", "parser", "=", "_get_xmlparser", "(", "xmlclass", "=", "xmlclass", ",", "validate", "=", "validate", ...
Initialize an XmlObject from a string. If an xmlclass is specified, construct an instance of that class instead of :class:`~eulxml.xmlmap.XmlObject`. It should be a subclass of XmlObject. The constructor will be passed a single node. If validation is requested and the specified subclass of :class:`Xml...
[ "Initialize", "an", "XmlObject", "from", "a", "string", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/core.py#L596-L616
train
64,045
emory-libraries/eulxml
eulxml/xmlmap/core.py
load_xmlobject_from_file
def load_xmlobject_from_file(filename, xmlclass=XmlObject, validate=False, resolver=None): """Initialize an XmlObject from a file. See :meth:`load_xmlobject_from_string` for more details; behaves exactly the same, and accepts the same parameters, except that it takes a filename instead of a str...
python
def load_xmlobject_from_file(filename, xmlclass=XmlObject, validate=False, resolver=None): """Initialize an XmlObject from a file. See :meth:`load_xmlobject_from_string` for more details; behaves exactly the same, and accepts the same parameters, except that it takes a filename instead of a str...
[ "def", "load_xmlobject_from_file", "(", "filename", ",", "xmlclass", "=", "XmlObject", ",", "validate", "=", "False", ",", "resolver", "=", "None", ")", ":", "parser", "=", "_get_xmlparser", "(", "xmlclass", "=", "xmlclass", ",", "validate", "=", "validate", ...
Initialize an XmlObject from a file. See :meth:`load_xmlobject_from_string` for more details; behaves exactly the same, and accepts the same parameters, except that it takes a filename instead of a string. :param filename: name of the file that should be loaded as an xmlobject. :meth:`etree.lx...
[ "Initialize", "an", "XmlObject", "from", "a", "file", "." ]
17d71c7d98c0cebda9932b7f13e72093805e1fe2
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/core.py#L619-L635
train
64,046
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_io.py
ZmatIO.read_zmat
def read_zmat(cls, inputfile, implicit_index=True): """Reads a zmat file. Lines beginning with ``#`` are ignored. Args: inputfile (str): implicit_index (bool): If this option is true the first column has to be the element symbols for the atoms. ...
python
def read_zmat(cls, inputfile, implicit_index=True): """Reads a zmat file. Lines beginning with ``#`` are ignored. Args: inputfile (str): implicit_index (bool): If this option is true the first column has to be the element symbols for the atoms. ...
[ "def", "read_zmat", "(", "cls", ",", "inputfile", ",", "implicit_index", "=", "True", ")", ":", "cols", "=", "[", "'atom'", ",", "'b'", ",", "'bond'", ",", "'a'", ",", "'angle'", ",", "'d'", ",", "'dihedral'", "]", "if", "implicit_index", ":", "zmat_fr...
Reads a zmat file. Lines beginning with ``#`` are ignored. Args: inputfile (str): implicit_index (bool): If this option is true the first column has to be the element symbols for the atoms. The row number is used to determine the index. Retu...
[ "Reads", "a", "zmat", "file", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_io.py#L89-L139
train
64,047
mcocdawc/chemcoord
src/chemcoord/internal_coordinates/_zmat_class_io.py
ZmatIO.to_zmat
def to_zmat(self, buf=None, upper_triangle=True, implicit_index=True, float_format='{:.6f}'.format, overwrite=True, header=False): """Write zmat-file Args: buf (str): StringIO-like, optional buffer to write to implicit_index (bool): If implicit_in...
python
def to_zmat(self, buf=None, upper_triangle=True, implicit_index=True, float_format='{:.6f}'.format, overwrite=True, header=False): """Write zmat-file Args: buf (str): StringIO-like, optional buffer to write to implicit_index (bool): If implicit_in...
[ "def", "to_zmat", "(", "self", ",", "buf", "=", "None", ",", "upper_triangle", "=", "True", ",", "implicit_index", "=", "True", ",", "float_format", "=", "'{:.6f}'", ".", "format", ",", "overwrite", "=", "True", ",", "header", "=", "False", ")", ":", "...
Write zmat-file Args: buf (str): StringIO-like, optional buffer to write to implicit_index (bool): If implicit_index is set, the zmat indexing is changed to ``range(1, len(self) + 1)``. Using :meth:`~chemcoord.Zmat.change_numbering` Beside...
[ "Write", "zmat", "-", "file" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/internal_coordinates/_zmat_class_io.py#L141-L179
train
64,048
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.to_xyz
def to_xyz(self, buf=None, sort_index=True, index=False, header=False, float_format='{:.6f}'.format, overwrite=True): """Write xyz-file Args: buf (str): StringIO-like, optional buffer to write to sort_index (bool): If sort_index is true, the ...
python
def to_xyz(self, buf=None, sort_index=True, index=False, header=False, float_format='{:.6f}'.format, overwrite=True): """Write xyz-file Args: buf (str): StringIO-like, optional buffer to write to sort_index (bool): If sort_index is true, the ...
[ "def", "to_xyz", "(", "self", ",", "buf", "=", "None", ",", "sort_index", "=", "True", ",", "index", "=", "False", ",", "header", "=", "False", ",", "float_format", "=", "'{:.6f}'", ".", "format", ",", "overwrite", "=", "True", ")", ":", "if", "sort_...
Write xyz-file Args: buf (str): StringIO-like, optional buffer to write to sort_index (bool): If sort_index is true, the :class:`~chemcoord.Cartesian` is sorted by the index before writing. float_format (one-parameter function): Formatter func...
[ "Write", "xyz", "-", "file" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L90-L133
train
64,049
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.read_xyz
def read_xyz(cls, buf, start_index=0, get_bonds=True, nrows=None, engine=None): """Read a file of coordinate information. Reads xyz-files. Args: inputfile (str): start_index (int): get_bonds (bool): nrows (int): Number of rows of...
python
def read_xyz(cls, buf, start_index=0, get_bonds=True, nrows=None, engine=None): """Read a file of coordinate information. Reads xyz-files. Args: inputfile (str): start_index (int): get_bonds (bool): nrows (int): Number of rows of...
[ "def", "read_xyz", "(", "cls", ",", "buf", ",", "start_index", "=", "0", ",", "get_bonds", "=", "True", ",", "nrows", "=", "None", ",", "engine", "=", "None", ")", ":", "frame", "=", "pd", ".", "read_table", "(", "buf", ",", "skiprows", "=", "2", ...
Read a file of coordinate information. Reads xyz-files. Args: inputfile (str): start_index (int): get_bonds (bool): nrows (int): Number of rows of file to read. Note that the first two rows are implicitly excluded. engine (str...
[ "Read", "a", "file", "of", "coordinate", "information", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L145-L175
train
64,050
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.to_cjson
def to_cjson(self, buf=None, **kwargs): """Write a cjson file or return dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str): If it is a filepath, the data is written to filepath. If it is None, a...
python
def to_cjson(self, buf=None, **kwargs): """Write a cjson file or return dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str): If it is a filepath, the data is written to filepath. If it is None, a...
[ "def", "to_cjson", "(", "self", ",", "buf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cjson_dict", "=", "{", "'chemical json'", ":", "0", "}", "cjson_dict", "[", "'atoms'", "]", "=", "{", "}", "atomic_number", "=", "constants", ".", "elements", ...
Write a cjson file or return dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str): If it is a filepath, the data is written to filepath. If it is None, a dictionary with the cjson informat...
[ "Write", "a", "cjson", "file", "or", "return", "dictionary", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L177-L221
train
64,051
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.read_cjson
def read_cjson(cls, buf): """Read a cjson file or a dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str, dict): If it is a filepath, the data is read from filepath. If it is a dictionary, the dict...
python
def read_cjson(cls, buf): """Read a cjson file or a dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str, dict): If it is a filepath, the data is read from filepath. If it is a dictionary, the dict...
[ "def", "read_cjson", "(", "cls", ",", "buf", ")", ":", "if", "isinstance", "(", "buf", ",", "dict", ")", ":", "data", "=", "buf", ".", "copy", "(", ")", "else", ":", "with", "open", "(", "buf", ",", "'r'", ")", "as", "f", ":", "data", "=", "j...
Read a cjson file or a dictionary. The cjson format is specified `here <https://github.com/OpenChemistry/chemicaljson>`_. Args: buf (str, dict): If it is a filepath, the data is read from filepath. If it is a dictionary, the dictionary is interpreted ...
[ "Read", "a", "cjson", "file", "or", "a", "dictionary", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L224-L274
train
64,052
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.view
def view(self, viewer=None, use_curr_dir=False): """View your molecule. .. note:: This function writes a temporary file and opens it with an external viewer. If you modify your molecule afterwards you have to recall view in order to see the changes. Args: ...
python
def view(self, viewer=None, use_curr_dir=False): """View your molecule. .. note:: This function writes a temporary file and opens it with an external viewer. If you modify your molecule afterwards you have to recall view in order to see the changes. Args: ...
[ "def", "view", "(", "self", ",", "viewer", "=", "None", ",", "use_curr_dir", "=", "False", ")", ":", "if", "viewer", "is", "None", ":", "viewer", "=", "settings", "[", "'defaults'", "]", "[", "'viewer'", "]", "if", "use_curr_dir", ":", "TEMP_DIR", "=",...
View your molecule. .. note:: This function writes a temporary file and opens it with an external viewer. If you modify your molecule afterwards you have to recall view in order to see the changes. Args: viewer (str): The external viewer to use. If it is...
[ "View", "your", "molecule", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L276-L323
train
64,053
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.get_pymatgen_molecule
def get_pymatgen_molecule(self): """Create a Molecule instance of the pymatgen library .. warning:: The `pymatgen library <http://pymatgen.org>`_ is imported locally in this function and will raise an ``ImportError`` exception, if it is not installed. Args: ...
python
def get_pymatgen_molecule(self): """Create a Molecule instance of the pymatgen library .. warning:: The `pymatgen library <http://pymatgen.org>`_ is imported locally in this function and will raise an ``ImportError`` exception, if it is not installed. Args: ...
[ "def", "get_pymatgen_molecule", "(", "self", ")", ":", "from", "pymatgen", "import", "Molecule", "return", "Molecule", "(", "self", "[", "'atom'", "]", ".", "values", ",", "self", ".", "loc", "[", ":", ",", "[", "'x'", ",", "'y'", ",", "'z'", "]", "]...
Create a Molecule instance of the pymatgen library .. warning:: The `pymatgen library <http://pymatgen.org>`_ is imported locally in this function and will raise an ``ImportError`` exception, if it is not installed. Args: None Returns: :class:`p...
[ "Create", "a", "Molecule", "instance", "of", "the", "pymatgen", "library" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L325-L340
train
64,054
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.from_pymatgen_molecule
def from_pymatgen_molecule(cls, molecule): """Create an instance of the own class from a pymatgen molecule Args: molecule (:class:`pymatgen.core.structure.Molecule`): Returns: Cartesian: """ new = cls(atoms=[el.value for el in molecule.species], ...
python
def from_pymatgen_molecule(cls, molecule): """Create an instance of the own class from a pymatgen molecule Args: molecule (:class:`pymatgen.core.structure.Molecule`): Returns: Cartesian: """ new = cls(atoms=[el.value for el in molecule.species], ...
[ "def", "from_pymatgen_molecule", "(", "cls", ",", "molecule", ")", ":", "new", "=", "cls", "(", "atoms", "=", "[", "el", ".", "value", "for", "el", "in", "molecule", ".", "species", "]", ",", "coords", "=", "molecule", ".", "cart_coords", ")", "return"...
Create an instance of the own class from a pymatgen molecule Args: molecule (:class:`pymatgen.core.structure.Molecule`): Returns: Cartesian:
[ "Create", "an", "instance", "of", "the", "own", "class", "from", "a", "pymatgen", "molecule" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L343-L354
train
64,055
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_io.py
CartesianIO.from_ase_atoms
def from_ase_atoms(cls, atoms): """Create an instance of the own class from an ase molecule Args: molecule (:class:`ase.atoms.Atoms`): Returns: Cartesian: """ return cls(atoms=atoms.get_chemical_symbols(), coords=atoms.positions)
python
def from_ase_atoms(cls, atoms): """Create an instance of the own class from an ase molecule Args: molecule (:class:`ase.atoms.Atoms`): Returns: Cartesian: """ return cls(atoms=atoms.get_chemical_symbols(), coords=atoms.positions)
[ "def", "from_ase_atoms", "(", "cls", ",", "atoms", ")", ":", "return", "cls", "(", "atoms", "=", "atoms", ".", "get_chemical_symbols", "(", ")", ",", "coords", "=", "atoms", ".", "positions", ")" ]
Create an instance of the own class from an ase molecule Args: molecule (:class:`ase.atoms.Atoms`): Returns: Cartesian:
[ "Create", "an", "instance", "of", "the", "own", "class", "from", "an", "ase", "molecule" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_io.py#L373-L382
train
64,056
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py
CartesianSymmetry._convert_eq
def _convert_eq(self, eq): """WORKS INPLACE on eq """ rename = dict(enumerate(self.index)) eq['eq_sets'] = {rename[k]: {rename[x] for x in v} for k, v in eq['eq_sets'].items()} eq['sym_ops'] = {rename[k]: {rename[x]: v[x] for x in v} ...
python
def _convert_eq(self, eq): """WORKS INPLACE on eq """ rename = dict(enumerate(self.index)) eq['eq_sets'] = {rename[k]: {rename[x] for x in v} for k, v in eq['eq_sets'].items()} eq['sym_ops'] = {rename[k]: {rename[x]: v[x] for x in v} ...
[ "def", "_convert_eq", "(", "self", ",", "eq", ")", ":", "rename", "=", "dict", "(", "enumerate", "(", "self", ".", "index", ")", ")", "eq", "[", "'eq_sets'", "]", "=", "{", "rename", "[", "k", "]", ":", "{", "rename", "[", "x", "]", "for", "x",...
WORKS INPLACE on eq
[ "WORKS", "INPLACE", "on", "eq" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py#L16-L29
train
64,057
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py
CartesianSymmetry.get_pointgroup
def get_pointgroup(self, tolerance=0.3): """Returns a PointGroup object for the molecule. Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: :class:`~PointGroupOperations` """ PA = self._get_poin...
python
def get_pointgroup(self, tolerance=0.3): """Returns a PointGroup object for the molecule. Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: :class:`~PointGroupOperations` """ PA = self._get_poin...
[ "def", "get_pointgroup", "(", "self", ",", "tolerance", "=", "0.3", ")", ":", "PA", "=", "self", ".", "_get_point_group_analyzer", "(", "tolerance", "=", "tolerance", ")", "return", "PointGroupOperations", "(", "PA", ".", "sch_symbol", ",", "PA", ".", "symmo...
Returns a PointGroup object for the molecule. Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: :class:`~PointGroupOperations`
[ "Returns", "a", "PointGroup", "object", "for", "the", "molecule", "." ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py#L31-L43
train
64,058
mcocdawc/chemcoord
src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py
CartesianSymmetry.get_equivalent_atoms
def get_equivalent_atoms(self, tolerance=0.3): """Returns sets of equivalent atoms with symmetry operations Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: dict: The returned dictionary has two possible keys: ...
python
def get_equivalent_atoms(self, tolerance=0.3): """Returns sets of equivalent atoms with symmetry operations Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: dict: The returned dictionary has two possible keys: ...
[ "def", "get_equivalent_atoms", "(", "self", ",", "tolerance", "=", "0.3", ")", ":", "PA", "=", "self", ".", "_get_point_group_analyzer", "(", "tolerance", "=", "tolerance", ")", "eq", "=", "PA", ".", "get_equivalent_atoms", "(", ")", "self", ".", "_convert_e...
Returns sets of equivalent atoms with symmetry operations Args: tolerance (float): Tolerance to generate the full set of symmetry operations. Returns: dict: The returned dictionary has two possible keys: ``eq_sets``: A dictionary of indi...
[ "Returns", "sets", "of", "equivalent", "atoms", "with", "symmetry", "operations" ]
95561ce387c142227c38fb14a1d182179aef8f5f
https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_symmetry.py#L45-L68
train
64,059
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_serialize
def btc_tx_serialize(_txobj): """ Given a transaction dict returned by btc_tx_deserialize, convert it back into a hex-encoded byte string. Derived from code written by Vitalik Buterin in pybitcointools (https://github.com/vbuterin/pybitcointools) """ # output buffer o = [] txobj = ...
python
def btc_tx_serialize(_txobj): """ Given a transaction dict returned by btc_tx_deserialize, convert it back into a hex-encoded byte string. Derived from code written by Vitalik Buterin in pybitcointools (https://github.com/vbuterin/pybitcointools) """ # output buffer o = [] txobj = ...
[ "def", "btc_tx_serialize", "(", "_txobj", ")", ":", "# output buffer", "o", "=", "[", "]", "txobj", "=", "None", "if", "encoding", ".", "json_is_base", "(", "_txobj", ",", "16", ")", ":", "# txobj is built from hex strings already. deserialize them ", "txobj", "=...
Given a transaction dict returned by btc_tx_deserialize, convert it back into a hex-encoded byte string. Derived from code written by Vitalik Buterin in pybitcointools (https://github.com/vbuterin/pybitcointools)
[ "Given", "a", "transaction", "dict", "returned", "by", "btc_tx_deserialize", "convert", "it", "back", "into", "a", "hex", "-", "encoded", "byte", "string", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L318-L397
train
64,060
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_witness_strip
def btc_tx_witness_strip( tx_serialized ): """ Strip the witness information from a serialized transaction """ if not btc_tx_is_segwit(tx_serialized): # already strippped return tx_serialized tx = btc_tx_deserialize(tx_serialized) for inp in tx['ins']: del inp['witn...
python
def btc_tx_witness_strip( tx_serialized ): """ Strip the witness information from a serialized transaction """ if not btc_tx_is_segwit(tx_serialized): # already strippped return tx_serialized tx = btc_tx_deserialize(tx_serialized) for inp in tx['ins']: del inp['witn...
[ "def", "btc_tx_witness_strip", "(", "tx_serialized", ")", ":", "if", "not", "btc_tx_is_segwit", "(", "tx_serialized", ")", ":", "# already strippped", "return", "tx_serialized", "tx", "=", "btc_tx_deserialize", "(", "tx_serialized", ")", "for", "inp", "in", "tx", ...
Strip the witness information from a serialized transaction
[ "Strip", "the", "witness", "information", "from", "a", "serialized", "transaction" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L493-L506
train
64,061
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_script_to_asm
def btc_tx_script_to_asm( script_hex ): """ Decode a script into assembler """ if len(script_hex) == 0: return "" try: script_array = btc_script_deserialize(script_hex) except: log.error("Failed to convert '%s' to assembler" % script_hex) raise script_tokens...
python
def btc_tx_script_to_asm( script_hex ): """ Decode a script into assembler """ if len(script_hex) == 0: return "" try: script_array = btc_script_deserialize(script_hex) except: log.error("Failed to convert '%s' to assembler" % script_hex) raise script_tokens...
[ "def", "btc_tx_script_to_asm", "(", "script_hex", ")", ":", "if", "len", "(", "script_hex", ")", "==", "0", ":", "return", "\"\"", "try", ":", "script_array", "=", "btc_script_deserialize", "(", "script_hex", ")", "except", ":", "log", ".", "error", "(", "...
Decode a script into assembler
[ "Decode", "a", "script", "into", "assembler" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L525-L555
train
64,062
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_extend
def btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockchain_opts): """ Given an unsigned serialized transaction, add more inputs and outputs to it. @new_inputs and @new_outputs will be virtualchain-formatted: * new_inputs[i] will have {'outpoint': {'index':..., 'hash':...}, 'script':..., 'wi...
python
def btc_tx_extend(partial_tx_hex, new_inputs, new_outputs, **blockchain_opts): """ Given an unsigned serialized transaction, add more inputs and outputs to it. @new_inputs and @new_outputs will be virtualchain-formatted: * new_inputs[i] will have {'outpoint': {'index':..., 'hash':...}, 'script':..., 'wi...
[ "def", "btc_tx_extend", "(", "partial_tx_hex", ",", "new_inputs", ",", "new_outputs", ",", "*", "*", "blockchain_opts", ")", ":", "# recover tx", "tx", "=", "btc_tx_deserialize", "(", "partial_tx_hex", ")", "tx_inputs", ",", "tx_outputs", "=", "tx", "[", "'ins'"...
Given an unsigned serialized transaction, add more inputs and outputs to it. @new_inputs and @new_outputs will be virtualchain-formatted: * new_inputs[i] will have {'outpoint': {'index':..., 'hash':...}, 'script':..., 'witness_script': ...} * new_outputs[i] will have {'script':..., 'value':... (in fundament...
[ "Given", "an", "unsigned", "serialized", "transaction", "add", "more", "inputs", "and", "outputs", "to", "it", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L577-L601
train
64,063
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_der_encode_length
def btc_tx_der_encode_length(l): """ Return a DER-encoded length field Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license. """ if l < 0: raise ValueError("length cannot be negative") if l < 0x80: return int2...
python
def btc_tx_der_encode_length(l): """ Return a DER-encoded length field Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license. """ if l < 0: raise ValueError("length cannot be negative") if l < 0x80: return int2...
[ "def", "btc_tx_der_encode_length", "(", "l", ")", ":", "if", "l", "<", "0", ":", "raise", "ValueError", "(", "\"length cannot be negative\"", ")", "if", "l", "<", "0x80", ":", "return", "int2byte", "(", "l", ")", "s", "=", "(", "\"%x\"", "%", "l", ")",...
Return a DER-encoded length field Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license.
[ "Return", "a", "DER", "-", "encoded", "length", "field" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L629-L646
train
64,064
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_der_encode_sequence
def btc_tx_der_encode_sequence(*encoded_pieces): """ Return a DER-encoded sequence Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license. """ # borrowed from python-ecdsa total_len = sum([len(p) for p in encoded_pieces]) re...
python
def btc_tx_der_encode_sequence(*encoded_pieces): """ Return a DER-encoded sequence Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license. """ # borrowed from python-ecdsa total_len = sum([len(p) for p in encoded_pieces]) re...
[ "def", "btc_tx_der_encode_sequence", "(", "*", "encoded_pieces", ")", ":", "# borrowed from python-ecdsa", "total_len", "=", "sum", "(", "[", "len", "(", "p", ")", "for", "p", "in", "encoded_pieces", "]", ")", "return", "b", "(", "'\\x30'", ")", "+", "btc_tx...
Return a DER-encoded sequence Based on code from python-ecdsa (https://github.com/warner/python-ecdsa) by Brian Warner. Subject to the MIT license.
[ "Return", "a", "DER", "-", "encoded", "sequence" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L649-L658
train
64,065
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_sighash
def btc_tx_sighash( tx, idx, script, hashcode=SIGHASH_ALL): """ Calculate the sighash of a non-segwit transaction. If it's SIGHASH_NONE, then digest the inputs but no outputs If it's SIGHASH_SINGLE, then digest all inputs and all outputs up to i (excluding values and scripts), and fully digest the ith...
python
def btc_tx_sighash( tx, idx, script, hashcode=SIGHASH_ALL): """ Calculate the sighash of a non-segwit transaction. If it's SIGHASH_NONE, then digest the inputs but no outputs If it's SIGHASH_SINGLE, then digest all inputs and all outputs up to i (excluding values and scripts), and fully digest the ith...
[ "def", "btc_tx_sighash", "(", "tx", ",", "idx", ",", "script", ",", "hashcode", "=", "SIGHASH_ALL", ")", ":", "txobj", "=", "btc_tx_deserialize", "(", "tx", ")", "idx", "=", "int", "(", "idx", ")", "hashcode", "=", "int", "(", "hashcode", ")", "newtx",...
Calculate the sighash of a non-segwit transaction. If it's SIGHASH_NONE, then digest the inputs but no outputs If it's SIGHASH_SINGLE, then digest all inputs and all outputs up to i (excluding values and scripts), and fully digest the ith input and output If it's (something) | SIGHASH_ANYONECANPAY, then o...
[ "Calculate", "the", "sighash", "of", "a", "non", "-", "segwit", "transaction", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L672-L730
train
64,066
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_sign_multisig_segwit
def btc_tx_sign_multisig_segwit(tx, idx, prevout_amount, witness_script, private_keys, hashcode=SIGHASH_ALL, hashcodes=None, native=False): """ Sign a native p2wsh or p2sh-p2wsh multisig input. @tx must be a hex-encoded tx Return the signed transaction """ from .multisig import parse_multisig...
python
def btc_tx_sign_multisig_segwit(tx, idx, prevout_amount, witness_script, private_keys, hashcode=SIGHASH_ALL, hashcodes=None, native=False): """ Sign a native p2wsh or p2sh-p2wsh multisig input. @tx must be a hex-encoded tx Return the signed transaction """ from .multisig import parse_multisig...
[ "def", "btc_tx_sign_multisig_segwit", "(", "tx", ",", "idx", ",", "prevout_amount", ",", "witness_script", ",", "private_keys", ",", "hashcode", "=", "SIGHASH_ALL", ",", "hashcodes", "=", "None", ",", "native", "=", "False", ")", ":", "from", ".", "multisig", ...
Sign a native p2wsh or p2sh-p2wsh multisig input. @tx must be a hex-encoded tx Return the signed transaction
[ "Sign", "a", "native", "p2wsh", "or", "p2sh", "-", "p2wsh", "multisig", "input", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L935-L996
train
64,067
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_privkey_scriptsig_classify
def btc_privkey_scriptsig_classify(private_key_info): """ What kind of scriptsig can this private key make? """ if btc_is_singlesig(private_key_info): return 'p2pkh' if btc_is_multisig(private_key_info): return 'p2sh' if btc_is_singlesig_segwit(private_key_info): return...
python
def btc_privkey_scriptsig_classify(private_key_info): """ What kind of scriptsig can this private key make? """ if btc_is_singlesig(private_key_info): return 'p2pkh' if btc_is_multisig(private_key_info): return 'p2sh' if btc_is_singlesig_segwit(private_key_info): return...
[ "def", "btc_privkey_scriptsig_classify", "(", "private_key_info", ")", ":", "if", "btc_is_singlesig", "(", "private_key_info", ")", ":", "return", "'p2pkh'", "if", "btc_is_multisig", "(", "private_key_info", ")", ":", "return", "'p2sh'", "if", "btc_is_singlesig_segwit",...
What kind of scriptsig can this private key make?
[ "What", "kind", "of", "scriptsig", "can", "this", "private", "key", "make?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1162-L1178
train
64,068
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
btc_tx_sign_all_unsigned_inputs
def btc_tx_sign_all_unsigned_inputs(private_key_info, prev_outputs, unsigned_tx_hex, scriptsig_type=None, segwit=None, **blockchain_opts): """ Sign all unsigned inputs with a given key. Use the given outputs to fund them. @private_key_info: either a hex private key, or a dict with 'private_keys' and 'r...
python
def btc_tx_sign_all_unsigned_inputs(private_key_info, prev_outputs, unsigned_tx_hex, scriptsig_type=None, segwit=None, **blockchain_opts): """ Sign all unsigned inputs with a given key. Use the given outputs to fund them. @private_key_info: either a hex private key, or a dict with 'private_keys' and 'r...
[ "def", "btc_tx_sign_all_unsigned_inputs", "(", "private_key_info", ",", "prev_outputs", ",", "unsigned_tx_hex", ",", "scriptsig_type", "=", "None", ",", "segwit", "=", "None", ",", "*", "*", "blockchain_opts", ")", ":", "if", "segwit", "is", "None", ":", "segwit...
Sign all unsigned inputs with a given key. Use the given outputs to fund them. @private_key_info: either a hex private key, or a dict with 'private_keys' and 'redeem_script' defined as keys. @prev_outputs: a list of {'out_script': xxx, 'value': xxx} that are in 1-to-1 correspondence with the unsigned i...
[ "Sign", "all", "unsigned", "inputs", "with", "a", "given", "key", ".", "Use", "the", "given", "outputs", "to", "fund", "them", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1200-L1250
train
64,069
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
block_header_serialize
def block_header_serialize( inp ): """ Given block header information, serialize it and return the hex hash. inp has: * version (int) * prevhash (str) * merkle_root (str) * timestamp (int) * bits (int) * nonce (int) Based on code from pybitcointools (https://github.com/vbuterin...
python
def block_header_serialize( inp ): """ Given block header information, serialize it and return the hex hash. inp has: * version (int) * prevhash (str) * merkle_root (str) * timestamp (int) * bits (int) * nonce (int) Based on code from pybitcointools (https://github.com/vbuterin...
[ "def", "block_header_serialize", "(", "inp", ")", ":", "# concatenate to form header", "o", "=", "encoding", ".", "encode", "(", "inp", "[", "'version'", "]", ",", "256", ",", "4", ")", "[", ":", ":", "-", "1", "]", "+", "inp", "[", "'prevhash'", "]", ...
Given block header information, serialize it and return the hex hash. inp has: * version (int) * prevhash (str) * merkle_root (str) * timestamp (int) * bits (int) * nonce (int) Based on code from pybitcointools (https://github.com/vbuterin/pybitcointools) by Vitalik Buterin
[ "Given", "block", "header", "information", "serialize", "it", "and", "return", "the", "hex", "hash", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1253-L1281
train
64,070
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
block_header_to_hex
def block_header_to_hex( block_data, prev_hash ): """ Calculate the hex form of a block's header, given its getblock information from bitcoind. """ header_info = { "version": block_data['version'], "prevhash": prev_hash, "merkle_root": block_data['merkleroot'], "timestamp": b...
python
def block_header_to_hex( block_data, prev_hash ): """ Calculate the hex form of a block's header, given its getblock information from bitcoind. """ header_info = { "version": block_data['version'], "prevhash": prev_hash, "merkle_root": block_data['merkleroot'], "timestamp": b...
[ "def", "block_header_to_hex", "(", "block_data", ",", "prev_hash", ")", ":", "header_info", "=", "{", "\"version\"", ":", "block_data", "[", "'version'", "]", ",", "\"prevhash\"", ":", "prev_hash", ",", "\"merkle_root\"", ":", "block_data", "[", "'merkleroot'", ...
Calculate the hex form of a block's header, given its getblock information from bitcoind.
[ "Calculate", "the", "hex", "form", "of", "a", "block", "s", "header", "given", "its", "getblock", "information", "from", "bitcoind", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1284-L1298
train
64,071
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/bits.py
block_header_verify
def block_header_verify( block_data, prev_hash, block_hash ): """ Verify whether or not bitcoind's block header matches the hash we expect. """ serialized_header = block_header_to_hex( block_data, prev_hash ) candidate_hash_bin_reversed = hashing.bin_double_sha256(binascii.unhexlify(serialized_heade...
python
def block_header_verify( block_data, prev_hash, block_hash ): """ Verify whether or not bitcoind's block header matches the hash we expect. """ serialized_header = block_header_to_hex( block_data, prev_hash ) candidate_hash_bin_reversed = hashing.bin_double_sha256(binascii.unhexlify(serialized_heade...
[ "def", "block_header_verify", "(", "block_data", ",", "prev_hash", ",", "block_hash", ")", ":", "serialized_header", "=", "block_header_to_hex", "(", "block_data", ",", "prev_hash", ")", "candidate_hash_bin_reversed", "=", "hashing", ".", "bin_double_sha256", "(", "bi...
Verify whether or not bitcoind's block header matches the hash we expect.
[ "Verify", "whether", "or", "not", "bitcoind", "s", "block", "header", "matches", "the", "hash", "we", "expect", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/bits.py#L1301-L1309
train
64,072
gregreen/dustmaps
dustmaps/config.py
Configuration.save
def save(self, force=False): """ Saves the configuration to a JSON, in the standard config location. Args: force (Optional[:obj:`bool`]): Continue writing, even if the original config file was not loaded properly. This is dangerous, because it could c...
python
def save(self, force=False): """ Saves the configuration to a JSON, in the standard config location. Args: force (Optional[:obj:`bool`]): Continue writing, even if the original config file was not loaded properly. This is dangerous, because it could c...
[ "def", "save", "(", "self", ",", "force", "=", "False", ")", ":", "if", "(", "not", "self", ".", "_success", ")", "and", "(", "not", "force", ")", ":", "raise", "ConfigError", "(", "(", "'The config file appears to be corrupted:\\n\\n'", "' {fname}\\n\\n'",...
Saves the configuration to a JSON, in the standard config location. Args: force (Optional[:obj:`bool`]): Continue writing, even if the original config file was not loaded properly. This is dangerous, because it could cause the previous configuration options to be los...
[ "Saves", "the", "configuration", "to", "a", "JSON", "in", "the", "standard", "config", "location", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/config.py#L65-L92
train
64,073
gregreen/dustmaps
dustmaps/config.py
Configuration.reset
def reset(self): """ Resets the configuration, and overwrites the existing configuration file. """ self._options = {} self.save(force=True) self._success = True
python
def reset(self): """ Resets the configuration, and overwrites the existing configuration file. """ self._options = {} self.save(force=True) self._success = True
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_options", "=", "{", "}", "self", ".", "save", "(", "force", "=", "True", ")", "self", ".", "_success", "=", "True" ]
Resets the configuration, and overwrites the existing configuration file.
[ "Resets", "the", "configuration", "and", "overwrites", "the", "existing", "configuration", "file", "." ]
c8f571a71da0d951bf8ea865621bee14492bdfd9
https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/config.py#L115-L122
train
64,074
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.run
def run( self ): """ Interact with the blockchain peer, until we get a socket error or we exit the loop explicitly. The order of operations is: * send version * receive version * send verack * send getdata * receive blocks * for ea...
python
def run( self ): """ Interact with the blockchain peer, until we get a socket error or we exit the loop explicitly. The order of operations is: * send version * receive version * send verack * send getdata * receive blocks * for ea...
[ "def", "run", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Segwit support: {}\"", ".", "format", "(", "get_features", "(", "'segwit'", ")", ")", ")", "self", ".", "begin", "(", ")", "try", ":", "self", ".", "loop", "(", ")", "except", "socket"...
Interact with the blockchain peer, until we get a socket error or we exit the loop explicitly. The order of operations is: * send version * receive version * send verack * send getdata * receive blocks * for each block: * for each transa...
[ "Interact", "with", "the", "blockchain", "peer", "until", "we", "get", "a", "socket", "error", "or", "we", "exit", "the", "loop", "explicitly", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L152-L199
train
64,075
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.have_all_block_data
def have_all_block_data(self): """ Have we received all block data? """ if not (self.num_blocks_received == self.num_blocks_requested): log.debug("num blocks received = %s, num requested = %s" % (self.num_blocks_received, self.num_blocks_requested)) return False ...
python
def have_all_block_data(self): """ Have we received all block data? """ if not (self.num_blocks_received == self.num_blocks_requested): log.debug("num blocks received = %s, num requested = %s" % (self.num_blocks_received, self.num_blocks_requested)) return False ...
[ "def", "have_all_block_data", "(", "self", ")", ":", "if", "not", "(", "self", ".", "num_blocks_received", "==", "self", ".", "num_blocks_requested", ")", ":", "log", ".", "debug", "(", "\"num blocks received = %s, num requested = %s\"", "%", "(", "self", ".", "...
Have we received all block data?
[ "Have", "we", "received", "all", "block", "data?" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L202-L210
train
64,076
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.fetch_sender_txs
def fetch_sender_txs(self): """ Fetch all sender txs via JSON-RPC, and merge them into our block data. Try backing off (up to 5 times) if we fail to fetch transactions via JSONRPC Return True on success Raise on error """ # fetch remaini...
python
def fetch_sender_txs(self): """ Fetch all sender txs via JSON-RPC, and merge them into our block data. Try backing off (up to 5 times) if we fail to fetch transactions via JSONRPC Return True on success Raise on error """ # fetch remaini...
[ "def", "fetch_sender_txs", "(", "self", ")", ":", "# fetch remaining sender transactions", "if", "len", "(", "self", ".", "sender_info", ".", "keys", "(", ")", ")", ">", "0", ":", "sender_txids", "=", "self", ".", "sender_info", ".", "keys", "(", ")", "[",...
Fetch all sender txs via JSON-RPC, and merge them into our block data. Try backing off (up to 5 times) if we fail to fetch transactions via JSONRPC Return True on success Raise on error
[ "Fetch", "all", "sender", "txs", "via", "JSON", "-", "RPC", "and", "merge", "them", "into", "our", "block", "data", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L213-L277
train
64,077
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.block_data_sanity_checks
def block_data_sanity_checks(self): """ Verify that the data we received makes sense. Return True on success Raise on error """ assert self.have_all_block_data(), "Still missing block data" assert self.num_txs_received == len(self.sender_info.keys()), "Num TXs rec...
python
def block_data_sanity_checks(self): """ Verify that the data we received makes sense. Return True on success Raise on error """ assert self.have_all_block_data(), "Still missing block data" assert self.num_txs_received == len(self.sender_info.keys()), "Num TXs rec...
[ "def", "block_data_sanity_checks", "(", "self", ")", ":", "assert", "self", ".", "have_all_block_data", "(", ")", ",", "\"Still missing block data\"", "assert", "self", ".", "num_txs_received", "==", "len", "(", "self", ".", "sender_info", ".", "keys", "(", ")",...
Verify that the data we received makes sense. Return True on success Raise on error
[ "Verify", "that", "the", "data", "we", "received", "makes", "sense", ".", "Return", "True", "on", "success", "Raise", "on", "error" ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L280-L302
train
64,078
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.begin
def begin(self): """ This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading. """ log.debug("handsha...
python
def begin(self): """ This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading. """ log.debug("handsha...
[ "def", "begin", "(", "self", ")", ":", "log", ".", "debug", "(", "\"handshake (version %s)\"", "%", "PROTOCOL_VERSION", ")", "version", "=", "Version", "(", ")", "version", ".", "services", "=", "0", "# can't send blocks", "log", ".", "debug", "(", "\"send V...
This method will implement the handshake of the Bitcoin protocol. It will send the Version message, and block until it receives a VerAck. Once we receive the version, we'll send the verack, and begin downloading.
[ "This", "method", "will", "implement", "the", "handshake", "of", "the", "Bitcoin", "protocol", ".", "It", "will", "send", "the", "Version", "message", "and", "block", "until", "it", "receives", "a", "VerAck", ".", "Once", "we", "receive", "the", "version", ...
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L305-L317
train
64,079
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.add_sender_info
def add_sender_info( self, sender_txhash, nulldata_vin_outpoint, sender_out_data ): """ Record sender information in our block info. @sender_txhash: txid of the sender @nulldata_vin_outpoint: the 'vout' index from the nulldata tx input that this transaction funded """ ass...
python
def add_sender_info( self, sender_txhash, nulldata_vin_outpoint, sender_out_data ): """ Record sender information in our block info. @sender_txhash: txid of the sender @nulldata_vin_outpoint: the 'vout' index from the nulldata tx input that this transaction funded """ ass...
[ "def", "add_sender_info", "(", "self", ",", "sender_txhash", ",", "nulldata_vin_outpoint", ",", "sender_out_data", ")", ":", "assert", "sender_txhash", "in", "self", ".", "sender_info", ".", "keys", "(", ")", ",", "\"Missing sender info for %s\"", "%", "sender_txhas...
Record sender information in our block info. @sender_txhash: txid of the sender @nulldata_vin_outpoint: the 'vout' index from the nulldata tx input that this transaction funded
[ "Record", "sender", "information", "in", "our", "block", "info", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L411-L447
train
64,080
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.make_sender_info
def make_sender_info( self, block_hash, txn, i, block_height ): """ Make sender information bundle for a particular input of a nulldata transaction. We'll use it to go find the transaction output that funded the ith input of the given tx. """ inp = txn['ins'][i]...
python
def make_sender_info( self, block_hash, txn, i, block_height ): """ Make sender information bundle for a particular input of a nulldata transaction. We'll use it to go find the transaction output that funded the ith input of the given tx. """ inp = txn['ins'][i]...
[ "def", "make_sender_info", "(", "self", ",", "block_hash", ",", "txn", ",", "i", ",", "block_height", ")", ":", "inp", "=", "txn", "[", "'ins'", "]", "[", "i", "]", "ret", "=", "{", "# to be filled in...", "'scriptPubKey'", ":", "None", ",", "'addresses'...
Make sender information bundle for a particular input of a nulldata transaction. We'll use it to go find the transaction output that funded the ith input of the given tx.
[ "Make", "sender", "information", "bundle", "for", "a", "particular", "input", "of", "a", "nulldata", "transaction", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L495-L519
train
64,081
blockstack/virtualchain
virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py
BlockchainDownloader.fetch_txs_rpc
def fetch_txs_rpc( self, bitcoind_opts, txids ): """ Fetch the given list of transactions via the JSON-RPC interface. Return a dict of parsed transactions on success, keyed by txid. Return None on error """ headers = {'content-type': 'application/json'}...
python
def fetch_txs_rpc( self, bitcoind_opts, txids ): """ Fetch the given list of transactions via the JSON-RPC interface. Return a dict of parsed transactions on success, keyed by txid. Return None on error """ headers = {'content-type': 'application/json'}...
[ "def", "fetch_txs_rpc", "(", "self", ",", "bitcoind_opts", ",", "txids", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/json'", "}", "reqs", "=", "[", "]", "ret", "=", "{", "}", "for", "i", "in", "xrange", "(", "0", ",", "len", "...
Fetch the given list of transactions via the JSON-RPC interface. Return a dict of parsed transactions on success, keyed by txid. Return None on error
[ "Fetch", "the", "given", "list", "of", "transactions", "via", "the", "JSON", "-", "RPC", "interface", "." ]
fcfc970064ca7dfcab26ebd3ab955870a763ea39
https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/blocks.py#L671-L774
train
64,082
troeger/opensubmit
executor/opensubmitexec/config.py
read_config
def read_config(config_file=CONFIG_FILE_DEFAULT, override_url=None): ''' Read configuration file, perform sanity check and return configuration dictionary used by other functions.''' config = ConfigParser() config.read_dict(DEFAULT_SETTINGS) try: config.readfp(open(config_file)) ...
python
def read_config(config_file=CONFIG_FILE_DEFAULT, override_url=None): ''' Read configuration file, perform sanity check and return configuration dictionary used by other functions.''' config = ConfigParser() config.read_dict(DEFAULT_SETTINGS) try: config.readfp(open(config_file)) ...
[ "def", "read_config", "(", "config_file", "=", "CONFIG_FILE_DEFAULT", ",", "override_url", "=", "None", ")", ":", "config", "=", "ConfigParser", "(", ")", "config", ".", "read_dict", "(", "DEFAULT_SETTINGS", ")", "try", ":", "config", ".", "readfp", "(", "op...
Read configuration file, perform sanity check and return configuration dictionary used by other functions.
[ "Read", "configuration", "file", "perform", "sanity", "check", "and", "return", "configuration", "dictionary", "used", "by", "other", "functions", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/config.py#L109-L138
train
64,083
troeger/opensubmit
executor/opensubmitexec/config.py
check_config
def check_config(config): ''' Check the executor config file for consistency. ''' # Check server URL url = config.get("Server", "url") try: urlopen(url) except Exception as e: logger.error( "The configured OpenSubmit server URL ({0}) seems to be invalid: {1}"....
python
def check_config(config): ''' Check the executor config file for consistency. ''' # Check server URL url = config.get("Server", "url") try: urlopen(url) except Exception as e: logger.error( "The configured OpenSubmit server URL ({0}) seems to be invalid: {1}"....
[ "def", "check_config", "(", "config", ")", ":", "# Check server URL", "url", "=", "config", ".", "get", "(", "\"Server\"", ",", "\"url\"", ")", "try", ":", "urlopen", "(", "url", ")", "except", "Exception", "as", "e", ":", "logger", ".", "error", "(", ...
Check the executor config file for consistency.
[ "Check", "the", "executor", "config", "file", "for", "consistency", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/config.py#L141-L163
train
64,084
troeger/opensubmit
executor/opensubmitexec/config.py
has_config
def has_config(config_fname): ''' Determine if the given config file exists. ''' config = RawConfigParser() try: config.readfp(open(config_fname)) return True except IOError: return False
python
def has_config(config_fname): ''' Determine if the given config file exists. ''' config = RawConfigParser() try: config.readfp(open(config_fname)) return True except IOError: return False
[ "def", "has_config", "(", "config_fname", ")", ":", "config", "=", "RawConfigParser", "(", ")", "try", ":", "config", ".", "readfp", "(", "open", "(", "config_fname", ")", ")", "return", "True", "except", "IOError", ":", "return", "False" ]
Determine if the given config file exists.
[ "Determine", "if", "the", "given", "config", "file", "exists", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/config.py#L166-L175
train
64,085
troeger/opensubmit
executor/opensubmitexec/config.py
create_config
def create_config(config_fname, override_url=None): ''' Create the config file from the defaults under the given name. ''' config_path = os.path.dirname(config_fname) os.makedirs(config_path, exist_ok=True) # Consider override URL. Only used by test suite runs settings = DEFAULT_SETTINGS_FL...
python
def create_config(config_fname, override_url=None): ''' Create the config file from the defaults under the given name. ''' config_path = os.path.dirname(config_fname) os.makedirs(config_path, exist_ok=True) # Consider override URL. Only used by test suite runs settings = DEFAULT_SETTINGS_FL...
[ "def", "create_config", "(", "config_fname", ",", "override_url", "=", "None", ")", ":", "config_path", "=", "os", ".", "path", ".", "dirname", "(", "config_fname", ")", "os", ".", "makedirs", "(", "config_path", ",", "exist_ok", "=", "True", ")", "# Consi...
Create the config file from the defaults under the given name.
[ "Create", "the", "config", "file", "from", "the", "defaults", "under", "the", "given", "name", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/config.py#L178-L193
train
64,086
troeger/opensubmit
web/opensubmit/security.py
make_student
def make_student(user): ''' Makes the given user a student. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = False user.is_superuser = False user.save() owner_group.user_set.remove(user) owner_group.save() tutor_group.user_set.remove(user) tutor_group.save()
python
def make_student(user): ''' Makes the given user a student. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = False user.is_superuser = False user.save() owner_group.user_set.remove(user) owner_group.save() tutor_group.user_set.remove(user) tutor_group.save()
[ "def", "make_student", "(", "user", ")", ":", "tutor_group", ",", "owner_group", "=", "_get_user_groups", "(", ")", "user", ".", "is_staff", "=", "False", "user", ".", "is_superuser", "=", "False", "user", ".", "save", "(", ")", "owner_group", ".", "user_s...
Makes the given user a student.
[ "Makes", "the", "given", "user", "a", "student", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/security.py#L138-L149
train
64,087
troeger/opensubmit
web/opensubmit/security.py
make_tutor
def make_tutor(user): ''' Makes the given user a tutor. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = False user.save() owner_group.user_set.remove(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
python
def make_tutor(user): ''' Makes the given user a tutor. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = False user.save() owner_group.user_set.remove(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
[ "def", "make_tutor", "(", "user", ")", ":", "tutor_group", ",", "owner_group", "=", "_get_user_groups", "(", ")", "user", ".", "is_staff", "=", "True", "user", ".", "is_superuser", "=", "False", "user", ".", "save", "(", ")", "owner_group", ".", "user_set"...
Makes the given user a tutor.
[ "Makes", "the", "given", "user", "a", "tutor", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/security.py#L152-L163
train
64,088
troeger/opensubmit
web/opensubmit/security.py
make_owner
def make_owner(user): ''' Makes the given user a owner and tutor. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = False user.save() owner_group.user_set.add(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
python
def make_owner(user): ''' Makes the given user a owner and tutor. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = False user.save() owner_group.user_set.add(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
[ "def", "make_owner", "(", "user", ")", ":", "tutor_group", ",", "owner_group", "=", "_get_user_groups", "(", ")", "user", ".", "is_staff", "=", "True", "user", ".", "is_superuser", "=", "False", "user", ".", "save", "(", ")", "owner_group", ".", "user_set"...
Makes the given user a owner and tutor.
[ "Makes", "the", "given", "user", "a", "owner", "and", "tutor", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/security.py#L166-L177
train
64,089
troeger/opensubmit
web/opensubmit/security.py
make_admin
def make_admin(user): ''' Makes the given user an admin. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = True user.save() owner_group.user_set.add(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
python
def make_admin(user): ''' Makes the given user an admin. ''' tutor_group, owner_group = _get_user_groups() user.is_staff = True user.is_superuser = True user.save() owner_group.user_set.add(user) owner_group.save() tutor_group.user_set.add(user) tutor_group.save()
[ "def", "make_admin", "(", "user", ")", ":", "tutor_group", ",", "owner_group", "=", "_get_user_groups", "(", ")", "user", ".", "is_staff", "=", "True", "user", ".", "is_superuser", "=", "True", "user", ".", "save", "(", ")", "owner_group", ".", "user_set",...
Makes the given user an admin.
[ "Makes", "the", "given", "user", "an", "admin", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/security.py#L180-L191
train
64,090
umich-brcf-bioinf/Connor
connor/utils.py
_get_username_hostname
def _get_username_hostname(): '''Best attempt to get username and hostname, returns "na" if problem.''' user = 'na' host = 'na' try: user = getpass.getuser() except Exception: pass try: host = socket.gethostname() except Exception: pass return user, host
python
def _get_username_hostname(): '''Best attempt to get username and hostname, returns "na" if problem.''' user = 'na' host = 'na' try: user = getpass.getuser() except Exception: pass try: host = socket.gethostname() except Exception: pass return user, host
[ "def", "_get_username_hostname", "(", ")", ":", "user", "=", "'na'", "host", "=", "'na'", "try", ":", "user", "=", "getpass", ".", "getuser", "(", ")", "except", "Exception", ":", "pass", "try", ":", "host", "=", "socket", ".", "gethostname", "(", ")",...
Best attempt to get username and hostname, returns "na" if problem.
[ "Best", "attempt", "to", "get", "username", "and", "hostname", "returns", "na", "if", "problem", "." ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/utils.py#L21-L33
train
64,091
troeger/opensubmit
web/opensubmit/social/lti.py
LtiAuth.get_user_details
def get_user_details(self, response): """ Complete with additional information from original LTI POST data, as available. """ data = {} # None of them is mandatory data['id'] = response.get('user_id', None) data['username'] = response.get('custom_username', None) if not d...
python
def get_user_details(self, response): """ Complete with additional information from original LTI POST data, as available. """ data = {} # None of them is mandatory data['id'] = response.get('user_id', None) data['username'] = response.get('custom_username', None) if not d...
[ "def", "get_user_details", "(", "self", ",", "response", ")", ":", "data", "=", "{", "}", "# None of them is mandatory", "data", "[", "'id'", "]", "=", "response", ".", "get", "(", "'user_id'", ",", "None", ")", "data", "[", "'username'", "]", "=", "resp...
Complete with additional information from original LTI POST data, as available.
[ "Complete", "with", "additional", "information", "from", "original", "LTI", "POST", "data", "as", "available", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/social/lti.py#L15-L29
train
64,092
troeger/opensubmit
web/opensubmit/models/userprofile.py
user_unicode
def user_unicode(self): ''' Monkey patch for getting better user name stringification, user proxies did not make the job. Django's custom user model feature would have needed to be introduced before the first syncdb, which does not work for existing installations. ''' if self.ema...
python
def user_unicode(self): ''' Monkey patch for getting better user name stringification, user proxies did not make the job. Django's custom user model feature would have needed to be introduced before the first syncdb, which does not work for existing installations. ''' if self.ema...
[ "def", "user_unicode", "(", "self", ")", ":", "if", "self", ".", "email", ":", "shortened", "=", "self", ".", "email", ".", "split", "(", "'@'", ")", "[", "0", "]", "return", "'%s %s (%s@...)'", "%", "(", "self", ".", "first_name", ",", "self", ".", ...
Monkey patch for getting better user name stringification, user proxies did not make the job. Django's custom user model feature would have needed to be introduced before the first syncdb, which does not work for existing installations.
[ "Monkey", "patch", "for", "getting", "better", "user", "name", "stringification", "user", "proxies", "did", "not", "make", "the", "job", ".", "Django", "s", "custom", "user", "model", "feature", "would", "have", "needed", "to", "be", "introduced", "before", ...
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L102-L117
train
64,093
troeger/opensubmit
web/opensubmit/models/userprofile.py
move_user_data
def move_user_data(primary, secondary): ''' Moves all submissions and other data linked to the secondary user into the primary user. Nothing is deleted here, we just modify foreign user keys. ''' # Update all submission authorships of the secondary to the primary submissions = Submission...
python
def move_user_data(primary, secondary): ''' Moves all submissions and other data linked to the secondary user into the primary user. Nothing is deleted here, we just modify foreign user keys. ''' # Update all submission authorships of the secondary to the primary submissions = Submission...
[ "def", "move_user_data", "(", "primary", ",", "secondary", ")", ":", "# Update all submission authorships of the secondary to the primary", "submissions", "=", "Submission", ".", "objects", ".", "filter", "(", "authors__id", "=", "secondary", ".", "pk", ")", "for", "s...
Moves all submissions and other data linked to the secondary user into the primary user. Nothing is deleted here, we just modify foreign user keys.
[ "Moves", "all", "submissions", "and", "other", "data", "linked", "to", "the", "secondary", "user", "into", "the", "primary", "user", ".", "Nothing", "is", "deleted", "here", "we", "just", "modify", "foreign", "user", "keys", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L124-L144
train
64,094
troeger/opensubmit
web/opensubmit/models/userprofile.py
UserProfile.add_course_safe
def add_course_safe(self, id): ''' Adds a course for the user after conducting a set of sanity checks. Return the title of the course or an exception. ''' course = get_object_or_404(Course, pk=int(id), active=True) if course not in self.courses.all(): ...
python
def add_course_safe(self, id): ''' Adds a course for the user after conducting a set of sanity checks. Return the title of the course or an exception. ''' course = get_object_or_404(Course, pk=int(id), active=True) if course not in self.courses.all(): ...
[ "def", "add_course_safe", "(", "self", ",", "id", ")", ":", "course", "=", "get_object_or_404", "(", "Course", ",", "pk", "=", "int", "(", "id", ")", ",", "active", "=", "True", ")", "if", "course", "not", "in", "self", ".", "courses", ".", "all", ...
Adds a course for the user after conducting a set of sanity checks. Return the title of the course or an exception.
[ "Adds", "a", "course", "for", "the", "user", "after", "conducting", "a", "set", "of", "sanity", "checks", ".", "Return", "the", "title", "of", "the", "course", "or", "an", "exception", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L26-L34
train
64,095
troeger/opensubmit
web/opensubmit/models/userprofile.py
UserProfile.tutor_courses
def tutor_courses(self): ''' Returns the list of courses this user is tutor or owner for. ''' tutoring = self.user.courses_tutoring.all().filter(active__exact=True) owning = self.user.courses.all().filter(active__exact=True) result = (tutoring | owning).distinct() ...
python
def tutor_courses(self): ''' Returns the list of courses this user is tutor or owner for. ''' tutoring = self.user.courses_tutoring.all().filter(active__exact=True) owning = self.user.courses.all().filter(active__exact=True) result = (tutoring | owning).distinct() ...
[ "def", "tutor_courses", "(", "self", ")", ":", "tutoring", "=", "self", ".", "user", ".", "courses_tutoring", ".", "all", "(", ")", ".", "filter", "(", "active__exact", "=", "True", ")", "owning", "=", "self", ".", "user", ".", "courses", ".", "all", ...
Returns the list of courses this user is tutor or owner for.
[ "Returns", "the", "list", "of", "courses", "this", "user", "is", "tutor", "or", "owner", "for", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L43-L50
train
64,096
troeger/opensubmit
web/opensubmit/models/userprofile.py
UserProfile.user_courses
def user_courses(self): ''' Returns the list of courses this user is subscribed for, or owning, or tutoring. This leads to the fact that tutors and owners don't need course membership. ''' registered = self.courses.filter(active__exact=True).distin...
python
def user_courses(self): ''' Returns the list of courses this user is subscribed for, or owning, or tutoring. This leads to the fact that tutors and owners don't need course membership. ''' registered = self.courses.filter(active__exact=True).distin...
[ "def", "user_courses", "(", "self", ")", ":", "registered", "=", "self", ".", "courses", ".", "filter", "(", "active__exact", "=", "True", ")", ".", "distinct", "(", ")", "return", "(", "self", ".", "tutor_courses", "(", ")", "|", "registered", ")", "....
Returns the list of courses this user is subscribed for, or owning, or tutoring. This leads to the fact that tutors and owners don't need course membership.
[ "Returns", "the", "list", "of", "courses", "this", "user", "is", "subscribed", "for", "or", "owning", "or", "tutoring", ".", "This", "leads", "to", "the", "fact", "that", "tutors", "and", "owners", "don", "t", "need", "course", "membership", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L52-L60
train
64,097
troeger/opensubmit
web/opensubmit/models/userprofile.py
UserProfile.open_assignments
def open_assignments(self): ''' Returns the list of open assignments from the viewpoint of this user. ''' # Include only assignments with future, or no, hard deadline qs = Assignment.objects.filter(hard_deadline__gt=timezone.now( )) | Assignment.objects.fi...
python
def open_assignments(self): ''' Returns the list of open assignments from the viewpoint of this user. ''' # Include only assignments with future, or no, hard deadline qs = Assignment.objects.filter(hard_deadline__gt=timezone.now( )) | Assignment.objects.fi...
[ "def", "open_assignments", "(", "self", ")", ":", "# Include only assignments with future, or no, hard deadline", "qs", "=", "Assignment", ".", "objects", ".", "filter", "(", "hard_deadline__gt", "=", "timezone", ".", "now", "(", ")", ")", "|", "Assignment", ".", ...
Returns the list of open assignments from the viewpoint of this user.
[ "Returns", "the", "list", "of", "open", "assignments", "from", "the", "viewpoint", "of", "this", "user", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L62-L87
train
64,098
troeger/opensubmit
web/opensubmit/models/userprofile.py
UserProfile.gone_assignments
def gone_assignments(self): ''' Returns the list of past assignments the user did not submit for before the hard deadline. ''' # Include only assignments with past hard deadline qs = Assignment.objects.filter(hard_deadline__lt=timezone.now()) # Include onl...
python
def gone_assignments(self): ''' Returns the list of past assignments the user did not submit for before the hard deadline. ''' # Include only assignments with past hard deadline qs = Assignment.objects.filter(hard_deadline__lt=timezone.now()) # Include onl...
[ "def", "gone_assignments", "(", "self", ")", ":", "# Include only assignments with past hard deadline", "qs", "=", "Assignment", ".", "objects", ".", "filter", "(", "hard_deadline__lt", "=", "timezone", ".", "now", "(", ")", ")", "# Include only assignments from courses...
Returns the list of past assignments the user did not submit for before the hard deadline.
[ "Returns", "the", "list", "of", "past", "assignments", "the", "user", "did", "not", "submit", "for", "before", "the", "hard", "deadline", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/userprofile.py#L89-L99
train
64,099