id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
47,100
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
47,101
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
47,102
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
47,103
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
47,104
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
47,105
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
47,106
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
47,107
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
47,108
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
47,109
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
47,110
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
47,111
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
47,112
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
47,113
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
47,114
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
47,115
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
47,116
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
47,117
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
47,118
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
47,119
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
47,120
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
47,121
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
47,122
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
47,123
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
47,124
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
47,125
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
47,126
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
47,127
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
47,128
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
47,129
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
47,130
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
47,131
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
47,132
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
47,133
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
47,134
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
47,135
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
47,136
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
47,137
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
47,138
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
47,139
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
47,140
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
47,141
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
47,142
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
47,143
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
47,144
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
47,145
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
47,146
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
47,147
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
47,148
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
47,149
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
47,150
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
47,151
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
47,152
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
47,153
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
47,154
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
47,155
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
47,156
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
47,157
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
47,158
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
47,159
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
47,160
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
47,161
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
47,162
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
47,163
idlesign/django-sitemessage
sitemessage/messengers/smtp.py
SMTPMessenger._build_message
def _build_message(self, to, text, subject=None, mtype=None, unsubscribe_url=None): """Constructs a MIME message from message and dispatch models.""" # TODO Maybe file attachments handling through `files` message_model context var. if subject is None: subject = u'%s' % _('No Subject...
python
def _build_message(self, to, text, subject=None, mtype=None, unsubscribe_url=None): """Constructs a MIME message from message and dispatch models.""" # TODO Maybe file attachments handling through `files` message_model context var. if subject is None: subject = u'%s' % _('No Subject...
[ "def", "_build_message", "(", "self", ",", "to", ",", "text", ",", "subject", "=", "None", ",", "mtype", "=", "None", ",", "unsubscribe_url", "=", "None", ")", ":", "# TODO Maybe file attachments handling through `files` message_model context var.", "if", "subject", ...
Constructs a MIME message from message and dispatch models.
[ "Constructs", "a", "MIME", "message", "from", "message", "and", "dispatch", "models", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/smtp.py#L94-L118
47,164
troeger/opensubmit
web/opensubmit/admin/__init__.py
_social_auth_login
def _social_auth_login(self, request, **kwargs): ''' View function that redirects to social auth login, in case the user is not logged in. ''' if request.user.is_authenticated(): if not request.user.is_active or not request.user.is_staff: raise PermissionDenied() else...
python
def _social_auth_login(self, request, **kwargs): ''' View function that redirects to social auth login, in case the user is not logged in. ''' if request.user.is_authenticated(): if not request.user.is_active or not request.user.is_staff: raise PermissionDenied() else...
[ "def", "_social_auth_login", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "user", ".", "is_authenticated", "(", ")", ":", "if", "not", "request", ".", "user", ".", "is_active", "or", "not", "request", ".", "user...
View function that redirects to social auth login, in case the user is not logged in.
[ "View", "function", "that", "redirects", "to", "social", "auth", "login", "in", "case", "the", "user", "is", "not", "logged", "in", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/__init__.py#L20-L30
47,165
troeger/opensubmit
web/opensubmit/admin/course.py
CourseAdmin.get_queryset
def get_queryset(self, request): ''' Restrict the listed courses for the current user.''' qs = super(CourseAdmin, self).get_queryset(request) if request.user.is_superuser: return qs else: return qs.filter(Q(tutors__pk=request.user.pk) | Q(owner=request.user)).dist...
python
def get_queryset(self, request): ''' Restrict the listed courses for the current user.''' qs = super(CourseAdmin, self).get_queryset(request) if request.user.is_superuser: return qs else: return qs.filter(Q(tutors__pk=request.user.pk) | Q(owner=request.user)).dist...
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "super", "(", "CourseAdmin", ",", "self", ")", ".", "get_queryset", "(", "request", ")", "if", "request", ".", "user", ".", "is_superuser", ":", "return", "qs", "else", ":", "retu...
Restrict the listed courses for the current user.
[ "Restrict", "the", "listed", "courses", "for", "the", "current", "user", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/course.py#L25-L31
47,166
umich-brcf-bioinf/Connor
connor/connor.py
_build_tag_families
def _build_tag_families(tagged_paired_aligns, ranked_tags, hamming_threshold, consensus_threshold, family_filter=lambda _: None): '''Partition paired aligns into families. Each read is considered against each ranked...
python
def _build_tag_families(tagged_paired_aligns, ranked_tags, hamming_threshold, consensus_threshold, family_filter=lambda _: None): '''Partition paired aligns into families. Each read is considered against each ranked...
[ "def", "_build_tag_families", "(", "tagged_paired_aligns", ",", "ranked_tags", ",", "hamming_threshold", ",", "consensus_threshold", ",", "family_filter", "=", "lambda", "_", ":", "None", ")", ":", "tag_aligns", "=", "defaultdict", "(", "set", ")", "tag_inexact_matc...
Partition paired aligns into families. Each read is considered against each ranked tag until all reads are partitioned into families.
[ "Partition", "paired", "aligns", "into", "families", "." ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L61-L96
47,167
umich-brcf-bioinf/Connor
connor/connor.py
_rank_tags
def _rank_tags(tagged_paired_aligns): '''Return the list of tags ranked from most to least popular.''' tag_count_dict = defaultdict(int) for paired_align in tagged_paired_aligns: tag_count_dict[paired_align.umt] += 1 tags_by_count = utils.sort_dict(tag_count_dict) ranked_tags = [tag_count[0]...
python
def _rank_tags(tagged_paired_aligns): '''Return the list of tags ranked from most to least popular.''' tag_count_dict = defaultdict(int) for paired_align in tagged_paired_aligns: tag_count_dict[paired_align.umt] += 1 tags_by_count = utils.sort_dict(tag_count_dict) ranked_tags = [tag_count[0]...
[ "def", "_rank_tags", "(", "tagged_paired_aligns", ")", ":", "tag_count_dict", "=", "defaultdict", "(", "int", ")", "for", "paired_align", "in", "tagged_paired_aligns", ":", "tag_count_dict", "[", "paired_align", ".", "umt", "]", "+=", "1", "tags_by_count", "=", ...
Return the list of tags ranked from most to least popular.
[ "Return", "the", "list", "of", "tags", "ranked", "from", "most", "to", "least", "popular", "." ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L102-L109
47,168
umich-brcf-bioinf/Connor
connor/connor.py
main
def main(command_line_args=None): '''Connor entry point. See help for more info''' log = None if not command_line_args: command_line_args = sys.argv try: start_time = time.time() args = parse_command_line_args(command_line_args) log = utils.Logger(args) command_va...
python
def main(command_line_args=None): '''Connor entry point. See help for more info''' log = None if not command_line_args: command_line_args = sys.argv try: start_time = time.time() args = parse_command_line_args(command_line_args) log = utils.Logger(args) command_va...
[ "def", "main", "(", "command_line_args", "=", "None", ")", ":", "log", "=", "None", "if", "not", "command_line_args", ":", "command_line_args", "=", "sys", ".", "argv", "try", ":", "start_time", "=", "time", ".", "time", "(", ")", "args", "=", "parse_com...
Connor entry point. See help for more info
[ "Connor", "entry", "point", ".", "See", "help", "for", "more", "info" ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L151-L198
47,169
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_email
def schedule_email(message, to, subject=None, sender=None, priority=None): """Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|s...
python
def schedule_email(message, to, subject=None, sender=None, priority=None): """Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|s...
[ "def", "schedule_email", "(", "message", ",", "to", ",", "subject", "=", "None", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "if", "SHORTCUT_EMAIL_MESSAGE_TYPE", ":", "message_cls", "=", "get_registered_message_type", "(", "SHORTCUT_EMAIL...
Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|str|unicode to: recipients addresses or Django User model heir instances :param...
[ "Schedules", "an", "email", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L6-L31
47,170
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_jabber_message
def schedule_jabber_message(message, to, sender=None, priority=None): """Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instan...
python
def schedule_jabber_message(message, to, sender=None, priority=None): """Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instan...
[ "def", "schedule_jabber_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'xmppsleek'", ",", "to", ")", ",", "sender", "=", "sender", ",", ...
Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. If set overri...
[ "Schedules", "Jabber", "XMPP", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L34-L42
47,171
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_tweet
def schedule_tweet(message, to='', sender=None, priority=None): """Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User...
python
def schedule_tweet(message, to='', sender=None, priority=None): """Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User...
[ "def", "schedule_tweet", "(", "message", ",", "to", "=", "''", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'twitter'", ",", "to", ")", ",", "sender", "=", "sender", "...
Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User sender: User model heir instance :param int priority: number descr...
[ "Schedules", "a", "Tweet", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L45-L54
47,172
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_telegram_message
def schedule_telegram_message(message, to, sender=None, priority=None): """Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir inst...
python
def schedule_telegram_message(message, to, sender=None, priority=None): """Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir inst...
[ "def", "schedule_telegram_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'telegram'", ",", "to", ")", ",", "sender", "=", "sender", ",",...
Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. If set overri...
[ "Schedules", "Telegram", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L57-L65
47,173
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_facebook_message
def schedule_facebook_message(message, sender=None, priority=None): """Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with ...
python
def schedule_facebook_message(message, sender=None, priority=None): """Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with ...
[ "def", "schedule_facebook_message", "(", "message", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'fb'", ",", "''", ")", ",", "sender", "=", "sender", ",", "priority", "=",...
Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with message type.
[ "Schedules", "Facebook", "wall", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L68-L75
47,174
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_vkontakte_message
def schedule_vkontakte_message(message, to, sender=None, priority=None): """Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User m...
python
def schedule_vkontakte_message(message, to, sender=None, priority=None): """Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User m...
[ "def", "schedule_vkontakte_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'vk'", ",", "to", ")", ",", "sender", "=", "sender", ",", "p...
Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. ...
[ "Schedules", "VKontakte", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L78-L86
47,175
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.get_alias
def get_alias(cls): """Returns messenger alias. :return: str :rtype: str """ if cls.alias is None: cls.alias = cls.__name__ return cls.alias
python
def get_alias(cls): """Returns messenger alias. :return: str :rtype: str """ if cls.alias is None: cls.alias = cls.__name__ return cls.alias
[ "def", "get_alias", "(", "cls", ")", ":", "if", "cls", ".", "alias", "is", "None", ":", "cls", ".", "alias", "=", "cls", ".", "__name__", "return", "cls", ".", "alias" ]
Returns messenger alias. :return: str :rtype: str
[ "Returns", "messenger", "alias", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L28-L36
47,176
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase._structure_recipients_data
def _structure_recipients_data(cls, recipients): """Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list """ try: # That's all due Django 1.7 apps loading. from django.cont...
python
def _structure_recipients_data(cls, recipients): """Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list """ try: # That's all due Django 1.7 apps loading. from django.cont...
[ "def", "_structure_recipients_data", "(", "cls", ",", "recipients", ")", ":", "try", ":", "# That's all due Django 1.7 apps loading.", "from", "django", ".", "contrib", ".", "auth", "import", "get_user_model", "USER_MODEL", "=", "get_user_model", "(", ")", "except", ...
Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list
[ "Converts", "recipients", "data", "into", "a", "list", "of", "Recipient", "objects", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L89-L115
47,177
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.mark_error
def mark_error(self, dispatch, error_log, message_cls): """Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message ...
python
def mark_error(self, dispatch, error_log, message_cls): """Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message ...
[ "def", "mark_error", "(", "self", ",", "dispatch", ",", "error_log", ",", "message_cls", ")", ":", "if", "message_cls", ".", "send_retry_limit", "is", "not", "None", "and", "(", "dispatch", ".", "retry_count", "+", "1", ")", ">=", "message_cls", ".", "send...
Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message :param MessageBase message_cls: MessageBase heir
[ "Marks", "a", "dispatch", "as", "having", "error", "or", "consequently", "as", "failed", "if", "send", "retry", "limit", "for", "that", "message", "type", "is", "exhausted", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L144-L158
47,178
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.mark_failed
def mark_failed(self, dispatch, error_log): """Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message """ dispatch.error_...
python
def mark_failed(self, dispatch, error_log): """Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message """ dispatch.error_...
[ "def", "mark_failed", "(", "self", ",", "dispatch", ",", "error_log", ")", ":", "dispatch", ".", "error_log", "=", "error_log", "self", ".", "_st", "[", "'failed'", "]", ".", "append", "(", "dispatch", ")" ]
Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message
[ "Marks", "a", "dispatch", "as", "failed", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L160-L171
47,179
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase._process_messages
def _process_messages(self, messages, ignore_unknown_message_types=False): """Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError: ...
python
def _process_messages(self, messages, ignore_unknown_message_types=False): """Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError: ...
[ "def", "_process_messages", "(", "self", ",", "messages", ",", "ignore_unknown_message_types", "=", "False", ")", ":", "with", "self", ".", "before_after_send_handling", "(", ")", ":", "for", "message_id", ",", "message_data", "in", "messages", ".", "items", "("...
Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError:
[ "Performs", "message", "processing", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L185-L217
47,180
tg123/bottle-mysql
bottle_mysql.py
MySQLPlugin.setup
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument. ''' for other in app.plugins: if not isinstance(other, MySQLPlugin): continue if other.keyword == self.keyword: raise PluginErr...
python
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument. ''' for other in app.plugins: if not isinstance(other, MySQLPlugin): continue if other.keyword == self.keyword: raise PluginErr...
[ "def", "setup", "(", "self", ",", "app", ")", ":", "for", "other", "in", "app", ".", "plugins", ":", "if", "not", "isinstance", "(", "other", ",", "MySQLPlugin", ")", ":", "continue", "if", "other", ".", "keyword", "==", "self", ".", "keyword", ":", ...
Make sure that other installed plugins don't affect the same keyword argument.
[ "Make", "sure", "that", "other", "installed", "plugins", "don", "t", "affect", "the", "same", "keyword", "argument", "." ]
6e7a7ae034f7735334c664bb0af6e7c72e15cbd9
https://github.com/tg123/bottle-mysql/blob/6e7a7ae034f7735334c664bb0af6e7c72e15cbd9/bottle_mysql.py#L79-L89
47,181
troeger/opensubmit
web/opensubmit/views/demo.py
assign_role
def assign_role(backend, user, response, *args, **kwargs): ''' Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group. ''' if backend.name is 'passthrough' and settings.DEMO is True and 'role' in kwargs['request'].session[passthrough.SESSION_VAR]: ...
python
def assign_role(backend, user, response, *args, **kwargs): ''' Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group. ''' if backend.name is 'passthrough' and settings.DEMO is True and 'role' in kwargs['request'].session[passthrough.SESSION_VAR]: ...
[ "def", "assign_role", "(", "backend", ",", "user", ",", "response", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "backend", ".", "name", "is", "'passthrough'", "and", "settings", ".", "DEMO", "is", "True", "and", "'role'", "in", "kwargs",...
Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group.
[ "Part", "of", "the", "Python", "Social", "Auth", "Pipeline", ".", "Checks", "if", "the", "created", "demo", "user", "should", "be", "pushed", "into", "some", "group", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/views/demo.py#L13-L25
47,182
troeger/opensubmit
executor/opensubmitexec/server.py
fetch
def fetch(url, fullpath): ''' Fetch data from an URL and save it under the given target name. ''' logger.debug("Fetching %s from %s" % (fullpath, url)) try: tmpfile, headers = urlretrieve(url) if os.path.exists(fullpath): os.remove(fullpath) shutil.move(tmpfile, ...
python
def fetch(url, fullpath): ''' Fetch data from an URL and save it under the given target name. ''' logger.debug("Fetching %s from %s" % (fullpath, url)) try: tmpfile, headers = urlretrieve(url) if os.path.exists(fullpath): os.remove(fullpath) shutil.move(tmpfile, ...
[ "def", "fetch", "(", "url", ",", "fullpath", ")", ":", "logger", ".", "debug", "(", "\"Fetching %s from %s\"", "%", "(", "fullpath", ",", "url", ")", ")", "try", ":", "tmpfile", ",", "headers", "=", "urlretrieve", "(", "url", ")", "if", "os", ".", "p...
Fetch data from an URL and save it under the given target name.
[ "Fetch", "data", "from", "an", "URL", "and", "save", "it", "under", "the", "given", "target", "name", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L24-L37
47,183
troeger/opensubmit
executor/opensubmitexec/server.py
send_post
def send_post(config, urlpath, post_data): ''' Send POST data to an OpenSubmit server url path, according to the configuration. ''' server = config.get("Server", "url") logger.debug("Sending executor payload to " + server) post_data = urlencode(post_data) post_data = post_data.encode("ut...
python
def send_post(config, urlpath, post_data): ''' Send POST data to an OpenSubmit server url path, according to the configuration. ''' server = config.get("Server", "url") logger.debug("Sending executor payload to " + server) post_data = urlencode(post_data) post_data = post_data.encode("ut...
[ "def", "send_post", "(", "config", ",", "urlpath", ",", "post_data", ")", ":", "server", "=", "config", ".", "get", "(", "\"Server\"", ",", "\"url\"", ")", "logger", ".", "debug", "(", "\"Sending executor payload to \"", "+", "server", ")", "post_data", "=",...
Send POST data to an OpenSubmit server url path, according to the configuration.
[ "Send", "POST", "data", "to", "an", "OpenSubmit", "server", "url", "path", "according", "to", "the", "configuration", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L39-L52
47,184
troeger/opensubmit
executor/opensubmitexec/server.py
send_hostinfo
def send_hostinfo(config): ''' Register this host on OpenSubmit test machine. ''' info = all_host_infos() logger.debug("Sending host information: " + str(info)) post_data = [("Config", json.dumps(info)), ("Action", "get_config"), ("UUID", config.get("Server", "u...
python
def send_hostinfo(config): ''' Register this host on OpenSubmit test machine. ''' info = all_host_infos() logger.debug("Sending host information: " + str(info)) post_data = [("Config", json.dumps(info)), ("Action", "get_config"), ("UUID", config.get("Server", "u...
[ "def", "send_hostinfo", "(", "config", ")", ":", "info", "=", "all_host_infos", "(", ")", "logger", ".", "debug", "(", "\"Sending host information: \"", "+", "str", "(", "info", ")", ")", "post_data", "=", "[", "(", "\"Config\"", ",", "json", ".", "dumps",...
Register this host on OpenSubmit test machine.
[ "Register", "this", "host", "on", "OpenSubmit", "test", "machine", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L55-L68
47,185
troeger/opensubmit
executor/opensubmitexec/server.py
compatible_api_version
def compatible_api_version(server_version): ''' Check if this server API version is compatible to us. ''' try: semver = server_version.split('.') if semver[0] != '1': logger.error( 'Server API version (%s) is too new for us. Please update the executor installa...
python
def compatible_api_version(server_version): ''' Check if this server API version is compatible to us. ''' try: semver = server_version.split('.') if semver[0] != '1': logger.error( 'Server API version (%s) is too new for us. Please update the executor installa...
[ "def", "compatible_api_version", "(", "server_version", ")", ":", "try", ":", "semver", "=", "server_version", ".", "split", "(", "'.'", ")", "if", "semver", "[", "0", "]", "!=", "'1'", ":", "logger", ".", "error", "(", "'Server API version (%s) is too new for...
Check if this server API version is compatible to us.
[ "Check", "if", "this", "server", "API", "version", "is", "compatible", "to", "us", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L71-L86
47,186
troeger/opensubmit
executor/opensubmitexec/server.py
fetch_job
def fetch_job(config): ''' Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly. ''' url = "%s/jobs/?Secret=%s&UUID=%s" % (config.get("Server", "url"), ...
python
def fetch_job(config): ''' Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly. ''' url = "%s/jobs/?Secret=%s&UUID=%s" % (config.get("Server", "url"), ...
[ "def", "fetch_job", "(", "config", ")", ":", "url", "=", "\"%s/jobs/?Secret=%s&UUID=%s\"", "%", "(", "config", ".", "get", "(", "\"Server\"", ",", "\"url\"", ")", ",", "config", ".", "get", "(", "\"Server\"", ",", "\"secret\"", ")", ",", "config", ".", "...
Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly.
[ "Fetch", "any", "available", "work", "from", "the", "OpenSubmit", "server", "and", "return", "an", "according", "job", "object", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L89-L168
47,187
troeger/opensubmit
executor/opensubmitexec/server.py
fake_fetch_job
def fake_fetch_job(config, src_dir): ''' Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py. ''' logger.debug("Creating fake job from " + src_dir) ...
python
def fake_fetch_job(config, src_dir): ''' Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py. ''' logger.debug("Creating fake job from " + src_dir) ...
[ "def", "fake_fetch_job", "(", "config", ",", "src_dir", ")", ":", "logger", ".", "debug", "(", "\"Creating fake job from \"", "+", "src_dir", ")", "from", ".", "job", "import", "Job", "job", "=", "Job", "(", "config", ",", "online", "=", "False", ")", "j...
Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py.
[ "Act", "like", "fetch_job", "but", "take", "the", "validator", "file", "and", "the", "student", "submission", "files", "directly", "from", "a", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L171-L205
47,188
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_configure
def run_configure(self, mandatory=True): """Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing. """ if not has_file(self.working_dir, 'configure')...
python
def run_configure(self, mandatory=True): """Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing. """ if not has_file(self.working_dir, 'configure')...
[ "def", "run_configure", "(", "self", ",", "mandatory", "=", "True", ")", ":", "if", "not", "has_file", "(", "self", ".", "working_dir", ",", "'configure'", ")", ":", "if", "mandatory", ":", "raise", "FileNotFoundError", "(", "\"Could not find a configure script ...
Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing.
[ "Runs", "the", "configure", "program", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L81-L100
47,189
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_compiler
def run_compiler(self, compiler=GCC, inputs=None, output=None): """Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tupl...
python
def run_compiler(self, compiler=GCC, inputs=None, output=None): """Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tupl...
[ "def", "run_compiler", "(", "self", ",", "compiler", "=", "GCC", ",", "inputs", "=", "None", ",", "output", "=", "None", ")", ":", "# Let exceptions travel through", "prog", "=", "RunningProgram", "(", "self", ",", "*", "compiler_cmdline", "(", "compiler", "...
Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tuple): The list of input files for the compiler. output (str): ...
[ "Runs", "a", "compiler", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L122-L136
47,190
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_build
def run_build(self, compiler=GCC, inputs=None, output=None): """Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler. """ logger.info("Running build steps ...") self.run_...
python
def run_build(self, compiler=GCC, inputs=None, output=None): """Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler. """ logger.info("Running build steps ...") self.run_...
[ "def", "run_build", "(", "self", ",", "compiler", "=", "GCC", ",", "inputs", "=", "None", ",", "output", "=", "None", ")", ":", "logger", ".", "info", "(", "\"Running build steps ...\"", ")", "self", ".", "run_configure", "(", "mandatory", "=", "False", ...
Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler.
[ "Combined", "call", "of", "configure", "make", "and", "the", "compiler", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L138-L150
47,191
troeger/opensubmit
executor/opensubmitexec/job.py
Job.spawn_program
def spawn_program(self, name, arguments=[], timeout=30, exclusive=False): """Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program...
python
def spawn_program(self, name, arguments=[], timeout=30, exclusive=False): """Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program...
[ "def", "spawn_program", "(", "self", ",", "name", ",", "arguments", "=", "[", "]", ",", "timeout", "=", "30", ",", "exclusive", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Spawning program for interaction ...\"", ")", "if", "exclusive", ":", "k...
Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the progra...
[ "Spawns", "a", "program", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L152-L174
47,192
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_program
def run_program(self, name, arguments=[], timeout=30, exclusive=False): """Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int)...
python
def run_program(self, name, arguments=[], timeout=30, exclusive=False): """Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int)...
[ "def", "run_program", "(", "self", ",", "name", ",", "arguments", "=", "[", "]", ",", "timeout", "=", "30", ",", "exclusive", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Running program ...\"", ")", "if", "exclusive", ":", "kill_longrunning", ...
Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int): The timeout for execution. exclusive (bool): Prevent parallel va...
[ "Runs", "a", "program", "in", "the", "working", "directory", "to", "completion", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L176-L196
47,193
troeger/opensubmit
executor/opensubmitexec/job.py
Job.grep
def grep(self, regex): """Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory. """ matches = [] logger...
python
def grep(self, regex): """Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory. """ matches = [] logger...
[ "def", "grep", "(", "self", ",", "regex", ")", ":", "matches", "=", "[", "]", "logger", ".", "debug", "(", "\"Searching student files for '{0}'\"", ".", "format", "(", "regex", ")", ")", "for", "fname", "in", "self", ".", "student_files", ":", "if", "os"...
Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory.
[ "Scans", "the", "student", "files", "for", "text", "patterns", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L198-L215
47,194
troeger/opensubmit
executor/opensubmitexec/job.py
Job.ensure_files
def ensure_files(self, filenames): """Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive. """ logger.debug("Testing {...
python
def ensure_files(self, filenames): """Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive. """ logger.debug("Testing {...
[ "def", "ensure_files", "(", "self", ",", "filenames", ")", ":", "logger", ".", "debug", "(", "\"Testing {0} for the following files: {1}\"", ".", "format", "(", "self", ".", "working_dir", ",", "filenames", ")", ")", "dircontent", "=", "os", ".", "listdir", "(...
Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive.
[ "Checks", "the", "student", "submission", "for", "specific", "files", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L217-L232
47,195
praekelt/django-livechat
livechat/templatetags/livechat_tags.py
live_chat_banner
def live_chat_banner(context): """ Display any available live chats as advertisements. """ context = copy(context) # Find any upcoming or current live chat. The Chat date must be less than 5 # days away, or currently in progress. oldchat = LiveChat.chat_finder.get_last_live_chat() if oldc...
python
def live_chat_banner(context): """ Display any available live chats as advertisements. """ context = copy(context) # Find any upcoming or current live chat. The Chat date must be less than 5 # days away, or currently in progress. oldchat = LiveChat.chat_finder.get_last_live_chat() if oldc...
[ "def", "live_chat_banner", "(", "context", ")", ":", "context", "=", "copy", "(", "context", ")", "# Find any upcoming or current live chat. The Chat date must be less than 5", "# days away, or currently in progress.", "oldchat", "=", "LiveChat", ".", "chat_finder", ".", "get...
Display any available live chats as advertisements.
[ "Display", "any", "available", "live", "chats", "as", "advertisements", "." ]
22d86fb4219e5af6c83e0542aa30e5ea54e71d26
https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/templatetags/livechat_tags.py#L18-L58
47,196
troeger/opensubmit
executor/opensubmitexec/running.py
kill_longrunning
def kill_longrunning(config): ''' Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ... '''...
python
def kill_longrunning(config): ''' Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ... '''...
[ "def", "kill_longrunning", "(", "config", ")", ":", "import", "psutil", "ourpid", "=", "os", ".", "getpid", "(", ")", "username", "=", "psutil", ".", "Process", "(", "ourpid", ")", ".", "username", "# Check for other processes running under this account", "# Take ...
Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ...
[ "Terminate", "everything", "under", "the", "current", "user", "account", "that", "has", "run", "too", "long", ".", "This", "is", "a", "final", "safeguard", "if", "the", "subprocess", "timeout", "stuff", "is", "not", "working", ".", "You", "better", "have", ...
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L12-L36
47,197
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.get_exitstatus
def get_exitstatus(self): """Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available. """ logger.debug("Exit status is {0}".format(self._spawn.exitstatus)) return sel...
python
def get_exitstatus(self): """Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available. """ logger.debug("Exit status is {0}".format(self._spawn.exitstatus)) return sel...
[ "def", "get_exitstatus", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Exit status is {0}\"", ".", "format", "(", "self", ".", "_spawn", ".", "exitstatus", ")", ")", "return", "self", ".", "_spawn", ".", "exitstatus" ]
Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available.
[ "Get", "the", "exit", "status", "of", "the", "program", "execution", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L67-L75
47,198
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.expect_output
def expect_output(self, pattern, timeout=-1): """Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argumen...
python
def expect_output(self, pattern, timeout=-1): """Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argumen...
[ "def", "expect_output", "(", "self", ",", "pattern", ",", "timeout", "=", "-", "1", ")", ":", "logger", ".", "debug", "(", "\"Expecting output '{0}' from '{1}'\"", ".", "format", "(", "pattern", ",", "self", ".", "name", ")", ")", "try", ":", "return", "...
Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argument may be a string, a compiled regular expression, ...
[ "Wait", "until", "the", "running", "program", "performs", "some", "given", "output", "or", "terminates", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L105-L134
47,199
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.sendline
def sendline(self, text): """Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An in...
python
def sendline(self, text): """Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An in...
[ "def", "sendline", "(", "self", ",", "text", ")", ":", "logger", ".", "debug", "(", "\"Sending input '{0}' to '{1}'\"", ".", "format", "(", "text", ",", "self", ".", "name", ")", ")", "try", ":", "return", "self", ".", "_spawn", ".", "sendline", "(", "...
Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An internal problem occured while waiting ...
[ "Sends", "an", "input", "line", "to", "the", "running", "program", "including", "os", ".", "linesep", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L136-L157