partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | get_ot_study_info_from_treebase_nexml | Normalize treebase-specific metadata into the locations where
open tree of life software that expects it.
See get_ot_study_info_from_nexml for the explanation of the src,
nexml_content, encoding, and nexson_syntax_version arguments
If merge_blocks is True then peyotl.manip.merge_otus_and_trees
Act... | peyotl/external.py | def get_ot_study_info_from_treebase_nexml(src=None,
nexml_content=None,
encoding=u'utf8',
nexson_syntax_version=DEFAULT_NEXSON_VERSION,
merge_blocks=Tru... | def get_ot_study_info_from_treebase_nexml(src=None,
nexml_content=None,
encoding=u'utf8',
nexson_syntax_version=DEFAULT_NEXSON_VERSION,
merge_blocks=Tru... | [
"Normalize",
"treebase",
"-",
"specific",
"metadata",
"into",
"the",
"locations",
"where",
"open",
"tree",
"of",
"life",
"software",
"that",
"expects",
"it",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/external.py#L32-L203 | [
"def",
"get_ot_study_info_from_treebase_nexml",
"(",
"src",
"=",
"None",
",",
"nexml_content",
"=",
"None",
",",
"encoding",
"=",
"u'utf8'",
",",
"nexson_syntax_version",
"=",
"DEFAULT_NEXSON_VERSION",
",",
"merge_blocks",
"=",
"True",
",",
"sort_arbitrary",
"=",
"F... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | InvenioCommunities.init_app | Flask application initialization. | invenio_communities/ext.py | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.cli.add_command(cmd)
app.extensions['invenio-communities'] = self
# Register the jinja do extension
app.jinja_env.add_extension('jinja2.ext.do')
self.register_signals(app) | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.cli.add_command(cmd)
app.extensions['invenio-communities'] = self
# Register the jinja do extension
app.jinja_env.add_extension('jinja2.ext.do')
self.register_signals(app) | [
"Flask",
"application",
"initialization",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/ext.py#L50-L57 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"app",
".",
"cli",
".",
"add_command",
"(",
"cmd",
")",
"app",
".",
"extensions",
"[",
"'invenio-communities'",
"]",
"=",
"self",
"# Register the jinja do ex... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | InvenioCommunities.register_signals | Register the signals. | invenio_communities/ext.py | 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):
"""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)
... | [
"Register",
"the",
"signals",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/ext.py#L59-L65 | [
"def",
"register_signals",
"(",
"self",
",",
"app",
")",
":",
"before_record_index",
".",
"connect",
"(",
"inject_provisional_community",
")",
"if",
"app",
".",
"config",
"[",
"'COMMUNITIES_OAI_ENABLED'",
"]",
":",
"listen",
"(",
"Community",
",",
"'after_insert'"... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | genargs | Create a command line parser
:return: parser | pyjsg/validate_json.py | 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:
"""
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... | [
"Create",
"a",
"command",
"line",
"parser"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L88-L100 | [
"def",
"genargs",
"(",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"spec\"",
",",
"help",
"=",
"\"JSG specification - can be file name, URI or string\"",
")",
"parser",
".",
"add_argument",
"(",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGPython._to_string | Convert a URL or file name to a string | pyjsg/validate_json.py | 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:
""" 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:
... | [
"Convert",
"a",
"URL",
"or",
"file",
"name",
"to",
"a",
"string"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L57-L66 | [
"def",
"_to_string",
"(",
"inp",
":",
"str",
")",
"->",
"str",
":",
"if",
"'://'",
"in",
"inp",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"inp",
")",
"if",
"not",
"req",
".",
"ok",
":",
"raise",
"ValueError",
"(",
"f\"Unable to read {inp}\"",
")"... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGPython.conforms | 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 | pyjsg/validate_json.py | 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:
""" 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... | [
"Determine",
"whether",
"json",
"conforms",
"with",
"the",
"JSG",
"specification"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/validate_json.py#L68-L85 | [
"def",
"conforms",
"(",
"self",
",",
"json",
":",
"str",
",",
"name",
":",
"str",
"=",
"\"\"",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"ValidationResult",
":",
"json",
"=",
"self",
".",
"_to_string",
"(",
"json",
")",
"if",
"not",
"se... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | _write_to_next_free | #WARNING not thread safe just a easy of debugging routine! | peyotl/phylesystem/git_workflows.py | def _write_to_next_free(tag, blob):
"""#WARNING not thread safe just a easy of debugging routine!"""
ind = 0
pref = '/tmp/peyotl-' + tag + str(ind)
while os.path.exists(pref):
ind += 1
pref = '/tmp/peyotl-' + tag + str(ind)
write_as_json(blob, pref) | def _write_to_next_free(tag, blob):
"""#WARNING not thread safe just a easy of debugging routine!"""
ind = 0
pref = '/tmp/peyotl-' + tag + str(ind)
while os.path.exists(pref):
ind += 1
pref = '/tmp/peyotl-' + tag + str(ind)
write_as_json(blob, pref) | [
"#WARNING",
"not",
"thread",
"safe",
"just",
"a",
"easy",
"of",
"debugging",
"routine!"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_workflows.py#L21-L28 | [
"def",
"_write_to_next_free",
"(",
"tag",
",",
"blob",
")",
":",
"ind",
"=",
"0",
"pref",
"=",
"'/tmp/peyotl-'",
"+",
"tag",
"+",
"str",
"(",
"ind",
")",
"while",
"os",
".",
"path",
".",
"exists",
"(",
"pref",
")",
":",
"ind",
"+=",
"1",
"pref",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | validate_and_convert_nexson | Runs the nexson validator and returns a converted 4 object:
nexson, annotation, validation_log, nexson_adaptor
`nexson` is the nexson dict.
`output_version` is the version of nexson syntax to be used after validation.
if `allow_invalid` is False, and the nexson validation has errors, then
a... | peyotl/phylesystem/git_workflows.py | def validate_and_convert_nexson(nexson, output_version, allow_invalid, **kwargs):
"""Runs the nexson validator and returns a converted 4 object:
nexson, annotation, validation_log, nexson_adaptor
`nexson` is the nexson dict.
`output_version` is the version of nexson syntax to be used after validati... | def validate_and_convert_nexson(nexson, output_version, allow_invalid, **kwargs):
"""Runs the nexson validator and returns a converted 4 object:
nexson, annotation, validation_log, nexson_adaptor
`nexson` is the nexson dict.
`output_version` is the version of nexson syntax to be used after validati... | [
"Runs",
"the",
"nexson",
"validator",
"and",
"returns",
"a",
"converted",
"4",
"object",
":",
"nexson",
"annotation",
"validation_log",
"nexson_adaptor"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_workflows.py#L31-L54 | [
"def",
"validate_and_convert_nexson",
"(",
"nexson",
",",
"output_version",
",",
"allow_invalid",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"TRACE_FILES",
":",
"_write_to_next_free",
"(",
"'input'",
",",
"nexson",
")",
"annotation",
",",
"validation_l... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | commit_and_try_merge2master | Actually make a local Git commit and push it to our remote | peyotl/phylesystem/git_workflows.py | def commit_and_try_merge2master(git_action,
file_content,
study_id,
auth_info,
parent_sha,
commit_msg='',
merged_sha=None):
... | def commit_and_try_merge2master(git_action,
file_content,
study_id,
auth_info,
parent_sha,
commit_msg='',
merged_sha=None):
... | [
"Actually",
"make",
"a",
"local",
"Git",
"commit",
"and",
"push",
"it",
"to",
"our",
"remote"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_workflows.py#L57-L73 | [
"def",
"commit_and_try_merge2master",
"(",
"git_action",
",",
"file_content",
",",
"study_id",
",",
"auth_info",
",",
"parent_sha",
",",
"commit_msg",
"=",
"''",
",",
"merged_sha",
"=",
"None",
")",
":",
"return",
"generic_commit_and_try_merge2master_wf",
"(",
"git_... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | merge_from_master | merge from master into the WIP for this study/author
this is needed to allow a worker's future saves to
be merged seamlessly into master | peyotl/phylesystem/git_workflows.py | def merge_from_master(git_action, study_id, auth_info, parent_sha):
"""merge from master into the WIP for this study/author
this is needed to allow a worker's future saves to
be merged seamlessly into master
"""
return _merge_from_master(git_action,
doc_id=study_id,
... | def merge_from_master(git_action, study_id, auth_info, parent_sha):
"""merge from master into the WIP for this study/author
this is needed to allow a worker's future saves to
be merged seamlessly into master
"""
return _merge_from_master(git_action,
doc_id=study_id,
... | [
"merge",
"from",
"master",
"into",
"the",
"WIP",
"for",
"this",
"study",
"/",
"author",
"this",
"is",
"needed",
"to",
"allow",
"a",
"worker",
"s",
"future",
"saves",
"to",
"be",
"merged",
"seamlessly",
"into",
"master"
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/phylesystem/git_workflows.py#L91-L100 | [
"def",
"merge_from_master",
"(",
"git_action",
",",
"study_id",
",",
"auth_info",
",",
"parent_sha",
")",
":",
"return",
"_merge_from_master",
"(",
"git_action",
",",
"doc_id",
"=",
"study_id",
",",
"auth_info",
"=",
"auth_info",
",",
"parent_sha",
"=",
"parent_... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | Issuer.open | Explicit entry. Perform ancestor opening operations,
then synchronize revocation registry to tails tree content.
:return: current object | von_agent/agent/issuer.py | async def open(self) -> 'Issuer':
"""
Explicit entry. Perform ancestor opening operations,
then synchronize revocation registry to tails tree content.
:return: current object
"""
LOGGER.debug('Issuer.open >>>')
await super().open()
for path_rr_id in Tai... | async def open(self) -> 'Issuer':
"""
Explicit entry. Perform ancestor opening operations,
then synchronize revocation registry to tails tree content.
:return: current object
"""
LOGGER.debug('Issuer.open >>>')
await super().open()
for path_rr_id in Tai... | [
"Explicit",
"entry",
".",
"Perform",
"ancestor",
"opening",
"operations",
"then",
"synchronize",
"revocation",
"registry",
"to",
"tails",
"tree",
"content",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L70-L85 | [
"async",
"def",
"open",
"(",
"self",
")",
"->",
"'Issuer'",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer.open >>>'",
")",
"await",
"super",
"(",
")",
".",
"open",
"(",
")",
"for",
"path_rr_id",
"in",
"Tails",
".",
"links",
"(",
"self",
".",
"_dir_tails",... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer._create_rev_reg | Create revocation registry and new tails file (and association to
corresponding revocation registry definition via symbolic link) for input
revocation registry identifier.
:param rr_id: revocation registry identifier
:param rr_size: revocation registry size (defaults to 256) | von_agent/agent/issuer.py | async def _create_rev_reg(self, rr_id: str, rr_size: int = None) -> None:
"""
Create revocation registry and new tails file (and association to
corresponding revocation registry definition via symbolic link) for input
revocation registry identifier.
:param rr_id: revocation regi... | async def _create_rev_reg(self, rr_id: str, rr_size: int = None) -> None:
"""
Create revocation registry and new tails file (and association to
corresponding revocation registry definition via symbolic link) for input
revocation registry identifier.
:param rr_id: revocation regi... | [
"Create",
"revocation",
"registry",
"and",
"new",
"tails",
"file",
"(",
"and",
"association",
"to",
"corresponding",
"revocation",
"registry",
"definition",
"via",
"symbolic",
"link",
")",
"for",
"input",
"revocation",
"registry",
"identifier",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L87-L137 | [
"async",
"def",
"_create_rev_reg",
"(",
"self",
",",
"rr_id",
":",
"str",
",",
"rr_size",
":",
"int",
"=",
"None",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer._create_rev_reg >>> rr_id: %s, rr_size: %s'",
",",
"rr_id",
",",
"rr_size",
")",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer._sync_revoc | 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()) | von_agent/agent/issuer.py | 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:
"""
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... | [
"Create",
"revoc",
"registry",
"if",
"need",
"be",
"for",
"input",
"revocation",
"registry",
"identifier",
";",
"open",
"and",
"cache",
"tails",
"file",
"reader",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L139-L178 | [
"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",
")",
"(",
"... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.path_tails | Return path to tails file for input revocation registry identifier.
:param rr_id: revocation registry identifier of interest
:return: path to tails file for input revocation registry identifier | von_agent/agent/issuer.py | def path_tails(self, rr_id: str) -> str:
"""
Return path to tails file for input revocation registry identifier.
:param rr_id: revocation registry identifier of interest
:return: path to tails file for input revocation registry identifier
"""
return Tails.linked(self._d... | def path_tails(self, rr_id: str) -> str:
"""
Return path to tails file for input revocation registry identifier.
:param rr_id: revocation registry identifier of interest
:return: path to tails file for input revocation registry identifier
"""
return Tails.linked(self._d... | [
"Return",
"path",
"to",
"tails",
"file",
"for",
"input",
"revocation",
"registry",
"identifier",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L180-L188 | [
"def",
"path_tails",
"(",
"self",
",",
"rr_id",
":",
"str",
")",
"->",
"str",
":",
"return",
"Tails",
".",
"linked",
"(",
"self",
".",
"_dir_tails",
",",
"rr_id",
")"
] | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.send_cred_def | Create a credential definition as Issuer, store it in its wallet, and send it to the ledger.
Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure
to send credential definition to ledger if need be, or IndyError for any other failure
to create and store creden... | von_agent/agent/issuer.py | async def send_cred_def(self, s_id: str, revocation: bool = True, rr_size: int = None) -> str:
"""
Create a credential definition as Issuer, store it in its wallet, and send it to the ledger.
Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure
to sen... | async def send_cred_def(self, s_id: str, revocation: bool = True, rr_size: int = None) -> str:
"""
Create a credential definition as Issuer, store it in its wallet, and send it to the ledger.
Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure
to sen... | [
"Create",
"a",
"credential",
"definition",
"as",
"Issuer",
"store",
"it",
"in",
"its",
"wallet",
"and",
"send",
"it",
"to",
"the",
"ledger",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L190-L275 | [
"async",
"def",
"send_cred_def",
"(",
"self",
",",
"s_id",
":",
"str",
",",
"revocation",
":",
"bool",
"=",
"True",
",",
"rr_size",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer.send_cred_def >>> s_id: %s, revocation: ... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.create_cred_offer | Create credential offer as Issuer for given schema.
Raise CorruptWallet if the wallet has no private key for the corresponding credential definition.
:param schema_seq_no: schema sequence number
:return: credential offer json for use in storing credentials at HolderProver. | von_agent/agent/issuer.py | async def create_cred_offer(self, schema_seq_no: int) -> str:
"""
Create credential offer as Issuer for given schema.
Raise CorruptWallet if the wallet has no private key for the corresponding credential definition.
:param schema_seq_no: schema sequence number
:return: credenti... | async def create_cred_offer(self, schema_seq_no: int) -> str:
"""
Create credential offer as Issuer for given schema.
Raise CorruptWallet if the wallet has no private key for the corresponding credential definition.
:param schema_seq_no: schema sequence number
:return: credenti... | [
"Create",
"credential",
"offer",
"as",
"Issuer",
"for",
"given",
"schema",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L277-L307 | [
"async",
"def",
"create_cred_offer",
"(",
"self",
",",
"schema_seq_no",
":",
"int",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer.create_cred_offer >>> schema_seq_no: %s'",
",",
"schema_seq_no",
")",
"rv",
"=",
"None",
"cd_id",
"=",
"cred_def_id",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.create_cred | Create credential as Issuer out of credential request and dict of key:value (raw, unencoded)
entries for attributes.
Return credential json, and if cred def supports revocation, credential revocation identifier
and revocation registry delta ledger timestamp (epoch seconds).
If the cred... | von_agent/agent/issuer.py | async def create_cred(
self,
cred_offer_json,
cred_req_json: str,
cred_attrs: dict,
rr_size: int = None) -> (str, str, int):
"""
Create credential as Issuer out of credential request and dict of key:value (raw, unencoded)
entries for at... | async def create_cred(
self,
cred_offer_json,
cred_req_json: str,
cred_attrs: dict,
rr_size: int = None) -> (str, str, int):
"""
Create credential as Issuer out of credential request and dict of key:value (raw, unencoded)
entries for at... | [
"Create",
"credential",
"as",
"Issuer",
"out",
"of",
"credential",
"request",
"and",
"dict",
"of",
"key",
":",
"value",
"(",
"raw",
"unencoded",
")",
"entries",
"for",
"attributes",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L309-L407 | [
"async",
"def",
"create_cred",
"(",
"self",
",",
"cred_offer_json",
",",
"cred_req_json",
":",
"str",
",",
"cred_attrs",
":",
"dict",
",",
"rr_size",
":",
"int",
"=",
"None",
")",
"->",
"(",
"str",
",",
"str",
",",
"int",
")",
":",
"LOGGER",
".",
"de... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.revoke_cred | Revoke credential that input revocation registry identifier and
credential revocation identifier specify.
Return (epoch seconds) time of revocation.
Raise AbsentTails if no tails file is available for input
revocation registry identifier. Raise BadRevocation if issuer cannot
re... | von_agent/agent/issuer.py | async def revoke_cred(self, rr_id: str, cr_id) -> int:
"""
Revoke credential that input revocation registry identifier and
credential revocation identifier specify.
Return (epoch seconds) time of revocation.
Raise AbsentTails if no tails file is available for input
revo... | async def revoke_cred(self, rr_id: str, cr_id) -> int:
"""
Revoke credential that input revocation registry identifier and
credential revocation identifier specify.
Return (epoch seconds) time of revocation.
Raise AbsentTails if no tails file is available for input
revo... | [
"Revoke",
"credential",
"that",
"input",
"revocation",
"registry",
"identifier",
"and",
"credential",
"revocation",
"identifier",
"specify",
"."
] | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L409-L455 | [
"async",
"def",
"revoke_cred",
"(",
"self",
",",
"rr_id",
":",
"str",
",",
"cr_id",
")",
"->",
"int",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer.revoke_cred >>> rr_id: %s, cr_id: %s'",
",",
"rr_id",
",",
"cr_id",
")",
"tails_reader_handle",
"=",
"(",
"await",
... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | Issuer.get_box_ids_json | Return json object on lists of all unique box identifiers (schema identifiers,
credential definition identifiers, and revocation registry identifiers) for
all credential definitions and credentials issued; e.g.,
::
{
"schema_id": [
"R17v42T4pk...:2:tombstone... | von_agent/agent/issuer.py | async def get_box_ids_json(self) -> str:
"""
Return json object on lists of all unique box identifiers (schema identifiers,
credential definition identifiers, and revocation registry identifiers) for
all credential definitions and credentials issued; e.g.,
::
{
... | async def get_box_ids_json(self) -> str:
"""
Return json object on lists of all unique box identifiers (schema identifiers,
credential definition identifiers, and revocation registry identifiers) for
all credential definitions and credentials issued; e.g.,
::
{
... | [
"Return",
"json",
"object",
"on",
"lists",
"of",
"all",
"unique",
"box",
"identifiers",
"(",
"schema",
"identifiers",
"credential",
"definition",
"identifiers",
"and",
"revocation",
"registry",
"identifiers",
")",
"for",
"all",
"credential",
"definitions",
"and",
... | PSPC-SPAC-buyandsell/von_agent | python | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/issuer.py#L457-L512 | [
"async",
"def",
"get_box_ids_json",
"(",
"self",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'Issuer.get_box_ids_json >>>'",
")",
"cd_ids",
"=",
"[",
"d",
"for",
"d",
"in",
"listdir",
"(",
"self",
".",
"_dir_tails",
")",
"if",
"isdir",
"(",
"joi... | 0b1c17cca3bd178b6e6974af84dbac1dfce5cf45 |
train | quote_xml | Format a value for display as an XML text node.
Returns:
Unicode string (str on Python 3, unicode on Python 2) | mixbox/binding_utils.py | 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):
"""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... | [
"Format",
"a",
"value",
"for",
"display",
"as",
"an",
"XML",
"text",
"node",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/binding_utils.py#L299-L313 | [
"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 ... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | _NamespaceInfo.__construct_from_components | Initialize this instance from a namespace URI, and optional
prefix and schema location URI. | mixbox/namespaces.py | 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):
"""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... | [
"Initialize",
"this",
"instance",
"from",
"a",
"namespace",
"URI",
"and",
"optional",
"prefix",
"and",
"schema",
"location",
"URI",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L145-L157 | [
"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",
"="... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.__add_namespaceinfo | Internal method to directly add a _NamespaceInfo object to this
set. No sanity checks are done (e.g. checking for prefix conflicts),
so be sure to do it yourself before calling this. | mixbox/namespaces.py | def __add_namespaceinfo(self, ni):
"""Internal method to directly add a _NamespaceInfo object to this
set. No sanity checks are done (e.g. checking for prefix conflicts),
so be sure to do it yourself before calling this."""
self.__ns_uri_map[ni.uri] = ni
for prefix in ni.prefixe... | def __add_namespaceinfo(self, ni):
"""Internal method to directly add a _NamespaceInfo object to this
set. No sanity checks are done (e.g. checking for prefix conflicts),
so be sure to do it yourself before calling this."""
self.__ns_uri_map[ni.uri] = ni
for prefix in ni.prefixe... | [
"Internal",
"method",
"to",
"directly",
"add",
"a",
"_NamespaceInfo",
"object",
"to",
"this",
"set",
".",
"No",
"sanity",
"checks",
"are",
"done",
"(",
"e",
".",
"g",
".",
"checking",
"for",
"prefix",
"conflicts",
")",
"so",
"be",
"sure",
"to",
"do",
"... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L218-L224 | [
"def",
"__add_namespaceinfo",
"(",
"self",
",",
"ni",
")",
":",
"self",
".",
"__ns_uri_map",
"[",
"ni",
".",
"uri",
"]",
"=",
"ni",
"for",
"prefix",
"in",
"ni",
".",
"prefixes",
":",
"self",
".",
"__prefix_map",
"[",
"prefix",
"]",
"=",
"ni"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.__check_prefix_conflict | If existing_ni_or_ns_uri is a _NamespaceInfo object (which must
be in this set), then caller wants to map incoming_prefix to that
namespace. This function verifies that the prefix isn't already mapped
to a different namespace URI. If it is, an exception is raised.
Otherwise, existing_... | mixbox/namespaces.py | def __check_prefix_conflict(self, existing_ni_or_ns_uri, incoming_prefix):
"""If existing_ni_or_ns_uri is a _NamespaceInfo object (which must
be in this set), then caller wants to map incoming_prefix to that
namespace. This function verifies that the prefix isn't already mapped
to a dif... | def __check_prefix_conflict(self, existing_ni_or_ns_uri, incoming_prefix):
"""If existing_ni_or_ns_uri is a _NamespaceInfo object (which must
be in this set), then caller wants to map incoming_prefix to that
namespace. This function verifies that the prefix isn't already mapped
to a dif... | [
"If",
"existing_ni_or_ns_uri",
"is",
"a",
"_NamespaceInfo",
"object",
"(",
"which",
"must",
"be",
"in",
"this",
"set",
")",
"then",
"caller",
"wants",
"to",
"map",
"incoming_prefix",
"to",
"that",
"namespace",
".",
"This",
"function",
"verifies",
"that",
"the"... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L226-L253 | [
"def",
"__check_prefix_conflict",
"(",
"self",
",",
"existing_ni_or_ns_uri",
",",
"incoming_prefix",
")",
":",
"if",
"incoming_prefix",
"not",
"in",
"self",
".",
"__prefix_map",
":",
"return",
"# Prefix found in the prefix map. Check that there are no conflicts",
"prefix_chec... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.namespace_for_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. | mixbox/namespaces.py | 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):
"""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.... | [
"Get",
"the",
"namespace",
"the",
"given",
"prefix",
"maps",
"to",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L271-L286 | [
"def",
"namespace_for_prefix",
"(",
"self",
",",
"prefix",
")",
":",
"try",
":",
"ni",
"=",
"self",
".",
"__lookup_prefix",
"(",
"prefix",
")",
"except",
"PrefixNotFoundError",
":",
"return",
"None",
"else",
":",
"return",
"ni",
".",
"uri"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.set_preferred_prefix_for_namespace | 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... | mixbox/namespaces.py | 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):
"""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... | [
"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... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L294-L322 | [
"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",
"=... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.__merge_schema_locations | 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. | mixbox/namespaces.py | 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):
"""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: ... | [
"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"... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L324-L336 | [
"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"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.add_namespace_uri | 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... | mixbox/namespaces.py | 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):
"""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... | [
"Adds",
"a",
"new",
"namespace",
"to",
"this",
"set",
"optionally",
"with",
"a",
"prefix",
"and",
"schema",
"location",
"URI",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L344-L405 | [
"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... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.remove_namespace | Removes the indicated namespace from this set. | mixbox/namespaces.py | 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):
"""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] | [
"Removes",
"the",
"indicated",
"namespace",
"from",
"this",
"set",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L407-L414 | [
"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",
"."... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.add_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... | mixbox/namespaces.py | 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):
"""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... | [
"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",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L416-L441 | [
"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... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.get_prefixes | Gets (a copy of) the prefix set for the given namespace. | mixbox/namespaces.py | def get_prefixes(self, ns_uri):
"""Gets (a copy of) the prefix set for the given namespace."""
ni = self.__lookup_uri(ns_uri)
return ni.prefixes.copy() | def get_prefixes(self, ns_uri):
"""Gets (a copy of) the prefix set for the given namespace."""
ni = self.__lookup_uri(ns_uri)
return ni.prefixes.copy() | [
"Gets",
"(",
"a",
"copy",
"of",
")",
"the",
"prefix",
"set",
"for",
"the",
"given",
"namespace",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L443-L446 | [
"def",
"get_prefixes",
"(",
"self",
",",
"ns_uri",
")",
":",
"ni",
"=",
"self",
".",
"__lookup_uri",
"(",
"ns_uri",
")",
"return",
"ni",
".",
"prefixes",
".",
"copy",
"(",
")"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.prefix_iter | Gets an iterator over the prefixes for the given namespace. | mixbox/namespaces.py | 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):
"""Gets an iterator over the prefixes for the given namespace."""
ni = self.__lookup_uri(ns_uri)
return iter(ni.prefixes) | [
"Gets",
"an",
"iterator",
"over",
"the",
"prefixes",
"for",
"the",
"given",
"namespace",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L448-L451 | [
"def",
"prefix_iter",
"(",
"self",
",",
"ns_uri",
")",
":",
"ni",
"=",
"self",
".",
"__lookup_uri",
"(",
"ns_uri",
")",
"return",
"iter",
"(",
"ni",
".",
"prefixes",
")"
] | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.remove_prefix | Removes prefix from this set. This is a no-op if the prefix
doesn't exist in it. | mixbox/namespaces.py | 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):
"""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... | [
"Removes",
"prefix",
"from",
"this",
"set",
".",
"This",
"is",
"a",
"no",
"-",
"op",
"if",
"the",
"prefix",
"doesn",
"t",
"exist",
"in",
"it",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L453-L466 | [
"def",
"remove_prefix",
"(",
"self",
",",
"prefix",
")",
":",
"if",
"prefix",
"not",
"in",
"self",
".",
"__prefix_map",
":",
"return",
"ni",
"=",
"self",
".",
"__lookup_prefix",
"(",
"prefix",
")",
"ni",
".",
"prefixes",
".",
"discard",
"(",
"prefix",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.set_schema_location | 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... | mixbox/namespaces.py | 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):
"""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... | [
"Sets",
"the",
"schema",
"location",
"of",
"the",
"given",
"namespace",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L483-L512 | [
"def",
"set_schema_location",
"(",
"self",
",",
"ns_uri",
",",
"schema_location",
",",
"replace",
"=",
"False",
")",
":",
"ni",
"=",
"self",
".",
"__lookup_uri",
"(",
"ns_uri",
")",
"if",
"ni",
".",
"schema_location",
"==",
"schema_location",
":",
"return",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.get_xmlns_string | Generates XML namespace declarations for namespaces in this
set. It must be suitable for use in an actual XML document,
so an exception is raised if this can't be done, e.g. if it would
have more than one default namespace declaration.
If ``preferred_prefixes_only`` is ``True`` and a n... | mixbox/namespaces.py | def get_xmlns_string(self, ns_uris=None, sort=False,
preferred_prefixes_only=True, delim="\n"):
"""Generates XML namespace declarations for namespaces in this
set. It must be suitable for use in an actual XML document,
so an exception is raised if this can't be done, e.... | def get_xmlns_string(self, ns_uris=None, sort=False,
preferred_prefixes_only=True, delim="\n"):
"""Generates XML namespace declarations for namespaces in this
set. It must be suitable for use in an actual XML document,
so an exception is raised if this can't be done, e.... | [
"Generates",
"XML",
"namespace",
"declarations",
"for",
"namespaces",
"in",
"this",
"set",
".",
"It",
"must",
"be",
"suitable",
"for",
"use",
"in",
"an",
"actual",
"XML",
"document",
"so",
"an",
"exception",
"is",
"raised",
"if",
"this",
"can",
"t",
"be",
... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L514-L591 | [
"def",
"get_xmlns_string",
"(",
"self",
",",
"ns_uris",
"=",
"None",
",",
"sort",
"=",
"False",
",",
"preferred_prefixes_only",
"=",
"True",
",",
"delim",
"=",
"\"\\n\"",
")",
":",
"if",
"ns_uris",
"is",
"None",
":",
"ns_uris",
"=",
"self",
".",
"namespa... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.get_schemaloc_string | 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.
... | mixbox/namespaces.py | 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"):
"""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... | [
"Constructs",
"and",
"returns",
"a",
"schemalocation",
"attribute",
".",
"If",
"no",
"namespaces",
"in",
"this",
"set",
"have",
"any",
"schema",
"locations",
"defined",
"returns",
"an",
"empty",
"string",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L593-L627 | [
"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"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.get_uri_prefix_map | 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... | mixbox/namespaces.py | 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):
"""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
... | [
"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",... | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L629-L650 | [
"def",
"get_uri_prefix_map",
"(",
"self",
")",
":",
"mapping",
"=",
"{",
"}",
"for",
"ni",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"__ns_uri_map",
")",
":",
"if",
"ni",
".",
"preferred_prefix",
":",
"mapping",
"[",
"ni",
".",
"uri",
"]",
"=... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.get_uri_schemaloc_map | Constructs and returns a map from namespace URI to schema location
URI. Namespaces without schema locations are excluded. | mixbox/namespaces.py | 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):
"""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] ... | [
"Constructs",
"and",
"returns",
"a",
"map",
"from",
"namespace",
"URI",
"to",
"schema",
"location",
"URI",
".",
"Namespaces",
"without",
"schema",
"locations",
"are",
"excluded",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L673-L682 | [
"def",
"get_uri_schemaloc_map",
"(",
"self",
")",
":",
"mapping",
"=",
"{",
"}",
"for",
"ni",
"in",
"six",
".",
"itervalues",
"(",
"self",
".",
"__ns_uri_map",
")",
":",
"if",
"ni",
".",
"schema_location",
":",
"mapping",
"[",
"ni",
".",
"uri",
"]",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.subset | 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... | mixbox/namespaces.py | 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):
"""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... | [
"Return",
"a",
"subset",
"of",
"this",
"NamespaceSet",
"containing",
"only",
"data",
"for",
"the",
"given",
"namespaces",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L690-L717 | [
"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",
")"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.import_from | 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... | mixbox/namespaces.py | 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):
"""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... | [
"Imports",
"namespaces",
"into",
"this",
"set",
"from",
"other_ns",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L719-L756 | [
"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... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | NamespaceSet.assert_valid | For debugging; does some sanity checks on this set. Raises
InvalidNamespaceSetError if this namespace set is invalid. Otherwise,
raises/returns nothing. | mixbox/namespaces.py | def assert_valid(self):
"""For debugging; does some sanity checks on this set. Raises
InvalidNamespaceSetError if this namespace set is invalid. Otherwise,
raises/returns nothing."""
for ns_uri, ni in six.iteritems(self.__ns_uri_map):
if not ni.uri:
raise I... | def assert_valid(self):
"""For debugging; does some sanity checks on this set. Raises
InvalidNamespaceSetError if this namespace set is invalid. Otherwise,
raises/returns nothing."""
for ns_uri, ni in six.iteritems(self.__ns_uri_map):
if not ni.uri:
raise I... | [
"For",
"debugging",
";",
"does",
"some",
"sanity",
"checks",
"on",
"this",
"set",
".",
"Raises",
"InvalidNamespaceSetError",
"if",
"this",
"namespace",
"set",
"is",
"invalid",
".",
"Otherwise",
"raises",
"/",
"returns",
"nothing",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/namespaces.py#L758-L809 | [
"def",
"assert_valid",
"(",
"self",
")",
":",
"for",
"ns_uri",
",",
"ni",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"__ns_uri_map",
")",
":",
"if",
"not",
"ni",
".",
"uri",
":",
"raise",
"InvalidNamespaceSetError",
"(",
"\"URI not set in _NamespaceInf... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityParser._get_version | Return the version of the root element passed in.
Args:
root (etree.Element)
Returns:
distutils.StrictVersion
Raises:
UnknownVersionError | mixbox/parser.py | 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):
"""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... | [
"Return",
"the",
"version",
"of",
"the",
"root",
"element",
"passed",
"in",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L55-L77 | [
"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... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityParser._check_version | Ensure the root element is a supported version.
Args:
root (etree.Element)
Raises:
UnsupportedVersionError | mixbox/parser.py | 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):
"""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... | [
"Ensure",
"the",
"root",
"element",
"is",
"a",
"supported",
"version",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L79-L100 | [
"def",
"_check_version",
"(",
"self",
",",
"root",
")",
":",
"version",
"=",
"self",
".",
"_get_version",
"(",
"root",
")",
"supported",
"=",
"[",
"StrictVersion",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"supported_versions",
"(",
"root",
".",
"t... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityParser._check_root_tag | Check that the XML element tree has a supported root element.
Args:
root (etree.Element)
Raises:
UnsupportedRootElementError | mixbox/parser.py | 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):
"""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
... | [
"Check",
"that",
"the",
"XML",
"element",
"tree",
"has",
"a",
"supported",
"root",
"element",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L102-L120 | [
"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... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityParser.parse_xml_to_obj | 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.
... | mixbox/parser.py | 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):
"""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
... | [
"Creates",
"a",
"STIX",
"binding",
"object",
"from",
"the",
"supplied",
"xml",
"file",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L122-L154 | [
"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",... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | EntityParser.parse_xml | 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... | mixbox/parser.py | 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):
"""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
... | [
"Creates",
"a",
"python",
"-",
"stix",
"STIXPackage",
"object",
"from",
"the",
"supplied",
"xml_file",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/parser.py#L156-L195 | [
"def",
"parse_xml",
"(",
"self",
",",
"xml_file",
",",
"check_version",
"=",
"True",
",",
"check_root",
"=",
"True",
",",
"encoding",
"=",
"None",
")",
":",
"xml_etree",
"=",
"get_etree",
"(",
"xml_file",
",",
"encoding",
"=",
"encoding",
")",
"entity_obj"... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | _TreeCollectionsAPIWrapper.get | Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.get('pg_10', 'trees', format='nexus')
w.get('pg_10', t... | peyotl/api/collections_api.py | def get(self, collection_id, content=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.g... | def get(self, collection_id, content=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.g... | [
"Syntactic",
"sugar",
"around",
"to",
"make",
"it",
"easier",
"to",
"get",
"fine",
"-",
"grained",
"access",
"to",
"the",
"parts",
"of",
"a",
"file",
"without",
"composing",
"a",
"PhyloSchema",
"object",
".",
"Possible",
"invocations",
"include",
":",
"w",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/collections_api.py#L107-L121 | [
"def",
"get",
"(",
"self",
",",
"collection_id",
",",
"content",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"COLLECTION_ID_PATTERN",
".",
"match",
"(",
"collection_id",
")",
"r",
"=",
"self",
".",
"get_collection",
"(",
"collection_id",
")",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | patents | HTTP REQUEST
GET https://api.nasa.gov/patents
QUERY PARAMETERS
Parameter Type Default Description
query string None Search text to filter results
concept_tags bool False Return an ordered dictionary of concepts from the patent abstract
limit int all number of patents to return
api_key str... | bowshock/patents.py | def patents(query=None, concept_tags=None, limit=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/patents
QUERY PARAMETERS
Parameter Type Default Description
query string None Search text to filter results
concept_tags bool False Return an ordered dictionary of concepts from the patent ab... | def patents(query=None, concept_tags=None, limit=None):
'''
HTTP REQUEST
GET https://api.nasa.gov/patents
QUERY PARAMETERS
Parameter Type Default Description
query string None Search text to filter results
concept_tags bool False Return an ordered dictionary of concepts from the patent ab... | [
"HTTP",
"REQUEST"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/patents.py#L10-L52 | [
"def",
"patents",
"(",
"query",
"=",
"None",
",",
"concept_tags",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"base_url",
"=",
"\"https://api.nasa.gov/patents/content?\"",
"if",
"not",
"query",
":",
"raise",
"ValueError",
"(",
"\"search query is missing, whi... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | default_links_item_factory | Factory for record links generation. | invenio_communities/links.py | def default_links_item_factory(community):
"""Factory for record links generation."""
return dict(
self=url_for(
'.communities_item', community_id=community['id'], _external=True),
html=current_app.config.get(
'COMMUNITIES_URL_COMMUNITY_VIEW',
'{protocol}://{h... | def default_links_item_factory(community):
"""Factory for record links generation."""
return dict(
self=url_for(
'.communities_item', community_id=community['id'], _external=True),
html=current_app.config.get(
'COMMUNITIES_URL_COMMUNITY_VIEW',
'{protocol}://{h... | [
"Factory",
"for",
"record",
"links",
"generation",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/links.py#L32-L45 | [
"def",
"default_links_item_factory",
"(",
"community",
")",
":",
"return",
"dict",
"(",
"self",
"=",
"url_for",
"(",
"'.communities_item'",
",",
"community_id",
"=",
"community",
"[",
"'id'",
"]",
",",
"_external",
"=",
"True",
")",
",",
"html",
"=",
"curren... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | default_links_pagination_factory | Factory for record links generation. | invenio_communities/links.py | def default_links_pagination_factory(page, urlkwargs):
"""Factory for record links generation."""
endpoint = '.communities_list'
links = {
'self': url_for(endpoint, page=page.page, _external=True, **urlkwargs),
}
if page.has_prev:
links['prev'] = url_for(endpoint, page=page.prev_nu... | def default_links_pagination_factory(page, urlkwargs):
"""Factory for record links generation."""
endpoint = '.communities_list'
links = {
'self': url_for(endpoint, page=page.page, _external=True, **urlkwargs),
}
if page.has_prev:
links['prev'] = url_for(endpoint, page=page.prev_nu... | [
"Factory",
"for",
"record",
"links",
"generation",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/links.py#L48-L63 | [
"def",
"default_links_pagination_factory",
"(",
"page",
",",
"urlkwargs",
")",
":",
"endpoint",
"=",
"'.communities_list'",
"links",
"=",
"{",
"'self'",
":",
"url_for",
"(",
"endpoint",
",",
"page",
"=",
"page",
".",
"page",
",",
"_external",
"=",
"True",
",... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | Badgerfish2DirectNexson.convert | Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and
converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place
and returned. | peyotl/nexson_syntax/badgerfish2direct_nexson.py | def convert(self, obj):
"""Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and
converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place
and returned.
"""
if self.pristine_if_invalid:
raise NotImplementedError('pristi... | def convert(self, obj):
"""Takes a dict corresponding to the honeybadgerfish JSON blob of the 1.0.* type and
converts it to BY_ID_HONEY_BADGERFISH version. The object is modified in place
and returned.
"""
if self.pristine_if_invalid:
raise NotImplementedError('pristi... | [
"Takes",
"a",
"dict",
"corresponding",
"to",
"the",
"honeybadgerfish",
"JSON",
"blob",
"of",
"the",
"1",
".",
"0",
".",
"*",
"type",
"and",
"converts",
"it",
"to",
"BY_ID_HONEY_BADGERFISH",
"version",
".",
"The",
"object",
"is",
"modified",
"in",
"place",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/nexson_syntax/badgerfish2direct_nexson.py#L116-L140 | [
"def",
"convert",
"(",
"self",
",",
"obj",
")",
":",
"if",
"self",
".",
"pristine_if_invalid",
":",
"raise",
"NotImplementedError",
"(",
"'pristine_if_invalid option is not supported yet'",
")",
"nex",
"=",
"get_nexml_el",
"(",
"obj",
")",
"assert",
"nex",
"self",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | CommunitySchemaV1.get_logo_url | Get the community logo URL. | invenio_communities/serializers/schemas/community.py | 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):
"""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,
) | [
"Get",
"the",
"community",
"logo",
"URL",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L50-L56 | [
"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'",
")",
... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | CommunitySchemaV1.item_links_addition | Add the links for each community. | invenio_communities/serializers/schemas/community.py | 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):
"""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 | [
"Add",
"the",
"links",
"for",
"each",
"community",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L59-L64 | [
"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... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | CommunitySchemaV1.envelope | Wrap result in envelope. | invenio_communities/serializers/schemas/community.py | 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):
"""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')
... | [
"Wrap",
"result",
"in",
"envelope",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/serializers/schemas/community.py#L67-L90 | [
"def",
"envelope",
"(",
"self",
",",
"data",
",",
"many",
")",
":",
"if",
"not",
"many",
":",
"return",
"data",
"result",
"=",
"dict",
"(",
"hits",
"=",
"dict",
"(",
"hits",
"=",
"data",
",",
"total",
"=",
"self",
".",
"context",
".",
"get",
"(",... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | parse_datetime | 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. | mixbox/dates.py | 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):
"""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... | [
"Attempts",
"to",
"parse",
"value",
"into",
"an",
"instance",
"of",
"datetime",
".",
"datetime",
".",
"If",
"value",
"is",
"None",
"this",
"function",
"will",
"return",
"None",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/dates.py#L13-L25 | [
"def",
"parse_datetime",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"value",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"valu... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | parse_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. | mixbox/dates.py | 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):
"""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... | [
"Attempts",
"to",
"parse",
"value",
"into",
"an",
"instance",
"of",
"datetime",
".",
"date",
".",
"If",
"value",
"is",
"None",
"this",
"function",
"will",
"return",
"None",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/dates.py#L44-L59 | [
"def",
"parse_date",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"date",
")",
":",
"return",
"value",
"return",
"parse_datetime",
"(",
"value",
")",
".",
"date",
"(",
")"
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | serialize_date | Attempts to convert `value` into an ``xs:date`` string. If `value` is
``None``, ``None`` will be returned.
Args:
value: A date value. This can be a string, datetime.date, or
datetime.datetime object.
Returns:
An ``xs:date`` formatted timestamp string. | mixbox/dates.py | def serialize_date(value):
"""Attempts to convert `value` into an ``xs:date`` string. If `value` is
``None``, ``None`` will be returned.
Args:
value: A date value. This can be a string, datetime.date, or
datetime.datetime object.
Returns:
An ``xs:date`` formatted timestamp ... | def serialize_date(value):
"""Attempts to convert `value` into an ``xs:date`` string. If `value` is
``None``, ``None`` will be returned.
Args:
value: A date value. This can be a string, datetime.date, or
datetime.datetime object.
Returns:
An ``xs:date`` formatted timestamp ... | [
"Attempts",
"to",
"convert",
"value",
"into",
"an",
"xs",
":",
"date",
"string",
".",
"If",
"value",
"is",
"None",
"None",
"will",
"be",
"returned",
"."
] | CybOXProject/mixbox | python | https://github.com/CybOXProject/mixbox/blob/9097dae7a433f5b98c18171c4a5598f69a7d30af/mixbox/dates.py#L62-L81 | [
"def",
"serialize_date",
"(",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"value",
".",
"date",
"(",
")",
".",
"isoformat",
"(",
")",
"elif",
... | 9097dae7a433f5b98c18171c4a5598f69a7d30af |
train | correct_word | Finds all valid one and two letter corrections for word_string, returning the word
with the highest relative probability as type str. | preprocessing/spellcheck.py | 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):
'''
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... | [
"Finds",
"all",
"valid",
"one",
"and",
"two",
"letter",
"corrections",
"for",
"word_string",
"returning",
"the",
"word",
"with",
"the",
"highest",
"relative",
"probability",
"as",
"type",
"str",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L18-L28 | [
"def",
"correct_word",
"(",
"word_string",
")",
":",
"if",
"word_string",
"is",
"None",
":",
"return",
"\"\"",
"elif",
"isinstance",
"(",
"word_string",
",",
"str",
")",
":",
"return",
"max",
"(",
"find_candidates",
"(",
"word_string",
")",
",",
"key",
"="... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | find_candidates | 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,... | preprocessing/spellcheck.py | 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):
'''
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... | [
"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... | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L30-L45 | [
"def",
"find_candidates",
"(",
"word_string",
")",
":",
"if",
"word_string",
"is",
"None",
":",
"return",
"{",
"}",
"elif",
"isinstance",
"(",
"word_string",
",",
"str",
")",
":",
"return",
"(",
"validate_words",
"(",
"[",
"word_string",
"]",
")",
"or",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | find_one_letter_edits | Finds all possible one letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical letter
- Inserting all possible alphabetical char... | preprocessing/spellcheck.py | def find_one_letter_edits(word_string):
'''
Finds all possible one letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical l... | def find_one_letter_edits(word_string):
'''
Finds all possible one letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical l... | [
"Finds",
"all",
"possible",
"one",
"letter",
"edits",
"of",
"word_string",
":",
"-",
"Splitting",
"word_string",
"into",
"two",
"words",
"at",
"all",
"character",
"locations",
"-",
"Deleting",
"one",
"letter",
"at",
"all",
"character",
"locations",
"-",
"Switc... | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L47-L68 | [
"def",
"find_one_letter_edits",
"(",
"word_string",
")",
":",
"if",
"word_string",
"is",
"None",
":",
"return",
"{",
"}",
"elif",
"isinstance",
"(",
"word_string",
",",
"str",
")",
":",
"splits",
"=",
"[",
"(",
"word_string",
"[",
":",
"i",
"]",
",",
"... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | find_two_letter_edits | Finds all possible two letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical letter
- Inserting all possible alphabetical char... | preprocessing/spellcheck.py | def find_two_letter_edits(word_string):
'''
Finds all possible two letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical l... | def find_two_letter_edits(word_string):
'''
Finds all possible two letter edits of word_string:
- Splitting word_string into two words at all character locations
- Deleting one letter at all character locations
- Switching neighbouring characters
- Replacing a character with every alphabetical l... | [
"Finds",
"all",
"possible",
"two",
"letter",
"edits",
"of",
"word_string",
":",
"-",
"Splitting",
"word_string",
"into",
"two",
"words",
"at",
"all",
"character",
"locations",
"-",
"Deleting",
"one",
"letter",
"at",
"all",
"character",
"locations",
"-",
"Switc... | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L70-L89 | [
"def",
"find_two_letter_edits",
"(",
"word_string",
")",
":",
"if",
"word_string",
"is",
"None",
":",
"return",
"{",
"}",
"elif",
"isinstance",
"(",
"word_string",
",",
"str",
")",
":",
"return",
"(",
"e2",
"for",
"e1",
"in",
"find_one_letter_edits",
"(",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | find_word_prob | Finds the relative probability of the word appearing given context of a base corpus.
Returns this probability value as a float instance. | preprocessing/spellcheck.py | 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())):
'''
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)... | [
"Finds",
"the",
"relative",
"probability",
"of",
"the",
"word",
"appearing",
"given",
"context",
"of",
"a",
"base",
"corpus",
".",
"Returns",
"this",
"probability",
"value",
"as",
"a",
"float",
"instance",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L91-L101 | [
"def",
"find_word_prob",
"(",
"word_string",
",",
"word_total",
"=",
"sum",
"(",
"WORD_DISTRIBUTION",
".",
"values",
"(",
")",
")",
")",
":",
"if",
"word_string",
"is",
"None",
":",
"return",
"0",
"elif",
"isinstance",
"(",
"word_string",
",",
"str",
")",
... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | validate_words | 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. | preprocessing/spellcheck.py | 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):
'''
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 {}
... | [
"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",
"."
] | SpotlightData/preprocessing | python | https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/spellcheck.py#L103-L116 | [
"def",
"validate_words",
"(",
"word_list",
")",
":",
"if",
"word_list",
"is",
"None",
":",
"return",
"{",
"}",
"elif",
"isinstance",
"(",
"word_list",
",",
"list",
")",
":",
"if",
"not",
"word_list",
":",
"return",
"{",
"}",
"else",
":",
"return",
"set... | 180c6472bc2642afbd7a1ece08d0b0d14968a708 |
train | search_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 | bowshock/star.py | 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):
'''
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... | [
"It",
"is",
"also",
"possible",
"to",
"query",
"the",
"stars",
"by",
"label",
"here",
"is",
"an",
"example",
"of",
"querying",
"for",
"the",
"star",
"labeled",
"as",
"Sun",
"."
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L16-L30 | [
"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"... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | search_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 | bowshock/star.py | 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):
'''
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... | [
"It",
"is",
"also",
"possible",
"to",
"query",
"the",
"exoplanets",
"by",
"label",
"here",
"is",
"an",
"example",
"of",
"querying",
"for",
"the",
"exoplanet",
"labeled",
"as",
"11",
"Com"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L43-L58 | [
"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 ... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | search_local_galaxies | 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 | bowshock/star.py | 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):
'''
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... | [
"It",
"is",
"also",
"possible",
"to",
"query",
"the",
"local",
"galaxies",
"by",
"label",
"here",
"is",
"an",
"example",
"of",
"querying",
"for",
"the",
"local",
"galaxy",
"labeled",
"IC",
"10"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L71-L85 | [
"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 ... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | search_star_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 | bowshock/star.py | 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):
'''
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/"
... | [
"It",
"is",
"also",
"possible",
"to",
"query",
"the",
"star",
"clusters",
"by",
"label",
"here",
"is",
"an",
"example",
"of",
"querying",
"for",
"the",
"star",
"cluster",
"labeled",
"Berkeley",
"59"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/star.py#L98-L112 | [
"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... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | _TaxonomicAmendmentsAPIWrapper.get | Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.get('pg_10', 'trees', format='nexus')
w.get('pg_10', t... | peyotl/api/amendments_api.py | def get(self, amendment_id, content=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.ge... | def get(self, amendment_id, content=None, **kwargs):
"""Syntactic sugar around to make it easier to get fine-grained access
to the parts of a file without composing a PhyloSchema object.
Possible invocations include:
w.get('pg_10')
w.get('pg_10', 'trees')
w.ge... | [
"Syntactic",
"sugar",
"around",
"to",
"make",
"it",
"easier",
"to",
"get",
"fine",
"-",
"grained",
"access",
"to",
"the",
"parts",
"of",
"a",
"file",
"without",
"composing",
"a",
"PhyloSchema",
"object",
".",
"Possible",
"invocations",
"include",
":",
"w",
... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/api/amendments_api.py#L107-L121 | [
"def",
"get",
"(",
"self",
",",
"amendment_id",
",",
"content",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"AMENDMENT_ID_PATTERN",
".",
"match",
"(",
"amendment_id",
")",
"r",
"=",
"self",
".",
"get_amendment",
"(",
"amendment_id",
")",
"i... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | JSGLexerRuleBlock.as_python | Return the python representation | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | 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:
""" 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:
... | [
"Return",
"the",
"python",
"representation"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L59-L67 | [
"def",
"as_python",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"str",
":",
"if",
"self",
".",
"_ruleTokens",
":",
"pattern",
"=",
"\"jsg.JSGPattern(r'{}'.format({}))\"",
".",
"format",
"(",
"self",
".",
"_rulePattern",
",",
"', '",
".",
"join",
"(",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGLexerRuleBlock.visitLexerAltList | lexerAltList: lexerAlt (LBAR lexerAlt)* | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | def visitLexerAltList(self, ctx: jsgParser.LexerAltListContext):
""" lexerAltList: lexerAlt (LBAR lexerAlt)* """
altlist = ctx.lexerAlt()
self.visit(altlist[0])
for alt in altlist[1:]:
self._rulePattern += '|'
self.visit(alt) | def visitLexerAltList(self, ctx: jsgParser.LexerAltListContext):
""" lexerAltList: lexerAlt (LBAR lexerAlt)* """
altlist = ctx.lexerAlt()
self.visit(altlist[0])
for alt in altlist[1:]:
self._rulePattern += '|'
self.visit(alt) | [
"lexerAltList",
":",
"lexerAlt",
"(",
"LBAR",
"lexerAlt",
")",
"*"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L75-L81 | [
"def",
"visitLexerAltList",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerAltListContext",
")",
":",
"altlist",
"=",
"ctx",
".",
"lexerAlt",
"(",
")",
"self",
".",
"visit",
"(",
"altlist",
"[",
"0",
"]",
")",
"for",
"alt",
"in",
"altlist",
"[",... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGLexerRuleBlock.visitLexerElement | lexerElement: lexerAtom ebnfSuffix? | lexerBlock ebnfSuffix? | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | def visitLexerElement(self, ctx: jsgParser.LexerElementContext):
""" lexerElement: lexerAtom ebnfSuffix? | lexerBlock ebnfSuffix? """
self.visitChildren(ctx)
if ctx.ebnfSuffix():
self._rulePattern += ctx.ebnfSuffix().getText() | def visitLexerElement(self, ctx: jsgParser.LexerElementContext):
""" lexerElement: lexerAtom ebnfSuffix? | lexerBlock ebnfSuffix? """
self.visitChildren(ctx)
if ctx.ebnfSuffix():
self._rulePattern += ctx.ebnfSuffix().getText() | [
"lexerElement",
":",
"lexerAtom",
"ebnfSuffix?",
"|",
"lexerBlock",
"ebnfSuffix?"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L83-L87 | [
"def",
"visitLexerElement",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerElementContext",
")",
":",
"self",
".",
"visitChildren",
"(",
"ctx",
")",
"if",
"ctx",
".",
"ebnfSuffix",
"(",
")",
":",
"self",
".",
"_rulePattern",
"+=",
"ctx",
".",
"ebn... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGLexerRuleBlock.visitLexerBlock | lexerBlock: OPREN lexeraltList CPREN | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | def visitLexerBlock(self, ctx: jsgParser.LexerBlockContext):
""" lexerBlock: OPREN lexeraltList CPREN """
self._rulePattern += '('
self.visitChildren(ctx)
self._rulePattern += ')' | def visitLexerBlock(self, ctx: jsgParser.LexerBlockContext):
""" lexerBlock: OPREN lexeraltList CPREN """
self._rulePattern += '('
self.visitChildren(ctx)
self._rulePattern += ')' | [
"lexerBlock",
":",
"OPREN",
"lexeraltList",
"CPREN"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L89-L93 | [
"def",
"visitLexerBlock",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerBlockContext",
")",
":",
"self",
".",
"_rulePattern",
"+=",
"'('",
"self",
".",
"visitChildren",
"(",
"ctx",
")",
"self",
".",
"_rulePattern",
"+=",
"')'"
] | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGLexerRuleBlock.visitLexerAtom | lexerAtom : lexerTerminal | LEXER_CHAR_SET | ANY | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | def visitLexerAtom(self, ctx: jsgParser.LexerAtomContext):
""" lexerAtom : lexerTerminal | LEXER_CHAR_SET | ANY """
if ctx.LEXER_CHAR_SET() or ctx.ANY():
self._rulePattern += str(ctx.getText())
else:
self.visitChildren(ctx) | def visitLexerAtom(self, ctx: jsgParser.LexerAtomContext):
""" lexerAtom : lexerTerminal | LEXER_CHAR_SET | ANY """
if ctx.LEXER_CHAR_SET() or ctx.ANY():
self._rulePattern += str(ctx.getText())
else:
self.visitChildren(ctx) | [
"lexerAtom",
":",
"lexerTerminal",
"|",
"LEXER_CHAR_SET",
"|",
"ANY"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L95-L100 | [
"def",
"visitLexerAtom",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerAtomContext",
")",
":",
"if",
"ctx",
".",
"LEXER_CHAR_SET",
"(",
")",
"or",
"ctx",
".",
"ANY",
"(",
")",
":",
"self",
".",
"_rulePattern",
"+=",
"str",
"(",
"ctx",
".",
"g... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | JSGLexerRuleBlock.visitLexerTerminal | terminal: LEXER_ID | STRING | pyjsg/parser_impl/jsg_lexerruleblock_parser.py | def visitLexerTerminal(self, ctx: jsgParser.LexerTerminalContext):
""" terminal: LEXER_ID | STRING """
if ctx.LEXER_ID():
# Substitute LEXER_ID with its string equivalent - "{LEXER_ID}".format(LEXER_ID=LEXER_ID.pattern)
idtoken = as_token(ctx)
self._rulePattern += '(... | def visitLexerTerminal(self, ctx: jsgParser.LexerTerminalContext):
""" terminal: LEXER_ID | STRING """
if ctx.LEXER_ID():
# Substitute LEXER_ID with its string equivalent - "{LEXER_ID}".format(LEXER_ID=LEXER_ID.pattern)
idtoken = as_token(ctx)
self._rulePattern += '(... | [
"terminal",
":",
"LEXER_ID",
"|",
"STRING"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/parser_impl/jsg_lexerruleblock_parser.py#L102-L110 | [
"def",
"visitLexerTerminal",
"(",
"self",
",",
"ctx",
":",
"jsgParser",
".",
"LexerTerminalContext",
")",
":",
"if",
"ctx",
".",
"LEXER_ID",
"(",
")",
":",
"# Substitute LEXER_ID with its string equivalent - \"{LEXER_ID}\".format(LEXER_ID=LEXER_ID.pattern)",
"idtoken",
"=",... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | slugify | Convert any string to a "slug", a simplified form suitable for filename and URL part.
EXAMPLE: "Trees about bees" => 'trees-about-bees'
EXAMPLE: "My favorites!" => 'my-favorites'
N.B. that its behavior should match this client-side slugify function, so
we can accurately "preview" slugs in the browser:... | peyotl/utility/str_util.py | def slugify(s):
"""Convert any string to a "slug", a simplified form suitable for filename and URL part.
EXAMPLE: "Trees about bees" => 'trees-about-bees'
EXAMPLE: "My favorites!" => 'my-favorites'
N.B. that its behavior should match this client-side slugify function, so
we can accurately "preview... | def slugify(s):
"""Convert any string to a "slug", a simplified form suitable for filename and URL part.
EXAMPLE: "Trees about bees" => 'trees-about-bees'
EXAMPLE: "My favorites!" => 'my-favorites'
N.B. that its behavior should match this client-side slugify function, so
we can accurately "preview... | [
"Convert",
"any",
"string",
"to",
"a",
"slug",
"a",
"simplified",
"form",
"suitable",
"for",
"filename",
"and",
"URL",
"part",
".",
"EXAMPLE",
":",
"Trees",
"about",
"bees",
"=",
">",
"trees",
"-",
"about",
"-",
"bees",
"EXAMPLE",
":",
"My",
"favorites!"... | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/str_util.py#L64-L79 | [
"def",
"slugify",
"(",
"s",
")",
":",
"slug",
"=",
"s",
".",
"lower",
"(",
")",
"# force to lower case",
"slug",
"=",
"re",
".",
"sub",
"(",
"'[^a-z0-9 -]'",
",",
"''",
",",
"slug",
")",
"# remove invalid chars",
"slug",
"=",
"re",
".",
"sub",
"(",
"... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | increment_slug | 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
... | peyotl/utility/str_util.py | 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):
"""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 =... | [
"Generate",
"next",
"slug",
"for",
"a",
"series",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/str_util.py#L82-L101 | [
"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",
"[",
"-",
... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | underscored2camel_case | converts ott_id to ottId. | peyotl/utility/str_util.py | 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):
"""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) | [
"converts",
"ott_id",
"to",
"ottId",
"."
] | OpenTreeOfLife/peyotl | python | https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/peyotl/utility/str_util.py#L104-L114 | [
"def",
"underscored2camel_case",
"(",
"v",
")",
":",
"vlist",
"=",
"v",
".",
"split",
"(",
"'_'",
")",
"c",
"=",
"[",
"]",
"for",
"n",
",",
"el",
"in",
"enumerate",
"(",
"vlist",
")",
":",
"if",
"el",
":",
"if",
"n",
"==",
"0",
":",
"c",
".",... | 5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0 |
train | JSGContext.unvalidated_parm | Return true if the pair name should be ignored
:param parm: string part of pair string:value
:return: True if it should be accepted | pyjsg/jsglib/jsg_context.py | 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 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... | [
"Return",
"true",
"if",
"the",
"pair",
"name",
"should",
"be",
"ignored"
] | hsolbrig/pyjsg | python | https://github.com/hsolbrig/pyjsg/blob/9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7/pyjsg/jsglib/jsg_context.py#L24-L31 | [
"def",
"unvalidated_parm",
"(",
"self",
",",
"parm",
":",
"str",
")",
"->",
"bool",
":",
"return",
"parm",
".",
"startswith",
"(",
"\"_\"",
")",
"or",
"parm",
"==",
"self",
".",
"TYPE",
"or",
"parm",
"in",
"self",
".",
"IGNORE",
"or",
"(",
"self",
... | 9b2b8fa8e3b8448abe70b09f804a79f0f31b32b7 |
train | Registry.dispatch | 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 | typedjsonrpc/registry.py | 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):
"""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",
"."
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L95-L118 | [
"def",
"dispatch",
"(",
"self",
",",
"request",
")",
":",
"def",
"_wrapped",
"(",
")",
":",
"messages",
"=",
"self",
".",
"_get_request_messages",
"(",
"request",
")",
"results",
"=",
"[",
"self",
".",
"_dispatch_and_handle_errors",
"(",
"message",
")",
"f... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | Registry.register | 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:... | typedjsonrpc/registry.py | 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):
"""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... | [
"Registers",
"a",
"method",
"with",
"a",
"given",
"name",
"and",
"signature",
"."
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L218-L232 | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"method",
",",
"method_signature",
"=",
"None",
")",
":",
"if",
"inspect",
".",
"ismethod",
"(",
"method",
")",
":",
"raise",
"Exception",
"(",
"\"typedjsonrpc does not support making class methods into endpoints\"",... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | Registry.method | 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... | typedjsonrpc/registry.py | 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):
"""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... | [
"Syntactic",
"sugar",
"for",
"registering",
"a",
"method"
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L234-L291 | [
"def",
"method",
"(",
"self",
",",
"returns",
",",
"*",
"*",
"parameter_types",
")",
":",
"@",
"wrapt",
".",
"decorator",
"def",
"type_check_wrapper",
"(",
"method",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"\"\"\"Wraps a method so that it is typ... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | Registry._collect_parameters | 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... | typedjsonrpc/registry.py | 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):
"""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
... | [
"Creates",
"a",
"dictionary",
"mapping",
"parameters",
"names",
"to",
"their",
"values",
"in",
"the",
"method",
"call",
"."
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L294-L317 | [
"def",
"_collect_parameters",
"(",
"parameter_names",
",",
"args",
",",
"kwargs",
",",
"defaults",
")",
":",
"parameters",
"=",
"{",
"}",
"if",
"defaults",
"is",
"not",
"None",
":",
"zipped_defaults",
"=",
"zip",
"(",
"reversed",
"(",
"parameter_names",
")",... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | Registry._get_request_messages | 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] | typedjsonrpc/registry.py | 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):
"""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_... | [
"Parses",
"the",
"request",
"as",
"a",
"json",
"message",
"."
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L332-L348 | [
"def",
"_get_request_messages",
"(",
"self",
",",
"request",
")",
":",
"data",
"=",
"request",
".",
"get_data",
"(",
"as_text",
"=",
"True",
")",
"try",
":",
"msg",
"=",
"self",
".",
"json_decoder",
".",
"decode",
"(",
"data",
")",
"except",
"Exception",... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | Registry._check_request | Checks that the request json is well-formed.
:param msg: The request's json data
:type msg: dict[str, object] | typedjsonrpc/registry.py | 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):
"""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"... | [
"Checks",
"that",
"the",
"request",
"json",
"is",
"well",
"-",
"formed",
"."
] | palantir/typedjsonrpc | python | https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/registry.py#L350-L372 | [
"def",
"_check_request",
"(",
"self",
",",
"msg",
")",
":",
"if",
"\"jsonrpc\"",
"not",
"in",
"msg",
":",
"raise",
"InvalidRequestError",
"(",
"\"'\\\"jsonrpc\\\": \\\"2.0\\\"' must be included.\"",
")",
"if",
"msg",
"[",
"\"jsonrpc\"",
"]",
"!=",
"\"2.0\"",
":",
... | 274218fcd236ff9643506caa629029c9ba25a0fb |
train | maas_archive | This returns a collection of JSON objects for every weather report available for October 2012:
{
"count": 29,
"next": "http://marsweather.ingenology.com/v1/archive/?terrestrial_date_end=2012-10-31&terrestrial_date_start=2012-10-01&page=2",
"previous": null,
"results": [
...
]
} | bowshock/maas.py | def maas_archive(begin, end):
'''
This returns a collection of JSON objects for every weather report available for October 2012:
{
"count": 29,
"next": "http://marsweather.ingenology.com/v1/archive/?terrestrial_date_end=2012-10-31&terrestrial_date_start=2012-10-01&page=2",
"previous": null,
... | def maas_archive(begin, end):
'''
This returns a collection of JSON objects for every weather report available for October 2012:
{
"count": 29,
"next": "http://marsweather.ingenology.com/v1/archive/?terrestrial_date_end=2012-10-31&terrestrial_date_start=2012-10-01&page=2",
"previous": null,
... | [
"This",
"returns",
"a",
"collection",
"of",
"JSON",
"objects",
"for",
"every",
"weather",
"report",
"available",
"for",
"October",
"2012",
":"
] | emirozer/bowshock | python | https://github.com/emirozer/bowshock/blob/9f5e053f1d54995b833b83616f37c67178c3e840/bowshock/maas.py#L45-L67 | [
"def",
"maas_archive",
"(",
"begin",
",",
"end",
")",
":",
"base_url",
"=",
"'http://marsweather.ingenology.com/v1/archive/?'",
"try",
":",
"vali_date",
"(",
"begin",
")",
"vali_date",
"(",
"end",
")",
"base_url",
"+=",
"'terrestrial_date_start='",
"+",
"begin",
"... | 9f5e053f1d54995b833b83616f37c67178c3e840 |
train | render_template_to_string | 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... | invenio_communities/utils.py | 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):
"""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
... | [
"Render",
"a",
"template",
"from",
"the",
"template",
"folder",
"with",
"the",
"given",
"context",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L79-L95 | [
"def",
"render_template_to_string",
"(",
"input",
",",
"_from_string",
"=",
"False",
",",
"*",
"*",
"context",
")",
":",
"if",
"_from_string",
":",
"template",
"=",
"current_app",
".",
"jinja_env",
".",
"from_string",
"(",
"input",
")",
"else",
":",
"templat... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | save_and_validate_logo | Validate if communities logo is in limit size and save it. | invenio_communities/utils.py | 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):
"""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... | [
"Validate",
"if",
"communities",
"logo",
"is",
"in",
"limit",
"size",
"and",
"save",
"it",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L98-L120 | [
"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_... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | initialize_communities_bucket | Initialize the communities file bucket.
:raises: `invenio_files_rest.errors.FilesException` | invenio_communities/utils.py | 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():
"""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."... | [
"Initialize",
"the",
"communities",
"file",
"bucket",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L123-L140 | [
"def",
"initialize_communities_bucket",
"(",
")",
":",
"bucket_id",
"=",
"UUID",
"(",
"current_app",
".",
"config",
"[",
"'COMMUNITIES_BUCKET_UUID'",
"]",
")",
"if",
"Bucket",
".",
"query",
".",
"get",
"(",
"bucket_id",
")",
":",
"raise",
"FilesException",
"("... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | format_request_email_templ | 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... | invenio_communities/utils.py | 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):
"""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 ... | [
"Format",
"the",
"email",
"message",
"element",
"for",
"inclusion",
"request",
"notification",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L143-L176 | [
"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_... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | format_request_email_title | 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... | invenio_communities/utils.py | 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):
"""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... | [
"Format",
"the",
"email",
"message",
"title",
"for",
"inclusion",
"request",
"notification",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L179-L190 | [
"def",
"format_request_email_title",
"(",
"increq",
",",
"*",
"*",
"ctx",
")",
":",
"template",
"=",
"current_app",
".",
"config",
"[",
"\"COMMUNITIES_REQUEST_EMAIL_TITLE_TEMPLATE\"",
"]",
",",
"return",
"format_request_email_templ",
"(",
"increq",
",",
"template",
... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | format_request_email_body | 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... | invenio_communities/utils.py | 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):
"""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... | [
"Format",
"the",
"email",
"message",
"body",
"for",
"inclusion",
"request",
"notification",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L193-L204 | [
"def",
"format_request_email_body",
"(",
"increq",
",",
"*",
"*",
"ctx",
")",
":",
"template",
"=",
"current_app",
".",
"config",
"[",
"\"COMMUNITIES_REQUEST_EMAIL_BODY_TEMPLATE\"",
"]",
",",
"return",
"format_request_email_templ",
"(",
"increq",
",",
"template",
",... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | send_community_request_email | Signal for sending emails after community inclusion request. | invenio_communities/utils.py | 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):
"""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... | [
"Signal",
"for",
"sending",
"emails",
"after",
"community",
"inclusion",
"request",
"."
] | inveniosoftware/invenio-communities | python | https://github.com/inveniosoftware/invenio-communities/blob/5c4de6783724d276ae1b6dd13a399a9e22fadc7a/invenio_communities/utils.py#L207-L224 | [
"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... | 5c4de6783724d276ae1b6dd13a399a9e22fadc7a |
train | modifydocs | 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... | tabular/tab.py | 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=''):
"""
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... | [
"Convenience",
"function",
"for",
"writing",
"documentation",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L34-L68 | [
"def",
"modifydocs",
"(",
"a",
",",
"b",
",",
"desc",
"=",
"''",
")",
":",
"newdoc",
"=",
"a",
".",
"func_doc",
".",
"replace",
"(",
"'\\t\\t'",
",",
"'\\t'",
")",
"newdoc",
"+=",
"\"Documentation from \"",
"+",
"desc",
"+",
"\":\\n\"",
"+",
"b",
"."... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tab_colstack | "Horizontal stacking" of tabarrays, e.g. adding columns.
Wrapper for :func:`tabular.spreadsheet.colstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.colstack(ListOfTabArrays, mode=mode) | tabular/tab.py | def tab_colstack(ListOfTabArrays, mode='abort'):
"""
"Horizontal stacking" of tabarrays, e.g. adding columns.
Wrapper for :func:`tabular.spreadsheet.colstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.colstack(ListOfTabAr... | def tab_colstack(ListOfTabArrays, mode='abort'):
"""
"Horizontal stacking" of tabarrays, e.g. adding columns.
Wrapper for :func:`tabular.spreadsheet.colstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.colstack(ListOfTabAr... | [
"Horizontal",
"stacking",
"of",
"tabarrays",
"e",
".",
"g",
".",
"adding",
"columns",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L70-L104 | [
"def",
"tab_colstack",
"(",
"ListOfTabArrays",
",",
"mode",
"=",
"'abort'",
")",
":",
"(",
"data",
",",
"naming",
")",
"=",
"spreadsheet",
".",
"colstack",
"(",
"ListOfTabArrays",
",",
"mode",
"=",
"mode",
",",
"returnnaming",
"=",
"True",
")",
"coloring",... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tab_rowstack | "Vertical stacking" of tabarrays, e.g. adding rows.
Wrapper for :func:`tabular.spreadsheet.rowstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.rowstack(ListOfTabArrays, mode=mode) | tabular/tab.py | def tab_rowstack(ListOfTabArrays, mode='nulls'):
"""
"Vertical stacking" of tabarrays, e.g. adding rows.
Wrapper for :func:`tabular.spreadsheet.rowstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.rowstack(ListOfTabArrays,... | def tab_rowstack(ListOfTabArrays, mode='nulls'):
"""
"Vertical stacking" of tabarrays, e.g. adding rows.
Wrapper for :func:`tabular.spreadsheet.rowstack` that deals with the
coloring and returns the result as a tabarray.
Method calls::
data = tabular.spreadsheet.rowstack(ListOfTabArrays,... | [
"Vertical",
"stacking",
"of",
"tabarrays",
"e",
".",
"g",
".",
"adding",
"rows",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L108-L138 | [
"def",
"tab_rowstack",
"(",
"ListOfTabArrays",
",",
"mode",
"=",
"'nulls'",
")",
":",
"data",
"=",
"spreadsheet",
".",
"rowstack",
"(",
"ListOfTabArrays",
",",
"mode",
"=",
"mode",
")",
"coloring",
"=",
"{",
"}",
"for",
"a",
"in",
"ListOfTabArrays",
":",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tab_join | 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 | tabular/tab.py | 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):
'''
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 ... | [
"Database",
"-",
"join",
"for",
"tabular",
"arrays",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L142-L186 | [
"def",
"tab_join",
"(",
"ToMerge",
",",
"keycols",
"=",
"None",
",",
"nullvals",
"=",
"None",
",",
"renamer",
"=",
"None",
",",
"returnrenaming",
"=",
"False",
",",
"Names",
"=",
"None",
")",
":",
"[",
"Result",
",",
"Renaming",
"]",
"=",
"spreadsheet"... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.extract | 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. | tabular/tab.py | 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):
"""
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",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L550-L559 | [
"def",
"extract",
"(",
"self",
")",
":",
"return",
"np",
".",
"vstack",
"(",
"[",
"self",
"[",
"r",
"]",
"for",
"r",
"in",
"self",
".",
"dtype",
".",
"names",
"]",
")",
".",
"T",
".",
"squeeze",
"(",
")"
] | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.addrecords | Append one or more records to the end of the array.
Method wraps::
tabular.spreadsheet.addrecords(self, new) | tabular/tab.py | 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):
"""
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
... | [
"Append",
"one",
"or",
"more",
"records",
"to",
"the",
"end",
"of",
"the",
"array",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L609-L621 | [
"def",
"addrecords",
"(",
"self",
",",
"new",
")",
":",
"data",
"=",
"spreadsheet",
".",
"addrecords",
"(",
"self",
",",
"new",
")",
"data",
"=",
"data",
".",
"view",
"(",
"tabarray",
")",
"data",
".",
"coloring",
"=",
"self",
".",
"coloring",
"retur... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.addcols | Add one or more new columns.
Method wraps::
tabular.spreadsheet.addcols(self, cols, names) | tabular/tab.py | 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):
"""
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
... | [
"Add",
"one",
"or",
"more",
"new",
"columns",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L625-L637 | [
"def",
"addcols",
"(",
"self",
",",
"cols",
",",
"names",
"=",
"None",
")",
":",
"data",
"=",
"spreadsheet",
".",
"addcols",
"(",
"self",
",",
"cols",
",",
"names",
")",
"data",
"=",
"data",
".",
"view",
"(",
"tabarray",
")",
"data",
".",
"coloring... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.deletecols | Delete columns and/or colors.
Method wraps::
tabular.spreadsheet.deletecols(self, cols) | tabular/tab.py | def deletecols(self, cols):
"""
Delete columns and/or colors.
Method wraps::
tabular.spreadsheet.deletecols(self, cols)
"""
if isinstance(cols, str):
cols = cols.split(',')
deletenames = utils.uniqify(utils.listunion([[c] if c in
self.... | def deletecols(self, cols):
"""
Delete columns and/or colors.
Method wraps::
tabular.spreadsheet.deletecols(self, cols)
"""
if isinstance(cols, str):
cols = cols.split(',')
deletenames = utils.uniqify(utils.listunion([[c] if c in
self.... | [
"Delete",
"columns",
"and",
"/",
"or",
"colors",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L641-L654 | [
"def",
"deletecols",
"(",
"self",
",",
"cols",
")",
":",
"if",
"isinstance",
"(",
"cols",
",",
"str",
")",
":",
"cols",
"=",
"cols",
".",
"split",
"(",
"','",
")",
"deletenames",
"=",
"utils",
".",
"uniqify",
"(",
"utils",
".",
"listunion",
"(",
"[... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
train | tabarray.renamecol | Rename column or color in-place.
Method wraps::
tabular.spreadsheet.renamecol(self, old, new) | tabular/tab.py | 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):
"""
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]:
... | [
"Rename",
"column",
"or",
"color",
"in",
"-",
"place",
"."
] | yamins81/tabular | python | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/tab.py#L658-L671 | [
"def",
"renamecol",
"(",
"self",
",",
"old",
",",
"new",
")",
":",
"spreadsheet",
".",
"renamecol",
"(",
"self",
",",
"old",
",",
"new",
")",
"for",
"x",
"in",
"self",
".",
"coloring",
".",
"keys",
"(",
")",
":",
"if",
"old",
"in",
"self",
".",
... | 1caf091c8c395960a9ad7078f95158b533cc52dd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.