partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
bowshock_logger
creates a logger obj
bowshock/helpers.py
def bowshock_logger(): '''creates a logger obj''' FORMAT = '%(asctime)-15s %(message)s' logging.basicConfig(format=FORMAT, level=logging.INFO) logger = logging.getLogger('bowshock_logger') return logger
def bowshock_logger(): '''creates a logger obj''' FORMAT = '%(asctime)-15s %(message)s' logging.basicConfig(format=FORMAT, level=logging.INFO) logger = logging.getLogger('bowshock_logger') return logger
[ "creates", "a", "logger", "obj" ]
emirozer/bowshock
python
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/helpers.py#L7-L14
[ "def", "bowshock_logger", "(", ")", ":", "FORMAT", "=", "'%(asctime)-15s %(message)s'", "logging", ".", "basicConfig", "(", "format", "=", "FORMAT", ",", "level", "=", "logging", ".", "INFO", ")", "logger", "=", "logging", ".", "getLogger", "(", "'bowshock_log...
9f5e053f1d54995b833b83616f37c67178c3e840
train
TreeCollectionsGitAction.remove_collection
Remove a collection Given a collection_id, branch and optionally an author, remove a collection on the given branch and attribute the commit to author. Returns the SHA of the commit on branch.
peyotl/collections_store/git_actions.py
def remove_collection(self, first_arg, sec_arg, third_arg, fourth_arg=None, commit_msg=None): """Remove a collection Given a collection_id, branch and optionally an author, remove a collection on the given branch and attribute the commit to author. Returns the SHA of the commit o...
def remove_collection(self, first_arg, sec_arg, third_arg, fourth_arg=None, commit_msg=None): """Remove a collection Given a collection_id, branch and optionally an author, remove a collection on the given branch and attribute the commit to author. Returns the SHA of the commit o...
[ "Remove", "a", "collection", "Given", "a", "collection_id", "branch", "and", "optionally", "an", "author", "remove", "a", "collection", "on", "the", "given", "branch", "and", "attribute", "the", "commit", "to", "author", ".", "Returns", "the", "SHA", "of", "...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/git_actions.py#L92-L107
[ "def", "remove_collection", "(", "self", ",", "first_arg", ",", "sec_arg", ",", "third_arg", ",", "fourth_arg", "=", "None", ",", "commit_msg", "=", "None", ")", ":", "if", "fourth_arg", "is", "None", ":", "collection_id", ",", "branch_name", ",", "author", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
TreeCollectionsGitAction.write_collection
Given a collection_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master...
peyotl/collections_store/git_actions.py
def write_collection(self, collection_id, file_content, branch, author): """Given a collection_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master... """ gh_user = branch.split('_collection_')[0] msg = "Update Col...
def write_collection(self, collection_id, file_content, branch, author): """Given a collection_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master... """ gh_user = branch.split('_collection_')[0] msg = "Update Col...
[ "Given", "a", "collection_id", "temporary", "filename", "of", "content", "branch", "and", "auth_info" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/git_actions.py#L109-L121
[ "def", "write_collection", "(", "self", ",", "collection_id", ",", "file_content", ",", "branch", ",", "author", ")", ":", "gh_user", "=", "branch", ".", "split", "(", "'_collection_'", ")", "[", "0", "]", "msg", "=", "\"Update Collection '%s' via OpenTree API\"...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
TreeCollectionsGitAction.write_collection_from_tmpfile
Given a collection_id, temporary filename of content, branch and auth_info
peyotl/collections_store/git_actions.py
def write_collection_from_tmpfile(self, collection_id, tmpfi, parent_sha, auth_info, commit_msg=''): """Given a collection_id, temporary filename of content, branch and auth_info """ return self.write_doc_from_tmpfile(collection_id, tmpfi, ...
def write_collection_from_tmpfile(self, collection_id, tmpfi, parent_sha, auth_info, commit_msg=''): """Given a collection_id, temporary filename of content, branch and auth_info """ return self.write_doc_from_tmpfile(collection_id, tmpfi, ...
[ "Given", "a", "collection_id", "temporary", "filename", "of", "content", "branch", "and", "auth_info" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/git_actions.py#L123-L131
[ "def", "write_collection_from_tmpfile", "(", "self", ",", "collection_id", ",", "tmpfi", ",", "parent_sha", ",", "auth_info", ",", "commit_msg", "=", "''", ")", ":", "return", "self", ".", "write_doc_from_tmpfile", "(", "collection_id", ",", "tmpfi", ",", "paren...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
Verifier.load_cache
Load caches and archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load event, also used as subdirectory for cache archives. :param archive: whether to archive caches to disk :return...
von_agent/agent/verifier.py
async def load_cache(self, archive: bool = False) -> int: """ Load caches and archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load event, also used as subdirectory for cache archiv...
async def load_cache(self, archive: bool = False) -> int: """ Load caches and archive enough to go offline and be able to verify proof on content marked of interest in configuration. Return timestamp (epoch seconds) of cache load event, also used as subdirectory for cache archiv...
[ "Load", "caches", "and", "archive", "enough", "to", "go", "offline", "and", "be", "able", "to", "verify", "proof", "on", "content", "marked", "of", "interest", "in", "configuration", "." ]
PSPC-SPAC-buyandsell/von_agent
python
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/verifier.py#L165-L204
[ "async", "def", "load_cache", "(", "self", ",", "archive", ":", "bool", "=", "False", ")", "->", "int", ":", "LOGGER", ".", "debug", "(", "'Verifier.load_cache >>> archive: %s'", ",", "archive", ")", "rv", "=", "int", "(", "time", "(", ")", ")", "for", ...
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
train
Verifier.open
Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object
von_agent/agent/verifier.py
async def open(self) -> 'HolderProver': """ Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Verifier.open >>...
async def open(self) -> 'HolderProver': """ Explicit entry. Perform ancestor opening operations, then parse cache from archive if so configured, and synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Verifier.open >>...
[ "Explicit", "entry", ".", "Perform", "ancestor", "opening", "operations", "then", "parse", "cache", "from", "archive", "if", "so", "configured", "and", "synchronize", "revocation", "registry", "to", "tails", "tree", "content", "." ]
PSPC-SPAC-buyandsell/von_agent
python
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/verifier.py#L206-L222
[ "async", "def", "open", "(", "self", ")", "->", "'HolderProver'", ":", "LOGGER", ".", "debug", "(", "'Verifier.open >>>'", ")", "await", "super", "(", ")", ".", "open", "(", ")", "if", "self", ".", "cfg", ".", "get", "(", "'parse-cache-on-open'", ",", ...
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
train
Verifier.close
Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object
von_agent/agent/verifier.py
async def close(self) -> None: """ Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object ""...
async def close(self) -> None: """ Explicit exit. If so configured, populate cache to prove for any creds on schemata, cred defs, and rev regs marked of interest in configuration at initialization, archive cache, and purge prior cache archives. :return: current object ""...
[ "Explicit", "exit", ".", "If", "so", "configured", "populate", "cache", "to", "prove", "for", "any", "creds", "on", "schemata", "cred", "defs", "and", "rev", "regs", "marked", "of", "interest", "in", "configuration", "at", "initialization", "archive", "cache",...
PSPC-SPAC-buyandsell/von_agent
python
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/verifier.py#L224-L241
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'Verifier.close >>>'", ")", "if", "self", ".", "cfg", ".", "get", "(", "'archive-on-close'", ",", "{", "}", ")", ":", "await", "self", ".", "load_cache", "(", ...
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
train
Verifier.verify_proof
Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above :param proof: proof as HolderProver creates :return: json encoded True if p...
von_agent/agent/verifier.py
async def verify_proof(self, proof_req: dict, proof: dict) -> str: """ Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above ...
async def verify_proof(self, proof_req: dict, proof: dict) -> str: """ Verify proof as Verifier. Raise AbsentRevReg if a proof cites a revocation registry that does not exist on the distributed ledger. :param proof_req: proof request as Verifier creates, as per proof_req_json above ...
[ "Verify", "proof", "as", "Verifier", ".", "Raise", "AbsentRevReg", "if", "a", "proof", "cites", "a", "revocation", "registry", "that", "does", "not", "exist", "on", "the", "distributed", "ledger", "." ]
PSPC-SPAC-buyandsell/von_agent
python
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/verifier.py#L243-L306
[ "async", "def", "verify_proof", "(", "self", ",", "proof_req", ":", "dict", ",", "proof", ":", "dict", ")", "->", "str", ":", "LOGGER", ".", "debug", "(", "'Verifier.verify_proof >>> proof_req: %s, proof: %s'", ",", "proof_req", ",", "proof", ")", "s_id2schema",...
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
train
_Permission.can
Grant permission if owner or admin.
invenio_communities/permissions.py
def can(self): """Grant permission if owner or admin.""" return str(current_user.get_id()) == str(self.community.id_user) or \ DynamicPermission(ActionNeed('admin-access')).can()
def can(self): """Grant permission if owner or admin.""" return str(current_user.get_id()) == str(self.community.id_user) or \ DynamicPermission(ActionNeed('admin-access')).can()
[ "Grant", "permission", "if", "owner", "or", "admin", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/permissions.py#L46-L49
[ "def", "can", "(", "self", ")", ":", "return", "str", "(", "current_user", ".", "get_id", "(", ")", ")", "==", "str", "(", "self", ".", "community", ".", "id_user", ")", "or", "DynamicPermission", "(", "ActionNeed", "(", "'admin-access'", ")", ")", "."...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
tabular2html
Creates an html representation of tabular data, either from a tabarray or an externa file (`including ``.hsv``, ``.csv``, ``.tsv``). If no data is directly provided by passing a tabarray to `X`, then a tabarray is constructed using :func:`tabular.tabarray.tabarray.__new__`. **Parameters** ...
tabular/web.py
def tabular2html(fname=None, X=None, fin=None, title=None, printheader=False, split=True, usecss=None, writecss=None, SERVERNAME=None, SERVER_FROM_CURDIR='../', ROWS_PER_PAGE=1000, returnstring = False, **kwargs): """ Creates an html representation of tabula...
def tabular2html(fname=None, X=None, fin=None, title=None, printheader=False, split=True, usecss=None, writecss=None, SERVERNAME=None, SERVER_FROM_CURDIR='../', ROWS_PER_PAGE=1000, returnstring = False, **kwargs): """ Creates an html representation of tabula...
[ "Creates", "an", "html", "representation", "of", "tabular", "data", "either", "from", "a", "tabarray", "or", "an", "externa", "file", "(", "including", ".", "hsv", ".", "csv", ".", "tsv", ")", ".", "If", "no", "data", "is", "directly", "provided", "by", ...
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/web.py#L22-L318
[ "def", "tabular2html", "(", "fname", "=", "None", ",", "X", "=", "None", ",", "fin", "=", "None", ",", "title", "=", "None", ",", "printheader", "=", "False", ",", "split", "=", "True", ",", "usecss", "=", "None", ",", "writecss", "=", "None", ",",...
1caf091c8c395960a9ad7078f95158b533cc52dd
train
space_events
lat & lon expect decimal latitude and longitude values. (Required) elevation assumes meters. (Optional) limit assumes an integer. Default is 5. (Optional) date expects an ISO 8601 formatted date. (Optional)
bowshock/predictthesky.py
def space_events(lon=None, lat=None, limit=None, date=None): ''' lat & lon expect decimal latitude and longitude values. (Required) elevation assumes meters. (Optional) limit assumes an integer. Default is 5. (Optional) date expects an ISO 8601 formatted date. (Optional) ''' base_url =...
def space_events(lon=None, lat=None, limit=None, date=None): ''' lat & lon expect decimal latitude and longitude values. (Required) elevation assumes meters. (Optional) limit assumes an integer. Default is 5. (Optional) date expects an ISO 8601 formatted date. (Optional) ''' base_url =...
[ "lat", "&", "lon", "expect", "decimal", "latitude", "and", "longitude", "values", ".", "(", "Required", ")", "elevation", "assumes", "meters", ".", "(", "Optional", ")", "limit", "assumes", "an", "integer", ".", "Default", "is", "5", ".", "(", "Optional", ...
emirozer/bowshock
python
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/predictthesky.py#L20-L66
[ "def", "space_events", "(", "lon", "=", "None", ",", "lat", "=", "None", ",", "limit", "=", "None", ",", "date", "=", "None", ")", ":", "base_url", "=", "'http://api.predictthesky.org/?'", "if", "not", "lon", "or", "not", "lat", ":", "raise", "ValueError...
9f5e053f1d54995b833b83616f37c67178c3e840
train
listunion
Take the union of a list of lists. Take a Python list of Python lists:: [[l11,l12, ...], [l21,l22, ...], ... , [ln1, ln2, ...]] and return the aggregated list:: [l11,l12, ..., l21, l22 , ...] For a list of two lists, e.g. `[a, b]`, this is like:: a.extend(b) **...
tabular/utils.py
def listunion(ListOfLists): """ Take the union of a list of lists. Take a Python list of Python lists:: [[l11,l12, ...], [l21,l22, ...], ... , [ln1, ln2, ...]] and return the aggregated list:: [l11,l12, ..., l21, l22 , ...] For a list of two lists, e.g. `[a, b]`, this is...
def listunion(ListOfLists): """ Take the union of a list of lists. Take a Python list of Python lists:: [[l11,l12, ...], [l21,l22, ...], ... , [ln1, ln2, ...]] and return the aggregated list:: [l11,l12, ..., l21, l22 , ...] For a list of two lists, e.g. `[a, b]`, this is...
[ "Take", "the", "union", "of", "a", "list", "of", "lists", "." ]
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/utils.py#L49-L83
[ "def", "listunion", "(", "ListOfLists", ")", ":", "u", "=", "[", "]", "for", "s", "in", "ListOfLists", ":", "if", "s", "!=", "None", ":", "u", ".", "extend", "(", "s", ")", "return", "u" ]
1caf091c8c395960a9ad7078f95158b533cc52dd
train
perminverse
Fast inverse of a (numpy) permutation. **Paramters** **s** : sequence Sequence of indices giving a permutation. **Returns** **inv** : numpy array Sequence of indices giving the inverse of permutation `s`.
tabular/utils.py
def perminverse(s): ''' Fast inverse of a (numpy) permutation. **Paramters** **s** : sequence Sequence of indices giving a permutation. **Returns** **inv** : numpy array Sequence of indices giving the inverse of permutation `s`. ...
def perminverse(s): ''' Fast inverse of a (numpy) permutation. **Paramters** **s** : sequence Sequence of indices giving a permutation. **Returns** **inv** : numpy array Sequence of indices giving the inverse of permutation `s`. ...
[ "Fast", "inverse", "of", "a", "(", "numpy", ")", "permutation", "." ]
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/utils.py#L93-L112
[ "def", "perminverse", "(", "s", ")", ":", "X", "=", "np", ".", "array", "(", "range", "(", "len", "(", "s", ")", ")", ")", "X", "[", "s", "]", "=", "range", "(", "len", "(", "s", ")", ")", "return", "X" ]
1caf091c8c395960a9ad7078f95158b533cc52dd
train
listarraytranspose
Tranposes the simple array presentation of a list of lists (of equal length). Argument: L = [row1, row2, ...., rowN] where the rowi are python lists of equal length. Returns: LT, a list of python lists such that LT[j][i] = L[i][j].
tabular/utils.py
def listarraytranspose(L): ''' Tranposes the simple array presentation of a list of lists (of equal length). Argument: L = [row1, row2, ...., rowN] where the rowi are python lists of equal length. Returns: LT, a list of python lists such that LT[j][i] = L[i][j]. ''' retur...
def listarraytranspose(L): ''' Tranposes the simple array presentation of a list of lists (of equal length). Argument: L = [row1, row2, ...., rowN] where the rowi are python lists of equal length. Returns: LT, a list of python lists such that LT[j][i] = L[i][j]. ''' retur...
[ "Tranposes", "the", "simple", "array", "presentation", "of", "a", "list", "of", "lists", "(", "of", "equal", "length", ")", ".", "Argument", ":", "L", "=", "[", "row1", "row2", "....", "rowN", "]", "where", "the", "rowi", "are", "python", "lists", "of"...
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/utils.py#L141-L150
[ "def", "listarraytranspose", "(", "L", ")", ":", "return", "[", "[", "row", "[", "i", "]", "for", "row", "in", "L", "]", "for", "i", "in", "range", "(", "len", "(", "L", "[", "0", "]", ")", ")", "]" ]
1caf091c8c395960a9ad7078f95158b533cc52dd
train
DEFAULT_TYPEINFERER
Infer the data type (int, float, str) of a list of strings. Take a list of strings, and attempts to infer a numeric data type that fits them all. If the strings are all integers, returns a NumPy array of integers. If the strings are all floats, returns a NumPy array of floats. Otherwise, returns...
tabular/utils.py
def DEFAULT_TYPEINFERER(column): """ Infer the data type (int, float, str) of a list of strings. Take a list of strings, and attempts to infer a numeric data type that fits them all. If the strings are all integers, returns a NumPy array of integers. If the strings are all floats, returns a N...
def DEFAULT_TYPEINFERER(column): """ Infer the data type (int, float, str) of a list of strings. Take a list of strings, and attempts to infer a numeric data type that fits them all. If the strings are all integers, returns a NumPy array of integers. If the strings are all floats, returns a N...
[ "Infer", "the", "data", "type", "(", "int", "float", "str", ")", "of", "a", "list", "of", "strings", "." ]
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/utils.py#L314-L356
[ "def", "DEFAULT_TYPEINFERER", "(", "column", ")", ":", "try", ":", "return", "np", ".", "array", "(", "[", "int", "(", "x", ")", "for", "x", "in", "column", "]", ",", "'int'", ")", "except", ":", "try", ":", "return", "np", ".", "array", "(", "["...
1caf091c8c395960a9ad7078f95158b533cc52dd
train
DEFAULT_NULLVALUE
Returns a null value for each of various kinds of test values. **Parameters** **test** : bool, int, float or string Value to test. **Returns** **null** : element in `[False, 0, 0.0, '']` Null value corresponding to the given test value: ...
tabular/utils.py
def DEFAULT_NULLVALUE(test): """ Returns a null value for each of various kinds of test values. **Parameters** **test** : bool, int, float or string Value to test. **Returns** **null** : element in `[False, 0, 0.0, '']` Null value c...
def DEFAULT_NULLVALUE(test): """ Returns a null value for each of various kinds of test values. **Parameters** **test** : bool, int, float or string Value to test. **Returns** **null** : element in `[False, 0, 0.0, '']` Null value c...
[ "Returns", "a", "null", "value", "for", "each", "of", "various", "kinds", "of", "test", "values", "." ]
yamins81/tabular
python
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/utils.py#L369-L394
[ "def", "DEFAULT_NULLVALUE", "(", "test", ")", ":", "return", "False", "if", "isinstance", "(", "test", ",", "bool", ")", "else", "0", "if", "isinstance", "(", "test", ",", "int", ")", "else", "0.0", "if", "isinstance", "(", "test", ",", "float", ")", ...
1caf091c8c395960a9ad7078f95158b533cc52dd
train
JSGObjectExpr.as_python
Return the python representation of the class represented by this object
pyjsg/parser_impl/jsg_objectexpr_parser.py
def as_python(self, name: str) -> str: """ Return the python representation of the class represented by this object """ if self._map_valuetype: return self.map_as_python(name) else: return self.obj_as_python(name)
def as_python(self, name: str) -> str: """ Return the python representation of the class represented by this object """ if self._map_valuetype: return self.map_as_python(name) else: return self.obj_as_python(name)
[ "Return", "the", "python", "representation", "of", "the", "class", "represented", "by", "this", "object" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_objectexpr_parser.py#L87-L92
[ "def", "as_python", "(", "self", ",", "name", ":", "str", ")", "->", "str", ":", "if", "self", ".", "_map_valuetype", ":", "return", "self", ".", "map_as_python", "(", "name", ")", "else", ":", "return", "self", ".", "obj_as_python", "(", "name", ")" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGObjectExpr.members_entries
Return an ordered list of elements for the _members section :param all_are_optional: True means we're in a choice situation so everything is optional :return:
pyjsg/parser_impl/jsg_objectexpr_parser.py
def members_entries(self, all_are_optional: bool=False) -> List[Tuple[str, str]]: """ Return an ordered list of elements for the _members section :param all_are_optional: True means we're in a choice situation so everything is optional :return: """ rval = [] if self._mem...
def members_entries(self, all_are_optional: bool=False) -> List[Tuple[str, str]]: """ Return an ordered list of elements for the _members section :param all_are_optional: True means we're in a choice situation so everything is optional :return: """ rval = [] if self._mem...
[ "Return", "an", "ordered", "list", "of", "elements", "for", "the", "_members", "section" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_objectexpr_parser.py#L196-L211
[ "def", "members_entries", "(", "self", ",", "all_are_optional", ":", "bool", "=", "False", ")", "->", "List", "[", "Tuple", "[", "str", ",", "str", "]", "]", ":", "rval", "=", "[", "]", "if", "self", ".", "_members", ":", "for", "member", "in", "se...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGObjectExpr.visitObjectExpr
objectExpr: OBRACE membersDef? CBRACE OBRACE (LEXER_ID_REF | ANY)? MAPSTO valueType ebnfSuffix? CBRACE
pyjsg/parser_impl/jsg_objectexpr_parser.py
def visitObjectExpr(self, ctx: jsgParser.ObjectExprContext): """ objectExpr: OBRACE membersDef? CBRACE OBRACE (LEXER_ID_REF | ANY)? MAPSTO valueType ebnfSuffix? CBRACE """ if not self._name: self._name = self._context.anon_id() if ctx.membersDef(): ...
def visitObjectExpr(self, ctx: jsgParser.ObjectExprContext): """ objectExpr: OBRACE membersDef? CBRACE OBRACE (LEXER_ID_REF | ANY)? MAPSTO valueType ebnfSuffix? CBRACE """ if not self._name: self._name = self._context.anon_id() if ctx.membersDef(): ...
[ "objectExpr", ":", "OBRACE", "membersDef?", "CBRACE", "OBRACE", "(", "LEXER_ID_REF", "|", "ANY", ")", "?", "MAPSTO", "valueType", "ebnfSuffix?", "CBRACE" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_objectexpr_parser.py#L224-L238
[ "def", "visitObjectExpr", "(", "self", ",", "ctx", ":", "jsgParser", ".", "ObjectExprContext", ")", ":", "if", "not", "self", ".", "_name", ":", "self", ".", "_name", "=", "self", ".", "_context", ".", "anon_id", "(", ")", "if", "ctx", ".", "membersDef...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGObjectExpr.visitMembersDef
membersDef: COMMA | member+ (BAR altMemberDef)* (BAR lastComma)? ; altMemberDef: member* ; member: pairDef COMMA? lastComma: COMMA ;
pyjsg/parser_impl/jsg_objectexpr_parser.py
def visitMembersDef(self, ctx: jsgParser.MembersDefContext): """ membersDef: COMMA | member+ (BAR altMemberDef)* (BAR lastComma)? ; altMemberDef: member* ; member: pairDef COMMA? lastComma: COMMA ; """ if not self._name: self._name = self._context....
def visitMembersDef(self, ctx: jsgParser.MembersDefContext): """ membersDef: COMMA | member+ (BAR altMemberDef)* (BAR lastComma)? ; altMemberDef: member* ; member: pairDef COMMA? lastComma: COMMA ; """ if not self._name: self._name = self._context....
[ "membersDef", ":", "COMMA", "|", "member", "+", "(", "BAR", "altMemberDef", ")", "*", "(", "BAR", "lastComma", ")", "?", ";", "altMemberDef", ":", "member", "*", ";", "member", ":", "pairDef", "COMMA?", "lastComma", ":", "COMMA", ";" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_objectexpr_parser.py#L240-L260
[ "def", "visitMembersDef", "(", "self", ",", "ctx", ":", "jsgParser", ".", "MembersDefContext", ")", ":", "if", "not", "self", ".", "_name", ":", "self", ".", "_name", "=", "self", ".", "_context", ".", "anon_id", "(", ")", "if", "ctx", ".", "COMMA", ...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGObjectExpr.visitMember
member: pairDef COMMA?
pyjsg/parser_impl/jsg_objectexpr_parser.py
def visitMember(self, ctx: jsgParser.MemberContext): """ member: pairDef COMMA? """ self._strict = ctx.COMMA() is None self.visitChildren(ctx)
def visitMember(self, ctx: jsgParser.MemberContext): """ member: pairDef COMMA? """ self._strict = ctx.COMMA() is None self.visitChildren(ctx)
[ "member", ":", "pairDef", "COMMA?" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_objectexpr_parser.py#L262-L265
[ "def", "visitMember", "(", "self", ",", "ctx", ":", "jsgParser", ".", "MemberContext", ")", ":", "self", ".", "_strict", "=", "ctx", ".", "COMMA", "(", ")", "is", "None", "self", ".", "visitChildren", "(", "ctx", ")" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
_get_filtered_study_ids
Optionally filters out aliases from standard doc-id list
peyotl/phylesystem/phylesystem_shard.py
def _get_filtered_study_ids(shard, include_aliases=False): """Optionally filters out aliases from standard doc-id list""" from peyotl.phylesystem.helper import DIGIT_PATTERN k = shard.get_doc_ids() if shard.has_aliases and (not include_aliases): x = [] for i in k: if DIGIT_PA...
def _get_filtered_study_ids(shard, include_aliases=False): """Optionally filters out aliases from standard doc-id list""" from peyotl.phylesystem.helper import DIGIT_PATTERN k = shard.get_doc_ids() if shard.has_aliases and (not include_aliases): x = [] for i in k: if DIGIT_PA...
[ "Optionally", "filters", "out", "aliases", "from", "standard", "doc", "-", "id", "list" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L18-L29
[ "def", "_get_filtered_study_ids", "(", "shard", ",", "include_aliases", "=", "False", ")", ":", "from", "peyotl", ".", "phylesystem", ".", "helper", "import", "DIGIT_PATTERN", "k", "=", "shard", ".", "get_doc_ids", "(", ")", "if", "shard", ".", "has_aliases", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
diagnose_repo_nexml2json
Optimistic test for Nexson version in a shard (tests first study found)
peyotl/phylesystem/phylesystem_shard.py
def diagnose_repo_nexml2json(shard): """Optimistic test for Nexson version in a shard (tests first study found)""" with shard._index_lock: fp = next(iter(shard.study_index.values()))[2] with codecs.open(fp, mode='r', encoding='utf-8') as fo: fj = json.load(fo) from peyotl.nexson_synt...
def diagnose_repo_nexml2json(shard): """Optimistic test for Nexson version in a shard (tests first study found)""" with shard._index_lock: fp = next(iter(shard.study_index.values()))[2] with codecs.open(fp, mode='r', encoding='utf-8') as fo: fj = json.load(fo) from peyotl.nexson_synt...
[ "Optimistic", "test", "for", "Nexson", "version", "in", "a", "shard", "(", "tests", "first", "study", "found", ")" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L77-L84
[ "def", "diagnose_repo_nexml2json", "(", "shard", ")", ":", "with", "shard", ".", "_index_lock", ":", "fp", "=", "next", "(", "iter", "(", "shard", ".", "study_index", ".", "values", "(", ")", ")", ")", "[", "2", "]", "with", "codecs", ".", "open", "(...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemShard._determine_next_study_id
Return the numeric part of the newest study_id Checks out master branch as a side effect!
peyotl/phylesystem/phylesystem_shard.py
def _determine_next_study_id(self): """Return the numeric part of the newest study_id Checks out master branch as a side effect! """ if self._doc_counter_lock is None: self._doc_counter_lock = Lock() prefix = self._new_study_prefix lp = len(prefix) n ...
def _determine_next_study_id(self): """Return the numeric part of the newest study_id Checks out master branch as a side effect! """ if self._doc_counter_lock is None: self._doc_counter_lock = Lock() prefix = self._new_study_prefix lp = len(prefix) n ...
[ "Return", "the", "numeric", "part", "of", "the", "newest", "study_id" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L246-L279
[ "def", "_determine_next_study_id", "(", "self", ")", ":", "if", "self", ".", "_doc_counter_lock", "is", "None", ":", "self", ".", "_doc_counter_lock", "=", "Lock", "(", ")", "prefix", "=", "self", ".", "_new_study_prefix", "lp", "=", "len", "(", "prefix", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemShard._advance_new_study_id
ASSUMES the caller holds the _doc_counter_lock ! Returns the current numeric part of the next study ID, advances the counter to the next value, and stores that value in the file in case the server is restarted.
peyotl/phylesystem/phylesystem_shard.py
def _advance_new_study_id(self): """ ASSUMES the caller holds the _doc_counter_lock ! Returns the current numeric part of the next study ID, advances the counter to the next value, and stores that value in the file in case the server is restarted. """ c = self._next_study...
def _advance_new_study_id(self): """ ASSUMES the caller holds the _doc_counter_lock ! Returns the current numeric part of the next study ID, advances the counter to the next value, and stores that value in the file in case the server is restarted. """ c = self._next_study...
[ "ASSUMES", "the", "caller", "holds", "the", "_doc_counter_lock", "!", "Returns", "the", "current", "numeric", "part", "of", "the", "next", "study", "ID", "advances", "the", "counter", "to", "the", "next", "value", "and", "stores", "that", "value", "in", "the...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L281-L296
[ "def", "_advance_new_study_id", "(", "self", ")", ":", "c", "=", "self", ".", "_next_study_id", "self", ".", "_next_study_id", "=", "1", "+", "c", "content", "=", "u'{\"next_study_id\": %d}\\n'", "%", "self", ".", "_next_study_id", "# The content is JSON, but we han...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemShard._diagnose_prefixes
Returns a set of all of the prefixes seen in the main document dir
peyotl/phylesystem/phylesystem_shard.py
def _diagnose_prefixes(self): """Returns a set of all of the prefixes seen in the main document dir """ from peyotl.phylesystem import STUDY_ID_PATTERN p = set() for name in os.listdir(self.doc_dir): if STUDY_ID_PATTERN.match(name): p.add(name[:3]) ...
def _diagnose_prefixes(self): """Returns a set of all of the prefixes seen in the main document dir """ from peyotl.phylesystem import STUDY_ID_PATTERN p = set() for name in os.listdir(self.doc_dir): if STUDY_ID_PATTERN.match(name): p.add(name[:3]) ...
[ "Returns", "a", "set", "of", "all", "of", "the", "prefixes", "seen", "in", "the", "main", "document", "dir" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L298-L306
[ "def", "_diagnose_prefixes", "(", "self", ")", ":", "from", "peyotl", ".", "phylesystem", "import", "STUDY_ID_PATTERN", "p", "=", "set", "(", ")", "for", "name", "in", "os", ".", "listdir", "(", "self", ".", "doc_dir", ")", ":", "if", "STUDY_ID_PATTERN", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemShard._mint_new_study_id
Checks out master branch as a side effect
peyotl/phylesystem/phylesystem_shard.py
def _mint_new_study_id(self): """Checks out master branch as a side effect""" # studies created by the OpenTree API start with ot_, # so they don't conflict with new study id's from other sources with self._doc_counter_lock: c = self._advance_new_study_id() # @TODO. T...
def _mint_new_study_id(self): """Checks out master branch as a side effect""" # studies created by the OpenTree API start with ot_, # so they don't conflict with new study id's from other sources with self._doc_counter_lock: c = self._advance_new_study_id() # @TODO. T...
[ "Checks", "out", "master", "branch", "as", "a", "side", "effect" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L321-L330
[ "def", "_mint_new_study_id", "(", "self", ")", ":", "# studies created by the OpenTree API start with ot_,", "# so they don't conflict with new study id's from other sources", "with", "self", ".", "_doc_counter_lock", ":", "c", "=", "self", ".", "_advance_new_study_id", "(", ")...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemShard.create_git_action_for_new_study
Checks out master branch as a side effect
peyotl/phylesystem/phylesystem_shard.py
def create_git_action_for_new_study(self, new_study_id=None): """Checks out master branch as a side effect""" ga = self.create_git_action() if new_study_id is None: new_study_id = self._mint_new_study_id() self.register_doc_id(ga, new_study_id) return ga, new_study_id
def create_git_action_for_new_study(self, new_study_id=None): """Checks out master branch as a side effect""" ga = self.create_git_action() if new_study_id is None: new_study_id = self._mint_new_study_id() self.register_doc_id(ga, new_study_id) return ga, new_study_id
[ "Checks", "out", "master", "branch", "as", "a", "side", "effect" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/phylesystem_shard.py#L332-L338
[ "def", "create_git_action_for_new_study", "(", "self", ",", "new_study_id", "=", "None", ")", ":", "ga", "=", "self", ".", "create_git_action", "(", ")", "if", "new_study_id", "is", "None", ":", "new_study_id", "=", "self", ".", "_mint_new_study_id", "(", ")",...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
flatten
Return a list of all non-list items in l :param l: list to be flattened :return:
pyjsg/parser_impl/parser_utils.py
def flatten(l: Iterable) -> List: """Return a list of all non-list items in l :param l: list to be flattened :return: """ rval = [] for e in l: if not isinstance(e, str) and isinstance(e, Iterable): if len(list(e)): rval += flatten(e) else: ...
def flatten(l: Iterable) -> List: """Return a list of all non-list items in l :param l: list to be flattened :return: """ rval = [] for e in l: if not isinstance(e, str) and isinstance(e, Iterable): if len(list(e)): rval += flatten(e) else: ...
[ "Return", "a", "list", "of", "all", "non", "-", "list", "items", "in", "l" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/parser_utils.py#L14-L27
[ "def", "flatten", "(", "l", ":", "Iterable", ")", "->", "List", ":", "rval", "=", "[", "]", "for", "e", "in", "l", ":", "if", "not", "isinstance", "(", "e", ",", "str", ")", "and", "isinstance", "(", "e", ",", "Iterable", ")", ":", "if", "len",...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
flatten_unique
Return a list of UNIQUE non-list items in l
pyjsg/parser_impl/parser_utils.py
def flatten_unique(l: Iterable) -> List: """ Return a list of UNIQUE non-list items in l """ rval = OrderedDict() for e in l: if not isinstance(e, str) and isinstance(e, Iterable): for ev in flatten_unique(e): rval[ev] = None else: rval[e] = None r...
def flatten_unique(l: Iterable) -> List: """ Return a list of UNIQUE non-list items in l """ rval = OrderedDict() for e in l: if not isinstance(e, str) and isinstance(e, Iterable): for ev in flatten_unique(e): rval[ev] = None else: rval[e] = None r...
[ "Return", "a", "list", "of", "UNIQUE", "non", "-", "list", "items", "in", "l" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/parser_utils.py#L30-L39
[ "def", "flatten_unique", "(", "l", ":", "Iterable", ")", "->", "List", ":", "rval", "=", "OrderedDict", "(", ")", "for", "e", "in", "l", ":", "if", "not", "isinstance", "(", "e", ",", "str", ")", "and", "isinstance", "(", "e", ",", "Iterable", ")",...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
get_terminal
Extract the token for an identifier from the context. Tokens can be: * ID - The name of a JSG definition * idref -- A reference to an existing JSG definition * LEXER_ID - The name of a match pattern definition * LEXER_ID_REF - A reference to an existing match pattern definition *...
pyjsg/parser_impl/parser_utils.py
def get_terminal(ctx: ParserRuleContext) -> str: """ Extract the token for an identifier from the context. Tokens can be: * ID - The name of a JSG definition * idref -- A reference to an existing JSG definition * LEXER_ID - The name of a match pattern definition * LEXER_ID_REF - A re...
def get_terminal(ctx: ParserRuleContext) -> str: """ Extract the token for an identifier from the context. Tokens can be: * ID - The name of a JSG definition * idref -- A reference to an existing JSG definition * LEXER_ID - The name of a match pattern definition * LEXER_ID_REF - A re...
[ "Extract", "the", "token", "for", "an", "identifier", "from", "the", "context", ".", "Tokens", "can", "be", ":", "*", "ID", "-", "The", "name", "of", "a", "JSG", "definition", "*", "idref", "--", "A", "reference", "to", "an", "existing", "JSG", "defini...
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/parser_utils.py#L53-L69
[ "def", "get_terminal", "(", "ctx", ":", "ParserRuleContext", ")", "->", "str", ":", "tkn", "=", "None", "for", "ele_name", "in", "identifier_types", ":", "ele", "=", "getattr", "(", "ctx", ",", "ele_name", ",", "None", ")", "if", "ele", "and", "ele", "...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
as_tokens
Return a stringified list of identifiers in ctx :param ctx: JSG parser item with a set of identifiers :return:
pyjsg/parser_impl/parser_utils.py
def as_tokens(ctx: List[ParserRuleContext]) -> List[str]: """Return a stringified list of identifiers in ctx :param ctx: JSG parser item with a set of identifiers :return: """ return [as_token(e) for e in ctx]
def as_tokens(ctx: List[ParserRuleContext]) -> List[str]: """Return a stringified list of identifiers in ctx :param ctx: JSG parser item with a set of identifiers :return: """ return [as_token(e) for e in ctx]
[ "Return", "a", "stringified", "list", "of", "identifiers", "in", "ctx" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/parser_utils.py#L85-L91
[ "def", "as_tokens", "(", "ctx", ":", "List", "[", "ParserRuleContext", "]", ")", "->", "List", "[", "str", "]", ":", "return", "[", "as_token", "(", "e", ")", "for", "e", "in", "ctx", "]" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
is_valid_python
Determine whether tkn is a valid python identifier :param tkn: :return:
pyjsg/parser_impl/parser_utils.py
def is_valid_python(tkn: str) -> bool: """Determine whether tkn is a valid python identifier :param tkn: :return: """ try: root = ast.parse(tkn) except SyntaxError: return False return len(root.body) == 1 and isinstance(root.body[0], ast.Expr) and isinstance(root.body[0].val...
def is_valid_python(tkn: str) -> bool: """Determine whether tkn is a valid python identifier :param tkn: :return: """ try: root = ast.parse(tkn) except SyntaxError: return False return len(root.body) == 1 and isinstance(root.body[0], ast.Expr) and isinstance(root.body[0].val...
[ "Determine", "whether", "tkn", "is", "a", "valid", "python", "identifier" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/parser_utils.py#L94-L104
[ "def", "is_valid_python", "(", "tkn", ":", "str", ")", "->", "bool", ":", "try", ":", "root", "=", "ast", ".", "parse", "(", "tkn", ")", "except", "SyntaxError", ":", "return", "False", "return", "len", "(", "root", ".", "body", ")", "==", "1", "an...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
PhylesystemGitAction.remove_study
Remove a study Given a study_id, branch and optionally an author, remove a study on the given branch and attribute the commit to author. Returns the SHA of the commit on branch.
peyotl/phylesystem/git_actions.py
def remove_study(self, first_arg, sec_arg, third_arg, fourth_arg=None, commit_msg=None): """Remove a study Given a study_id, branch and optionally an author, remove a study on the given branch and attribute the commit to author. Returns the SHA of the commit on branch. ""...
def remove_study(self, first_arg, sec_arg, third_arg, fourth_arg=None, commit_msg=None): """Remove a study Given a study_id, branch and optionally an author, remove a study on the given branch and attribute the commit to author. Returns the SHA of the commit on branch. ""...
[ "Remove", "a", "study", "Given", "a", "study_id", "branch", "and", "optionally", "an", "author", "remove", "a", "study", "on", "the", "given", "branch", "and", "attribute", "the", "commit", "to", "author", ".", "Returns", "the", "SHA", "of", "the", "commit...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_actions.py#L108-L123
[ "def", "remove_study", "(", "self", ",", "first_arg", ",", "sec_arg", ",", "third_arg", ",", "fourth_arg", "=", "None", ",", "commit_msg", "=", "None", ")", ":", "if", "fourth_arg", "is", "None", ":", "study_id", ",", "branch_name", ",", "author", "=", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemGitAction.write_study
Given a study_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master...
peyotl/phylesystem/git_actions.py
def write_study(self, study_id, file_content, branch, author): """Given a study_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master... """ gh_user = branch.split('_study_')[0] msg = "Update Study #%s via OpenTree ...
def write_study(self, study_id, file_content, branch, author): """Given a study_id, temporary filename of content, branch and auth_info Deprecated but needed until we merge api local-dep to master... """ gh_user = branch.split('_study_')[0] msg = "Update Study #%s via OpenTree ...
[ "Given", "a", "study_id", "temporary", "filename", "of", "content", "branch", "and", "auth_info" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_actions.py#L125-L138
[ "def", "write_study", "(", "self", ",", "study_id", ",", "file_content", ",", "branch", ",", "author", ")", ":", "gh_user", "=", "branch", ".", "split", "(", "'_study_'", ")", "[", "0", "]", "msg", "=", "\"Update Study #%s via OpenTree API\"", "%", "study_id...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhylesystemGitAction.write_study_from_tmpfile
Given a study_id, temporary filename of content, branch and auth_info
peyotl/phylesystem/git_actions.py
def write_study_from_tmpfile(self, study_id, tmpfi, parent_sha, auth_info, commit_msg=''): """Given a study_id, temporary filename of content, branch and auth_info """ return self.write_doc_from_tmpfile(study_id, tmpfi, ...
def write_study_from_tmpfile(self, study_id, tmpfi, parent_sha, auth_info, commit_msg=''): """Given a study_id, temporary filename of content, branch and auth_info """ return self.write_doc_from_tmpfile(study_id, tmpfi, ...
[ "Given", "a", "study_id", "temporary", "filename", "of", "content", "branch", "and", "auth_info" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_actions.py#L140-L148
[ "def", "write_study_from_tmpfile", "(", "self", ",", "study_id", ",", "tmpfi", ",", "parent_sha", ",", "auth_info", ",", "commit_msg", "=", "''", ")", ":", "return", "self", ".", "write_doc_from_tmpfile", "(", "study_id", ",", "tmpfi", ",", "parent_sha", ",", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
init
Initialize the communities file storage.
invenio_communities/cli.py
def init(): """Initialize the communities file storage.""" try: initialize_communities_bucket() click.secho('Community init successful.', fg='green') except FilesException as e: click.secho(e.message, fg='red')
def init(): """Initialize the communities file storage.""" try: initialize_communities_bucket() click.secho('Community init successful.', fg='green') except FilesException as e: click.secho(e.message, fg='red')
[ "Initialize", "the", "communities", "file", "storage", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/cli.py#L50-L56
[ "def", "init", "(", ")", ":", "try", ":", "initialize_communities_bucket", "(", ")", "click", ".", "secho", "(", "'Community init successful.'", ",", "fg", "=", "'green'", ")", "except", "FilesException", "as", "e", ":", "click", ".", "secho", "(", "e", "....
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
addlogo
Add logo to the community.
invenio_communities/cli.py
def addlogo(community_id, logo): """Add logo to the community.""" # Create the bucket c = Community.get(community_id) if not c: click.secho('Community {0} does not exist.'.format(community_id), fg='red') return ext = save_and_validate_logo(logo, logo.name, c.id) ...
def addlogo(community_id, logo): """Add logo to the community.""" # Create the bucket c = Community.get(community_id) if not c: click.secho('Community {0} does not exist.'.format(community_id), fg='red') return ext = save_and_validate_logo(logo, logo.name, c.id) ...
[ "Add", "logo", "to", "the", "community", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/cli.py#L63-L73
[ "def", "addlogo", "(", "community_id", ",", "logo", ")", ":", "# Create the bucket", "c", "=", "Community", ".", "get", "(", "community_id", ")", "if", "not", "c", ":", "click", ".", "secho", "(", "'Community {0} does not exist.'", ".", "format", "(", "commu...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
request
Request a record acceptance to a community.
invenio_communities/cli.py
def request(community_id, record_id, accept): """Request a record acceptance to a community.""" c = Community.get(community_id) assert c is not None record = Record.get_record(record_id) if accept: c.add_record(record) record.commit() else: InclusionRequest.create(communi...
def request(community_id, record_id, accept): """Request a record acceptance to a community.""" c = Community.get(community_id) assert c is not None record = Record.get_record(record_id) if accept: c.add_record(record) record.commit() else: InclusionRequest.create(communi...
[ "Request", "a", "record", "acceptance", "to", "a", "community", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/cli.py#L81-L93
[ "def", "request", "(", "community_id", ",", "record_id", ",", "accept", ")", ":", "c", "=", "Community", ".", "get", "(", "community_id", ")", "assert", "c", "is", "not", "None", "record", "=", "Record", ".", "get_record", "(", "record_id", ")", "if", ...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
remove
Remove a record from community.
invenio_communities/cli.py
def remove(community_id, record_id): """Remove a record from community.""" c = Community.get(community_id) assert c is not None c.remove_record(record_id) db.session.commit() RecordIndexer().index_by_id(record_id)
def remove(community_id, record_id): """Remove a record from community.""" c = Community.get(community_id) assert c is not None c.remove_record(record_id) db.session.commit() RecordIndexer().index_by_id(record_id)
[ "Remove", "a", "record", "from", "community", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/cli.py#L100-L106
[ "def", "remove", "(", "community_id", ",", "record_id", ")", ":", "c", "=", "Community", ".", "get", "(", "community_id", ")", "assert", "c", "is", "not", "None", "c", ".", "remove_record", "(", "record_id", ")", "db", ".", "session", ".", "commit", "(...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
sets_are_rooted_compat
treats the 2 sets are sets of taxon IDs on the same (unstated) universe of taxon ids. Returns True clades implied by each are compatible and False otherwise
peyotl/phylo/compat.py
def sets_are_rooted_compat(one_set, other): """treats the 2 sets are sets of taxon IDs on the same (unstated) universe of taxon ids. Returns True clades implied by each are compatible and False otherwise """ if one_set.issubset(other) or other.issubset(one_set): return True return not in...
def sets_are_rooted_compat(one_set, other): """treats the 2 sets are sets of taxon IDs on the same (unstated) universe of taxon ids. Returns True clades implied by each are compatible and False otherwise """ if one_set.issubset(other) or other.issubset(one_set): return True return not in...
[ "treats", "the", "2", "sets", "are", "sets", "of", "taxon", "IDs", "on", "the", "same", "(", "unstated", ")", "universe", "of", "taxon", "ids", ".", "Returns", "True", "clades", "implied", "by", "each", "are", "compatible", "and", "False", "otherwise" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylo/compat.py#L31-L38
[ "def", "sets_are_rooted_compat", "(", "one_set", ",", "other", ")", ":", "if", "one_set", ".", "issubset", "(", "other", ")", "or", "other", ".", "issubset", "(", "one_set", ")", ":", "return", "True", "return", "not", "intersection_not_empty", "(", "one_set...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
gen_otu_dict
Takes a NexSON object and returns a dict of otu_id -> otu_obj
peyotl/__init__.py
def gen_otu_dict(nex_obj, nexson_version=None): """Takes a NexSON object and returns a dict of otu_id -> otu_obj """ if nexson_version is None: nexson_version = detect_nexson_version(nex_obj) if _is_by_id_hbf(nexson_version): otus = nex_obj['nexml']['otusById'] if len(otus) >...
def gen_otu_dict(nex_obj, nexson_version=None): """Takes a NexSON object and returns a dict of otu_id -> otu_obj """ if nexson_version is None: nexson_version = detect_nexson_version(nex_obj) if _is_by_id_hbf(nexson_version): otus = nex_obj['nexml']['otusById'] if len(otus) >...
[ "Takes", "a", "NexSON", "object", "and", "returns", "a", "dict", "of", "otu_id", "-", ">", "otu_obj" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/__init__.py#L33-L53
[ "def", "gen_otu_dict", "(", "nex_obj", ",", "nexson_version", "=", "None", ")", ":", "if", "nexson_version", "is", "None", ":", "nexson_version", "=", "detect_nexson_version", "(", "nex_obj", ")", "if", "_is_by_id_hbf", "(", "nexson_version", ")", ":", "otus", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
NodePool.open
Explicit entry. Opens pool as configured, for later closure via close(). For use when keeping pool open across multiple calls. Raise any IndyError causing failure to create ledger configuration. :return: current object
von_agent/nodepool.py
async def open(self) -> 'NodePool': """ Explicit entry. Opens pool as configured, for later closure via close(). For use when keeping pool open across multiple calls. Raise any IndyError causing failure to create ledger configuration. :return: current object """ ...
async def open(self) -> 'NodePool': """ Explicit entry. Opens pool as configured, for later closure via close(). For use when keeping pool open across multiple calls. Raise any IndyError causing failure to create ledger configuration. :return: current object """ ...
[ "Explicit", "entry", ".", "Opens", "pool", "as", "configured", "for", "later", "closure", "via", "close", "()", ".", "For", "use", "when", "keeping", "pool", "open", "across", "multiple", "calls", "." ]
PSPC-SPAC-buyandsell/von_agent
python
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/nodepool.py#L129-L154
[ "async", "def", "open", "(", "self", ")", "->", "'NodePool'", ":", "LOGGER", ".", "debug", "(", "'NodePool.open >>>'", ")", "try", ":", "await", "pool", ".", "set_protocol_version", "(", "2", ")", "# 1 for indy-node 1.3, 2 for indy-node 1.4", "await", "pool", "....
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
train
acquire_lock_raise
Adapts LockError to HTTP. If an exception is not thrown, the git_action has the lock (and must release it!)
peyotl/git_storage/git_workflow.py
def acquire_lock_raise(git_action, fail_msg=''): """Adapts LockError to HTTP. If an exception is not thrown, the git_action has the lock (and must release it!) """ try: git_action.acquire_lock() except LockError as e: msg = '{o} Details: {d}'.format(o=fail_msg, d=e.message) _LOG....
def acquire_lock_raise(git_action, fail_msg=''): """Adapts LockError to HTTP. If an exception is not thrown, the git_action has the lock (and must release it!) """ try: git_action.acquire_lock() except LockError as e: msg = '{o} Details: {d}'.format(o=fail_msg, d=e.message) _LOG....
[ "Adapts", "LockError", "to", "HTTP", ".", "If", "an", "exception", "is", "not", "thrown", "the", "git_action", "has", "the", "lock", "(", "and", "must", "release", "it!", ")" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/git_workflow.py#L17-L25
[ "def", "acquire_lock_raise", "(", "git_action", ",", "fail_msg", "=", "''", ")", ":", "try", ":", "git_action", ".", "acquire_lock", "(", ")", "except", "LockError", "as", "e", ":", "msg", "=", "'{o} Details: {d}'", ".", "format", "(", "o", "=", "fail_msg"...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
merge_from_master
merge from master into the WIP for this document/author this is needed to allow a worker's future saves to be merged seamlessly into master
peyotl/git_storage/git_workflow.py
def merge_from_master(git_action, doc_id, auth_info, parent_sha, doctype_display_name="document"): """merge from master into the WIP for this document/author this is needed to allow a worker's future saves to be merged seamlessly into master """ gh_user = get_user_author(auth_info)[0] acquire_lo...
def merge_from_master(git_action, doc_id, auth_info, parent_sha, doctype_display_name="document"): """merge from master into the WIP for this document/author this is needed to allow a worker's future saves to be merged seamlessly into master """ gh_user = get_user_author(auth_info)[0] acquire_lo...
[ "merge", "from", "master", "into", "the", "WIP", "for", "this", "document", "/", "author", "this", "is", "needed", "to", "allow", "a", "worker", "s", "future", "saves", "to", "be", "merged", "seamlessly", "into", "master" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/git_workflow.py#L129-L156
[ "def", "merge_from_master", "(", "git_action", ",", "doc_id", ",", "auth_info", ",", "parent_sha", ",", "doctype_display_name", "=", "\"document\"", ")", ":", "gh_user", "=", "get_user_author", "(", "auth_info", ")", "[", "0", "]", "acquire_lock_raise", "(", "gi...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
generic_commit_and_try_merge2master_wf
Actually make a local Git commit and push it to our remote
peyotl/git_storage/git_workflow.py
def generic_commit_and_try_merge2master_wf(git_action, file_content, doc_id, auth_info, parent_sha, commi...
def generic_commit_and_try_merge2master_wf(git_action, file_content, doc_id, auth_info, parent_sha, commi...
[ "Actually", "make", "a", "local", "Git", "commit", "and", "push", "it", "to", "our", "remote" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/git_storage/git_workflow.py#L159-L234
[ "def", "generic_commit_and_try_merge2master_wf", "(", "git_action", ",", "file_content", ",", "doc_id", ",", "auth_info", ",", "parent_sha", ",", "commit_msg", "=", "''", ",", "merged_sha", "=", "None", ",", "doctype_display_name", "=", "\"document\"", ")", ":", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
set_country
Sets the chosen country in the session or cookie. If `next' query param is present, it redirects to a given url.
django_country/views.py
def set_country(request): """ Sets the chosen country in the session or cookie. If `next' query param is present, it redirects to a given url. """ if request.method == 'POST': next = request.POST.get('next', request.GET.get('next')) if is_safe_url(url=next, host=request.get_host()):...
def set_country(request): """ Sets the chosen country in the session or cookie. If `next' query param is present, it redirects to a given url. """ if request.method == 'POST': next = request.POST.get('next', request.GET.get('next')) if is_safe_url(url=next, host=request.get_host()):...
[ "Sets", "the", "chosen", "country", "in", "the", "session", "or", "cookie", "." ]
color/django-country
python
https://github.com/color/django-country/blob/1d272a196d998e21bb8d407e2657b88211f35232/django_country/views.py#L8-L34
[ "def", "set_country", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "next", "=", "request", ".", "POST", ".", "get", "(", "'next'", ",", "request", ".", "GET", ".", "get", "(", "'next'", ")", ")", "if", "is_safe_url",...
1d272a196d998e21bb8d407e2657b88211f35232
train
JSGDocContext.reference
Return the element that tkn represents
pyjsg/parser_impl/jsg_doc_context.py
def reference(self, tkn: str): """ Return the element that tkn represents""" return self.grammarelts[tkn] if tkn in self.grammarelts else UndefinedElement(tkn)
def reference(self, tkn: str): """ Return the element that tkn represents""" return self.grammarelts[tkn] if tkn in self.grammarelts else UndefinedElement(tkn)
[ "Return", "the", "element", "that", "tkn", "represents" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L111-L113
[ "def", "reference", "(", "self", ",", "tkn", ":", "str", ")", ":", "return", "self", ".", "grammarelts", "[", "tkn", "]", "if", "tkn", "in", "self", ".", "grammarelts", "else", "UndefinedElement", "(", "tkn", ")" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.dependency_list
Return a list all of the grammarelts that depend on tkn :param tkn: :return:
pyjsg/parser_impl/jsg_doc_context.py
def dependency_list(self, tkn: str) -> List[str]: """Return a list all of the grammarelts that depend on tkn :param tkn: :return: """ if tkn not in self.dependency_map: self.dependency_map[tkn] = [tkn] # Force a circular reference self.dependency_...
def dependency_list(self, tkn: str) -> List[str]: """Return a list all of the grammarelts that depend on tkn :param tkn: :return: """ if tkn not in self.dependency_map: self.dependency_map[tkn] = [tkn] # Force a circular reference self.dependency_...
[ "Return", "a", "list", "all", "of", "the", "grammarelts", "that", "depend", "on", "tkn" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L139-L148
[ "def", "dependency_list", "(", "self", ",", "tkn", ":", "str", ")", "->", "List", "[", "str", "]", ":", "if", "tkn", "not", "in", "self", ".", "dependency_map", ":", "self", ".", "dependency_map", "[", "tkn", "]", "=", "[", "tkn", "]", "# Force a cir...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.dependencies
Return all the items that tkn depends on as a set :param tkn: :return:
pyjsg/parser_impl/jsg_doc_context.py
def dependencies(self, tkn: str) -> Set[str]: """Return all the items that tkn depends on as a set :param tkn: :return: """ return set(self.dependency_list(tkn))
def dependencies(self, tkn: str) -> Set[str]: """Return all the items that tkn depends on as a set :param tkn: :return: """ return set(self.dependency_list(tkn))
[ "Return", "all", "the", "items", "that", "tkn", "depends", "on", "as", "a", "set" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L150-L156
[ "def", "dependencies", "(", "self", ",", "tkn", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "self", ".", "dependency_list", "(", "tkn", ")", ")" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.undefined_entries
Return the set of tokens that are referenced but not defined.
pyjsg/parser_impl/jsg_doc_context.py
def undefined_entries(self) -> Set[str]: """ Return the set of tokens that are referenced but not defined. """ return as_set([[d for d in self.dependencies(k) if d not in self.grammarelts] for k in self.grammarelts.keys()])
def undefined_entries(self) -> Set[str]: """ Return the set of tokens that are referenced but not defined. """ return as_set([[d for d in self.dependencies(k) if d not in self.grammarelts] for k in self.grammarelts.keys()])
[ "Return", "the", "set", "of", "tokens", "that", "are", "referenced", "but", "not", "defined", "." ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L158-L161
[ "def", "undefined_entries", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "return", "as_set", "(", "[", "[", "d", "for", "d", "in", "self", ".", "dependencies", "(", "k", ")", "if", "d", "not", "in", "self", ".", "grammarelts", "]", "for", ...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.dependency_closure
Determine the transitive closure of tkn's dependencies :param tkn: root token :param seen: list of tokens already visited in closure process :return: dependents, dependents of dependents, etc.
pyjsg/parser_impl/jsg_doc_context.py
def dependency_closure(self, tkn: str, seen: Optional[Set[str]]=None) -> Set[str]: """ Determine the transitive closure of tkn's dependencies :param tkn: root token :param seen: list of tokens already visited in closure process :return: dependents, dependents of dependents, etc. ...
def dependency_closure(self, tkn: str, seen: Optional[Set[str]]=None) -> Set[str]: """ Determine the transitive closure of tkn's dependencies :param tkn: root token :param seen: list of tokens already visited in closure process :return: dependents, dependents of dependents, etc. ...
[ "Determine", "the", "transitive", "closure", "of", "tkn", "s", "dependencies", ":", "param", "tkn", ":", "root", "token", ":", "param", "seen", ":", "list", "of", "tokens", "already", "visited", "in", "closure", "process", ":", "return", ":", "dependents", ...
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L163-L176
[ "def", "dependency_closure", "(", "self", ",", "tkn", ":", "str", ",", "seen", ":", "Optional", "[", "Set", "[", "str", "]", "]", "=", "None", ")", "->", "Set", "[", "str", "]", ":", "if", "seen", "is", "None", ":", "seen", "=", "set", "(", ")"...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.circular_references
Return the set of recursive (circular) references :return:
pyjsg/parser_impl/jsg_doc_context.py
def circular_references(self) -> Set[str]: """ Return the set of recursive (circular) references :return: """ rval = set() for k in self.grammarelts.keys(): if k in self.dependency_closure(k): rval.add(k) return rval
def circular_references(self) -> Set[str]: """ Return the set of recursive (circular) references :return: """ rval = set() for k in self.grammarelts.keys(): if k in self.dependency_closure(k): rval.add(k) return rval
[ "Return", "the", "set", "of", "recursive", "(", "circular", ")", "references", ":", "return", ":" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L178-L187
[ "def", "circular_references", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "rval", "=", "set", "(", ")", "for", "k", "in", "self", ".", "grammarelts", ".", "keys", "(", ")", ":", "if", "k", "in", "self", ".", "dependency_closure", "(", "k",...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.resolve_circular_references
Create forward references for all circular references :return:
pyjsg/parser_impl/jsg_doc_context.py
def resolve_circular_references(self) -> None: """ Create forward references for all circular references :return: """ circulars = self.circular_references() for c in circulars: fwdref = JSGForwardRef(c) self.grammarelts[fwdref.label] = fwdref ...
def resolve_circular_references(self) -> None: """ Create forward references for all circular references :return: """ circulars = self.circular_references() for c in circulars: fwdref = JSGForwardRef(c) self.grammarelts[fwdref.label] = fwdref ...
[ "Create", "forward", "references", "for", "all", "circular", "references", ":", "return", ":" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L189-L198
[ "def", "resolve_circular_references", "(", "self", ")", "->", "None", ":", "circulars", "=", "self", ".", "circular_references", "(", ")", "for", "c", "in", "circulars", ":", "fwdref", "=", "JSGForwardRef", "(", "c", ")", "self", ".", "grammarelts", "[", "...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGDocContext.ordered_elements
Generator that returns items in ther order needed for the actual python 1) All forward references 2) All lexer items 3) Object / Array definitions in order of increasing dependency depth Within each category, items are returned alphabetically
pyjsg/parser_impl/jsg_doc_context.py
def ordered_elements(self) -> str: """ Generator that returns items in ther order needed for the actual python 1) All forward references 2) All lexer items 3) Object / Array definitions in order of increasing dependency depth Within each category, items are retur...
def ordered_elements(self) -> str: """ Generator that returns items in ther order needed for the actual python 1) All forward references 2) All lexer items 3) Object / Array definitions in order of increasing dependency depth Within each category, items are retur...
[ "Generator", "that", "returns", "items", "in", "ther", "order", "needed", "for", "the", "actual", "python", "1", ")", "All", "forward", "references", "2", ")", "All", "lexer", "items", "3", ")", "Object", "/", "Array", "definitions", "in", "order", "of", ...
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_doc_context.py#L200-L253
[ "def", "ordered_elements", "(", "self", ")", "->", "str", ":", "from", "pyjsg", ".", "parser_impl", ".", "jsg_lexerruleblock_parser", "import", "JSGLexerRuleBlock", "from", "pyjsg", ".", "parser_impl", ".", "jsg_arrayexpr_parser", "import", "JSGArrayExpr", "from", "...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
new_request
New request for inclusion.
invenio_communities/receivers.py
def new_request(sender, request=None, notify=True, **kwargs): """New request for inclusion.""" if current_app.config['COMMUNITIES_MAIL_ENABLED'] and notify: send_community_request_email(request)
def new_request(sender, request=None, notify=True, **kwargs): """New request for inclusion.""" if current_app.config['COMMUNITIES_MAIL_ENABLED'] and notify: send_community_request_email(request)
[ "New", "request", "for", "inclusion", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/receivers.py#L36-L39
[ "def", "new_request", "(", "sender", ",", "request", "=", "None", ",", "notify", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "current_app", ".", "config", "[", "'COMMUNITIES_MAIL_ENABLED'", "]", "and", "notify", ":", "send_community_request_email", ...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
inject_provisional_community
Inject 'provisional_communities' key to ES index.
invenio_communities/receivers.py
def inject_provisional_community(sender, json=None, record=None, index=None, **kwargs): """Inject 'provisional_communities' key to ES index.""" if index and not index.startswith( current_app.config['COMMUNITIES_INDEX_PREFIX']): return json['provisional_c...
def inject_provisional_community(sender, json=None, record=None, index=None, **kwargs): """Inject 'provisional_communities' key to ES index.""" if index and not index.startswith( current_app.config['COMMUNITIES_INDEX_PREFIX']): return json['provisional_c...
[ "Inject", "provisional_communities", "key", "to", "ES", "index", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/receivers.py#L42-L51
[ "def", "inject_provisional_community", "(", "sender", ",", "json", "=", "None", ",", "record", "=", "None", ",", "index", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "index", "and", "not", "index", ".", "startswith", "(", "current_app", ".", ...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
create_oaipmh_set
Signal for creating OAI-PMH sets during community creation.
invenio_communities/receivers.py
def create_oaipmh_set(mapper, connection, community): """Signal for creating OAI-PMH sets during community creation.""" from invenio_oaiserver.models import OAISet with db.session.begin_nested(): obj = OAISet(spec=community.oaiset_spec, name=community.title, ...
def create_oaipmh_set(mapper, connection, community): """Signal for creating OAI-PMH sets during community creation.""" from invenio_oaiserver.models import OAISet with db.session.begin_nested(): obj = OAISet(spec=community.oaiset_spec, name=community.title, ...
[ "Signal", "for", "creating", "OAI", "-", "PMH", "sets", "during", "community", "creation", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/receivers.py#L54-L61
[ "def", "create_oaipmh_set", "(", "mapper", ",", "connection", ",", "community", ")", ":", "from", "invenio_oaiserver", ".", "models", "import", "OAISet", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "obj", "=", "OAISet", "(", "spec", "...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
destroy_oaipmh_set
Signal for creating OAI-PMH sets during community creation.
invenio_communities/receivers.py
def destroy_oaipmh_set(mapper, connection, community): """Signal for creating OAI-PMH sets during community creation.""" from invenio_oaiserver.models import OAISet with db.session.begin_nested(): oaiset = OAISet.query.filter_by( spec=community.oaiset_spec).one_or_none() if oaise...
def destroy_oaipmh_set(mapper, connection, community): """Signal for creating OAI-PMH sets during community creation.""" from invenio_oaiserver.models import OAISet with db.session.begin_nested(): oaiset = OAISet.query.filter_by( spec=community.oaiset_spec).one_or_none() if oaise...
[ "Signal", "for", "creating", "OAI", "-", "PMH", "sets", "during", "community", "creation", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/receivers.py#L64-L73
[ "def", "destroy_oaipmh_set", "(", "mapper", ",", "connection", ",", "community", ")", ":", "from", "invenio_oaiserver", ".", "models", "import", "OAISet", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "oaiset", "=", "OAISet", ".", "query"...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
_OTIWrapper.find_nodes
Query on node properties. See documentation for _OTIWrapper class.
peyotl/api/oti.py
def find_nodes(self, query_dict=None, exact=False, verbose=False, **kwargs): """Query on node properties. See documentation for _OTIWrapper class.""" assert self.use_v1 return self._do_query('{p}/singlePropertySearchForTreeNodes'.format(p=self.query_prefix), query_d...
def find_nodes(self, query_dict=None, exact=False, verbose=False, **kwargs): """Query on node properties. See documentation for _OTIWrapper class.""" assert self.use_v1 return self._do_query('{p}/singlePropertySearchForTreeNodes'.format(p=self.query_prefix), query_d...
[ "Query", "on", "node", "properties", ".", "See", "documentation", "for", "_OTIWrapper", "class", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/oti.py#L119-L127
[ "def", "find_nodes", "(", "self", ",", "query_dict", "=", "None", ",", "exact", "=", "False", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "use_v1", "return", "self", ".", "_do_query", "(", "'{p}/singlePropertyS...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_OTIWrapper.find_trees
Query on tree properties. See documentation for _OTIWrapper class.
peyotl/api/oti.py
def find_trees(self, query_dict=None, exact=False, verbose=False, wrap_response=False, **kwargs): """Query on tree properties. See documentation for _OTIWrapper class.""" if self.use_v1: uri = '{p}/singlePropertySearchForTrees'.format(p=self.query_prefix) else: uri = '{p}...
def find_trees(self, query_dict=None, exact=False, verbose=False, wrap_response=False, **kwargs): """Query on tree properties. See documentation for _OTIWrapper class.""" if self.use_v1: uri = '{p}/singlePropertySearchForTrees'.format(p=self.query_prefix) else: uri = '{p}...
[ "Query", "on", "tree", "properties", ".", "See", "documentation", "for", "_OTIWrapper", "class", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/oti.py#L129-L143
[ "def", "find_trees", "(", "self", ",", "query_dict", "=", "None", ",", "exact", "=", "False", ",", "verbose", "=", "False", ",", "wrap_response", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "use_v1", ":", "uri", "=", "'{p}/sin...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_OTIWrapper.find_studies
Query on study properties. See documentation for _OTIWrapper class.
peyotl/api/oti.py
def find_studies(self, query_dict=None, exact=False, verbose=False, **kwargs): """Query on study properties. See documentation for _OTIWrapper class.""" if self.use_v1: uri = '{p}/singlePropertySearchForStudies'.format(p=self.query_prefix) else: uri = '{p}/find_studies'.f...
def find_studies(self, query_dict=None, exact=False, verbose=False, **kwargs): """Query on study properties. See documentation for _OTIWrapper class.""" if self.use_v1: uri = '{p}/singlePropertySearchForStudies'.format(p=self.query_prefix) else: uri = '{p}/find_studies'.f...
[ "Query", "on", "study", "properties", ".", "See", "documentation", "for", "_OTIWrapper", "class", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/oti.py#L145-L156
[ "def", "find_studies", "(", "self", ",", "query_dict", "=", "None", ",", "exact", "=", "False", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "use_v1", ":", "uri", "=", "'{p}/singlePropertySearchForStudies'", ".", "f...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_OTIWrapper.find_all_studies
Returns a list of dicts for the entire set of studies indexed by oti. If verbose and include_trees are False, each dict will just have the ot:studyId If verbose is True, then the keys could also include: ot:curatorName ot:dataDeposit ot:focalClade ot:foca...
peyotl/api/oti.py
def find_all_studies(self, include_trees=False, verbose=False): """Returns a list of dicts for the entire set of studies indexed by oti. If verbose and include_trees are False, each dict will just have the ot:studyId If verbose is True, then the keys could also include: ot:curatorNa...
def find_all_studies(self, include_trees=False, verbose=False): """Returns a list of dicts for the entire set of studies indexed by oti. If verbose and include_trees are False, each dict will just have the ot:studyId If verbose is True, then the keys could also include: ot:curatorNa...
[ "Returns", "a", "list", "of", "dicts", "for", "the", "entire", "set", "of", "studies", "indexed", "by", "oti", ".", "If", "verbose", "and", "include_trees", "are", "False", "each", "dict", "will", "just", "have", "the", "ot", ":", "studyId", "If", "verbo...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/oti.py#L158-L179
[ "def", "find_all_studies", "(", "self", ",", "include_trees", "=", "False", ",", "verbose", "=", "False", ")", ":", "if", "not", "self", ".", "use_v1", ":", "return", "self", ".", "find_studies", "(", "verbose", "=", "verbose", ")", "url", "=", "'{p}/fin...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
get_requirements
returns requirements array for package
setup.py
def get_requirements(): '''returns requirements array for package''' packages = [] with open("requirements.txt", "r") as req_doc: for package in req_doc: packages.append(package.replace("\n", "")) return packages
def get_requirements(): '''returns requirements array for package''' packages = [] with open("requirements.txt", "r") as req_doc: for package in req_doc: packages.append(package.replace("\n", "")) return packages
[ "returns", "requirements", "array", "for", "package" ]
SpotlightData/preprocessing
python
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/setup.py#L5-L11
[ "def", "get_requirements", "(", ")", ":", "packages", "=", "[", "]", "with", "open", "(", "\"requirements.txt\"", ",", "\"r\"", ")", "as", "req_doc", ":", "for", "package", "in", "req_doc", ":", "packages", ".", "append", "(", "package", ".", "replace", ...
180c6472bc2642afbd7a1ece08d0b0d14968a708
train
TaxonomicAmendmentStore
Factory function for a _TaxonomicAmendmentStore object. A wrapper around the _TaxonomicAmendmentStore class instantiation for the most common use case: a singleton _TaxonomicAmendmentStore. If you need distinct _TaxonomicAmendmentStore objects, you'll need to call that class directly.
peyotl/amendments/amendments_umbrella.py
def TaxonomicAmendmentStore(repos_dict=None, repos_par=None, with_caching=True, assumed_doc_version=None, git_ssh=None, pkey=None, git_action_class=Taxo...
def TaxonomicAmendmentStore(repos_dict=None, repos_par=None, with_caching=True, assumed_doc_version=None, git_ssh=None, pkey=None, git_action_class=Taxo...
[ "Factory", "function", "for", "a", "_TaxonomicAmendmentStore", "object", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L352-L379
[ "def", "TaxonomicAmendmentStore", "(", "repos_dict", "=", "None", ",", "repos_par", "=", "None", ",", "with_caching", "=", "True", ",", "assumed_doc_version", "=", "None", ",", "git_ssh", "=", "None", ",", "pkey", "=", "None", ",", "git_action_class", "=", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_TaxonomicAmendmentStore.add_new_amendment
Validate and save this JSON. Ensure (and return) a unique amendment id
peyotl/amendments/amendments_umbrella.py
def add_new_amendment(self, json_repr, auth_info, commit_msg=''): """Validate and save this JSON. Ensure (and return) a unique amendment id""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None:...
def add_new_amendment(self, json_repr, auth_info, commit_msg=''): """Validate and save this JSON. Ensure (and return) a unique amendment id""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None:...
[ "Validate", "and", "save", "this", "JSON", ".", "Ensure", "(", "and", "return", ")", "a", "unique", "amendment", "id" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L129-L263
[ "def", "add_new_amendment", "(", "self", ",", "json_repr", ",", "auth_info", ",", "commit_msg", "=", "''", ")", ":", "amendment", "=", "self", ".", "_coerce_json_to_amendment", "(", "json_repr", ")", "if", "amendment", "is", "None", ":", "msg", "=", "\"File ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_TaxonomicAmendmentStore.update_existing_amendment
Validate and save this JSON. Ensure (and return) a unique amendment id
peyotl/amendments/amendments_umbrella.py
def update_existing_amendment(self, amendment_id=None, json_repr=None, auth_info=None, parent_sha=None, merged_sha=None, ...
def update_existing_amendment(self, amendment_id=None, json_repr=None, auth_info=None, parent_sha=None, merged_sha=None, ...
[ "Validate", "and", "save", "this", "JSON", ".", "Ensure", "(", "and", "return", ")", "a", "unique", "amendment", "id" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L265-L298
[ "def", "update_existing_amendment", "(", "self", ",", "amendment_id", "=", "None", ",", "json_repr", "=", "None", ",", "auth_info", "=", "None", ",", "parent_sha", "=", "None", ",", "merged_sha", "=", "None", ",", "commit_msg", "=", "''", ")", ":", "amendm...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_TaxonomicAmendmentStore._build_amendment_id
Parse the JSON, return a slug in the form '{subtype}-{first ottid}-{last-ottid}'.
peyotl/amendments/amendments_umbrella.py
def _build_amendment_id(self, json_repr): """Parse the JSON, return a slug in the form '{subtype}-{first ottid}-{last-ottid}'.""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None: return None amendment_subtype = 'additions' # TODO: Look more ...
def _build_amendment_id(self, json_repr): """Parse the JSON, return a slug in the form '{subtype}-{first ottid}-{last-ottid}'.""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None: return None amendment_subtype = 'additions' # TODO: Look more ...
[ "Parse", "the", "JSON", "return", "a", "slug", "in", "the", "form", "{", "subtype", "}", "-", "{", "first", "ottid", "}", "-", "{", "last", "-", "ottid", "}", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L300-L309
[ "def", "_build_amendment_id", "(", "self", ",", "json_repr", ")", ":", "amendment", "=", "self", ".", "_coerce_json_to_amendment", "(", "json_repr", ")", "if", "amendment", "is", "None", ":", "return", "None", "amendment_subtype", "=", "'additions'", "# TODO: Look...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_TaxonomicAmendmentStore._is_valid_amendment_json
Call the primary validator for a quick test
peyotl/amendments/amendments_umbrella.py
def _is_valid_amendment_json(self, json_repr): """Call the primary validator for a quick test""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None: # invalid JSON, definitely broken return False aa = validate_amendment(amendment) e...
def _is_valid_amendment_json(self, json_repr): """Call the primary validator for a quick test""" amendment = self._coerce_json_to_amendment(json_repr) if amendment is None: # invalid JSON, definitely broken return False aa = validate_amendment(amendment) e...
[ "Call", "the", "primary", "validator", "for", "a", "quick", "test" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L320-L332
[ "def", "_is_valid_amendment_json", "(", "self", ",", "json_repr", ")", ":", "amendment", "=", "self", ".", "_coerce_json_to_amendment", "(", "json_repr", ")", "if", "amendment", "is", "None", ":", "# invalid JSON, definitely broken", "return", "False", "aa", "=", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_TaxonomicAmendmentStore._coerce_json_to_amendment
Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python. If the incoming value is already parsed, do nothing. If a string fails to parse, return None.
peyotl/amendments/amendments_umbrella.py
def _coerce_json_to_amendment(self, json_repr): """Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python. If the incoming value is already parsed, do nothing. If a string fails to parse, return None.""" if isinstance(json_repr, dict): amendment = json...
def _coerce_json_to_amendment(self, json_repr): """Use to ensure that a JSON string (if found) is parsed to the equivalent dict in python. If the incoming value is already parsed, do nothing. If a string fails to parse, return None.""" if isinstance(json_repr, dict): amendment = json...
[ "Use", "to", "ensure", "that", "a", "JSON", "string", "(", "if", "found", ")", "is", "parsed", "to", "the", "equivalent", "dict", "in", "python", ".", "If", "the", "incoming", "value", "is", "already", "parsed", "do", "nothing", ".", "If", "a", "string...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/amendments/amendments_umbrella.py#L334-L345
[ "def", "_coerce_json_to_amendment", "(", "self", ",", "json_repr", ")", ":", "if", "isinstance", "(", "json_repr", ",", "dict", ")", ":", "amendment", "=", "json_repr", "else", ":", "try", ":", "amendment", "=", "anyjson", ".", "loads", "(", "json_repr", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
delete_marked_communities
Delete communities after holdout time.
invenio_communities/tasks.py
def delete_marked_communities(): """Delete communities after holdout time.""" # TODO: Delete the community ID from all records metadata first raise NotImplementedError() Community.query.filter_by( Community.delete_time > datetime.utcnow()).delete() db.session.commit()
def delete_marked_communities(): """Delete communities after holdout time.""" # TODO: Delete the community ID from all records metadata first raise NotImplementedError() Community.query.filter_by( Community.delete_time > datetime.utcnow()).delete() db.session.commit()
[ "Delete", "communities", "after", "holdout", "time", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/tasks.py#L38-L44
[ "def", "delete_marked_communities", "(", ")", ":", "# TODO: Delete the community ID from all records metadata first", "raise", "NotImplementedError", "(", ")", "Community", ".", "query", ".", "filter_by", "(", "Community", ".", "delete_time", ">", "datetime", ".", "utcnow...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
delete_expired_requests
Delete expired inclusion requests.
invenio_communities/tasks.py
def delete_expired_requests(): """Delete expired inclusion requests.""" InclusionRequest.query.filter_by( InclusionRequest.expiry_date > datetime.utcnow()).delete() db.session.commit()
def delete_expired_requests(): """Delete expired inclusion requests.""" InclusionRequest.query.filter_by( InclusionRequest.expiry_date > datetime.utcnow()).delete() db.session.commit()
[ "Delete", "expired", "inclusion", "requests", "." ]
inveniosoftware/invenio-communities
python
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/tasks.py#L48-L52
[ "def", "delete_expired_requests", "(", ")", ":", "InclusionRequest", ".", "query", ".", "filter_by", "(", "InclusionRequest", ".", "expiry_date", ">", "datetime", ".", "utcnow", "(", ")", ")", ".", "delete", "(", ")", "db", ".", "session", ".", "commit", "...
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
train
create_content_spec
Sugar. factory for a PhyloSchema object. Repackages the kwargs to kwargs for PhyloSchema so that our PhyloSchema.__init__ does not have to be soo rich
peyotl/nexson_syntax/__init__.py
def create_content_spec(**kwargs): """Sugar. factory for a PhyloSchema object. Repackages the kwargs to kwargs for PhyloSchema so that our PhyloSchema.__init__ does not have to be soo rich """ format_str = kwargs.get('format', 'nexson') nexson_version = kwargs.get('nexson_version', 'native') ...
def create_content_spec(**kwargs): """Sugar. factory for a PhyloSchema object. Repackages the kwargs to kwargs for PhyloSchema so that our PhyloSchema.__init__ does not have to be soo rich """ format_str = kwargs.get('format', 'nexson') nexson_version = kwargs.get('nexson_version', 'native') ...
[ "Sugar", ".", "factory", "for", "a", "PhyloSchema", "object", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L178-L205
[ "def", "create_content_spec", "(", "*", "*", "kwargs", ")", ":", "format_str", "=", "kwargs", ".", "get", "(", "'format'", ",", "'nexson'", ")", "nexson_version", "=", "kwargs", ".", "get", "(", "'nexson_version'", ",", "'native'", ")", "otu_label", "=", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
get_ot_study_info_from_nexml
Converts an XML doc to JSON using the honeybadgerfish convention (see to_honeybadgerfish_dict) and then prunes elements not used by open tree of life study curartion. If nexml_content is provided, it is interpreted as the contents of an NeXML file in utf-8 encoding. If nexml_content is None, then the ...
peyotl/nexson_syntax/__init__.py
def get_ot_study_info_from_nexml(src=None, nexml_content=None, encoding=u'utf8', nexson_syntax_version=DEFAULT_NEXSON_VERSION): """Converts an XML doc to JSON using the honeybadgerfish convention (see to_honeybadgerfi...
def get_ot_study_info_from_nexml(src=None, nexml_content=None, encoding=u'utf8', nexson_syntax_version=DEFAULT_NEXSON_VERSION): """Converts an XML doc to JSON using the honeybadgerfish convention (see to_honeybadgerfi...
[ "Converts", "an", "XML", "doc", "to", "JSON", "using", "the", "honeybadgerfish", "convention", "(", "see", "to_honeybadgerfish_dict", ")", "and", "then", "prunes", "elements", "not", "used", "by", "open", "tree", "of", "life", "study", "curartion", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L537-L587
[ "def", "get_ot_study_info_from_nexml", "(", "src", "=", "None", ",", "nexml_content", "=", "None", ",", "encoding", "=", "u'utf8'", ",", "nexson_syntax_version", "=", "DEFAULT_NEXSON_VERSION", ")", ":", "if", "_is_by_id_hbf", "(", "nexson_syntax_version", ")", ":", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
convert_nexson_format
Take a dict form of NexSON and converts its datastructures to those needed to serialize as out_nexson_format. If current_format is not specified, it will be inferred. If `remove_old_structs` is False and different honeybadgerfish varieties are selected, the `blob` will be 'fat" containing both types...
peyotl/nexson_syntax/__init__.py
def convert_nexson_format(blob, out_nexson_format, current_format=None, remove_old_structs=True, pristine_if_invalid=False, sort_arbitrary=False): """Take a dict form of NexSON and conve...
def convert_nexson_format(blob, out_nexson_format, current_format=None, remove_old_structs=True, pristine_if_invalid=False, sort_arbitrary=False): """Take a dict form of NexSON and conve...
[ "Take", "a", "dict", "form", "of", "NexSON", "and", "converts", "its", "datastructures", "to", "those", "needed", "to", "serialize", "as", "out_nexson_format", ".", "If", "current_format", "is", "not", "specified", "it", "will", "be", "inferred", ".", "If", ...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L646-L699
[ "def", "convert_nexson_format", "(", "blob", ",", "out_nexson_format", ",", "current_format", "=", "None", ",", "remove_old_structs", "=", "True", ",", "pristine_if_invalid", "=", "False", ",", "sort_arbitrary", "=", "False", ")", ":", "if", "not", "current_format...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
sort_meta_elements
For v0.0 (which has meta values in a list), this function recursively walks through the object and sorts each meta by @property or @rel values.
peyotl/nexson_syntax/__init__.py
def sort_meta_elements(blob): """For v0.0 (which has meta values in a list), this function recursively walks through the object and sorts each meta by @property or @rel values. """ v = detect_nexson_version(blob) if _is_badgerfish_version(v): _recursive_sort_meta(blob, '') return blo...
def sort_meta_elements(blob): """For v0.0 (which has meta values in a list), this function recursively walks through the object and sorts each meta by @property or @rel values. """ v = detect_nexson_version(blob) if _is_badgerfish_version(v): _recursive_sort_meta(blob, '') return blo...
[ "For", "v0", ".", "0", "(", "which", "has", "meta", "values", "in", "a", "list", ")", "this", "function", "recursively", "walks", "through", "the", "object", "and", "sorts", "each", "meta", "by" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L725-L733
[ "def", "sort_meta_elements", "(", "blob", ")", ":", "v", "=", "detect_nexson_version", "(", "blob", ")", "if", "_is_badgerfish_version", "(", "v", ")", ":", "_recursive_sort_meta", "(", "blob", ",", "''", ")", "return", "blob" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_inplace_sort_by_id
Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator
peyotl/nexson_syntax/__init__.py
def _inplace_sort_by_id(unsorted_list): """Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator """ if not isinstance(unsorted_list, list): return sorted_list ...
def _inplace_sort_by_id(unsorted_list): """Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator """ if not isinstance(unsorted_list, list): return sorted_list ...
[ "Takes", "a", "list", "of", "dicts", "each", "of", "which", "has", "an" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L736-L746
[ "def", "_inplace_sort_by_id", "(", "unsorted_list", ")", ":", "if", "not", "isinstance", "(", "unsorted_list", ",", "list", ")", ":", "return", "sorted_list", "=", "[", "(", "i", ".", "get", "(", "'@id'", ")", ",", "i", ")", "for", "i", "in", "unsorted...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
sort_arbitrarily_ordered_nexson
Primarily used for testing (getting nice diffs). Calls sort_meta_elements and then sorts otu, node and edge list by id
peyotl/nexson_syntax/__init__.py
def sort_arbitrarily_ordered_nexson(blob): """Primarily used for testing (getting nice diffs). Calls sort_meta_elements and then sorts otu, node and edge list by id """ # otu, node and edge elements have no necessary orger in v0.0 or v1.0 v = detect_nexson_version(blob) nex = get_nexml_el(blob) ...
def sort_arbitrarily_ordered_nexson(blob): """Primarily used for testing (getting nice diffs). Calls sort_meta_elements and then sorts otu, node and edge list by id """ # otu, node and edge elements have no necessary orger in v0.0 or v1.0 v = detect_nexson_version(blob) nex = get_nexml_el(blob) ...
[ "Primarily", "used", "for", "testing", "(", "getting", "nice", "diffs", ")", ".", "Calls", "sort_meta_elements", "and", "then", "sorts", "otu", "node", "and", "edge", "list", "by", "id" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L749-L765
[ "def", "sort_arbitrarily_ordered_nexson", "(", "blob", ")", ":", "# otu, node and edge elements have no necessary orger in v0.0 or v1.0", "v", "=", "detect_nexson_version", "(", "blob", ")", "nex", "=", "get_nexml_el", "(", "blob", ")", "if", "_is_by_id_hbf", "(", "v", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_write_newick_leaf_label
`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will hold the order encountered, and the dict will map name to index in the list
peyotl/nexson_syntax/__init__.py
def _write_newick_leaf_label(out, node_id, node, otu_group, label_key, leaf_labels, unlabeled_counter, needs_quotes_pattern): """ `label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu If `leaf_labels` is not None, it shoulr be a (list, dict) pair whi...
def _write_newick_leaf_label(out, node_id, node, otu_group, label_key, leaf_labels, unlabeled_counter, needs_quotes_pattern): """ `label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu If `leaf_labels` is not None, it shoulr be a (list, dict) pair whi...
[ "label_key", "is", "a", "string", "(", "a", "key", "in", "the", "otu", "object", ")", "or", "a", "callable", "that", "takes", "two", "arguments", ":", "the", "node", "and", "the", "otu", "If", "leaf_labels", "is", "not", "None", "it", "shoulr", "be", ...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L840-L865
[ "def", "_write_newick_leaf_label", "(", "out", ",", "node_id", ",", "node", ",", "otu_group", ",", "label_key", ",", "leaf_labels", ",", "unlabeled_counter", ",", "needs_quotes_pattern", ")", ":", "otu_id", "=", "node", "[", "'@otu'", "]", "otu", "=", "otu_gro...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
_write_newick_internal_label
`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu (which may be None for an internal node) If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will hold the order encountered, and the dict...
peyotl/nexson_syntax/__init__.py
def _write_newick_internal_label(out, node_id, node, otu_group, label_key, needs_quotes_pattern): """`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu (which may be None for an internal node) If `leaf_labels` is not None, it shoulr be a (list...
def _write_newick_internal_label(out, node_id, node, otu_group, label_key, needs_quotes_pattern): """`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu (which may be None for an internal node) If `leaf_labels` is not None, it shoulr be a (list...
[ "label_key", "is", "a", "string", "(", "a", "key", "in", "the", "otu", "object", ")", "or", "a", "callable", "that", "takes", "two", "arguments", ":", "the", "node", "and", "the", "otu", "(", "which", "may", "be", "None", "for", "an", "internal", "no...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L868-L885
[ "def", "_write_newick_internal_label", "(", "out", ",", "node_id", ",", "node", ",", "otu_group", ",", "label_key", ",", "needs_quotes_pattern", ")", ":", "otu_id", "=", "node", ".", "get", "(", "'@otu'", ")", "if", "is_str_type", "(", "label_key", ")", ":",...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
convert_tree_to_newick
`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu (which may be None for an internal node) If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will hold the order encountered, and the dict...
peyotl/nexson_syntax/__init__.py
def convert_tree_to_newick(tree, otu_group, label_key, leaf_labels, needs_quotes_pattern=NEWICK_NEEDING_QUOTING, subtree_id=None, bracket_ingroup=False): ...
def convert_tree_to_newick(tree, otu_group, label_key, leaf_labels, needs_quotes_pattern=NEWICK_NEEDING_QUOTING, subtree_id=None, bracket_ingroup=False): ...
[ "label_key", "is", "a", "string", "(", "a", "key", "in", "the", "otu", "object", ")", "or", "a", "callable", "that", "takes", "two", "arguments", ":", "the", "node", "and", "the", "otu", "(", "which", "may", "be", "None", "for", "an", "internal", "no...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L896-L935
[ "def", "convert_tree_to_newick", "(", "tree", ",", "otu_group", ",", "label_key", ",", "leaf_labels", ",", "needs_quotes_pattern", "=", "NEWICK_NEEDING_QUOTING", ",", "subtree_id", "=", "None", ",", "bracket_ingroup", "=", "False", ")", ":", "assert", "(", "not", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
nexson_frag_write_newick
`label_key` is a string (a key in the otu object) or a callable that takes two arguments: the node, and the otu (which may be None for an internal node) If `leaf_labels` is not None, it shoulr be a (list, dict) pair which will be filled. The list will hold the order encountered, and the dict...
peyotl/nexson_syntax/__init__.py
def nexson_frag_write_newick(out, edges, nodes, otu_group, label_key, leaf_labels, root_id, needs_quotes_pattern=NEWI...
def nexson_frag_write_newick(out, edges, nodes, otu_group, label_key, leaf_labels, root_id, needs_quotes_pattern=NEWI...
[ "label_key", "is", "a", "string", "(", "a", "key", "in", "the", "otu", "object", ")", "or", "a", "callable", "that", "takes", "two", "arguments", ":", "the", "node", "and", "the", "otu", "(", "which", "may", "be", "None", "for", "an", "internal", "no...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L973-L1053
[ "def", "nexson_frag_write_newick", "(", "out", ",", "edges", ",", "nodes", ",", "otu_group", ",", "label_key", ",", "leaf_labels", ",", "root_id", ",", "needs_quotes_pattern", "=", "NEWICK_NEEDING_QUOTING", ",", "ingroup_id", "=", "None", ",", "bracket_ingroup", "...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
cull_nonmatching_trees
Modifies `nexson` and returns it in version 1.2.1 with any tree that does not match the ID removed. Note that this does not search through the NexSON for every node, edge, tree that was deleted. So the resulting NexSON may have broken references !
peyotl/nexson_syntax/__init__.py
def cull_nonmatching_trees(nexson, tree_id, curr_version=None): """Modifies `nexson` and returns it in version 1.2.1 with any tree that does not match the ID removed. Note that this does not search through the NexSON for every node, edge, tree that was deleted. So the resulting NexSON may have brok...
def cull_nonmatching_trees(nexson, tree_id, curr_version=None): """Modifies `nexson` and returns it in version 1.2.1 with any tree that does not match the ID removed. Note that this does not search through the NexSON for every node, edge, tree that was deleted. So the resulting NexSON may have brok...
[ "Modifies", "nexson", "and", "returns", "it", "in", "version", "1", ".", "2", ".", "1", "with", "any", "tree", "that", "does", "not", "match", "the", "ID", "removed", "." ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L1156-L1184
[ "def", "cull_nonmatching_trees", "(", "nexson", ",", "tree_id", ",", "curr_version", "=", "None", ")", ":", "if", "curr_version", "is", "None", ":", "curr_version", "=", "detect_nexson_version", "(", "nexson", ")", "if", "not", "_is_by_id_hbf", "(", "curr_versio...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
extract_tree_nexson
Returns a list of (id, tree, otus_group) tuples for the specified tree_id (all trees if tree_id is None)
peyotl/nexson_syntax/__init__.py
def extract_tree_nexson(nexson, tree_id, curr_version=None): """Returns a list of (id, tree, otus_group) tuples for the specified tree_id (all trees if tree_id is None) """ if curr_version is None: curr_version = detect_nexson_version(nexson) if not _is_by_id_hbf(curr_version): nexso...
def extract_tree_nexson(nexson, tree_id, curr_version=None): """Returns a list of (id, tree, otus_group) tuples for the specified tree_id (all trees if tree_id is None) """ if curr_version is None: curr_version = detect_nexson_version(nexson) if not _is_by_id_hbf(curr_version): nexso...
[ "Returns", "a", "list", "of", "(", "id", "tree", "otus_group", ")", "tuples", "for", "the", "specified", "tree_id", "(", "all", "trees", "if", "tree_id", "is", "None", ")" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L1186-L1211
[ "def", "extract_tree_nexson", "(", "nexson", ",", "tree_id", ",", "curr_version", "=", "None", ")", ":", "if", "curr_version", "is", "None", ":", "curr_version", "=", "detect_nexson_version", "(", "nexson", ")", "if", "not", "_is_by_id_hbf", "(", "curr_version",...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
PhyloSchema.phylesystem_api_url
Returns URL and param dict for a GET call to phylesystem_api
peyotl/nexson_syntax/__init__.py
def phylesystem_api_url(self, base_url, study_id): """Returns URL and param dict for a GET call to phylesystem_api """ p = self._phylesystem_api_params() e = self._phylesystem_api_ext() if self.content == 'study': return '{d}/study/{i}{e}'.format(d=base_url, i=study_i...
def phylesystem_api_url(self, base_url, study_id): """Returns URL and param dict for a GET call to phylesystem_api """ p = self._phylesystem_api_params() e = self._phylesystem_api_ext() if self.content == 'study': return '{d}/study/{i}{e}'.format(d=base_url, i=study_i...
[ "Returns", "URL", "and", "param", "dict", "for", "a", "GET", "call", "to", "phylesystem_api" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L400-L429
[ "def", "phylesystem_api_url", "(", "self", ",", "base_url", ",", "study_id", ")", ":", "p", "=", "self", ".", "_phylesystem_api_params", "(", ")", "e", "=", "self", ".", "_phylesystem_api_ext", "(", ")", "if", "self", ".", "content", "==", "'study'", ":", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
JSGArray._is_valid
Determine whether the current contents are valid
pyjsg/jsglib/jsg_array.py
def _is_valid(self, log: Optional[Logger] = None) -> bool: """ Determine whether the current contents are valid """ return self._validate(self, log)[0]
def _is_valid(self, log: Optional[Logger] = None) -> bool: """ Determine whether the current contents are valid """ return self._validate(self, log)[0]
[ "Determine", "whether", "the", "current", "contents", "are", "valid" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_array.py#L33-L35
[ "def", "_is_valid", "(", "self", ",", "log", ":", "Optional", "[", "Logger", "]", "=", "None", ")", "->", "bool", ":", "return", "self", ".", "_validate", "(", "self", ",", "log", ")", "[", "0", "]" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
JSGArray._validate
Determine whether val is a valid instance of this array :returns: Success indicator and error list
pyjsg/jsglib/jsg_array.py
def _validate(self, val: list, log: Optional[Logger] = None) -> Tuple[bool, List[str]]: """ Determine whether val is a valid instance of this array :returns: Success indicator and error list """ errors = [] if not isinstance(val, list): errors.append(f"{self._variable_name}:...
def _validate(self, val: list, log: Optional[Logger] = None) -> Tuple[bool, List[str]]: """ Determine whether val is a valid instance of this array :returns: Success indicator and error list """ errors = [] if not isinstance(val, list): errors.append(f"{self._variable_name}:...
[ "Determine", "whether", "val", "is", "a", "valid", "instance", "of", "this", "array" ]
hsolbrig/pyjsg
python
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_array.py#L37-L61
[ "def", "_validate", "(", "self", ",", "val", ":", "list", ",", "log", ":", "Optional", "[", "Logger", "]", "=", "None", ")", "->", "Tuple", "[", "bool", ",", "List", "[", "str", "]", "]", ":", "errors", "=", "[", "]", "if", "not", "isinstance", ...
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
train
Direct2BadgerfishNexson.convert
Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place and returned.
peyotl/nexson_syntax/direct2badgerfish_nexson.py
def convert(self, obj): """Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place and returned. """ if self.pristine_if_invalid: raise NotImplementedError('pristi...
def convert(self, obj): """Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place and returned. """ if self.pristine_if_invalid: raise NotImplementedError('pristi...
[ "Takes", "a", "dict", "corresponding", "to", "the", "honeybadgerfish", "JSON", "blob", "of", "the", "1", ".", "0", ".", "*", "type", "and", "converts", "it", "to", "BY_ID_HONEY_BADGERFISH", "version", ".", "The", "object", "is", "modified", "in", "place", ...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/direct2badgerfish_nexson.py#L72-L94
[ "def", "convert", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "pristine_if_invalid", ":", "raise", "NotImplementedError", "(", "'pristine_if_invalid option is not supported yet'", ")", "nex", "=", "get_nexml_el", "(", "obj", ")", "assert", "nex", "self",...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
Optimal2DirectNexson.convert
Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.2.* type and converts it to DIRECT_HONEY_BADGERFISH version. The object is modified in place and returned.
peyotl/nexson_syntax/optimal2direct_nexson.py
def convert(self, obj): """Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.2.* type and converts it to DIRECT_HONEY_BADGERFISH version. The object is modified in place and returned. """ if self.pristine_if_invalid: raise NotImplementedError('prist...
def convert(self, obj): """Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.2.* type and converts it to DIRECT_HONEY_BADGERFISH version. The object is modified in place and returned. """ if self.pristine_if_invalid: raise NotImplementedError('prist...
[ "Takes", "a", "dict", "corresponding", "to", "the", "honeybadgerfish", "JSON", "blob", "of", "the", "1", ".", "2", ".", "*", "type", "and", "converts", "it", "to", "DIRECT_HONEY_BADGERFISH", "version", ".", "The", "object", "is", "modified", "in", "place", ...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/optimal2direct_nexson.py#L122-L151
[ "def", "convert", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "pristine_if_invalid", ":", "raise", "NotImplementedError", "(", "'pristine_if_invalid option is not supported yet'", ")", "nex", "=", "get_nexml_el", "(", "obj", ")", "assert", "nex", "# Crea...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
splitbins
t, trace=0 -> (t1, t2, shift). Split a table to save space. t is a sequence of ints. This function can be useful to save space if many of the ints are the same. t1 and t2 are lists of ints, and shift is an int, chosen to minimize the combined size of t1 and t2 (in C code), and where for each i in ra...
makeunicodedata.py
def splitbins(t, trace=0): """t, trace=0 -> (t1, t2, shift). Split a table to save space. t is a sequence of ints. This function can be useful to save space if many of the ints are the same. t1 and t2 are lists of ints, and shift is an int, chosen to minimize the combined size of t1 and t2 (in C ...
def splitbins(t, trace=0): """t, trace=0 -> (t1, t2, shift). Split a table to save space. t is a sequence of ints. This function can be useful to save space if many of the ints are the same. t1 and t2 are lists of ints, and shift is an int, chosen to minimize the combined size of t1 and t2 (in C ...
[ "t", "trace", "=", "0", "-", ">", "(", "t1", "t2", "shift", ")", ".", "Split", "a", "table", "to", "save", "space", "." ]
mikekap/unicodedata2
python
https://github.com/mikekap/unicodedata2/blob/190ea59368545d6784793edeb96726a2c517a74d/makeunicodedata.py#L1282-L1341
[ "def", "splitbins", "(", "t", ",", "trace", "=", "0", ")", ":", "if", "trace", ":", "def", "dump", "(", "t1", ",", "t2", ",", "shift", ",", "bytes", ")", ":", "print", "(", "\"%d+%d bins at shift %d; %d bytes\"", "%", "(", "len", "(", "t1", ")", ",...
190ea59368545d6784793edeb96726a2c517a74d
train
otu_iter_nexson_proxy
otu_sort can be None (not sorted or stable), True (sorted by ID lexigraphically) or a key function for a sort function on list of otuIDs Note that if there are multiple OTU groups, the NexSON specifies the order of sorting of the groups (so the sort argument here only refers to the sorting of OTUs with...
peyotl/nexson_proxy.py
def otu_iter_nexson_proxy(nexson_proxy, otu_sort=None): """otu_sort can be None (not sorted or stable), True (sorted by ID lexigraphically) or a key function for a sort function on list of otuIDs Note that if there are multiple OTU groups, the NexSON specifies the order of sorting of the groups (so...
def otu_iter_nexson_proxy(nexson_proxy, otu_sort=None): """otu_sort can be None (not sorted or stable), True (sorted by ID lexigraphically) or a key function for a sort function on list of otuIDs Note that if there are multiple OTU groups, the NexSON specifies the order of sorting of the groups (so...
[ "otu_sort", "can", "be", "None", "(", "not", "sorted", "or", "stable", ")", "True", "(", "sorted", "by", "ID", "lexigraphically", ")", "or", "a", "key", "function", "for", "a", "sort", "function", "on", "list", "of", "otuIDs" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_proxy.py#L25-L49
[ "def", "otu_iter_nexson_proxy", "(", "nexson_proxy", ",", "otu_sort", "=", "None", ")", ":", "nexml_el", "=", "nexson_proxy", ".", "_nexml_el", "og_order", "=", "nexml_el", "[", "'^ot:otusElementOrder'", "]", "ogd", "=", "nexml_el", "[", "'otusById'", "]", "for"...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
tree_iter_nexson_proxy
Iterates over NexsonTreeProxy objects in order determined by the nexson blob
peyotl/nexson_proxy.py
def tree_iter_nexson_proxy(nexson_proxy): """Iterates over NexsonTreeProxy objects in order determined by the nexson blob""" nexml_el = nexson_proxy._nexml_el tg_order = nexml_el['^ot:treesElementOrder'] tgd = nexml_el['treesById'] for tg_id in tg_order: tg = tgd[tg_id] tree_order = ...
def tree_iter_nexson_proxy(nexson_proxy): """Iterates over NexsonTreeProxy objects in order determined by the nexson blob""" nexml_el = nexson_proxy._nexml_el tg_order = nexml_el['^ot:treesElementOrder'] tgd = nexml_el['treesById'] for tg_id in tg_order: tg = tgd[tg_id] tree_order = ...
[ "Iterates", "over", "NexsonTreeProxy", "objects", "in", "order", "determined", "by", "the", "nexson", "blob" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_proxy.py#L52-L64
[ "def", "tree_iter_nexson_proxy", "(", "nexson_proxy", ")", ":", "nexml_el", "=", "nexson_proxy", ".", "_nexml_el", "tg_order", "=", "nexml_el", "[", "'^ot:treesElementOrder'", "]", "tgd", "=", "nexml_el", "[", "'treesById'", "]", "for", "tg_id", "in", "tg_order", ...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
nexson_tree_preorder_iter
Takes a tree in "By ID" NexSON (v1.2). provides and iterator over: NexsonNodeProxy object where the edge of the object is the edge connectin the node to the parent. The first node will be the root and will have None as it's edge
peyotl/nexson_proxy.py
def nexson_tree_preorder_iter(tree_proxy, node_id=None, node=None, edge_id=None, edge=None): """Takes a tree in "By ID" NexSON (v1.2). provides and iterator over: NexsonNodeProxy object where the edge of the object is the edge connectin the node to the parent. The first node will be the root and wi...
def nexson_tree_preorder_iter(tree_proxy, node_id=None, node=None, edge_id=None, edge=None): """Takes a tree in "By ID" NexSON (v1.2). provides and iterator over: NexsonNodeProxy object where the edge of the object is the edge connectin the node to the parent. The first node will be the root and wi...
[ "Takes", "a", "tree", "in", "By", "ID", "NexSON", "(", "v1", ".", "2", ")", ".", "provides", "and", "iterator", "over", ":", "NexsonNodeProxy", "object", "where", "the", "edge", "of", "the", "object", "is", "the", "edge", "connectin", "the", "node", "t...
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_proxy.py#L352-L394
[ "def", "nexson_tree_preorder_iter", "(", "tree_proxy", ",", "node_id", "=", "None", ",", "node", "=", "None", ",", "edge_id", "=", "None", ",", "edge", "=", "None", ")", ":", "tree", "=", "tree_proxy", ".", "_nexson_tree", "ebsid", "=", "tree", "[", "'ed...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
NexsonTreeProxy.edge_by_target
Returns a reference to the dict of target node id to (edge_id, edge)
peyotl/nexson_proxy.py
def edge_by_target(self): """Returns a reference to the dict of target node id to (edge_id, edge)""" if self._edge_by_target is None: self._edge_by_target = reverse_edge_by_source_dict(self._edge_by_source_id, self._nexson_tree['...
def edge_by_target(self): """Returns a reference to the dict of target node id to (edge_id, edge)""" if self._edge_by_target is None: self._edge_by_target = reverse_edge_by_source_dict(self._edge_by_source_id, self._nexson_tree['...
[ "Returns", "a", "reference", "to", "the", "dict", "of", "target", "node", "id", "to", "(", "edge_id", "edge", ")" ]
OpenTreeOfLife/peyotl
python
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_proxy.py#L298-L303
[ "def", "edge_by_target", "(", "self", ")", ":", "if", "self", ".", "_edge_by_target", "is", "None", ":", "self", ".", "_edge_by_target", "=", "reverse_edge_by_source_dict", "(", "self", ".", "_edge_by_source_id", ",", "self", ".", "_nexson_tree", "[", "'^ot:root...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
train
main
Get status from APC NIS and print output on stdout.
apcaccess/__main__.py
def main(): """Get status from APC NIS and print output on stdout.""" # No need to use "proper" names on such simple code. # pylint: disable=invalid-name p = argparse.ArgumentParser() p.add_argument("--host", default="localhost") p.add_argument("--port", type=int, default=3551) p.add_argumen...
def main(): """Get status from APC NIS and print output on stdout.""" # No need to use "proper" names on such simple code. # pylint: disable=invalid-name p = argparse.ArgumentParser() p.add_argument("--host", default="localhost") p.add_argument("--port", type=int, default=3551) p.add_argumen...
[ "Get", "status", "from", "APC", "NIS", "and", "print", "output", "on", "stdout", "." ]
flyte/apcaccess
python
https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/__main__.py#L12-L24
[ "def", "main", "(", ")", ":", "# No need to use \"proper\" names on such simple code.", "# pylint: disable=invalid-name", "p", "=", "argparse", ".", "ArgumentParser", "(", ")", "p", ".", "add_argument", "(", "\"--host\"", ",", "default", "=", "\"localhost\"", ")", "p"...
0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a
train
Server.wsgi_app
A basic WSGI app
typedjsonrpc/server.py
def wsgi_app(self, environ, start_response): """A basic WSGI app""" @_LOCAL_MANAGER.middleware def _wrapped_app(environ, start_response): request = Request(environ) setattr(_local, _CURRENT_REQUEST_KEY, request) response = self._dispatch_request(request) ...
def wsgi_app(self, environ, start_response): """A basic WSGI app""" @_LOCAL_MANAGER.middleware def _wrapped_app(environ, start_response): request = Request(environ) setattr(_local, _CURRENT_REQUEST_KEY, request) response = self._dispatch_request(request) ...
[ "A", "basic", "WSGI", "app" ]
palantir/typedjsonrpc
python
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L101-L109
[ "def", "wsgi_app", "(", "self", ",", "environ", ",", "start_response", ")", ":", "@", "_LOCAL_MANAGER", ".", "middleware", "def", "_wrapped_app", "(", "environ", ",", "start_response", ")", ":", "request", "=", "Request", "(", "environ", ")", "setattr", "(",...
274218fcd236ff9643506caa629029c9ba25a0fb
train
Server.run
For debugging purposes, you can run this as a standalone server. .. WARNING:: **Security vulnerability** This uses :class:`DebuggedJsonRpcApplication` to assist debugging. If you want to use this in production, you should run :class:`Server` as a standard WSGI app with `uWS...
typedjsonrpc/server.py
def run(self, host, port, **options): """For debugging purposes, you can run this as a standalone server. .. WARNING:: **Security vulnerability** This uses :class:`DebuggedJsonRpcApplication` to assist debugging. If you want to use this in production, you should run :class:`Ser...
def run(self, host, port, **options): """For debugging purposes, you can run this as a standalone server. .. WARNING:: **Security vulnerability** This uses :class:`DebuggedJsonRpcApplication` to assist debugging. If you want to use this in production, you should run :class:`Ser...
[ "For", "debugging", "purposes", "you", "can", "run", "this", "as", "a", "standalone", "server", "." ]
palantir/typedjsonrpc
python
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L114-L127
[ "def", "run", "(", "self", ",", "host", ",", "port", ",", "*", "*", "options", ")", ":", "self", ".", "registry", ".", "debug", "=", "True", "debugged", "=", "DebuggedJsonRpcApplication", "(", "self", ",", "evalex", "=", "True", ")", "run_simple", "(",...
274218fcd236ff9643506caa629029c9ba25a0fb
train
Server._try_trigger_before_first_request_funcs
Runs each function from ``self.before_first_request_funcs`` once and only once.
typedjsonrpc/server.py
def _try_trigger_before_first_request_funcs(self): # pylint: disable=C0103 """Runs each function from ``self.before_first_request_funcs`` once and only once.""" if self._after_first_request_handled: return else: with self._before_first_request_lock: if se...
def _try_trigger_before_first_request_funcs(self): # pylint: disable=C0103 """Runs each function from ``self.before_first_request_funcs`` once and only once.""" if self._after_first_request_handled: return else: with self._before_first_request_lock: if se...
[ "Runs", "each", "function", "from", "self", ".", "before_first_request_funcs", "once", "and", "only", "once", "." ]
palantir/typedjsonrpc
python
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L129-L139
[ "def", "_try_trigger_before_first_request_funcs", "(", "self", ")", ":", "# pylint: disable=C0103", "if", "self", ".", "_after_first_request_handled", ":", "return", "else", ":", "with", "self", ".", "_before_first_request_lock", ":", "if", "self", ".", "_after_first_re...
274218fcd236ff9643506caa629029c9ba25a0fb
train
DebuggedJsonRpcApplication.debug_application
Run the application and preserve the traceback frames. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of the wsgi application :type start_response: (str, list[(str, str)]) -> N...
typedjsonrpc/server.py
def debug_application(self, environ, start_response): """Run the application and preserve the traceback frames. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of the wsgi appli...
def debug_application(self, environ, start_response): """Run the application and preserve the traceback frames. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of the wsgi appli...
[ "Run", "the", "application", "and", "preserve", "the", "traceback", "frames", "." ]
palantir/typedjsonrpc
python
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L177-L194
[ "def", "debug_application", "(", "self", ",", "environ", ",", "start_response", ")", ":", "adapter", "=", "self", ".", "_debug_map", ".", "bind_to_environ", "(", "environ", ")", "if", "adapter", ".", "test", "(", ")", ":", "_", ",", "args", "=", "adapter...
274218fcd236ff9643506caa629029c9ba25a0fb
train
DebuggedJsonRpcApplication.handle_debug
Handles the debug endpoint for inspecting previous errors. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of the wsgi application :type start_response: (str, list[(str, str)]) ...
typedjsonrpc/server.py
def handle_debug(self, environ, start_response, traceback_id): """Handles the debug endpoint for inspecting previous errors. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of t...
def handle_debug(self, environ, start_response, traceback_id): """Handles the debug endpoint for inspecting previous errors. :param environ: The environment which is passed into the wsgi application :type environ: dict[str, object] :param start_response: The start_response function of t...
[ "Handles", "the", "debug", "endpoint", "for", "inspecting", "previous", "errors", "." ]
palantir/typedjsonrpc
python
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L196-L216
[ "def", "handle_debug", "(", "self", ",", "environ", ",", "start_response", ",", "traceback_id", ")", ":", "if", "traceback_id", "not", "in", "self", ".", "app", ".", "registry", ".", "tracebacks", ":", "abort", "(", "404", ")", "self", ".", "_copy_over_tra...
274218fcd236ff9643506caa629029c9ba25a0fb