repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
OpenTreeOfLife/peyotl
peyotl/nexson_syntax/__init__.py
_inplace_sort_by_id
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 ...
python
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", ")", ":", "if", "not", "isinstance", "(", "unsorted_list", ",", "list", ")", ":", "return", "sorted_list", "=", "[", "(", "i", ".", "get", "(", "'@id'", ")", ",", "i", ")", "for", "i", "in", "unsorted...
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
[ "Takes", "a", "list", "of", "dicts", "each", "of", "which", "has", "an" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L736-L746
train
OpenTreeOfLife/peyotl
peyotl/nexson_syntax/__init__.py
cull_nonmatching_trees
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...
python
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", ")", ":", "if", "curr_version", "is", "None", ":", "curr_version", "=", "detect_nexson_version", "(", "nexson", ")", "if", "not", "_is_by_id_hbf", "(", "curr_versio...
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 !
[ "Modifies", "nexson", "and", "returns", "it", "in", "version", "1", ".", "2", ".", "1", "with", "any", "tree", "that", "does", "not", "match", "the", "ID", "removed", "." ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L1156-L1184
train
OpenTreeOfLife/peyotl
peyotl/nexson_syntax/__init__.py
PhyloSchema.phylesystem_api_url
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...
python
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", ")", ":", "p", "=", "self", ".", "_phylesystem_api_params", "(", ")", "e", "=", "self", ".", "_phylesystem_api_ext", "(", ")", "if", "self", ".", "content", "==", "'study'", ":", ...
Returns URL and param dict for a GET call to phylesystem_api
[ "Returns", "URL", "and", "param", "dict", "for", "a", "GET", "call", "to", "phylesystem_api" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/__init__.py#L400-L429
train
hsolbrig/pyjsg
pyjsg/jsglib/jsg_array.py
JSGArray._is_valid
def _is_valid(self, log: Optional[Logger] = None) -> bool: """ Determine whether the current contents are valid """ return self._validate(self, log)[0]
python
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", ":", "return", "self", ".", "_validate", "(", "self", ",", "log", ")", "[", "0", "]" ]
Determine whether the current contents are valid
[ "Determine", "whether", "the", "current", "contents", "are", "valid" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_array.py#L33-L35
train
hsolbrig/pyjsg
pyjsg/jsglib/jsg_array.py
JSGArray._validate
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}:...
python
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", "]", "]", ":", "errors", "=", "[", "]", "if", "not", "isinstance", ...
Determine whether val is a valid instance of this array :returns: Success indicator and error list
[ "Determine", "whether", "val", "is", "a", "valid", "instance", "of", "this", "array" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_array.py#L37-L61
train
OpenTreeOfLife/peyotl
peyotl/nexson_proxy.py
tree_iter_nexson_proxy
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 = ...
python
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", ")", ":", "nexml_el", "=", "nexson_proxy", ".", "_nexml_el", "tg_order", "=", "nexml_el", "[", "'^ot:treesElementOrder'", "]", "tgd", "=", "nexml_el", "[", "'treesById'", "]", "for", "tg_id", "in", "tg_order", ...
Iterates over NexsonTreeProxy objects in order determined by the nexson blob
[ "Iterates", "over", "NexsonTreeProxy", "objects", "in", "order", "determined", "by", "the", "nexson", "blob" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_proxy.py#L52-L64
train
flyte/apcaccess
apcaccess/__main__.py
main
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...
python
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", "(", ")", ":", "# No need to use \"proper\" names on such simple code.", "# pylint: disable=invalid-name", "p", "=", "argparse", ".", "ArgumentParser", "(", ")", "p", ".", "add_argument", "(", "\"--host\"", ",", "default", "=", "\"localhost\"", ")", "p"...
Get status from APC NIS and print output on stdout.
[ "Get", "status", "from", "APC", "NIS", "and", "print", "output", "on", "stdout", "." ]
0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a
https://github.com/flyte/apcaccess/blob/0c8a5d5e4ba1c07110e411b4ffea4ddccef4829a/apcaccess/__main__.py#L12-L24
train
palantir/typedjsonrpc
typedjsonrpc/server.py
Server.wsgi_app
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) ...
python
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", ")", ":", "@", "_LOCAL_MANAGER", ".", "middleware", "def", "_wrapped_app", "(", "environ", ",", "start_response", ")", ":", "request", "=", "Request", "(", "environ", ")", "setattr", "(",...
A basic WSGI app
[ "A", "basic", "WSGI", "app" ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L101-L109
train
palantir/typedjsonrpc
typedjsonrpc/server.py
Server.run
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...
python
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", ")", ":", "self", ".", "registry", ".", "debug", "=", "True", "debugged", "=", "DebuggedJsonRpcApplication", "(", "self", ",", "evalex", "=", "True", ")", "run_simple", "(",...
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...
[ "For", "debugging", "purposes", "you", "can", "run", "this", "as", "a", "standalone", "server", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L114-L127
train
palantir/typedjsonrpc
typedjsonrpc/server.py
Server._try_trigger_before_first_request_funcs
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...
python
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", "if", "self", ".", "_after_first_request_handled", ":", "return", "else", ":", "with", "self", ".", "_before_first_request_lock", ":", "if", "self", ".", "_after_first_re...
Runs each function from ``self.before_first_request_funcs`` once and only once.
[ "Runs", "each", "function", "from", "self", ".", "before_first_request_funcs", "once", "and", "only", "once", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L129-L139
train
palantir/typedjsonrpc
typedjsonrpc/server.py
DebuggedJsonRpcApplication.debug_application
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...
python
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", ")", ":", "adapter", "=", "self", ".", "_debug_map", ".", "bind_to_environ", "(", "environ", ")", "if", "adapter", ".", "test", "(", ")", ":", "_", ",", "args", "=", "adapter...
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...
[ "Run", "the", "application", "and", "preserve", "the", "traceback", "frames", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L177-L194
train
palantir/typedjsonrpc
typedjsonrpc/server.py
DebuggedJsonRpcApplication.handle_debug
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...
python
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", ")", ":", "if", "traceback_id", "not", "in", "self", ".", "app", ".", "registry", ".", "tracebacks", ":", "abort", "(", "404", ")", "self", ".", "_copy_over_tra...
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)]) ...
[ "Handles", "the", "debug", "endpoint", "for", "inspecting", "previous", "errors", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L196-L216
train
inveniosoftware/invenio-communities
invenio_communities/ext.py
InvenioCommunities.register_signals
def register_signals(self, app): """Register the signals.""" before_record_index.connect(inject_provisional_community) if app.config['COMMUNITIES_OAI_ENABLED']: listen(Community, 'after_insert', create_oaipmh_set) listen(Community, 'after_delete', destroy_oaipmh_set) ...
python
def register_signals(self, app): """Register the signals.""" before_record_index.connect(inject_provisional_community) if app.config['COMMUNITIES_OAI_ENABLED']: listen(Community, 'after_insert', create_oaipmh_set) listen(Community, 'after_delete', destroy_oaipmh_set) ...
[ "def", "register_signals", "(", "self", ",", "app", ")", ":", "before_record_index", ".", "connect", "(", "inject_provisional_community", ")", "if", "app", ".", "config", "[", "'COMMUNITIES_OAI_ENABLED'", "]", ":", "listen", "(", "Community", ",", "'after_insert'"...
Register the signals.
[ "Register", "the", "signals", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/ext.py#L59-L65
train
hsolbrig/pyjsg
pyjsg/validate_json.py
genargs
def genargs() -> ArgumentParser: """ Create a command line parser :return: parser """ parser = ArgumentParser() parser.add_argument("spec", help="JSG specification - can be file name, URI or string") parser.add_argument("-o", "--outfile", help="Output python file - if omitted, python is not...
python
def genargs() -> ArgumentParser: """ Create a command line parser :return: parser """ parser = ArgumentParser() parser.add_argument("spec", help="JSG specification - can be file name, URI or string") parser.add_argument("-o", "--outfile", help="Output python file - if omitted, python is not...
[ "def", "genargs", "(", ")", "->", "ArgumentParser", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"spec\"", ",", "help", "=", "\"JSG specification - can be file name, URI or string\"", ")", "parser", ".", "add_argument", "(", ...
Create a command line parser :return: parser
[ "Create", "a", "command", "line", "parser" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L88-L100
train
hsolbrig/pyjsg
pyjsg/validate_json.py
JSGPython._to_string
def _to_string(inp: str) -> str: """ Convert a URL or file name to a string """ if '://' in inp: req = requests.get(inp) if not req.ok: raise ValueError(f"Unable to read {inp}") return req.text else: with open(inp) as infile: ...
python
def _to_string(inp: str) -> str: """ Convert a URL or file name to a string """ if '://' in inp: req = requests.get(inp) if not req.ok: raise ValueError(f"Unable to read {inp}") return req.text else: with open(inp) as infile: ...
[ "def", "_to_string", "(", "inp", ":", "str", ")", "->", "str", ":", "if", "'://'", "in", "inp", ":", "req", "=", "requests", ".", "get", "(", "inp", ")", "if", "not", "req", ".", "ok", ":", "raise", "ValueError", "(", "f\"Unable to read {inp}\"", ")"...
Convert a URL or file name to a string
[ "Convert", "a", "URL", "or", "file", "name", "to", "a", "string" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L57-L66
train
hsolbrig/pyjsg
pyjsg/validate_json.py
JSGPython.conforms
def conforms(self, json: str, name: str = "", verbose: bool=False) -> ValidationResult: """ Determine whether json conforms with the JSG specification :param json: JSON string, URI to JSON or file name with JSON :param name: Test name for ValidationResult -- printed in dx if present :pa...
python
def conforms(self, json: str, name: str = "", verbose: bool=False) -> ValidationResult: """ Determine whether json conforms with the JSG specification :param json: JSON string, URI to JSON or file name with JSON :param name: Test name for ValidationResult -- printed in dx if present :pa...
[ "def", "conforms", "(", "self", ",", "json", ":", "str", ",", "name", ":", "str", "=", "\"\"", ",", "verbose", ":", "bool", "=", "False", ")", "->", "ValidationResult", ":", "json", "=", "self", ".", "_to_string", "(", "json", ")", "if", "not", "se...
Determine whether json conforms with the JSG specification :param json: JSON string, URI to JSON or file name with JSON :param name: Test name for ValidationResult -- printed in dx if present :param verbose: True means print the response :return: pass/fail + fail reason
[ "Determine", "whether", "json", "conforms", "with", "the", "JSG", "specification" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L68-L85
train
PSPC-SPAC-buyandsell/von_agent
von_agent/agent/issuer.py
Issuer._sync_revoc
async def _sync_revoc(self, rr_id: str, rr_size: int = None) -> None: """ Create revoc registry if need be for input revocation registry identifier; open and cache tails file reader. :param rr_id: revocation registry identifier :param rr_size: if new revocation registry necessar...
python
async def _sync_revoc(self, rr_id: str, rr_size: int = None) -> None: """ Create revoc registry if need be for input revocation registry identifier; open and cache tails file reader. :param rr_id: revocation registry identifier :param rr_size: if new revocation registry necessar...
[ "async", "def", "_sync_revoc", "(", "self", ",", "rr_id", ":", "str", ",", "rr_size", ":", "int", "=", "None", ")", "->", "None", ":", "LOGGER", ".", "debug", "(", "'Issuer._sync_revoc >>> rr_id: %s, rr_size: %s'", ",", "rr_id", ",", "rr_size", ")", "(", "...
Create revoc registry if need be for input revocation registry identifier; open and cache tails file reader. :param rr_id: revocation registry identifier :param rr_size: if new revocation registry necessary, its size (default as per _create_rev_reg())
[ "Create", "revoc", "registry", "if", "need", "be", "for", "input", "revocation", "registry", "identifier", ";", "open", "and", "cache", "tails", "file", "reader", "." ]
0b1c17cca3bd178b6e6974af84dbac1dfce5cf45
https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L139-L178
train
CybOXProject/mixbox
mixbox/binding_utils.py
quote_xml
def quote_xml(text): """Format a value for display as an XML text node. Returns: Unicode string (str on Python 3, unicode on Python 2) """ text = _coerce_unicode(text) # If it's a CDATA block, return the text as is. if text.startswith(CDATA_START): return text # If it's no...
python
def quote_xml(text): """Format a value for display as an XML text node. Returns: Unicode string (str on Python 3, unicode on Python 2) """ text = _coerce_unicode(text) # If it's a CDATA block, return the text as is. if text.startswith(CDATA_START): return text # If it's no...
[ "def", "quote_xml", "(", "text", ")", ":", "text", "=", "_coerce_unicode", "(", "text", ")", "# If it's a CDATA block, return the text as is.", "if", "text", ".", "startswith", "(", "CDATA_START", ")", ":", "return", "text", "# If it's not a CDATA block, escape the XML ...
Format a value for display as an XML text node. Returns: Unicode string (str on Python 3, unicode on Python 2)
[ "Format", "a", "value", "for", "display", "as", "an", "XML", "text", "node", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/binding_utils.py#L299-L313
train
CybOXProject/mixbox
mixbox/namespaces.py
_NamespaceInfo.__construct_from_components
def __construct_from_components(self, ns_uri, prefix=None, schema_location=None): """Initialize this instance from a namespace URI, and optional prefix and schema location URI.""" assert ns_uri # other fields are optional self.uri = ns_uri self.schema_location = schema_locatio...
python
def __construct_from_components(self, ns_uri, prefix=None, schema_location=None): """Initialize this instance from a namespace URI, and optional prefix and schema location URI.""" assert ns_uri # other fields are optional self.uri = ns_uri self.schema_location = schema_locatio...
[ "def", "__construct_from_components", "(", "self", ",", "ns_uri", ",", "prefix", "=", "None", ",", "schema_location", "=", "None", ")", ":", "assert", "ns_uri", "# other fields are optional", "self", ".", "uri", "=", "ns_uri", "self", ".", "schema_location", "="...
Initialize this instance from a namespace URI, and optional prefix and schema location URI.
[ "Initialize", "this", "instance", "from", "a", "namespace", "URI", "and", "optional", "prefix", "and", "schema", "location", "URI", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L145-L157
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.namespace_for_prefix
def namespace_for_prefix(self, prefix): """Get the namespace the given prefix maps to. Args: prefix (str): The prefix Returns: str: The namespace, or None if the prefix isn't mapped to anything in this set. """ try: ni = self....
python
def namespace_for_prefix(self, prefix): """Get the namespace the given prefix maps to. Args: prefix (str): The prefix Returns: str: The namespace, or None if the prefix isn't mapped to anything in this set. """ try: ni = self....
[ "def", "namespace_for_prefix", "(", "self", ",", "prefix", ")", ":", "try", ":", "ni", "=", "self", ".", "__lookup_prefix", "(", "prefix", ")", "except", "PrefixNotFoundError", ":", "return", "None", "else", ":", "return", "ni", ".", "uri" ]
Get the namespace the given prefix maps to. Args: prefix (str): The prefix Returns: str: The namespace, or None if the prefix isn't mapped to anything in this set.
[ "Get", "the", "namespace", "the", "given", "prefix", "maps", "to", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L271-L286
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.set_preferred_prefix_for_namespace
def set_preferred_prefix_for_namespace(self, ns_uri, prefix, add_if_not_exist=False): """Sets the preferred prefix for ns_uri. If add_if_not_exist is True, the prefix is added if it's not already registered. Otherwise, setting an unknown prefix as preferred is an error. The default is...
python
def set_preferred_prefix_for_namespace(self, ns_uri, prefix, add_if_not_exist=False): """Sets the preferred prefix for ns_uri. If add_if_not_exist is True, the prefix is added if it's not already registered. Otherwise, setting an unknown prefix as preferred is an error. The default is...
[ "def", "set_preferred_prefix_for_namespace", "(", "self", ",", "ns_uri", ",", "prefix", ",", "add_if_not_exist", "=", "False", ")", ":", "ni", "=", "self", ".", "__lookup_uri", "(", "ns_uri", ")", "if", "not", "prefix", ":", "ni", ".", "preferred_prefix", "=...
Sets the preferred prefix for ns_uri. If add_if_not_exist is True, the prefix is added if it's not already registered. Otherwise, setting an unknown prefix as preferred is an error. The default is False. Setting to None always works, and indicates a preference to use the namespace as...
[ "Sets", "the", "preferred", "prefix", "for", "ns_uri", ".", "If", "add_if_not_exist", "is", "True", "the", "prefix", "is", "added", "if", "it", "s", "not", "already", "registered", ".", "Otherwise", "setting", "an", "unknown", "prefix", "as", "preferred", "i...
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L294-L322
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.__merge_schema_locations
def __merge_schema_locations(self, ni, incoming_schemaloc): """Merge incoming_schemaloc into the given `_NamespaceInfo`, ni. If we don't have one yet and the incoming value is non-None, update ours with theirs. This modifies ni. """ if ni.schema_location == incoming_schemaloc: ...
python
def __merge_schema_locations(self, ni, incoming_schemaloc): """Merge incoming_schemaloc into the given `_NamespaceInfo`, ni. If we don't have one yet and the incoming value is non-None, update ours with theirs. This modifies ni. """ if ni.schema_location == incoming_schemaloc: ...
[ "def", "__merge_schema_locations", "(", "self", ",", "ni", ",", "incoming_schemaloc", ")", ":", "if", "ni", ".", "schema_location", "==", "incoming_schemaloc", ":", "# TODO (bworrell): empty strings?", "return", "elif", "not", "ni", ".", "schema_location", ":", "ni"...
Merge incoming_schemaloc into the given `_NamespaceInfo`, ni. If we don't have one yet and the incoming value is non-None, update ours with theirs. This modifies ni.
[ "Merge", "incoming_schemaloc", "into", "the", "given", "_NamespaceInfo", "ni", ".", "If", "we", "don", "t", "have", "one", "yet", "and", "the", "incoming", "value", "is", "non", "-", "None", "update", "ours", "with", "theirs", ".", "This", "modifies", "ni"...
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L324-L336
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.add_namespace_uri
def add_namespace_uri(self, ns_uri, prefix=None, schema_location=None): """Adds a new namespace to this set, optionally with a prefix and schema location URI. If the namespace already exists, the given prefix and schema location are merged with the existing entry: * If non-N...
python
def add_namespace_uri(self, ns_uri, prefix=None, schema_location=None): """Adds a new namespace to this set, optionally with a prefix and schema location URI. If the namespace already exists, the given prefix and schema location are merged with the existing entry: * If non-N...
[ "def", "add_namespace_uri", "(", "self", ",", "ns_uri", ",", "prefix", "=", "None", ",", "schema_location", "=", "None", ")", ":", "assert", "ns_uri", "if", "ns_uri", "in", "self", ".", "__ns_uri_map", ":", "# We have a _NamespaceInfo object for this URI already. S...
Adds a new namespace to this set, optionally with a prefix and schema location URI. If the namespace already exists, the given prefix and schema location are merged with the existing entry: * If non-None, ``prefix`` is added to the set. The preferred prefix is not m...
[ "Adds", "a", "new", "namespace", "to", "this", "set", "optionally", "with", "a", "prefix", "and", "schema", "location", "URI", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L344-L405
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.remove_namespace
def remove_namespace(self, ns_uri): """Removes the indicated namespace from this set.""" if not self.contains_namespace(ns_uri): return ni = self.__ns_uri_map.pop(ns_uri) for prefix in ni.prefixes: del self.__prefix_map[prefix]
python
def remove_namespace(self, ns_uri): """Removes the indicated namespace from this set.""" if not self.contains_namespace(ns_uri): return ni = self.__ns_uri_map.pop(ns_uri) for prefix in ni.prefixes: del self.__prefix_map[prefix]
[ "def", "remove_namespace", "(", "self", ",", "ns_uri", ")", ":", "if", "not", "self", ".", "contains_namespace", "(", "ns_uri", ")", ":", "return", "ni", "=", "self", ".", "__ns_uri_map", ".", "pop", "(", "ns_uri", ")", "for", "prefix", "in", "ni", "."...
Removes the indicated namespace from this set.
[ "Removes", "the", "indicated", "namespace", "from", "this", "set", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L407-L414
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.add_prefix
def add_prefix(self, ns_uri, prefix, set_as_preferred=False): """Adds prefix for the given namespace URI. The namespace must already exist in this set. If set_as_preferred is True, also set this namespace as the preferred one. ``prefix`` must be non-None; a default preference can't be...
python
def add_prefix(self, ns_uri, prefix, set_as_preferred=False): """Adds prefix for the given namespace URI. The namespace must already exist in this set. If set_as_preferred is True, also set this namespace as the preferred one. ``prefix`` must be non-None; a default preference can't be...
[ "def", "add_prefix", "(", "self", ",", "ns_uri", ",", "prefix", ",", "set_as_preferred", "=", "False", ")", ":", "assert", "prefix", "ni", "=", "self", ".", "__lookup_uri", "(", "ns_uri", ")", "self", ".", "__check_prefix_conflict", "(", "ni", ",", "prefix...
Adds prefix for the given namespace URI. The namespace must already exist in this set. If set_as_preferred is True, also set this namespace as the preferred one. ``prefix`` must be non-None; a default preference can't be set this way. See :meth:`set_preferred_prefix_for_namespace` for...
[ "Adds", "prefix", "for", "the", "given", "namespace", "URI", ".", "The", "namespace", "must", "already", "exist", "in", "this", "set", ".", "If", "set_as_preferred", "is", "True", "also", "set", "this", "namespace", "as", "the", "preferred", "one", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L416-L441
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.prefix_iter
def prefix_iter(self, ns_uri): """Gets an iterator over the prefixes for the given namespace.""" ni = self.__lookup_uri(ns_uri) return iter(ni.prefixes)
python
def prefix_iter(self, ns_uri): """Gets an iterator over the prefixes for the given namespace.""" ni = self.__lookup_uri(ns_uri) return iter(ni.prefixes)
[ "def", "prefix_iter", "(", "self", ",", "ns_uri", ")", ":", "ni", "=", "self", ".", "__lookup_uri", "(", "ns_uri", ")", "return", "iter", "(", "ni", ".", "prefixes", ")" ]
Gets an iterator over the prefixes for the given namespace.
[ "Gets", "an", "iterator", "over", "the", "prefixes", "for", "the", "given", "namespace", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L448-L451
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.remove_prefix
def remove_prefix(self, prefix): """Removes prefix from this set. This is a no-op if the prefix doesn't exist in it. """ if prefix not in self.__prefix_map: return ni = self.__lookup_prefix(prefix) ni.prefixes.discard(prefix) del self.__prefix_map[pr...
python
def remove_prefix(self, prefix): """Removes prefix from this set. This is a no-op if the prefix doesn't exist in it. """ if prefix not in self.__prefix_map: return ni = self.__lookup_prefix(prefix) ni.prefixes.discard(prefix) del self.__prefix_map[pr...
[ "def", "remove_prefix", "(", "self", ",", "prefix", ")", ":", "if", "prefix", "not", "in", "self", ".", "__prefix_map", ":", "return", "ni", "=", "self", ".", "__lookup_prefix", "(", "prefix", ")", "ni", ".", "prefixes", ".", "discard", "(", "prefix", ...
Removes prefix from this set. This is a no-op if the prefix doesn't exist in it.
[ "Removes", "prefix", "from", "this", "set", ".", "This", "is", "a", "no", "-", "op", "if", "the", "prefix", "doesn", "t", "exist", "in", "it", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L453-L466
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.set_schema_location
def set_schema_location(self, ns_uri, schema_location, replace=False): """Sets the schema location of the given namespace. If ``replace`` is ``True``, then any existing schema location is replaced. Otherwise, if the schema location is already set to a different value, an exception is r...
python
def set_schema_location(self, ns_uri, schema_location, replace=False): """Sets the schema location of the given namespace. If ``replace`` is ``True``, then any existing schema location is replaced. Otherwise, if the schema location is already set to a different value, an exception is r...
[ "def", "set_schema_location", "(", "self", ",", "ns_uri", ",", "schema_location", ",", "replace", "=", "False", ")", ":", "ni", "=", "self", ".", "__lookup_uri", "(", "ns_uri", ")", "if", "ni", ".", "schema_location", "==", "schema_location", ":", "return", ...
Sets the schema location of the given namespace. If ``replace`` is ``True``, then any existing schema location is replaced. Otherwise, if the schema location is already set to a different value, an exception is raised. If the schema location is set to None, it is effectively erased fr...
[ "Sets", "the", "schema", "location", "of", "the", "given", "namespace", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L483-L512
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.get_schemaloc_string
def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"): """Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the co...
python
def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"): """Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the co...
[ "def", "get_schemaloc_string", "(", "self", ",", "ns_uris", "=", "None", ",", "sort", "=", "False", ",", "delim", "=", "\"\\n\"", ")", ":", "if", "not", "ns_uris", ":", "ns_uris", "=", "six", ".", "iterkeys", "(", "self", ".", "__ns_uri_map", ")", "if"...
Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the constructed attribute value. If None, all are included. ...
[ "Constructs", "and", "returns", "a", "schemalocation", "attribute", ".", "If", "no", "namespaces", "in", "this", "set", "have", "any", "schema", "locations", "defined", "returns", "an", "empty", "string", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L593-L627
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.get_uri_prefix_map
def get_uri_prefix_map(self): """Constructs and returns a map from namespace URI to prefix, representing all namespaces in this set. The prefix chosen for each namespace is its preferred prefix if it's not None. If the preferred prefix is None, one is chosen from the set of registered ...
python
def get_uri_prefix_map(self): """Constructs and returns a map from namespace URI to prefix, representing all namespaces in this set. The prefix chosen for each namespace is its preferred prefix if it's not None. If the preferred prefix is None, one is chosen from the set of registered ...
[ "def", "get_uri_prefix_map", "(", "self", ")", ":", "mapping", "=", "{", "}", "for", "ni", "in", "six", ".", "itervalues", "(", "self", ".", "__ns_uri_map", ")", ":", "if", "ni", ".", "preferred_prefix", ":", "mapping", "[", "ni", ".", "uri", "]", "=...
Constructs and returns a map from namespace URI to prefix, representing all namespaces in this set. The prefix chosen for each namespace is its preferred prefix if it's not None. If the preferred prefix is None, one is chosen from the set of registered prefixes. In the latter situatio...
[ "Constructs", "and", "returns", "a", "map", "from", "namespace", "URI", "to", "prefix", "representing", "all", "namespaces", "in", "this", "set", ".", "The", "prefix", "chosen", "for", "each", "namespace", "is", "its", "preferred", "prefix", "if", "it", "s",...
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L629-L650
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.get_uri_schemaloc_map
def get_uri_schemaloc_map(self): """Constructs and returns a map from namespace URI to schema location URI. Namespaces without schema locations are excluded.""" mapping = {} for ni in six.itervalues(self.__ns_uri_map): if ni.schema_location: mapping[ni.uri] ...
python
def get_uri_schemaloc_map(self): """Constructs and returns a map from namespace URI to schema location URI. Namespaces without schema locations are excluded.""" mapping = {} for ni in six.itervalues(self.__ns_uri_map): if ni.schema_location: mapping[ni.uri] ...
[ "def", "get_uri_schemaloc_map", "(", "self", ")", ":", "mapping", "=", "{", "}", "for", "ni", "in", "six", ".", "itervalues", "(", "self", ".", "__ns_uri_map", ")", ":", "if", "ni", ".", "schema_location", ":", "mapping", "[", "ni", ".", "uri", "]", ...
Constructs and returns a map from namespace URI to schema location URI. Namespaces without schema locations are excluded.
[ "Constructs", "and", "returns", "a", "map", "from", "namespace", "URI", "to", "schema", "location", "URI", ".", "Namespaces", "without", "schema", "locations", "are", "excluded", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L673-L682
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.subset
def subset(self, ns_uris): """Return a subset of this NamespaceSet containing only data for the given namespaces. Args: ns_uris (iterable): An iterable of namespace URIs which select the namespaces for the subset. Returns: The subset Rai...
python
def subset(self, ns_uris): """Return a subset of this NamespaceSet containing only data for the given namespaces. Args: ns_uris (iterable): An iterable of namespace URIs which select the namespaces for the subset. Returns: The subset Rai...
[ "def", "subset", "(", "self", ",", "ns_uris", ")", ":", "sub_ns", "=", "NamespaceSet", "(", ")", "for", "ns_uri", "in", "ns_uris", ":", "ni", "=", "self", ".", "__lookup_uri", "(", "ns_uri", ")", "new_ni", "=", "copy", ".", "deepcopy", "(", "ni", ")"...
Return a subset of this NamespaceSet containing only data for the given namespaces. Args: ns_uris (iterable): An iterable of namespace URIs which select the namespaces for the subset. Returns: The subset Raises: NamespaceNotFoundErro...
[ "Return", "a", "subset", "of", "this", "NamespaceSet", "containing", "only", "data", "for", "the", "given", "namespaces", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L690-L717
train
CybOXProject/mixbox
mixbox/namespaces.py
NamespaceSet.import_from
def import_from(self, other_ns, replace=False): """Imports namespaces into this set, from other_ns. Args: other_ns (NamespaceSet): The set to import from replace (bool): If a namespace exists in both sets, do we replace our data with other_ns's data? We could ge...
python
def import_from(self, other_ns, replace=False): """Imports namespaces into this set, from other_ns. Args: other_ns (NamespaceSet): The set to import from replace (bool): If a namespace exists in both sets, do we replace our data with other_ns's data? We could ge...
[ "def", "import_from", "(", "self", ",", "other_ns", ",", "replace", "=", "False", ")", ":", "for", "other_ns_uri", "in", "other_ns", ".", "namespace_uris", ":", "ni", "=", "self", ".", "__ns_uri_map", ".", "get", "(", "other_ns_uri", ")", "if", "ni", "is...
Imports namespaces into this set, from other_ns. Args: other_ns (NamespaceSet): The set to import from replace (bool): If a namespace exists in both sets, do we replace our data with other_ns's data? We could get fancy and define some merge strategies, b...
[ "Imports", "namespaces", "into", "this", "set", "from", "other_ns", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L719-L756
train
CybOXProject/mixbox
mixbox/parser.py
EntityParser._get_version
def _get_version(self, root): """Return the version of the root element passed in. Args: root (etree.Element) Returns: distutils.StrictVersion Raises: UnknownVersionError """ # Note: STIX and MAEC use a "version" attribute. To suppor...
python
def _get_version(self, root): """Return the version of the root element passed in. Args: root (etree.Element) Returns: distutils.StrictVersion Raises: UnknownVersionError """ # Note: STIX and MAEC use a "version" attribute. To suppor...
[ "def", "_get_version", "(", "self", ",", "root", ")", ":", "# Note: STIX and MAEC use a \"version\" attribute. To support CybOX, a", "# subclass will need to combine \"cybox_major_version\",", "# \"cybox_minor_version\", and \"cybox_update_version\".", "version", "=", "self", ".", "get...
Return the version of the root element passed in. Args: root (etree.Element) Returns: distutils.StrictVersion Raises: UnknownVersionError
[ "Return", "the", "version", "of", "the", "root", "element", "passed", "in", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L55-L77
train
CybOXProject/mixbox
mixbox/parser.py
EntityParser._check_version
def _check_version(self, root): """Ensure the root element is a supported version. Args: root (etree.Element) Raises: UnsupportedVersionError """ version = self._get_version(root) supported = [StrictVersion(x) for x in self.s...
python
def _check_version(self, root): """Ensure the root element is a supported version. Args: root (etree.Element) Raises: UnsupportedVersionError """ version = self._get_version(root) supported = [StrictVersion(x) for x in self.s...
[ "def", "_check_version", "(", "self", ",", "root", ")", ":", "version", "=", "self", ".", "_get_version", "(", "root", ")", "supported", "=", "[", "StrictVersion", "(", "x", ")", "for", "x", "in", "self", ".", "supported_versions", "(", "root", ".", "t...
Ensure the root element is a supported version. Args: root (etree.Element) Raises: UnsupportedVersionError
[ "Ensure", "the", "root", "element", "is", "a", "supported", "version", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L79-L100
train
CybOXProject/mixbox
mixbox/parser.py
EntityParser._check_root_tag
def _check_root_tag(self, root): """Check that the XML element tree has a supported root element. Args: root (etree.Element) Raises: UnsupportedRootElementError """ supported = self.supported_tags() if root.tag in supported: return ...
python
def _check_root_tag(self, root): """Check that the XML element tree has a supported root element. Args: root (etree.Element) Raises: UnsupportedRootElementError """ supported = self.supported_tags() if root.tag in supported: return ...
[ "def", "_check_root_tag", "(", "self", ",", "root", ")", ":", "supported", "=", "self", ".", "supported_tags", "(", ")", "if", "root", ".", "tag", "in", "supported", ":", "return", "error", "=", "\"Document root element ({0}) not one of ({1})\"", "raise", "Unsup...
Check that the XML element tree has a supported root element. Args: root (etree.Element) Raises: UnsupportedRootElementError
[ "Check", "that", "the", "XML", "element", "tree", "has", "a", "supported", "root", "element", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L102-L120
train
CybOXProject/mixbox
mixbox/parser.py
EntityParser.parse_xml_to_obj
def parse_xml_to_obj(self, xml_file, check_version=True, check_root=True, encoding=None): """Creates a STIX binding object from the supplied xml file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document ...
python
def parse_xml_to_obj(self, xml_file, check_version=True, check_root=True, encoding=None): """Creates a STIX binding object from the supplied xml file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document ...
[ "def", "parse_xml_to_obj", "(", "self", ",", "xml_file", ",", "check_version", "=", "True", ",", "check_root", "=", "True", ",", "encoding", "=", "None", ")", ":", "root", "=", "get_etree_root", "(", "xml_file", ",", "encoding", "=", "encoding", ")", "if",...
Creates a STIX binding object from the supplied xml file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document check_version: Inspect the version before parsing. check_root: Inspect the root element before parsing. ...
[ "Creates", "a", "STIX", "binding", "object", "from", "the", "supplied", "xml", "file", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L122-L154
train
CybOXProject/mixbox
mixbox/parser.py
EntityParser.parse_xml
def parse_xml(self, xml_file, check_version=True, check_root=True, encoding=None): """Creates a python-stix STIXPackage object from the supplied xml_file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document ...
python
def parse_xml(self, xml_file, check_version=True, check_root=True, encoding=None): """Creates a python-stix STIXPackage object from the supplied xml_file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document ...
[ "def", "parse_xml", "(", "self", ",", "xml_file", ",", "check_version", "=", "True", ",", "check_root", "=", "True", ",", "encoding", "=", "None", ")", ":", "xml_etree", "=", "get_etree", "(", "xml_file", ",", "encoding", "=", "encoding", ")", "entity_obj"...
Creates a python-stix STIXPackage object from the supplied xml_file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document check_version: Inspect the version before parsing. check_root: Inspect the root element before par...
[ "Creates", "a", "python", "-", "stix", "STIXPackage", "object", "from", "the", "supplied", "xml_file", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L156-L195
train
inveniosoftware/invenio-communities
invenio_communities/serializers/schemas/community.py
CommunitySchemaV1.get_logo_url
def get_logo_url(self, obj): """Get the community logo URL.""" if current_app and obj.logo_url: return u'{site_url}{path}'.format( site_url=current_app.config.get('THEME_SITEURL'), path=obj.logo_url, )
python
def get_logo_url(self, obj): """Get the community logo URL.""" if current_app and obj.logo_url: return u'{site_url}{path}'.format( site_url=current_app.config.get('THEME_SITEURL'), path=obj.logo_url, )
[ "def", "get_logo_url", "(", "self", ",", "obj", ")", ":", "if", "current_app", "and", "obj", ".", "logo_url", ":", "return", "u'{site_url}{path}'", ".", "format", "(", "site_url", "=", "current_app", ".", "config", ".", "get", "(", "'THEME_SITEURL'", ")", ...
Get the community logo URL.
[ "Get", "the", "community", "logo", "URL", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L50-L56
train
inveniosoftware/invenio-communities
invenio_communities/serializers/schemas/community.py
CommunitySchemaV1.item_links_addition
def item_links_addition(self, data): """Add the links for each community.""" links_item_factory = self.context.get('links_item_factory', default_links_item_factory) data['links'] = links_item_factory(data) return data
python
def item_links_addition(self, data): """Add the links for each community.""" links_item_factory = self.context.get('links_item_factory', default_links_item_factory) data['links'] = links_item_factory(data) return data
[ "def", "item_links_addition", "(", "self", ",", "data", ")", ":", "links_item_factory", "=", "self", ".", "context", ".", "get", "(", "'links_item_factory'", ",", "default_links_item_factory", ")", "data", "[", "'links'", "]", "=", "links_item_factory", "(", "da...
Add the links for each community.
[ "Add", "the", "links", "for", "each", "community", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L59-L64
train
inveniosoftware/invenio-communities
invenio_communities/serializers/schemas/community.py
CommunitySchemaV1.envelope
def envelope(self, data, many): """Wrap result in envelope.""" if not many: return data result = dict( hits=dict( hits=data, total=self.context.get('total', len(data)) ) ) page = self.context.get('page') ...
python
def envelope(self, data, many): """Wrap result in envelope.""" if not many: return data result = dict( hits=dict( hits=data, total=self.context.get('total', len(data)) ) ) page = self.context.get('page') ...
[ "def", "envelope", "(", "self", ",", "data", ",", "many", ")", ":", "if", "not", "many", ":", "return", "data", "result", "=", "dict", "(", "hits", "=", "dict", "(", "hits", "=", "data", ",", "total", "=", "self", ".", "context", ".", "get", "(",...
Wrap result in envelope.
[ "Wrap", "result", "in", "envelope", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L67-L90
train
CybOXProject/mixbox
mixbox/dates.py
parse_datetime
def parse_datetime(value): """Attempts to parse `value` into an instance of ``datetime.datetime``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string or datetime.datetime value. """ if not value: return None elif isinstanc...
python
def parse_datetime(value): """Attempts to parse `value` into an instance of ``datetime.datetime``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string or datetime.datetime value. """ if not value: return None elif isinstanc...
[ "def", "parse_datetime", "(", "value", ")", ":", "if", "not", "value", ":", "return", "None", "elif", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "return", "value", "return", "dateutil", ".", "parser", ".", "parse", "(", "valu...
Attempts to parse `value` into an instance of ``datetime.datetime``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string or datetime.datetime value.
[ "Attempts", "to", "parse", "value", "into", "an", "instance", "of", "datetime", ".", "datetime", ".", "If", "value", "is", "None", "this", "function", "will", "return", "None", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/dates.py#L13-L25
train
CybOXProject/mixbox
mixbox/dates.py
parse_date
def parse_date(value): """Attempts to parse `value` into an instance of ``datetime.date``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string, datetime.date, or datetime.datetime value. """ if not value: return Non...
python
def parse_date(value): """Attempts to parse `value` into an instance of ``datetime.date``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string, datetime.date, or datetime.datetime value. """ if not value: return Non...
[ "def", "parse_date", "(", "value", ")", ":", "if", "not", "value", ":", "return", "None", "if", "isinstance", "(", "value", ",", "datetime", ".", "date", ")", ":", "return", "value", "return", "parse_datetime", "(", "value", ")", ".", "date", "(", ")" ...
Attempts to parse `value` into an instance of ``datetime.date``. If `value` is ``None``, this function will return ``None``. Args: value: A timestamp. This can be a string, datetime.date, or datetime.datetime value.
[ "Attempts", "to", "parse", "value", "into", "an", "instance", "of", "datetime", ".", "date", ".", "If", "value", "is", "None", "this", "function", "will", "return", "None", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/dates.py#L44-L59
train
SpotlightData/preprocessing
preprocessing/spellcheck.py
correct_word
def correct_word(word_string): ''' Finds all valid one and two letter corrections for word_string, returning the word with the highest relative probability as type str. ''' if word_string is None: return "" elif isinstance(word_string, str): return max(find_candidates(word_string...
python
def correct_word(word_string): ''' Finds all valid one and two letter corrections for word_string, returning the word with the highest relative probability as type str. ''' if word_string is None: return "" elif isinstance(word_string, str): return max(find_candidates(word_string...
[ "def", "correct_word", "(", "word_string", ")", ":", "if", "word_string", "is", "None", ":", "return", "\"\"", "elif", "isinstance", "(", "word_string", ",", "str", ")", ":", "return", "max", "(", "find_candidates", "(", "word_string", ")", ",", "key", "="...
Finds all valid one and two letter corrections for word_string, returning the word with the highest relative probability as type str.
[ "Finds", "all", "valid", "one", "and", "two", "letter", "corrections", "for", "word_string", "returning", "the", "word", "with", "the", "highest", "relative", "probability", "as", "type", "str", "." ]
180c6472bc2642afbd7a1ece08d0b0d14968a708
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L18-L28
train
SpotlightData/preprocessing
preprocessing/spellcheck.py
find_candidates
def find_candidates(word_string): ''' Finds all potential words word_string could have intended to mean. If a word is not incorrectly spelled, it will return this word first, else if will look for one letter edits that are correct. If there are no valid one letter edits, it will perform a two letter edi...
python
def find_candidates(word_string): ''' Finds all potential words word_string could have intended to mean. If a word is not incorrectly spelled, it will return this word first, else if will look for one letter edits that are correct. If there are no valid one letter edits, it will perform a two letter edi...
[ "def", "find_candidates", "(", "word_string", ")", ":", "if", "word_string", "is", "None", ":", "return", "{", "}", "elif", "isinstance", "(", "word_string", ",", "str", ")", ":", "return", "(", "validate_words", "(", "[", "word_string", "]", ")", "or", ...
Finds all potential words word_string could have intended to mean. If a word is not incorrectly spelled, it will return this word first, else if will look for one letter edits that are correct. If there are no valid one letter edits, it will perform a two letter edit search. If valid corrections are found,...
[ "Finds", "all", "potential", "words", "word_string", "could", "have", "intended", "to", "mean", ".", "If", "a", "word", "is", "not", "incorrectly", "spelled", "it", "will", "return", "this", "word", "first", "else", "if", "will", "look", "for", "one", "let...
180c6472bc2642afbd7a1ece08d0b0d14968a708
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L30-L45
train
SpotlightData/preprocessing
preprocessing/spellcheck.py
find_word_prob
def find_word_prob(word_string, word_total=sum(WORD_DISTRIBUTION.values())): ''' Finds the relative probability of the word appearing given context of a base corpus. Returns this probability value as a float instance. ''' if word_string is None: return 0 elif isinstance(word_string, str)...
python
def find_word_prob(word_string, word_total=sum(WORD_DISTRIBUTION.values())): ''' Finds the relative probability of the word appearing given context of a base corpus. Returns this probability value as a float instance. ''' if word_string is None: return 0 elif isinstance(word_string, str)...
[ "def", "find_word_prob", "(", "word_string", ",", "word_total", "=", "sum", "(", "WORD_DISTRIBUTION", ".", "values", "(", ")", ")", ")", ":", "if", "word_string", "is", "None", ":", "return", "0", "elif", "isinstance", "(", "word_string", ",", "str", ")", ...
Finds the relative probability of the word appearing given context of a base corpus. Returns this probability value as a float instance.
[ "Finds", "the", "relative", "probability", "of", "the", "word", "appearing", "given", "context", "of", "a", "base", "corpus", ".", "Returns", "this", "probability", "value", "as", "a", "float", "instance", "." ]
180c6472bc2642afbd7a1ece08d0b0d14968a708
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L91-L101
train
SpotlightData/preprocessing
preprocessing/spellcheck.py
validate_words
def validate_words(word_list): ''' Checks for each edited word in word_list if that word is a valid english word.abs Returns all validated words as a set instance. ''' if word_list is None: return {} elif isinstance(word_list, list): if not word_list: return {} ...
python
def validate_words(word_list): ''' Checks for each edited word in word_list if that word is a valid english word.abs Returns all validated words as a set instance. ''' if word_list is None: return {} elif isinstance(word_list, list): if not word_list: return {} ...
[ "def", "validate_words", "(", "word_list", ")", ":", "if", "word_list", "is", "None", ":", "return", "{", "}", "elif", "isinstance", "(", "word_list", ",", "list", ")", ":", "if", "not", "word_list", ":", "return", "{", "}", "else", ":", "return", "set...
Checks for each edited word in word_list if that word is a valid english word.abs Returns all validated words as a set instance.
[ "Checks", "for", "each", "edited", "word", "in", "word_list", "if", "that", "word", "is", "a", "valid", "english", "word", ".", "abs", "Returns", "all", "validated", "words", "as", "a", "set", "instance", "." ]
180c6472bc2642afbd7a1ece08d0b0d14968a708
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L103-L116
train
emirozer/bowshock
bowshock/star.py
search_star
def search_star(star): ''' It is also possible to query the stars by label, here is an example of querying for the star labeled as Sun. http://star-api.herokuapp.com/api/v1/stars/Sun ''' base_url = "http://star-api.herokuapp.com/api/v1/stars/" if not isinstance(star, str): raise Value...
python
def search_star(star): ''' It is also possible to query the stars by label, here is an example of querying for the star labeled as Sun. http://star-api.herokuapp.com/api/v1/stars/Sun ''' base_url = "http://star-api.herokuapp.com/api/v1/stars/" if not isinstance(star, str): raise Value...
[ "def", "search_star", "(", "star", ")", ":", "base_url", "=", "\"http://star-api.herokuapp.com/api/v1/stars/\"", "if", "not", "isinstance", "(", "star", ",", "str", ")", ":", "raise", "ValueError", "(", "\"The star arg you provided is not the type of str\"", ")", "else"...
It is also possible to query the stars by label, here is an example of querying for the star labeled as Sun. http://star-api.herokuapp.com/api/v1/stars/Sun
[ "It", "is", "also", "possible", "to", "query", "the", "stars", "by", "label", "here", "is", "an", "example", "of", "querying", "for", "the", "star", "labeled", "as", "Sun", "." ]
9f5e053f1d54995b833b83616f37c67178c3e840
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L16-L30
train
emirozer/bowshock
bowshock/star.py
search_exoplanet
def search_exoplanet(exoplanet): ''' It is also possible to query the exoplanets by label, here is an example of querying for the exoplanet labeled as 11 Com http://star-api.herokuapp.com/api/v1/exo_planets/11 Com ''' base_url = "http://star-api.herokuapp.com/api/v1/exo_planets/" if not isins...
python
def search_exoplanet(exoplanet): ''' It is also possible to query the exoplanets by label, here is an example of querying for the exoplanet labeled as 11 Com http://star-api.herokuapp.com/api/v1/exo_planets/11 Com ''' base_url = "http://star-api.herokuapp.com/api/v1/exo_planets/" if not isins...
[ "def", "search_exoplanet", "(", "exoplanet", ")", ":", "base_url", "=", "\"http://star-api.herokuapp.com/api/v1/exo_planets/\"", "if", "not", "isinstance", "(", "exoplanet", ",", "str", ")", ":", "raise", "ValueError", "(", "\"The exoplanet arg you provided is not the type ...
It is also possible to query the exoplanets by label, here is an example of querying for the exoplanet labeled as 11 Com http://star-api.herokuapp.com/api/v1/exo_planets/11 Com
[ "It", "is", "also", "possible", "to", "query", "the", "exoplanets", "by", "label", "here", "is", "an", "example", "of", "querying", "for", "the", "exoplanet", "labeled", "as", "11", "Com" ]
9f5e053f1d54995b833b83616f37c67178c3e840
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L43-L58
train
emirozer/bowshock
bowshock/star.py
search_local_galaxies
def search_local_galaxies(galaxy): ''' It is also possible to query the local galaxies by label, here is an example of querying for the local galaxy labeled IC 10 http://star-api.herokuapp.com/api/v1/local_groups/IC 10 ''' base_url = "http://star-api.herokuapp.com/api/v1/local_groups/" if no...
python
def search_local_galaxies(galaxy): ''' It is also possible to query the local galaxies by label, here is an example of querying for the local galaxy labeled IC 10 http://star-api.herokuapp.com/api/v1/local_groups/IC 10 ''' base_url = "http://star-api.herokuapp.com/api/v1/local_groups/" if no...
[ "def", "search_local_galaxies", "(", "galaxy", ")", ":", "base_url", "=", "\"http://star-api.herokuapp.com/api/v1/local_groups/\"", "if", "not", "isinstance", "(", "galaxy", ",", "str", ")", ":", "raise", "ValueError", "(", "\"The galaxy arg you provided is not the type of ...
It is also possible to query the local galaxies by label, here is an example of querying for the local galaxy labeled IC 10 http://star-api.herokuapp.com/api/v1/local_groups/IC 10
[ "It", "is", "also", "possible", "to", "query", "the", "local", "galaxies", "by", "label", "here", "is", "an", "example", "of", "querying", "for", "the", "local", "galaxy", "labeled", "IC", "10" ]
9f5e053f1d54995b833b83616f37c67178c3e840
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L71-L85
train
emirozer/bowshock
bowshock/star.py
search_star_cluster
def search_star_cluster(cluster): ''' It is also possible to query the star clusters by label, here is an example of querying for the star cluster labeled Berkeley 59 http://star-api.herokuapp.com/api/v1/open_cluster/Berkeley 59 ''' base_url = "http://star-api.herokuapp.com/api/v1/open_cluster/" ...
python
def search_star_cluster(cluster): ''' It is also possible to query the star clusters by label, here is an example of querying for the star cluster labeled Berkeley 59 http://star-api.herokuapp.com/api/v1/open_cluster/Berkeley 59 ''' base_url = "http://star-api.herokuapp.com/api/v1/open_cluster/" ...
[ "def", "search_star_cluster", "(", "cluster", ")", ":", "base_url", "=", "\"http://star-api.herokuapp.com/api/v1/open_cluster/\"", "if", "not", "isinstance", "(", "cluster", ",", "str", ")", ":", "raise", "ValueError", "(", "\"The cluster arg you provided is not the type of...
It is also possible to query the star clusters by label, here is an example of querying for the star cluster labeled Berkeley 59 http://star-api.herokuapp.com/api/v1/open_cluster/Berkeley 59
[ "It", "is", "also", "possible", "to", "query", "the", "star", "clusters", "by", "label", "here", "is", "an", "example", "of", "querying", "for", "the", "star", "cluster", "labeled", "Berkeley", "59" ]
9f5e053f1d54995b833b83616f37c67178c3e840
https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L98-L112
train
hsolbrig/pyjsg
pyjsg/parser_impl/jsg_lexerruleblock_parser.py
JSGLexerRuleBlock.as_python
def as_python(self, name: str) -> str: """ Return the python representation """ if self._ruleTokens: pattern = "jsg.JSGPattern(r'{}'.format({}))".\ format(self._rulePattern, ', '.join(['{v}={v}.pattern'.format(v=v) for v in sorted(self._ruleTokens)])) else: ...
python
def as_python(self, name: str) -> str: """ Return the python representation """ if self._ruleTokens: pattern = "jsg.JSGPattern(r'{}'.format({}))".\ format(self._rulePattern, ', '.join(['{v}={v}.pattern'.format(v=v) for v in sorted(self._ruleTokens)])) else: ...
[ "def", "as_python", "(", "self", ",", "name", ":", "str", ")", "->", "str", ":", "if", "self", ".", "_ruleTokens", ":", "pattern", "=", "\"jsg.JSGPattern(r'{}'.format({}))\"", ".", "format", "(", "self", ".", "_rulePattern", ",", "', '", ".", "join", "(", ...
Return the python representation
[ "Return", "the", "python", "representation" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L59-L67
train
OpenTreeOfLife/peyotl
peyotl/utility/str_util.py
increment_slug
def increment_slug(s): """Generate next slug for a series. Some docstore types will use slugs (see above) as document ids. To support unique ids, we'll serialize them as follows: TestUserA/my-test TestUserA/my-test-2 TestUserA/my-test-3 ... """ slug_parts =...
python
def increment_slug(s): """Generate next slug for a series. Some docstore types will use slugs (see above) as document ids. To support unique ids, we'll serialize them as follows: TestUserA/my-test TestUserA/my-test-2 TestUserA/my-test-3 ... """ slug_parts =...
[ "def", "increment_slug", "(", "s", ")", ":", "slug_parts", "=", "s", ".", "split", "(", "'-'", ")", "# advance (or add) the serial counter on the end of this slug", "# noinspection PyBroadException", "try", ":", "# if it's an integer, increment it", "slug_parts", "[", "-", ...
Generate next slug for a series. Some docstore types will use slugs (see above) as document ids. To support unique ids, we'll serialize them as follows: TestUserA/my-test TestUserA/my-test-2 TestUserA/my-test-3 ...
[ "Generate", "next", "slug", "for", "a", "series", "." ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/str_util.py#L82-L101
train
OpenTreeOfLife/peyotl
peyotl/utility/str_util.py
underscored2camel_case
def underscored2camel_case(v): """converts ott_id to ottId.""" vlist = v.split('_') c = [] for n, el in enumerate(vlist): if el: if n == 0: c.append(el) else: c.extend([el[0].upper(), el[1:]]) return ''.join(c)
python
def underscored2camel_case(v): """converts ott_id to ottId.""" vlist = v.split('_') c = [] for n, el in enumerate(vlist): if el: if n == 0: c.append(el) else: c.extend([el[0].upper(), el[1:]]) return ''.join(c)
[ "def", "underscored2camel_case", "(", "v", ")", ":", "vlist", "=", "v", ".", "split", "(", "'_'", ")", "c", "=", "[", "]", "for", "n", ",", "el", "in", "enumerate", "(", "vlist", ")", ":", "if", "el", ":", "if", "n", "==", "0", ":", "c", ".",...
converts ott_id to ottId.
[ "converts", "ott_id", "to", "ottId", "." ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/str_util.py#L104-L114
train
hsolbrig/pyjsg
pyjsg/jsglib/jsg_context.py
JSGContext.unvalidated_parm
def unvalidated_parm(self, parm: str) -> bool: """Return true if the pair name should be ignored :param parm: string part of pair string:value :return: True if it should be accepted """ return parm.startswith("_") or parm == self.TYPE or parm in self.IGNORE or \ (sel...
python
def unvalidated_parm(self, parm: str) -> bool: """Return true if the pair name should be ignored :param parm: string part of pair string:value :return: True if it should be accepted """ return parm.startswith("_") or parm == self.TYPE or parm in self.IGNORE or \ (sel...
[ "def", "unvalidated_parm", "(", "self", ",", "parm", ":", "str", ")", "->", "bool", ":", "return", "parm", ".", "startswith", "(", "\"_\"", ")", "or", "parm", "==", "self", ".", "TYPE", "or", "parm", "in", "self", ".", "IGNORE", "or", "(", "self", ...
Return true if the pair name should be ignored :param parm: string part of pair string:value :return: True if it should be accepted
[ "Return", "true", "if", "the", "pair", "name", "should", "be", "ignored" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_context.py#L24-L31
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry.dispatch
def dispatch(self, request): """Takes a request and dispatches its data to a jsonrpc method. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: json output of the corresponding method :rtype: str .. versionadded:: 0.1.0 ...
python
def dispatch(self, request): """Takes a request and dispatches its data to a jsonrpc method. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: json output of the corresponding method :rtype: str .. versionadded:: 0.1.0 ...
[ "def", "dispatch", "(", "self", ",", "request", ")", ":", "def", "_wrapped", "(", ")", ":", "messages", "=", "self", ".", "_get_request_messages", "(", "request", ")", "results", "=", "[", "self", ".", "_dispatch_and_handle_errors", "(", "message", ")", "f...
Takes a request and dispatches its data to a jsonrpc method. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: json output of the corresponding method :rtype: str .. versionadded:: 0.1.0
[ "Takes", "a", "request", "and", "dispatches", "its", "data", "to", "a", "jsonrpc", "method", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L95-L118
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry.register
def register(self, name, method, method_signature=None): """Registers a method with a given name and signature. :param name: The name used to register the method :type name: str :param method: The method to register :type method: function :param method_signature: The met...
python
def register(self, name, method, method_signature=None): """Registers a method with a given name and signature. :param name: The name used to register the method :type name: str :param method: The method to register :type method: function :param method_signature: The met...
[ "def", "register", "(", "self", ",", "name", ",", "method", ",", "method_signature", "=", "None", ")", ":", "if", "inspect", ".", "ismethod", "(", "method", ")", ":", "raise", "Exception", "(", "\"typedjsonrpc does not support making class methods into endpoints\"",...
Registers a method with a given name and signature. :param name: The name used to register the method :type name: str :param method: The method to register :type method: function :param method_signature: The method signature for the given function :type method_signature:...
[ "Registers", "a", "method", "with", "a", "given", "name", "and", "signature", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L218-L232
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry.method
def method(self, returns, **parameter_types): """Syntactic sugar for registering a method Example: >>> registry = Registry() >>> @registry.method(returns=int, x=int, y=int) ... def add(x, y): ... return x + y :param returns: The method's ret...
python
def method(self, returns, **parameter_types): """Syntactic sugar for registering a method Example: >>> registry = Registry() >>> @registry.method(returns=int, x=int, y=int) ... def add(x, y): ... return x + y :param returns: The method's ret...
[ "def", "method", "(", "self", ",", "returns", ",", "*", "*", "parameter_types", ")", ":", "@", "wrapt", ".", "decorator", "def", "type_check_wrapper", "(", "method", ",", "instance", ",", "args", ",", "kwargs", ")", ":", "\"\"\"Wraps a method so that it is typ...
Syntactic sugar for registering a method Example: >>> registry = Registry() >>> @registry.method(returns=int, x=int, y=int) ... def add(x, y): ... return x + y :param returns: The method's return type :type returns: type :param param...
[ "Syntactic", "sugar", "for", "registering", "a", "method" ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L234-L291
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry._collect_parameters
def _collect_parameters(parameter_names, args, kwargs, defaults): """Creates a dictionary mapping parameters names to their values in the method call. :param parameter_names: The method's parameter names :type parameter_names: list[string] :param args: *args passed into the method ...
python
def _collect_parameters(parameter_names, args, kwargs, defaults): """Creates a dictionary mapping parameters names to their values in the method call. :param parameter_names: The method's parameter names :type parameter_names: list[string] :param args: *args passed into the method ...
[ "def", "_collect_parameters", "(", "parameter_names", ",", "args", ",", "kwargs", ",", "defaults", ")", ":", "parameters", "=", "{", "}", "if", "defaults", "is", "not", "None", ":", "zipped_defaults", "=", "zip", "(", "reversed", "(", "parameter_names", ")",...
Creates a dictionary mapping parameters names to their values in the method call. :param parameter_names: The method's parameter names :type parameter_names: list[string] :param args: *args passed into the method :type args: list[object] :param kwargs: **kwargs passed into the m...
[ "Creates", "a", "dictionary", "mapping", "parameters", "names", "to", "their", "values", "in", "the", "method", "call", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L294-L317
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry._get_request_messages
def _get_request_messages(self, request): """Parses the request as a json message. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: The parsed json object :rtype: dict[str, object] """ data = request.get_data(as_...
python
def _get_request_messages(self, request): """Parses the request as a json message. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: The parsed json object :rtype: dict[str, object] """ data = request.get_data(as_...
[ "def", "_get_request_messages", "(", "self", ",", "request", ")", ":", "data", "=", "request", ".", "get_data", "(", "as_text", "=", "True", ")", "try", ":", "msg", "=", "self", ".", "json_decoder", ".", "decode", "(", "data", ")", "except", "Exception",...
Parses the request as a json message. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: The parsed json object :rtype: dict[str, object]
[ "Parses", "the", "request", "as", "a", "json", "message", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L332-L348
train
palantir/typedjsonrpc
typedjsonrpc/registry.py
Registry._check_request
def _check_request(self, msg): """Checks that the request json is well-formed. :param msg: The request's json data :type msg: dict[str, object] """ if "jsonrpc" not in msg: raise InvalidRequestError("'\"jsonrpc\": \"2.0\"' must be included.") if msg["jsonrpc"...
python
def _check_request(self, msg): """Checks that the request json is well-formed. :param msg: The request's json data :type msg: dict[str, object] """ if "jsonrpc" not in msg: raise InvalidRequestError("'\"jsonrpc\": \"2.0\"' must be included.") if msg["jsonrpc"...
[ "def", "_check_request", "(", "self", ",", "msg", ")", ":", "if", "\"jsonrpc\"", "not", "in", "msg", ":", "raise", "InvalidRequestError", "(", "\"'\\\"jsonrpc\\\": \\\"2.0\\\"' must be included.\"", ")", "if", "msg", "[", "\"jsonrpc\"", "]", "!=", "\"2.0\"", ":", ...
Checks that the request json is well-formed. :param msg: The request's json data :type msg: dict[str, object]
[ "Checks", "that", "the", "request", "json", "is", "well", "-", "formed", "." ]
274218fcd236ff9643506caa629029c9ba25a0fb
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L350-L372
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
render_template_to_string
def render_template_to_string(input, _from_string=False, **context): """Render a template from the template folder with the given context. Code based on `<https://github.com/mitsuhiko/flask/blob/master/flask/templating.py>`_ :param input: the string template, or name of the template to be ...
python
def render_template_to_string(input, _from_string=False, **context): """Render a template from the template folder with the given context. Code based on `<https://github.com/mitsuhiko/flask/blob/master/flask/templating.py>`_ :param input: the string template, or name of the template to be ...
[ "def", "render_template_to_string", "(", "input", ",", "_from_string", "=", "False", ",", "*", "*", "context", ")", ":", "if", "_from_string", ":", "template", "=", "current_app", ".", "jinja_env", ".", "from_string", "(", "input", ")", "else", ":", "templat...
Render a template from the template folder with the given context. Code based on `<https://github.com/mitsuhiko/flask/blob/master/flask/templating.py>`_ :param input: the string template, or name of the template to be rendered, or an iterable with template names the firs...
[ "Render", "a", "template", "from", "the", "template", "folder", "with", "the", "given", "context", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L79-L95
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
save_and_validate_logo
def save_and_validate_logo(logo_stream, logo_filename, community_id): """Validate if communities logo is in limit size and save it.""" cfg = current_app.config logos_bucket_id = cfg['COMMUNITIES_BUCKET_UUID'] logo_max_size = cfg['COMMUNITIES_LOGO_MAX_SIZE'] logos_bucket = Bucket.query.get(logos_buc...
python
def save_and_validate_logo(logo_stream, logo_filename, community_id): """Validate if communities logo is in limit size and save it.""" cfg = current_app.config logos_bucket_id = cfg['COMMUNITIES_BUCKET_UUID'] logo_max_size = cfg['COMMUNITIES_LOGO_MAX_SIZE'] logos_bucket = Bucket.query.get(logos_buc...
[ "def", "save_and_validate_logo", "(", "logo_stream", ",", "logo_filename", ",", "community_id", ")", ":", "cfg", "=", "current_app", ".", "config", "logos_bucket_id", "=", "cfg", "[", "'COMMUNITIES_BUCKET_UUID'", "]", "logo_max_size", "=", "cfg", "[", "'COMMUNITIES_...
Validate if communities logo is in limit size and save it.
[ "Validate", "if", "communities", "logo", "is", "in", "limit", "size", "and", "save", "it", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L98-L120
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
initialize_communities_bucket
def initialize_communities_bucket(): """Initialize the communities file bucket. :raises: `invenio_files_rest.errors.FilesException` """ bucket_id = UUID(current_app.config['COMMUNITIES_BUCKET_UUID']) if Bucket.query.get(bucket_id): raise FilesException("Bucket with UUID {} already exists."...
python
def initialize_communities_bucket(): """Initialize the communities file bucket. :raises: `invenio_files_rest.errors.FilesException` """ bucket_id = UUID(current_app.config['COMMUNITIES_BUCKET_UUID']) if Bucket.query.get(bucket_id): raise FilesException("Bucket with UUID {} already exists."...
[ "def", "initialize_communities_bucket", "(", ")", ":", "bucket_id", "=", "UUID", "(", "current_app", ".", "config", "[", "'COMMUNITIES_BUCKET_UUID'", "]", ")", "if", "Bucket", ".", "query", ".", "get", "(", "bucket_id", ")", ":", "raise", "FilesException", "("...
Initialize the communities file bucket. :raises: `invenio_files_rest.errors.FilesException`
[ "Initialize", "the", "communities", "file", "bucket", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L123-L140
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
format_request_email_templ
def format_request_email_templ(increq, template, **ctx): """Format the email message element for inclusion request notification. Formats the message according to the provided template file, using some default fields from 'increq' object as default context. Arbitrary context can be provided as keywords ...
python
def format_request_email_templ(increq, template, **ctx): """Format the email message element for inclusion request notification. Formats the message according to the provided template file, using some default fields from 'increq' object as default context. Arbitrary context can be provided as keywords ...
[ "def", "format_request_email_templ", "(", "increq", ",", "template", ",", "*", "*", "ctx", ")", ":", "# Add minimal information to the contex (without overwriting).", "curate_link", "=", "'{site_url}/communities/{id}/curate/'", ".", "format", "(", "site_url", "=", "current_...
Format the email message element for inclusion request notification. Formats the message according to the provided template file, using some default fields from 'increq' object as default context. Arbitrary context can be provided as keywords ('ctx'), and those will not be overwritten by the fields fro...
[ "Format", "the", "email", "message", "element", "for", "inclusion", "request", "notification", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L143-L176
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
format_request_email_title
def format_request_email_title(increq, **ctx): """Format the email message title for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to...
python
def format_request_email_title(increq, **ctx): """Format the email message title for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to...
[ "def", "format_request_email_title", "(", "increq", ",", "*", "*", "ctx", ")", ":", "template", "=", "current_app", ".", "config", "[", "\"COMMUNITIES_REQUEST_EMAIL_TITLE_TEMPLATE\"", "]", ",", "return", "format_request_email_templ", "(", "increq", ",", "template", ...
Format the email message title for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to formatter. :type ctx: dict. :returns: Email m...
[ "Format", "the", "email", "message", "title", "for", "inclusion", "request", "notification", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L179-L190
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
format_request_email_body
def format_request_email_body(increq, **ctx): """Format the email message body for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to f...
python
def format_request_email_body(increq, **ctx): """Format the email message body for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to f...
[ "def", "format_request_email_body", "(", "increq", ",", "*", "*", "ctx", ")", ":", "template", "=", "current_app", ".", "config", "[", "\"COMMUNITIES_REQUEST_EMAIL_BODY_TEMPLATE\"", "]", ",", "return", "format_request_email_templ", "(", "increq", ",", "template", ",...
Format the email message body for inclusion request notification. :param increq: Inclusion request object for which the request is made. :type increq: `invenio_communities.models.InclusionRequest` :param ctx: Optional extra context parameters passed to formatter. :type ctx: dict. :returns: Email me...
[ "Format", "the", "email", "message", "body", "for", "inclusion", "request", "notification", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L193-L204
train
inveniosoftware/invenio-communities
invenio_communities/utils.py
send_community_request_email
def send_community_request_email(increq): """Signal for sending emails after community inclusion request.""" from flask_mail import Message from invenio_mail.tasks import send_email msg_body = format_request_email_body(increq) msg_title = format_request_email_title(increq) sender = current_app...
python
def send_community_request_email(increq): """Signal for sending emails after community inclusion request.""" from flask_mail import Message from invenio_mail.tasks import send_email msg_body = format_request_email_body(increq) msg_title = format_request_email_title(increq) sender = current_app...
[ "def", "send_community_request_email", "(", "increq", ")", ":", "from", "flask_mail", "import", "Message", "from", "invenio_mail", ".", "tasks", "import", "send_email", "msg_body", "=", "format_request_email_body", "(", "increq", ")", "msg_title", "=", "format_request...
Signal for sending emails after community inclusion request.
[ "Signal", "for", "sending", "emails", "after", "community", "inclusion", "request", "." ]
5c4de6783724d276ae1b6dd13a399a9e22fadc7a
https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L207-L224
train
yamins81/tabular
tabular/tab.py
modifydocs
def modifydocs(a, b, desc=''): """ Convenience function for writing documentation. For a class method `a` that is essentially a wrapper for an outside function `b`, rope in the docstring from `b` and append to that of `a`. Also modify the docstring of `a` to get the indentation right. W...
python
def modifydocs(a, b, desc=''): """ Convenience function for writing documentation. For a class method `a` that is essentially a wrapper for an outside function `b`, rope in the docstring from `b` and append to that of `a`. Also modify the docstring of `a` to get the indentation right. W...
[ "def", "modifydocs", "(", "a", ",", "b", ",", "desc", "=", "''", ")", ":", "newdoc", "=", "a", ".", "func_doc", ".", "replace", "(", "'\\t\\t'", ",", "'\\t'", ")", "newdoc", "+=", "\"Documentation from \"", "+", "desc", "+", "\":\\n\"", "+", "b", "."...
Convenience function for writing documentation. For a class method `a` that is essentially a wrapper for an outside function `b`, rope in the docstring from `b` and append to that of `a`. Also modify the docstring of `a` to get the indentation right. Will probably deprecate this soon. **Pa...
[ "Convenience", "function", "for", "writing", "documentation", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L34-L68
train
yamins81/tabular
tabular/tab.py
tab_join
def tab_join(ToMerge, keycols=None, nullvals=None, renamer=None, returnrenaming=False, Names=None): ''' Database-join for tabular arrays. Wrapper for :func:`tabular.spreadsheet.join` that deals with the coloring and returns the result as a tabarray. Method calls:: data ...
python
def tab_join(ToMerge, keycols=None, nullvals=None, renamer=None, returnrenaming=False, Names=None): ''' Database-join for tabular arrays. Wrapper for :func:`tabular.spreadsheet.join` that deals with the coloring and returns the result as a tabarray. Method calls:: data ...
[ "def", "tab_join", "(", "ToMerge", ",", "keycols", "=", "None", ",", "nullvals", "=", "None", ",", "renamer", "=", "None", ",", "returnrenaming", "=", "False", ",", "Names", "=", "None", ")", ":", "[", "Result", ",", "Renaming", "]", "=", "spreadsheet"...
Database-join for tabular arrays. Wrapper for :func:`tabular.spreadsheet.join` that deals with the coloring and returns the result as a tabarray. Method calls:: data = tabular.spreadsheet.join
[ "Database", "-", "join", "for", "tabular", "arrays", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L142-L186
train
yamins81/tabular
tabular/tab.py
tabarray.extract
def extract(self): """ Creates a copy of this tabarray in the form of a numpy ndarray. Useful if you want to do math on array elements, e.g. if you have a subset of the columns that are all numerical, you can construct a numerical matrix and do matrix operations. """ ...
python
def extract(self): """ Creates a copy of this tabarray in the form of a numpy ndarray. Useful if you want to do math on array elements, e.g. if you have a subset of the columns that are all numerical, you can construct a numerical matrix and do matrix operations. """ ...
[ "def", "extract", "(", "self", ")", ":", "return", "np", ".", "vstack", "(", "[", "self", "[", "r", "]", "for", "r", "in", "self", ".", "dtype", ".", "names", "]", ")", ".", "T", ".", "squeeze", "(", ")" ]
Creates a copy of this tabarray in the form of a numpy ndarray. Useful if you want to do math on array elements, e.g. if you have a subset of the columns that are all numerical, you can construct a numerical matrix and do matrix operations.
[ "Creates", "a", "copy", "of", "this", "tabarray", "in", "the", "form", "of", "a", "numpy", "ndarray", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L550-L559
train
yamins81/tabular
tabular/tab.py
tabarray.addrecords
def addrecords(self, new): """ Append one or more records to the end of the array. Method wraps:: tabular.spreadsheet.addrecords(self, new) """ data = spreadsheet.addrecords(self,new) data = data.view(tabarray) data.coloring = self.coloring ...
python
def addrecords(self, new): """ Append one or more records to the end of the array. Method wraps:: tabular.spreadsheet.addrecords(self, new) """ data = spreadsheet.addrecords(self,new) data = data.view(tabarray) data.coloring = self.coloring ...
[ "def", "addrecords", "(", "self", ",", "new", ")", ":", "data", "=", "spreadsheet", ".", "addrecords", "(", "self", ",", "new", ")", "data", "=", "data", ".", "view", "(", "tabarray", ")", "data", ".", "coloring", "=", "self", ".", "coloring", "retur...
Append one or more records to the end of the array. Method wraps:: tabular.spreadsheet.addrecords(self, new)
[ "Append", "one", "or", "more", "records", "to", "the", "end", "of", "the", "array", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L609-L621
train
yamins81/tabular
tabular/tab.py
tabarray.addcols
def addcols(self, cols, names=None): """ Add one or more new columns. Method wraps:: tabular.spreadsheet.addcols(self, cols, names) """ data = spreadsheet.addcols(self, cols, names) data = data.view(tabarray) data.coloring = self.coloring ...
python
def addcols(self, cols, names=None): """ Add one or more new columns. Method wraps:: tabular.spreadsheet.addcols(self, cols, names) """ data = spreadsheet.addcols(self, cols, names) data = data.view(tabarray) data.coloring = self.coloring ...
[ "def", "addcols", "(", "self", ",", "cols", ",", "names", "=", "None", ")", ":", "data", "=", "spreadsheet", ".", "addcols", "(", "self", ",", "cols", ",", "names", ")", "data", "=", "data", ".", "view", "(", "tabarray", ")", "data", ".", "coloring...
Add one or more new columns. Method wraps:: tabular.spreadsheet.addcols(self, cols, names)
[ "Add", "one", "or", "more", "new", "columns", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L625-L637
train
yamins81/tabular
tabular/tab.py
tabarray.renamecol
def renamecol(self, old, new): """ Rename column or color in-place. Method wraps:: tabular.spreadsheet.renamecol(self, old, new) """ spreadsheet.renamecol(self,old,new) for x in self.coloring.keys(): if old in self.coloring[x]: ...
python
def renamecol(self, old, new): """ Rename column or color in-place. Method wraps:: tabular.spreadsheet.renamecol(self, old, new) """ spreadsheet.renamecol(self,old,new) for x in self.coloring.keys(): if old in self.coloring[x]: ...
[ "def", "renamecol", "(", "self", ",", "old", ",", "new", ")", ":", "spreadsheet", ".", "renamecol", "(", "self", ",", "old", ",", "new", ")", "for", "x", "in", "self", ".", "coloring", ".", "keys", "(", ")", ":", "if", "old", "in", "self", ".", ...
Rename column or color in-place. Method wraps:: tabular.spreadsheet.renamecol(self, old, new)
[ "Rename", "column", "or", "color", "in", "-", "place", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L658-L671
train
yamins81/tabular
tabular/tab.py
tabarray.colstack
def colstack(self, new, mode='abort'): """ Horizontal stacking for tabarrays. Stack tabarray(s) in `new` to the right of `self`. **See also** :func:`tabular.tabarray.tab_colstack`, :func:`tabular.spreadsheet.colstack` """ if isinstance...
python
def colstack(self, new, mode='abort'): """ Horizontal stacking for tabarrays. Stack tabarray(s) in `new` to the right of `self`. **See also** :func:`tabular.tabarray.tab_colstack`, :func:`tabular.spreadsheet.colstack` """ if isinstance...
[ "def", "colstack", "(", "self", ",", "new", ",", "mode", "=", "'abort'", ")", ":", "if", "isinstance", "(", "new", ",", "list", ")", ":", "return", "tab_colstack", "(", "[", "self", "]", "+", "new", ",", "mode", ")", "else", ":", "return", "tab_col...
Horizontal stacking for tabarrays. Stack tabarray(s) in `new` to the right of `self`. **See also** :func:`tabular.tabarray.tab_colstack`, :func:`tabular.spreadsheet.colstack`
[ "Horizontal", "stacking", "for", "tabarrays", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L713-L728
train
yamins81/tabular
tabular/tab.py
tabarray.rowstack
def rowstack(self, new, mode='nulls'): """ Vertical stacking for tabarrays. Stack tabarray(s) in `new` below `self`. **See also** :func:`tabular.tabarray.tab_rowstack`, :func:`tabular.spreadsheet.rowstack` """ if isinstance(new,list): ...
python
def rowstack(self, new, mode='nulls'): """ Vertical stacking for tabarrays. Stack tabarray(s) in `new` below `self`. **See also** :func:`tabular.tabarray.tab_rowstack`, :func:`tabular.spreadsheet.rowstack` """ if isinstance(new,list): ...
[ "def", "rowstack", "(", "self", ",", "new", ",", "mode", "=", "'nulls'", ")", ":", "if", "isinstance", "(", "new", ",", "list", ")", ":", "return", "tab_rowstack", "(", "[", "self", "]", "+", "new", ",", "mode", ")", "else", ":", "return", "tab_row...
Vertical stacking for tabarrays. Stack tabarray(s) in `new` below `self`. **See also** :func:`tabular.tabarray.tab_rowstack`, :func:`tabular.spreadsheet.rowstack`
[ "Vertical", "stacking", "for", "tabarrays", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L733-L748
train
yamins81/tabular
tabular/tab.py
tabarray.aggregate
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList = None, returnsort=False,KeepOthers=True, keyfuncdict=None): """ Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFu...
python
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList = None, returnsort=False,KeepOthers=True, keyfuncdict=None): """ Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFu...
[ "def", "aggregate", "(", "self", ",", "On", "=", "None", ",", "AggFuncDict", "=", "None", ",", "AggFunc", "=", "None", ",", "AggList", "=", "None", ",", "returnsort", "=", "False", ",", "KeepOthers", "=", "True", ",", "keyfuncdict", "=", "None", ")", ...
Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFunc, returnsort)
[ "Aggregate", "a", "tabarray", "on", "columns", "for", "given", "functions", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L753-L781
train
yamins81/tabular
tabular/tab.py
tabarray.aggregate_in
def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None, AggList=None, interspersed=True): """ Aggregate a tabarray and include original data in the result. See the :func:`aggregate` method. Method wraps:: tabular.summarize.aggregate_in(self, On...
python
def aggregate_in(self, On=None, AggFuncDict=None, AggFunc=None, AggList=None, interspersed=True): """ Aggregate a tabarray and include original data in the result. See the :func:`aggregate` method. Method wraps:: tabular.summarize.aggregate_in(self, On...
[ "def", "aggregate_in", "(", "self", ",", "On", "=", "None", ",", "AggFuncDict", "=", "None", ",", "AggFunc", "=", "None", ",", "AggList", "=", "None", ",", "interspersed", "=", "True", ")", ":", "data", "=", "spreadsheet", ".", "aggregate_in", "(", "Da...
Aggregate a tabarray and include original data in the result. See the :func:`aggregate` method. Method wraps:: tabular.summarize.aggregate_in(self, On, AggFuncDict, AggFunc, interspersed)
[ "Aggregate", "a", "tabarray", "and", "include", "original", "data", "in", "the", "result", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L785-L802
train
yamins81/tabular
tabular/tab.py
tabarray.pivot
def pivot(self, a, b, Keep=None, NullVals=None, order = None, prefix='_'): """ Pivot with `a` as the row axis and `b` values as the column axis. Method wraps:: tabular.spreadsheet.pivot(X, a, b, Keep) """ [data,coloring] = spreadsheet.pivot(X=self, a=a, b=b, Ke...
python
def pivot(self, a, b, Keep=None, NullVals=None, order = None, prefix='_'): """ Pivot with `a` as the row axis and `b` values as the column axis. Method wraps:: tabular.spreadsheet.pivot(X, a, b, Keep) """ [data,coloring] = spreadsheet.pivot(X=self, a=a, b=b, Ke...
[ "def", "pivot", "(", "self", ",", "a", ",", "b", ",", "Keep", "=", "None", ",", "NullVals", "=", "None", ",", "order", "=", "None", ",", "prefix", "=", "'_'", ")", ":", "[", "data", ",", "coloring", "]", "=", "spreadsheet", ".", "pivot", "(", "...
Pivot with `a` as the row axis and `b` values as the column axis. Method wraps:: tabular.spreadsheet.pivot(X, a, b, Keep)
[ "Pivot", "with", "a", "as", "the", "row", "axis", "and", "b", "values", "as", "the", "column", "axis", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L807-L820
train
yamins81/tabular
tabular/tab.py
tabarray.join
def join(self, ToMerge, keycols=None, nullvals=None, renamer=None, returnrenaming=False, selfname=None, Names=None): """ Wrapper for spreadsheet.join, but handles coloring attributes. The `selfname` argument allows naming of `self` to be used if `ToMerge` is a dictionary....
python
def join(self, ToMerge, keycols=None, nullvals=None, renamer=None, returnrenaming=False, selfname=None, Names=None): """ Wrapper for spreadsheet.join, but handles coloring attributes. The `selfname` argument allows naming of `self` to be used if `ToMerge` is a dictionary....
[ "def", "join", "(", "self", ",", "ToMerge", ",", "keycols", "=", "None", ",", "nullvals", "=", "None", ",", "renamer", "=", "None", ",", "returnrenaming", "=", "False", ",", "selfname", "=", "None", ",", "Names", "=", "None", ")", ":", "if", "isinsta...
Wrapper for spreadsheet.join, but handles coloring attributes. The `selfname` argument allows naming of `self` to be used if `ToMerge` is a dictionary. **See also:** :func:`tabular.spreadsheet.join`, :func:`tab_join`
[ "Wrapper", "for", "spreadsheet", ".", "join", "but", "handles", "coloring", "attributes", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L839-L867
train
yamins81/tabular
tabular/tab.py
tabarray.argsort
def argsort(self, axis=-1, kind='quicksort', order=None): """ Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the gi...
python
def argsort(self, axis=-1, kind='quicksort', order=None): """ Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the gi...
[ "def", "argsort", "(", "self", ",", "axis", "=", "-", "1", ",", "kind", "=", "'quicksort'", ",", "order", "=", "None", ")", ":", "index_array", "=", "np", ".", "core", ".", "fromnumeric", ".", "_wrapit", "(", "self", ",", "'argsort'", ",", "axis", ...
Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the given axis using the algorithm specified by the `kind` keyword. It ret...
[ "Returns", "the", "indices", "that", "would", "sort", "an", "array", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L869-L937
train
hsolbrig/pyjsg
pyjsg/jsglib/jsg_strings.py
JSGPattern.matches
def matches(self, txt: str) -> bool: """Determine whether txt matches pattern :param txt: text to check :return: True if match """ # rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape') if r'\\u' in self.pattern_re.pattern: txt = txt.encode('ut...
python
def matches(self, txt: str) -> bool: """Determine whether txt matches pattern :param txt: text to check :return: True if match """ # rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape') if r'\\u' in self.pattern_re.pattern: txt = txt.encode('ut...
[ "def", "matches", "(", "self", ",", "txt", ":", "str", ")", "->", "bool", ":", "# rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')", "if", "r'\\\\u'", "in", "self", ".", "pattern_re", ".", "pattern", ":", "txt", "=", "txt", ".", "encode", "(",...
Determine whether txt matches pattern :param txt: text to check :return: True if match
[ "Determine", "whether", "txt", "matches", "pattern" ]
9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7
https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_strings.py#L23-L33
train
yamins81/tabular
tabular/colors.py
Point2HexColor
def Point2HexColor(a, lfrac, tfrac): """ Return web-safe hex triplets. """ [H,S,V] = [math.floor(360 * a), lfrac, tfrac] RGB = hsvToRGB(H, S, V) H = [hex(int(math.floor(255 * x))) for x in RGB] HEX = [a[a.find('x') + 1:] for a in H] HEX = ['0' + h if len(h) == 1 else h for h in HEX]...
python
def Point2HexColor(a, lfrac, tfrac): """ Return web-safe hex triplets. """ [H,S,V] = [math.floor(360 * a), lfrac, tfrac] RGB = hsvToRGB(H, S, V) H = [hex(int(math.floor(255 * x))) for x in RGB] HEX = [a[a.find('x') + 1:] for a in H] HEX = ['0' + h if len(h) == 1 else h for h in HEX]...
[ "def", "Point2HexColor", "(", "a", ",", "lfrac", ",", "tfrac", ")", ":", "[", "H", ",", "S", ",", "V", "]", "=", "[", "math", ".", "floor", "(", "360", "*", "a", ")", ",", "lfrac", ",", "tfrac", "]", "RGB", "=", "hsvToRGB", "(", "H", ",", "...
Return web-safe hex triplets.
[ "Return", "web", "-", "safe", "hex", "triplets", "." ]
1caf091c8c395960a9ad7078f95158b533cc52dd
https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/colors.py#L13-L28
train
OpenTreeOfLife/peyotl
peyotl/utility/get_logger.py
warn_from_util_logger
def warn_from_util_logger(msg): """Only to be used in this file and peyotl.utility.get_config""" global _LOG # This check is necessary to avoid infinite recursion when called from get_config, because # the _read_logging_conf can require reading a conf file. if _LOG is None and _LOGGING_CONF is Non...
python
def warn_from_util_logger(msg): """Only to be used in this file and peyotl.utility.get_config""" global _LOG # This check is necessary to avoid infinite recursion when called from get_config, because # the _read_logging_conf can require reading a conf file. if _LOG is None and _LOGGING_CONF is Non...
[ "def", "warn_from_util_logger", "(", "msg", ")", ":", "global", "_LOG", "# This check is necessary to avoid infinite recursion when called from get_config, because", "# the _read_logging_conf can require reading a conf file.", "if", "_LOG", "is", "None", "and", "_LOGGING_CONF", "is...
Only to be used in this file and peyotl.utility.get_config
[ "Only", "to", "be", "used", "in", "this", "file", "and", "peyotl", ".", "utility", ".", "get_config" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/get_logger.py#L85-L95
train
cydrobolt/pifx
pifx/core.py
PIFX.state_delta
def state_delta(self, selector='all', power=None, duration=1.0, infrared=None, hue=None, saturation=None, brightness=None, kelvin=None): """Given a state delta, apply the modifications to lights' state over a given period of time. selector: required String The select...
python
def state_delta(self, selector='all', power=None, duration=1.0, infrared=None, hue=None, saturation=None, brightness=None, kelvin=None): """Given a state delta, apply the modifications to lights' state over a given period of time. selector: required String The select...
[ "def", "state_delta", "(", "self", ",", "selector", "=", "'all'", ",", "power", "=", "None", ",", "duration", "=", "1.0", ",", "infrared", "=", "None", ",", "hue", "=", "None", ",", "saturation", "=", "None", ",", "brightness", "=", "None", ",", "kel...
Given a state delta, apply the modifications to lights' state over a given period of time. selector: required String The selector to limit which lights are controlled. power: String The power state you want to set on the selector. on or off duration: Double ...
[ "Given", "a", "state", "delta", "apply", "the", "modifications", "to", "lights", "state", "over", "a", "given", "period", "of", "time", "." ]
c9de9c2695c3e6e72de4aa0de47b78fc13c457c3
https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L75-L122
train
cydrobolt/pifx
pifx/core.py
PIFX.breathe_lights
def breathe_lights(self, color, selector='all', from_color=None, period=1.0, cycles=1.0, persist=False, power_on=True, peak=0.5): """Perform breathe effect on lights. selector: String The selector to limit which lights will run the effect. default: all c...
python
def breathe_lights(self, color, selector='all', from_color=None, period=1.0, cycles=1.0, persist=False, power_on=True, peak=0.5): """Perform breathe effect on lights. selector: String The selector to limit which lights will run the effect. default: all c...
[ "def", "breathe_lights", "(", "self", ",", "color", ",", "selector", "=", "'all'", ",", "from_color", "=", "None", ",", "period", "=", "1.0", ",", "cycles", "=", "1.0", ",", "persist", "=", "False", ",", "power_on", "=", "True", ",", "peak", "=", "0....
Perform breathe effect on lights. selector: String The selector to limit which lights will run the effect. default: all color: required String Color attributes to use during effect. See set_state for more. from_color: String The color to start t...
[ "Perform", "breathe", "effect", "on", "lights", "." ]
c9de9c2695c3e6e72de4aa0de47b78fc13c457c3
https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L135-L186
train
cydrobolt/pifx
pifx/core.py
PIFX.cycle_lights
def cycle_lights(self, states, defaults, direction='forward', selector='all'): """Cycle through list of effects. Provide array states as a list of dictionaries with set_state arguments. See http://api.developer.lifx.com/docs/cycle selector: String The selector to li...
python
def cycle_lights(self, states, defaults, direction='forward', selector='all'): """Cycle through list of effects. Provide array states as a list of dictionaries with set_state arguments. See http://api.developer.lifx.com/docs/cycle selector: String The selector to li...
[ "def", "cycle_lights", "(", "self", ",", "states", ",", "defaults", ",", "direction", "=", "'forward'", ",", "selector", "=", "'all'", ")", ":", "argument_tuples", "=", "[", "(", "\"states\"", ",", "states", ")", ",", "(", "\"defaults\"", ",", "defaults", ...
Cycle through list of effects. Provide array states as a list of dictionaries with set_state arguments. See http://api.developer.lifx.com/docs/cycle selector: String The selector to limit which lights will run the effect. default: all states: required List of D...
[ "Cycle", "through", "list", "of", "effects", "." ]
c9de9c2695c3e6e72de4aa0de47b78fc13c457c3
https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L235-L266
train
cydrobolt/pifx
pifx/core.py
PIFX.activate_scene
def activate_scene(self, scene_uuid, duration=1.0): """Activate a scene. See http://api.developer.lifx.com/docs/activate-scene scene_uuid: required String The UUID for the scene you wish to activate duration: Double The time in seconds to spend performing the s...
python
def activate_scene(self, scene_uuid, duration=1.0): """Activate a scene. See http://api.developer.lifx.com/docs/activate-scene scene_uuid: required String The UUID for the scene you wish to activate duration: Double The time in seconds to spend performing the s...
[ "def", "activate_scene", "(", "self", ",", "scene_uuid", ",", "duration", "=", "1.0", ")", ":", "argument_tuples", "=", "[", "(", "\"duration\"", ",", "duration", ")", ",", "]", "return", "self", ".", "client", ".", "perform_request", "(", "method", "=", ...
Activate a scene. See http://api.developer.lifx.com/docs/activate-scene scene_uuid: required String The UUID for the scene you wish to activate duration: Double The time in seconds to spend performing the scene transition. default: 1.0
[ "Activate", "a", "scene", "." ]
c9de9c2695c3e6e72de4aa0de47b78fc13c457c3
https://github.com/cydrobolt/pifx/blob/c9de9c2695c3e6e72de4aa0de47b78fc13c457c3/pifx/core.py#L276-L295
train
OpenTreeOfLife/peyotl
peyotl/nexson_syntax/inspect.py
count_num_trees
def count_num_trees(nexson, nexson_version=None): """Returns the number of trees summed across all tree groups. """ if nexson_version is None: nexson_version = detect_nexson_version(nexson) nex = get_nexml_el(nexson) num_trees_by_group = [] if _is_by_id_hbf(nexson_version): f...
python
def count_num_trees(nexson, nexson_version=None): """Returns the number of trees summed across all tree groups. """ if nexson_version is None: nexson_version = detect_nexson_version(nexson) nex = get_nexml_el(nexson) num_trees_by_group = [] if _is_by_id_hbf(nexson_version): f...
[ "def", "count_num_trees", "(", "nexson", ",", "nexson_version", "=", "None", ")", ":", "if", "nexson_version", "is", "None", ":", "nexson_version", "=", "detect_nexson_version", "(", "nexson", ")", "nex", "=", "get_nexml_el", "(", "nexson", ")", "num_trees_by_gr...
Returns the number of trees summed across all tree groups.
[ "Returns", "the", "number", "of", "trees", "summed", "across", "all", "tree", "groups", "." ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/inspect.py#L15-L38
train
OpenTreeOfLife/peyotl
peyotl/collections_store/collections_umbrella.py
TreeCollectionStore
def TreeCollectionStore(repos_dict=None, repos_par=None, with_caching=True, assumed_doc_version=None, git_ssh=None, pkey=None, git_action_class=TreeCollectionsGitAction, ...
python
def TreeCollectionStore(repos_dict=None, repos_par=None, with_caching=True, assumed_doc_version=None, git_ssh=None, pkey=None, git_action_class=TreeCollectionsGitAction, ...
[ "def", "TreeCollectionStore", "(", "repos_dict", "=", "None", ",", "repos_par", "=", "None", ",", "with_caching", "=", "True", ",", "assumed_doc_version", "=", "None", ",", "git_ssh", "=", "None", ",", "pkey", "=", "None", ",", "git_action_class", "=", "Tree...
Factory function for a _TreeCollectionStore object. A wrapper around the _TreeCollectionStore class instantiation for the most common use case: a singleton _TreeCollectionStore. If you need distinct _TreeCollectionStore objects, you'll need to call that class directly.
[ "Factory", "function", "for", "a", "_TreeCollectionStore", "object", "." ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L287-L314
train
OpenTreeOfLife/peyotl
peyotl/collections_store/collections_umbrella.py
_TreeCollectionStore._slugify_internal_collection_name
def _slugify_internal_collection_name(self, json_repr): """Parse the JSON, find its name, return a slug of its name""" collection = self._coerce_json_to_collection(json_repr) if collection is None: return None internal_name = collection['name'] return slugify(internal...
python
def _slugify_internal_collection_name(self, json_repr): """Parse the JSON, find its name, return a slug of its name""" collection = self._coerce_json_to_collection(json_repr) if collection is None: return None internal_name = collection['name'] return slugify(internal...
[ "def", "_slugify_internal_collection_name", "(", "self", ",", "json_repr", ")", ":", "collection", "=", "self", ".", "_coerce_json_to_collection", "(", "json_repr", ")", "if", "collection", "is", "None", ":", "return", "None", "internal_name", "=", "collection", "...
Parse the JSON, find its name, return a slug of its name
[ "Parse", "the", "JSON", "find", "its", "name", "return", "a", "slug", "of", "its", "name" ]
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/collections_store/collections_umbrella.py#L238-L244
train
ncmiller/roku-cli
rokucli/discover.py
discover_roku
def discover_roku(): """ Search LAN for available Roku devices. Returns a Roku object. """ print("Searching for Roku devices within LAN ...") rokus = Roku.discover() if not rokus: print("Unable to discover Roku devices. " + "Try again, or manually specify the IP address with " + ...
python
def discover_roku(): """ Search LAN for available Roku devices. Returns a Roku object. """ print("Searching for Roku devices within LAN ...") rokus = Roku.discover() if not rokus: print("Unable to discover Roku devices. " + "Try again, or manually specify the IP address with " + ...
[ "def", "discover_roku", "(", ")", ":", "print", "(", "\"Searching for Roku devices within LAN ...\"", ")", "rokus", "=", "Roku", ".", "discover", "(", ")", "if", "not", "rokus", ":", "print", "(", "\"Unable to discover Roku devices. \"", "+", "\"Try again, or manually...
Search LAN for available Roku devices. Returns a Roku object.
[ "Search", "LAN", "for", "available", "Roku", "devices", ".", "Returns", "a", "Roku", "object", "." ]
9101952edf9802146c794e63353abf2bf116c052
https://github.com/ncmiller/roku-cli/blob/9101952edf9802146c794e63353abf2bf116c052/rokucli/discover.py#L6-L42
train
OpenTreeOfLife/peyotl
tutorials/ot-info-for-taxon-name.py
ot_tnrs_match_names
def ot_tnrs_match_names(name_list, context_name=None, do_approximate_matching=True, include_dubious=False, include_deprecated=True, tnrs_wrapper=None): """Uses a peyotl wrapper around an Open Tree...
python
def ot_tnrs_match_names(name_list, context_name=None, do_approximate_matching=True, include_dubious=False, include_deprecated=True, tnrs_wrapper=None): """Uses a peyotl wrapper around an Open Tree...
[ "def", "ot_tnrs_match_names", "(", "name_list", ",", "context_name", "=", "None", ",", "do_approximate_matching", "=", "True", ",", "include_dubious", "=", "False", ",", "include_deprecated", "=", "True", ",", "tnrs_wrapper", "=", "None", ")", ":", "if", "tnrs_w...
Uses a peyotl wrapper around an Open Tree web service to get a list of OTT IDs matching the `name_list`. The tnrs_wrapper can be None (in which case the default wrapper from peyotl.sugar will be used. All other arguments correspond to the arguments of the web-service call. A ValueError will be raised if...
[ "Uses", "a", "peyotl", "wrapper", "around", "an", "Open", "Tree", "web", "service", "to", "get", "a", "list", "of", "OTT", "IDs", "matching", "the", "name_list", ".", "The", "tnrs_wrapper", "can", "be", "None", "(", "in", "which", "case", "the", "default...
5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-info-for-taxon-name.py#L10-L33
train
CybOXProject/mixbox
mixbox/entities.py
_objectify
def _objectify(field, value, ns_info): """Make `value` suitable for a binding object. If `value` is an Entity, call to_obj() on it. Otherwise, pass it off to the TypedField for an appropriate value. """ if (getattr(field.type_, "_treat_none_as_empty_list", False) and value is None): ...
python
def _objectify(field, value, ns_info): """Make `value` suitable for a binding object. If `value` is an Entity, call to_obj() on it. Otherwise, pass it off to the TypedField for an appropriate value. """ if (getattr(field.type_, "_treat_none_as_empty_list", False) and value is None): ...
[ "def", "_objectify", "(", "field", ",", "value", ",", "ns_info", ")", ":", "if", "(", "getattr", "(", "field", ".", "type_", ",", "\"_treat_none_as_empty_list\"", ",", "False", ")", "and", "value", "is", "None", ")", ":", "return", "[", "]", "if", "val...
Make `value` suitable for a binding object. If `value` is an Entity, call to_obj() on it. Otherwise, pass it off to the TypedField for an appropriate value.
[ "Make", "value", "suitable", "for", "a", "binding", "object", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L19-L33
train
CybOXProject/mixbox
mixbox/entities.py
_dictify
def _dictify(field, value): """Make `value` suitable for a dictionary. * If `value` is an Entity, call to_dict() on it. * If value is a timestamp, turn it into a string value. * If none of the above are satisfied, return the input value """ if value is None: return None elif field.t...
python
def _dictify(field, value): """Make `value` suitable for a dictionary. * If `value` is an Entity, call to_dict() on it. * If value is a timestamp, turn it into a string value. * If none of the above are satisfied, return the input value """ if value is None: return None elif field.t...
[ "def", "_dictify", "(", "field", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "elif", "field", ".", "type_", ":", "return", "value", ".", "to_dict", "(", ")", "return", "field", ".", "dict_value", "(", "value", ")" ]
Make `value` suitable for a dictionary. * If `value` is an Entity, call to_dict() on it. * If value is a timestamp, turn it into a string value. * If none of the above are satisfied, return the input value
[ "Make", "value", "suitable", "for", "a", "dictionary", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L36-L47
train
CybOXProject/mixbox
mixbox/entities.py
EntityFactory.from_dict
def from_dict(cls, cls_dict, fallback_xsi_type=None): """Parse the dictionary and return an Entity instance. This will attempt to extract type information from the input dictionary and pass it to entity_class to resolve the correct class for the type. Args: cls_dict...
python
def from_dict(cls, cls_dict, fallback_xsi_type=None): """Parse the dictionary and return an Entity instance. This will attempt to extract type information from the input dictionary and pass it to entity_class to resolve the correct class for the type. Args: cls_dict...
[ "def", "from_dict", "(", "cls", ",", "cls_dict", ",", "fallback_xsi_type", "=", "None", ")", ":", "if", "not", "cls_dict", ":", "return", "None", "if", "isinstance", "(", "cls_dict", ",", "six", ".", "string_types", ")", ":", "if", "not", "getattr", "(",...
Parse the dictionary and return an Entity instance. This will attempt to extract type information from the input dictionary and pass it to entity_class to resolve the correct class for the type. Args: cls_dict: A dictionary representation of an Entity object. fa...
[ "Parse", "the", "dictionary", "and", "return", "an", "Entity", "instance", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L137-L164
train
CybOXProject/mixbox
mixbox/entities.py
EntityFactory.from_obj
def from_obj(cls, cls_obj): """Parse the generateDS object and return an Entity instance. This will attempt to extract type information from the input object and pass it to entity_class to resolve the correct class for the type. Args: cls_obj: A generateDS object. ...
python
def from_obj(cls, cls_obj): """Parse the generateDS object and return an Entity instance. This will attempt to extract type information from the input object and pass it to entity_class to resolve the correct class for the type. Args: cls_obj: A generateDS object. ...
[ "def", "from_obj", "(", "cls", ",", "cls_obj", ")", ":", "if", "not", "cls_obj", ":", "return", "None", "typekey", "=", "cls", ".", "objkey", "(", "cls_obj", ")", "klass", "=", "cls", ".", "entity_class", "(", "typekey", ")", "return", "klass", ".", ...
Parse the generateDS object and return an Entity instance. This will attempt to extract type information from the input object and pass it to entity_class to resolve the correct class for the type. Args: cls_obj: A generateDS object. Returns: An Entity ...
[ "Parse", "the", "generateDS", "object", "and", "return", "an", "Entity", "instance", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L167-L185
train
CybOXProject/mixbox
mixbox/entities.py
Entity.typed_fields
def typed_fields(cls): """Return a tuple of this entity's TypedFields.""" # Checking cls._typed_fields could return a superclass _typed_fields # value. So we check our class __dict__ which does not include # inherited attributes. klassdict = cls.__dict__ try: ...
python
def typed_fields(cls): """Return a tuple of this entity's TypedFields.""" # Checking cls._typed_fields could return a superclass _typed_fields # value. So we check our class __dict__ which does not include # inherited attributes. klassdict = cls.__dict__ try: ...
[ "def", "typed_fields", "(", "cls", ")", ":", "# Checking cls._typed_fields could return a superclass _typed_fields", "# value. So we check our class __dict__ which does not include", "# inherited attributes.", "klassdict", "=", "cls", ".", "__dict__", "try", ":", "return", "klassdi...
Return a tuple of this entity's TypedFields.
[ "Return", "a", "tuple", "of", "this", "entity", "s", "TypedFields", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L201-L214
train
CybOXProject/mixbox
mixbox/entities.py
Entity.to_obj
def to_obj(self, ns_info=None): """Convert to a GenerateDS binding object. Subclasses can override this function. Returns: An instance of this Entity's ``_binding_class`` with properties set from this Entity. """ if ns_info: ns_info.collect(s...
python
def to_obj(self, ns_info=None): """Convert to a GenerateDS binding object. Subclasses can override this function. Returns: An instance of this Entity's ``_binding_class`` with properties set from this Entity. """ if ns_info: ns_info.collect(s...
[ "def", "to_obj", "(", "self", ",", "ns_info", "=", "None", ")", ":", "if", "ns_info", ":", "ns_info", ".", "collect", "(", "self", ")", "# null behavior for classes that inherit from Entity but do not", "# have _binding_class", "if", "not", "hasattr", "(", "self", ...
Convert to a GenerateDS binding object. Subclasses can override this function. Returns: An instance of this Entity's ``_binding_class`` with properties set from this Entity.
[ "Convert", "to", "a", "GenerateDS", "binding", "object", "." ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L275-L309
train
CybOXProject/mixbox
mixbox/entities.py
Entity.to_dict
def to_dict(self): """Convert to a ``dict`` Subclasses can override this function. Returns: Python dict with keys set from this Entity. """ entity_dict = {} for field, val in six.iteritems(self._fields): if field.multiple: if val...
python
def to_dict(self): """Convert to a ``dict`` Subclasses can override this function. Returns: Python dict with keys set from this Entity. """ entity_dict = {} for field, val in six.iteritems(self._fields): if field.multiple: if val...
[ "def", "to_dict", "(", "self", ")", ":", "entity_dict", "=", "{", "}", "for", "field", ",", "val", "in", "six", ".", "iteritems", "(", "self", ".", "_fields", ")", ":", "if", "field", ".", "multiple", ":", "if", "val", ":", "val", "=", "[", "_dic...
Convert to a ``dict`` Subclasses can override this function. Returns: Python dict with keys set from this Entity.
[ "Convert", "to", "a", "dict" ]
9097dae7a433f5b98c18171c4a5598f69a7d30af
https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/entities.py#L318-L343
train