repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
exa-analytics/exa | exa/static.py | staticdir | def staticdir():
"""Return the location of the static data directory."""
root = os.path.abspath(os.path.dirname(__file__))
return os.path.join(root, "static") | python | def staticdir():
"""Return the location of the static data directory."""
root = os.path.abspath(os.path.dirname(__file__))
return os.path.join(root, "static") | [
"def",
"staticdir",
"(",
")",
":",
"root",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"\"static\"",
")"
] | Return the location of the static data directory. | [
"Return",
"the",
"location",
"of",
"the",
"static",
"data",
"directory",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/static.py#L12-L15 |
exa-analytics/exa | exa/static.py | resource | def resource(name):
"""
Return the full path of a named resource in the static directory.
If multiple files with the same name exist, **name** should contain
the first directory as well.
.. code-block:: python
resource("myfile")
resource("test01/test.txt")
resource("test02... | python | def resource(name):
"""
Return the full path of a named resource in the static directory.
If multiple files with the same name exist, **name** should contain
the first directory as well.
.. code-block:: python
resource("myfile")
resource("test01/test.txt")
resource("test02... | [
"def",
"resource",
"(",
"name",
")",
":",
"for",
"path",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"staticdir",
"(",
")",
")",
":",
"if",
"name",
"in",
"files",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path... | Return the full path of a named resource in the static directory.
If multiple files with the same name exist, **name** should contain
the first directory as well.
.. code-block:: python
resource("myfile")
resource("test01/test.txt")
resource("test02/test.txt") | [
"Return",
"the",
"full",
"path",
"of",
"a",
"named",
"resource",
"in",
"the",
"static",
"directory",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/static.py#L18-L33 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/loader.py | RDFLoader.load_uri | def load_uri(self, uri, verbose):
"""
:param uri:
:param rdf_format_opts:
:param verbose:
:return:
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: <%s>" % uri)
success = False
for f in self.rdf_format_opt... | python | def load_uri(self, uri, verbose):
"""
:param uri:
:param rdf_format_opts:
:param verbose:
:return:
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: <%s>" % uri)
success = False
for f in self.rdf_format_opt... | [
"def",
"load_uri",
"(",
"self",
",",
"uri",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"printDebug",
"(",
"\"----------\"",
")",
"if",
"verbose",
":",
"printDebug",
"(",
"\"Reading: <%s>\"",
"%",
"uri",
")",
"success",
"=",
"False",
"for",
"f",
"in"... | :param uri:
:param rdf_format_opts:
:param verbose:
:return: | [
":",
"param",
"uri",
":",
":",
"param",
"rdf_format_opts",
":",
":",
"param",
"verbose",
":",
":",
"return",
":"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/loader.py#L116-L141 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/loader.py | RDFLoader.load_text | def load_text(self, text, verbose):
"""
:param text:
:param rdf_format_opts:
:param verbose:
:return:
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: '%s ...'" % text[:10])
success = False
for f in self.rd... | python | def load_text(self, text, verbose):
"""
:param text:
:param rdf_format_opts:
:param verbose:
:return:
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: '%s ...'" % text[:10])
success = False
for f in self.rd... | [
"def",
"load_text",
"(",
"self",
",",
"text",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"printDebug",
"(",
"\"----------\"",
")",
"if",
"verbose",
":",
"printDebug",
"(",
"\"Reading: '%s ...'\"",
"%",
"text",
"[",
":",
"10",
"]",
")",
"success",
"=... | :param text:
:param rdf_format_opts:
:param verbose:
:return: | [
":",
"param",
"text",
":",
":",
"param",
"rdf_format_opts",
":",
":",
"param",
"verbose",
":",
":",
"return",
":"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/loader.py#L143-L167 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/loader.py | RDFLoader.load_file | def load_file(self, file_obj, verbose):
"""
The type of open file objects such as sys.stdout; alias of the built-in file.
@TODO: when is this used?
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: <%s> ...'" % file_obj.name)
if type(file... | python | def load_file(self, file_obj, verbose):
"""
The type of open file objects such as sys.stdout; alias of the built-in file.
@TODO: when is this used?
"""
if verbose: printDebug("----------")
if verbose: printDebug("Reading: <%s> ...'" % file_obj.name)
if type(file... | [
"def",
"load_file",
"(",
"self",
",",
"file_obj",
",",
"verbose",
")",
":",
"if",
"verbose",
":",
"printDebug",
"(",
"\"----------\"",
")",
"if",
"verbose",
":",
"printDebug",
"(",
"\"Reading: <%s> ...'\"",
"%",
"file_obj",
".",
"name",
")",
"if",
"type",
... | The type of open file objects such as sys.stdout; alias of the built-in file.
@TODO: when is this used? | [
"The",
"type",
"of",
"open",
"file",
"objects",
"such",
"as",
"sys",
".",
"stdout",
";",
"alias",
"of",
"the",
"built",
"-",
"in",
"file",
"."
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/loader.py#L169-L182 |
ionelmc/python-cogen | cogen/core/proactors/stdlib_epoll_impl.py | StdlibEpollProactor.run | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of seconds.
"""
ptimeout = float(
timeout.microseconds/1000000+timeout.... | python | def run(self, timeout = 0):
"""
Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of seconds.
"""
ptimeout = float(
timeout.microseconds/1000000+timeout.... | [
"def",
"run",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"ptimeout",
"=",
"float",
"(",
"timeout",
".",
"microseconds",
"/",
"1000000",
"+",
"timeout",
".",
"seconds",
"if",
"timeout",
"else",
"(",
"self",
".",
"resolution",
"if",
"timeout",
"is"... | Run a proactor loop and return new socket events. Timeout is a timedelta
object, 0 if active coros or None.
epoll timeout param is a integer number of seconds. | [
"Run",
"a",
"proactor",
"loop",
"and",
"return",
"new",
"socket",
"events",
".",
"Timeout",
"is",
"a",
"timedelta",
"object",
"0",
"if",
"active",
"coros",
"or",
"None",
".",
"epoll",
"timeout",
"param",
"is",
"a",
"integer",
"number",
"of",
"seconds",
"... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/stdlib_epoll_impl.py#L49-L85 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/resolver.py | Resolver._check | def _check(self, terms):
"""Check terms do not contain unknown characters"""
for t in terms:
try:
_ = urllib.parse.quote(six.text_type(t).encode('utf8'))
except:
self.logger.error('Unknown character in [{0}]!'.format(t))
self.logger... | python | def _check(self, terms):
"""Check terms do not contain unknown characters"""
for t in terms:
try:
_ = urllib.parse.quote(six.text_type(t).encode('utf8'))
except:
self.logger.error('Unknown character in [{0}]!'.format(t))
self.logger... | [
"def",
"_check",
"(",
"self",
",",
"terms",
")",
":",
"for",
"t",
"in",
"terms",
":",
"try",
":",
"_",
"=",
"urllib",
".",
"parse",
".",
"quote",
"(",
"six",
".",
"text_type",
"(",
"t",
")",
".",
"encode",
"(",
"'utf8'",
")",
")",
"except",
":"... | Check terms do not contain unknown characters | [
"Check",
"terms",
"do",
"not",
"contain",
"unknown",
"characters"
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/resolver.py#L72-L80 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/resolver.py | Resolver.main | def main(self):
"""Search and sieve query names."""
# TODO: Break up, too complex
primary_bool = True
no_records = True
nsearch = 1
search_terms = self.terms
original_names = []
while True:
if primary_bool:
self.logger.info('Sea... | python | def main(self):
"""Search and sieve query names."""
# TODO: Break up, too complex
primary_bool = True
no_records = True
nsearch = 1
search_terms = self.terms
original_names = []
while True:
if primary_bool:
self.logger.info('Sea... | [
"def",
"main",
"(",
"self",
")",
":",
"# TODO: Break up, too complex",
"primary_bool",
"=",
"True",
"no_records",
"=",
"True",
"nsearch",
"=",
"1",
"search_terms",
"=",
"self",
".",
"terms",
"original_names",
"=",
"[",
"]",
"while",
"True",
":",
"if",
"prima... | Search and sieve query names. | [
"Search",
"and",
"sieve",
"query",
"names",
"."
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/resolver.py#L82-L127 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/resolver.py | Resolver._sieve | def _sieve(self, multiple_records):
"""Return json object without multiple returns per resolved name.\
Names with multiple records are reduced by finding the name in the clade of\
interest, have the highest score, have the lowest taxonomic rank (if lowrank is
true) and/or are the first item returned."""
... | python | def _sieve(self, multiple_records):
"""Return json object without multiple returns per resolved name.\
Names with multiple records are reduced by finding the name in the clade of\
interest, have the highest score, have the lowest taxonomic rank (if lowrank is
true) and/or are the first item returned."""
... | [
"def",
"_sieve",
"(",
"self",
",",
"multiple_records",
")",
":",
"# TODO: Break up, too complex",
"GnrStore",
"=",
"self",
".",
"_store",
"def",
"writeAsJson",
"(",
"term",
",",
"results",
")",
":",
"record",
"=",
"{",
"'supplied_name_string'",
":",
"term",
"}... | Return json object without multiple returns per resolved name.\
Names with multiple records are reduced by finding the name in the clade of\
interest, have the highest score, have the lowest taxonomic rank (if lowrank is
true) and/or are the first item returned. | [
"Return",
"json",
"object",
"without",
"multiple",
"returns",
"per",
"resolved",
"name",
".",
"\\",
"Names",
"with",
"multiple",
"records",
"are",
"reduced",
"by",
"finding",
"the",
"name",
"in",
"the",
"clade",
"of",
"\\",
"interest",
"have",
"the",
"highes... | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/resolver.py#L159-L222 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/resolver.py | Resolver.write | def write(self):
"""Write csv file of resolved names and txt file of unresolved names.
"""
csv_file = os.path.join(self.outdir, 'search_results.csv')
txt_file = os.path.join(self.outdir, 'unresolved.txt')
headers = self.key_terms
unresolved = []
with open(csv_file... | python | def write(self):
"""Write csv file of resolved names and txt file of unresolved names.
"""
csv_file = os.path.join(self.outdir, 'search_results.csv')
txt_file = os.path.join(self.outdir, 'unresolved.txt')
headers = self.key_terms
unresolved = []
with open(csv_file... | [
"def",
"write",
"(",
"self",
")",
":",
"csv_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"outdir",
",",
"'search_results.csv'",
")",
"txt_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"outdir",
",",
"'unresolved.txt'",
... | Write csv file of resolved names and txt file of unresolved names. | [
"Write",
"csv",
"file",
"of",
"resolved",
"names",
"and",
"txt",
"file",
"of",
"unresolved",
"names",
"."
] | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/resolver.py#L224-L258 |
DomBennett/TaxonNamesResolver | taxon_names_resolver/resolver.py | Resolver.retrieve | def retrieve(self, key_term):
"""Return data for key term specified for each resolved name as a list.
Possible terms (02/12/2013): 'query_name', 'classification_path',
'data_source_title', 'match_type', 'score', 'classification_path_ranks',
'name_string', 'canonical_form',\
'classification_path_ids', 'prescore'... | python | def retrieve(self, key_term):
"""Return data for key term specified for each resolved name as a list.
Possible terms (02/12/2013): 'query_name', 'classification_path',
'data_source_title', 'match_type', 'score', 'classification_path_ranks',
'name_string', 'canonical_form',\
'classification_path_ids', 'prescore'... | [
"def",
"retrieve",
"(",
"self",
",",
"key_term",
")",
":",
"if",
"key_term",
"not",
"in",
"self",
".",
"key_terms",
":",
"raise",
"IndexError",
"(",
"'Term given is invalid! Check doc string for \\\nvalid terms.'",
")",
"store",
"=",
"self",
".",
"_store",
"retrie... | Return data for key term specified for each resolved name as a list.
Possible terms (02/12/2013): 'query_name', 'classification_path',
'data_source_title', 'match_type', 'score', 'classification_path_ranks',
'name_string', 'canonical_form',\
'classification_path_ids', 'prescore', 'data_source_id', 'taxon_id',
'gni_uuid | [
"Return",
"data",
"for",
"key",
"term",
"specified",
"for",
"each",
"resolved",
"name",
"as",
"a",
"list",
".",
"Possible",
"terms",
"(",
"02",
"/",
"12",
"/",
"2013",
")",
":",
"query_name",
"classification_path",
"data_source_title",
"match_type",
"score",
... | train | https://github.com/DomBennett/TaxonNamesResolver/blob/a2556cc0f8b7442d83990715c92fdf6f787e1f41/taxon_names_resolver/resolver.py#L260-L283 |
yatiml/yatiml | yatiml/loader.py | set_document_type | def set_document_type(loader_cls: Type, type_: Type) -> None:
"""Set the type corresponding to the whole document.
Args:
loader_cls: The loader class to set the document type for.
type_: The type to loader should process the document into.
"""
loader_cls.document_type = type_
if no... | python | def set_document_type(loader_cls: Type, type_: Type) -> None:
"""Set the type corresponding to the whole document.
Args:
loader_cls: The loader class to set the document type for.
type_: The type to loader should process the document into.
"""
loader_cls.document_type = type_
if no... | [
"def",
"set_document_type",
"(",
"loader_cls",
":",
"Type",
",",
"type_",
":",
"Type",
")",
"->",
"None",
":",
"loader_cls",
".",
"document_type",
"=",
"type_",
"if",
"not",
"hasattr",
"(",
"loader_cls",
",",
"'_registered_classes'",
")",
":",
"loader_cls",
... | Set the type corresponding to the whole document.
Args:
loader_cls: The loader class to set the document type for.
type_: The type to loader should process the document into. | [
"Set",
"the",
"type",
"corresponding",
"to",
"the",
"whole",
"document",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L179-L189 |
yatiml/yatiml | yatiml/loader.py | add_to_loader | def add_to_loader(loader_cls: Type, classes: List[Type]) -> None:
"""Registers one or more classes with a YAtiML loader.
Once a class has been registered, it can be recognized and \
constructed when reading a YAML text.
Args:
loader_cls: The loader to register the classes with.
classes... | python | def add_to_loader(loader_cls: Type, classes: List[Type]) -> None:
"""Registers one or more classes with a YAtiML loader.
Once a class has been registered, it can be recognized and \
constructed when reading a YAML text.
Args:
loader_cls: The loader to register the classes with.
classes... | [
"def",
"add_to_loader",
"(",
"loader_cls",
":",
"Type",
",",
"classes",
":",
"List",
"[",
"Type",
"]",
")",
"->",
"None",
":",
"if",
"not",
"isinstance",
"(",
"classes",
",",
"list",
")",
":",
"classes",
"=",
"[",
"classes",
"]",
"# type: ignore",
"for... | Registers one or more classes with a YAtiML loader.
Once a class has been registered, it can be recognized and \
constructed when reading a YAML text.
Args:
loader_cls: The loader to register the classes with.
classes: The class(es) to register, a plain Python class or a \
... | [
"Registers",
"one",
"or",
"more",
"classes",
"with",
"a",
"YAtiML",
"loader",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L195-L220 |
yatiml/yatiml | yatiml/loader.py | Loader.get_single_node | def get_single_node(self) -> yaml.Node:
"""Hook used when loading a single document.
This is the hook we use to hook yatiml into ruamel.yaml. It is \
called by the yaml libray when the user uses load() to load a \
YAML document.
Returns:
A processed node representin... | python | def get_single_node(self) -> yaml.Node:
"""Hook used when loading a single document.
This is the hook we use to hook yatiml into ruamel.yaml. It is \
called by the yaml libray when the user uses load() to load a \
YAML document.
Returns:
A processed node representin... | [
"def",
"get_single_node",
"(",
"self",
")",
"->",
"yaml",
".",
"Node",
":",
"node",
"=",
"super",
"(",
")",
".",
"get_single_node",
"(",
")",
"if",
"node",
"is",
"not",
"None",
":",
"node",
"=",
"self",
".",
"__process_node",
"(",
"node",
",",
"type"... | Hook used when loading a single document.
This is the hook we use to hook yatiml into ruamel.yaml. It is \
called by the yaml libray when the user uses load() to load a \
YAML document.
Returns:
A processed node representing the document. | [
"Hook",
"used",
"when",
"loading",
"a",
"single",
"document",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L26-L39 |
yatiml/yatiml | yatiml/loader.py | Loader.__type_to_tag | def __type_to_tag(self, type_: Type) -> str:
"""Convert a type to the corresponding YAML tag.
Args:
type_: The type to convert
Returns:
A string containing the YAML tag.
"""
if type_ in scalar_type_to_tag:
return scalar_type_to_tag[type_]
... | python | def __type_to_tag(self, type_: Type) -> str:
"""Convert a type to the corresponding YAML tag.
Args:
type_: The type to convert
Returns:
A string containing the YAML tag.
"""
if type_ in scalar_type_to_tag:
return scalar_type_to_tag[type_]
... | [
"def",
"__type_to_tag",
"(",
"self",
",",
"type_",
":",
"Type",
")",
"->",
"str",
":",
"if",
"type_",
"in",
"scalar_type_to_tag",
":",
"return",
"scalar_type_to_tag",
"[",
"type_",
"]",
"if",
"is_generic_list",
"(",
"type_",
")",
":",
"return",
"'tag:yaml.or... | Convert a type to the corresponding YAML tag.
Args:
type_: The type to convert
Returns:
A string containing the YAML tag. | [
"Convert",
"a",
"type",
"to",
"the",
"corresponding",
"YAML",
"tag",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L56-L79 |
yatiml/yatiml | yatiml/loader.py | Loader.__savorize | def __savorize(self, node: yaml.Node, expected_type: Type) -> yaml.Node:
"""Removes syntactic sugar from the node.
This calls yatiml_savorize(), first on the class's base \
classes, then on the class itself.
Args:
node: The node to modify.
expected_type: The typ... | python | def __savorize(self, node: yaml.Node, expected_type: Type) -> yaml.Node:
"""Removes syntactic sugar from the node.
This calls yatiml_savorize(), first on the class's base \
classes, then on the class itself.
Args:
node: The node to modify.
expected_type: The typ... | [
"def",
"__savorize",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
",",
"expected_type",
":",
"Type",
")",
"->",
"yaml",
".",
"Node",
":",
"logger",
".",
"debug",
"(",
"'Savorizing node assuming type {}'",
".",
"format",
"(",
"expected_type",
".",
"_... | Removes syntactic sugar from the node.
This calls yatiml_savorize(), first on the class's base \
classes, then on the class itself.
Args:
node: The node to modify.
expected_type: The type to assume this type is. | [
"Removes",
"syntactic",
"sugar",
"from",
"the",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L81-L104 |
yatiml/yatiml | yatiml/loader.py | Loader.__process_node | def __process_node(self, node: yaml.Node,
expected_type: Type) -> yaml.Node:
"""Processes a node.
This is the main function that implements yatiml's \
functionality. It figures out how to interpret this node \
(recognition), then applies syntactic sugar, and final... | python | def __process_node(self, node: yaml.Node,
expected_type: Type) -> yaml.Node:
"""Processes a node.
This is the main function that implements yatiml's \
functionality. It figures out how to interpret this node \
(recognition), then applies syntactic sugar, and final... | [
"def",
"__process_node",
"(",
"self",
",",
"node",
":",
"yaml",
".",
"Node",
",",
"expected_type",
":",
"Type",
")",
"->",
"yaml",
".",
"Node",
":",
"logger",
".",
"info",
"(",
"'Processing node {} expecting type {}'",
".",
"format",
"(",
"node",
",",
"exp... | Processes a node.
This is the main function that implements yatiml's \
functionality. It figures out how to interpret this node \
(recognition), then applies syntactic sugar, and finally \
recurses to the subnodes, if any.
Args:
node: The node to process.
... | [
"Processes",
"a",
"node",
"."
] | train | https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/loader.py#L106-L176 |
seibert-media/Highton | highton/call_mixins/create_call_mixin.py | CreateCallMixin.create | def create(self):
"""
Creates the object
:return: the created object
:rtype: object
"""
# In the header.location there is the newly created object so get the id out of the url
created_id = self._post_request(
data=self.element_to_string(self.encode()... | python | def create(self):
"""
Creates the object
:return: the created object
:rtype: object
"""
# In the header.location there is the newly created object so get the id out of the url
created_id = self._post_request(
data=self.element_to_string(self.encode()... | [
"def",
"create",
"(",
"self",
")",
":",
"# In the header.location there is the newly created object so get the id out of the url",
"created_id",
"=",
"self",
".",
"_post_request",
"(",
"data",
"=",
"self",
".",
"element_to_string",
"(",
"self",
".",
"encode",
"(",
")",
... | Creates the object
:return: the created object
:rtype: object | [
"Creates",
"the",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/create_call_mixin.py#L10-L22 |
chop-dbhi/varify | varify/samples/resources.py | set_cell_value | def set_cell_value(cell, value):
"""
Convenience method for setting the value of an openpyxl cell
This is necessary since the value property changed from internal_value
to value between version 1.* and 2.*.
"""
if OPENPYXL_MAJOR_VERSION > 1:
cell.value = value
else:
cell.int... | python | def set_cell_value(cell, value):
"""
Convenience method for setting the value of an openpyxl cell
This is necessary since the value property changed from internal_value
to value between version 1.* and 2.*.
"""
if OPENPYXL_MAJOR_VERSION > 1:
cell.value = value
else:
cell.int... | [
"def",
"set_cell_value",
"(",
"cell",
",",
"value",
")",
":",
"if",
"OPENPYXL_MAJOR_VERSION",
">",
"1",
":",
"cell",
".",
"value",
"=",
"value",
"else",
":",
"cell",
".",
"internal_value",
"=",
"value"
] | Convenience method for setting the value of an openpyxl cell
This is necessary since the value property changed from internal_value
to value between version 1.* and 2.*. | [
"Convenience",
"method",
"for",
"setting",
"the",
"value",
"of",
"an",
"openpyxl",
"cell"
] | train | https://github.com/chop-dbhi/varify/blob/5dc721e49ed9bd3582f4b117785fdd1a8b6ba777/varify/samples/resources.py#L47-L57 |
chop-dbhi/varify | varify/samples/resources.py | SampleResultSetsResource.get_change_type | def get_change_type(self, ref, a1, a2):
"""
Given ref, allele1, and allele2, returns the type of change.
The only case of an amino acid insertion is when the ref is
represented as a '.'.
"""
if ref == '.':
return self.INSERTION
elif a1 == '.' or a2 == ... | python | def get_change_type(self, ref, a1, a2):
"""
Given ref, allele1, and allele2, returns the type of change.
The only case of an amino acid insertion is when the ref is
represented as a '.'.
"""
if ref == '.':
return self.INSERTION
elif a1 == '.' or a2 == ... | [
"def",
"get_change_type",
"(",
"self",
",",
"ref",
",",
"a1",
",",
"a2",
")",
":",
"if",
"ref",
"==",
"'.'",
":",
"return",
"self",
".",
"INSERTION",
"elif",
"a1",
"==",
"'.'",
"or",
"a2",
"==",
"'.'",
":",
"return",
"self",
".",
"DELETION"
] | Given ref, allele1, and allele2, returns the type of change.
The only case of an amino acid insertion is when the ref is
represented as a '.'. | [
"Given",
"ref",
"allele1",
"and",
"allele2",
"returns",
"the",
"type",
"of",
"change",
".",
"The",
"only",
"case",
"of",
"an",
"amino",
"acid",
"insertion",
"is",
"when",
"the",
"ref",
"is",
"represented",
"as",
"a",
".",
"."
] | train | https://github.com/chop-dbhi/varify/blob/5dc721e49ed9bd3582f4b117785fdd1a8b6ba777/varify/samples/resources.py#L419-L428 |
mitsei/dlkit | dlkit/json_/osid/default_mdata.py | get_osid_form_mdata | def get_osid_form_mdata():
"""Return default mdata map for OsidForm"""
return {
'journal_comment': {
'element_label': {
'text': 'Journal Comment',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_osid_form_mdata():
"""Return default mdata map for OsidForm"""
return {
'journal_comment': {
'element_label': {
'text': 'Journal Comment',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_osid_form_mdata",
"(",
")",
":",
"return",
"{",
"'journal_comment'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'Journal Comment'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
... | Return default mdata map for OsidForm | [
"Return",
"default",
"mdata",
"map",
"for",
"OsidForm"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/default_mdata.py#L12-L43 |
mitsei/dlkit | dlkit/json_/osid/default_mdata.py | get_osid_object_mdata | def get_osid_object_mdata():
"""Return default mdata map for OsidObject"""
return {
'display_name': {
'element_label': {
'text': 'Display Name',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_osid_object_mdata():
"""Return default mdata map for OsidObject"""
return {
'display_name': {
'element_label': {
'text': 'Display Name',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_osid_object_mdata",
"(",
")",
":",
"return",
"{",
"'display_name'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'Display Name'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
"("... | Return default mdata map for OsidObject | [
"Return",
"default",
"mdata",
"map",
"for",
"OsidObject"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/default_mdata.py#L46-L127 |
mitsei/dlkit | dlkit/json_/osid/default_mdata.py | get_osid_temporal_mdata | def get_osid_temporal_mdata():
"""Return default mdata map for OsidTemporal"""
return {
'start_date': {
'element_label': {
'text': 'Start Date',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_osid_temporal_mdata():
"""Return default mdata map for OsidTemporal"""
return {
'start_date': {
'element_label': {
'text': 'Start Date',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_osid_temporal_mdata",
"(",
")",
":",
"return",
"{",
"'start_date'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'Start Date'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
"(",
... | Return default mdata map for OsidTemporal | [
"Return",
"default",
"mdata",
"map",
"for",
"OsidTemporal"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/default_mdata.py#L130-L175 |
mitsei/dlkit | dlkit/json_/osid/default_mdata.py | get_osid_containable_mdata | def get_osid_containable_mdata():
"""Return default mdata map for OsidContainable"""
return {
'sequestered': {
'element_label': {
'text': 'sequestered',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_osid_containable_mdata():
"""Return default mdata map for OsidContainable"""
return {
'sequestered': {
'element_label': {
'text': 'sequestered',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_osid_containable_mdata",
"(",
")",
":",
"return",
"{",
"'sequestered'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'sequestered'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
... | Return default mdata map for OsidContainable | [
"Return",
"default",
"mdata",
"map",
"for",
"OsidContainable"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/default_mdata.py#L178-L201 |
mitsei/dlkit | dlkit/json_/osid/default_mdata.py | get_osid_sourceable_mdata | def get_osid_sourceable_mdata():
"""Return default mdata map for OsidSourceable"""
return {
'provider': {
'element_label': {
'text': 'provider',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_osid_sourceable_mdata():
"""Return default mdata map for OsidSourceable"""
return {
'provider': {
'element_label': {
'text': 'provider',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_osid_sourceable_mdata",
"(",
")",
":",
"return",
"{",
"'provider'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'provider'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
"(",
... | Return default mdata map for OsidSourceable | [
"Return",
"default",
"mdata",
"map",
"for",
"OsidSourceable"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/osid/default_mdata.py#L204-L277 |
mitsei/dlkit | dlkit/json_/resource/searches.py | ResourceSearchResults.get_resources | def get_resources(self):
"""Gets the resource list resulting from a search.
return: (osid.resource.ResourceList) - the resource list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved:
... | python | def get_resources(self):
"""Gets the resource list resulting from a search.
return: (osid.resource.ResourceList) - the resource list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved:
... | [
"def",
"get_resources",
"(",
"self",
")",
":",
"if",
"self",
".",
"retrieved",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'List has already been retrieved.'",
")",
"self",
".",
"retrieved",
"=",
"True",
"return",
"objects",
".",
"ResourceList",
"(",
"s... | Gets the resource list resulting from a search.
return: (osid.resource.ResourceList) - the resource list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"resource",
"list",
"resulting",
"from",
"a",
"search",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/searches.py#L96-L107 |
mitsei/dlkit | dlkit/json_/resource/searches.py | BinSearchResults.get_bins | def get_bins(self):
"""Gets the bin list resulting from the search.
return: (osid.resource.BinList) - the bin list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved:
raise errors.I... | python | def get_bins(self):
"""Gets the bin list resulting from the search.
return: (osid.resource.BinList) - the bin list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.*
"""
if self.retrieved:
raise errors.I... | [
"def",
"get_bins",
"(",
"self",
")",
":",
"if",
"self",
".",
"retrieved",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'List has already been retrieved.'",
")",
"self",
".",
"retrieved",
"=",
"True",
"return",
"objects",
".",
"BinList",
"(",
"self",
".... | Gets the bin list resulting from the search.
return: (osid.resource.BinList) - the bin list
raise: IllegalState - list already retrieved
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"bin",
"list",
"resulting",
"from",
"the",
"search",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/searches.py#L217-L228 |
jangler/readlike | readlike.py | _backward_delete_char | def _backward_delete_char(text, pos):
"""Delete the character behind pos."""
if pos == 0:
return text, pos
return text[:pos - 1] + text[pos:], pos - 1 | python | def _backward_delete_char(text, pos):
"""Delete the character behind pos."""
if pos == 0:
return text, pos
return text[:pos - 1] + text[pos:], pos - 1 | [
"def",
"_backward_delete_char",
"(",
"text",
",",
"pos",
")",
":",
"if",
"pos",
"==",
"0",
":",
"return",
"text",
",",
"pos",
"return",
"text",
"[",
":",
"pos",
"-",
"1",
"]",
"+",
"text",
"[",
"pos",
":",
"]",
",",
"pos",
"-",
"1"
] | Delete the character behind pos. | [
"Delete",
"the",
"character",
"behind",
"pos",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L51-L55 |
jangler/readlike | readlike.py | _backward_kill_word | def _backward_kill_word(text, pos):
""""
Kill the word behind pos. Word boundaries are the same as those
used by _backward_word.
"""
text, new_pos = _backward_word(text, pos)
return text[:new_pos] + text[pos:], new_pos | python | def _backward_kill_word(text, pos):
""""
Kill the word behind pos. Word boundaries are the same as those
used by _backward_word.
"""
text, new_pos = _backward_word(text, pos)
return text[:new_pos] + text[pos:], new_pos | [
"def",
"_backward_kill_word",
"(",
"text",
",",
"pos",
")",
":",
"text",
",",
"new_pos",
"=",
"_backward_word",
"(",
"text",
",",
"pos",
")",
"return",
"text",
"[",
":",
"new_pos",
"]",
"+",
"text",
"[",
"pos",
":",
"]",
",",
"new_pos"
] | Kill the word behind pos. Word boundaries are the same as those
used by _backward_word. | [
"Kill",
"the",
"word",
"behind",
"pos",
".",
"Word",
"boundaries",
"are",
"the",
"same",
"as",
"those",
"used",
"by",
"_backward_word",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L58-L64 |
jangler/readlike | readlike.py | _backward_word | def _backward_word(text, pos):
"""
Move pos back to the start of the current or previous word. Words
are composed of alphanumeric characters (letters and digits).
"""
while pos > 0 and not text[pos - 1].isalnum():
pos -= 1
while pos > 0 and text[pos - 1].isalnum():
pos -= 1
r... | python | def _backward_word(text, pos):
"""
Move pos back to the start of the current or previous word. Words
are composed of alphanumeric characters (letters and digits).
"""
while pos > 0 and not text[pos - 1].isalnum():
pos -= 1
while pos > 0 and text[pos - 1].isalnum():
pos -= 1
r... | [
"def",
"_backward_word",
"(",
"text",
",",
"pos",
")",
":",
"while",
"pos",
">",
"0",
"and",
"not",
"text",
"[",
"pos",
"-",
"1",
"]",
".",
"isalnum",
"(",
")",
":",
"pos",
"-=",
"1",
"while",
"pos",
">",
"0",
"and",
"text",
"[",
"pos",
"-",
... | Move pos back to the start of the current or previous word. Words
are composed of alphanumeric characters (letters and digits). | [
"Move",
"pos",
"back",
"to",
"the",
"start",
"of",
"the",
"current",
"or",
"previous",
"word",
".",
"Words",
"are",
"composed",
"of",
"alphanumeric",
"characters",
"(",
"letters",
"and",
"digits",
")",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L67-L76 |
jangler/readlike | readlike.py | _capitalize_word | def _capitalize_word(text, pos):
"""Capitalize the current (or following) word."""
while pos < len(text) and not text[pos].isalnum():
pos += 1
if pos < len(text):
text = text[:pos] + text[pos].upper() + text[pos + 1:]
while pos < len(text) and text[pos].isalnum():
pos += 1
re... | python | def _capitalize_word(text, pos):
"""Capitalize the current (or following) word."""
while pos < len(text) and not text[pos].isalnum():
pos += 1
if pos < len(text):
text = text[:pos] + text[pos].upper() + text[pos + 1:]
while pos < len(text) and text[pos].isalnum():
pos += 1
re... | [
"def",
"_capitalize_word",
"(",
"text",
",",
"pos",
")",
":",
"while",
"pos",
"<",
"len",
"(",
"text",
")",
"and",
"not",
"text",
"[",
"pos",
"]",
".",
"isalnum",
"(",
")",
":",
"pos",
"+=",
"1",
"if",
"pos",
"<",
"len",
"(",
"text",
")",
":",
... | Capitalize the current (or following) word. | [
"Capitalize",
"the",
"current",
"(",
"or",
"following",
")",
"word",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L84-L92 |
jangler/readlike | readlike.py | _delete_horizontal_space | def _delete_horizontal_space(text, pos):
"""Delete all spaces and tabs around pos."""
while pos > 0 and text[pos - 1].isspace():
pos -= 1
end_pos = pos
while end_pos < len(text) and text[end_pos].isspace():
end_pos += 1
return text[:pos] + text[end_pos:], pos | python | def _delete_horizontal_space(text, pos):
"""Delete all spaces and tabs around pos."""
while pos > 0 and text[pos - 1].isspace():
pos -= 1
end_pos = pos
while end_pos < len(text) and text[end_pos].isspace():
end_pos += 1
return text[:pos] + text[end_pos:], pos | [
"def",
"_delete_horizontal_space",
"(",
"text",
",",
"pos",
")",
":",
"while",
"pos",
">",
"0",
"and",
"text",
"[",
"pos",
"-",
"1",
"]",
".",
"isspace",
"(",
")",
":",
"pos",
"-=",
"1",
"end_pos",
"=",
"pos",
"while",
"end_pos",
"<",
"len",
"(",
... | Delete all spaces and tabs around pos. | [
"Delete",
"all",
"spaces",
"and",
"tabs",
"around",
"pos",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L100-L107 |
jangler/readlike | readlike.py | _downcase_word | def _downcase_word(text, pos):
"""Lowercase the current (or following) word."""
text, new_pos = _forward_word(text, pos)
return text[:pos] + text[pos:new_pos].lower() + text[new_pos:], new_pos | python | def _downcase_word(text, pos):
"""Lowercase the current (or following) word."""
text, new_pos = _forward_word(text, pos)
return text[:pos] + text[pos:new_pos].lower() + text[new_pos:], new_pos | [
"def",
"_downcase_word",
"(",
"text",
",",
"pos",
")",
":",
"text",
",",
"new_pos",
"=",
"_forward_word",
"(",
"text",
",",
"pos",
")",
"return",
"text",
"[",
":",
"pos",
"]",
"+",
"text",
"[",
"pos",
":",
"new_pos",
"]",
".",
"lower",
"(",
")",
... | Lowercase the current (or following) word. | [
"Lowercase",
"the",
"current",
"(",
"or",
"following",
")",
"word",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L110-L113 |
jangler/readlike | readlike.py | _forward_word | def _forward_word(text, pos):
"""
Move pos forward to the end of the next word. Words are composed of
alphanumeric characters (letters and digits).
"""
while pos < len(text) and not text[pos].isalnum():
pos += 1
while pos < len(text) and text[pos].isalnum():
pos += 1
return t... | python | def _forward_word(text, pos):
"""
Move pos forward to the end of the next word. Words are composed of
alphanumeric characters (letters and digits).
"""
while pos < len(text) and not text[pos].isalnum():
pos += 1
while pos < len(text) and text[pos].isalnum():
pos += 1
return t... | [
"def",
"_forward_word",
"(",
"text",
",",
"pos",
")",
":",
"while",
"pos",
"<",
"len",
"(",
"text",
")",
"and",
"not",
"text",
"[",
"pos",
"]",
".",
"isalnum",
"(",
")",
":",
"pos",
"+=",
"1",
"while",
"pos",
"<",
"len",
"(",
"text",
")",
"and"... | Move pos forward to the end of the next word. Words are composed of
alphanumeric characters (letters and digits). | [
"Move",
"pos",
"forward",
"to",
"the",
"end",
"of",
"the",
"next",
"word",
".",
"Words",
"are",
"composed",
"of",
"alphanumeric",
"characters",
"(",
"letters",
"and",
"digits",
")",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L126-L135 |
jangler/readlike | readlike.py | _kill_word | def _kill_word(text, pos):
"""
Kill from pos to the end of the current word, or if between words,
to the end of the next word. Word boundaries are the same as those
used by _forward_word.
"""
text, end_pos = _forward_word(text, pos)
return text[:pos] + text[end_pos:], pos | python | def _kill_word(text, pos):
"""
Kill from pos to the end of the current word, or if between words,
to the end of the next word. Word boundaries are the same as those
used by _forward_word.
"""
text, end_pos = _forward_word(text, pos)
return text[:pos] + text[end_pos:], pos | [
"def",
"_kill_word",
"(",
"text",
",",
"pos",
")",
":",
"text",
",",
"end_pos",
"=",
"_forward_word",
"(",
"text",
",",
"pos",
")",
"return",
"text",
"[",
":",
"pos",
"]",
"+",
"text",
"[",
"end_pos",
":",
"]",
",",
"pos"
] | Kill from pos to the end of the current word, or if between words,
to the end of the next word. Word boundaries are the same as those
used by _forward_word. | [
"Kill",
"from",
"pos",
"to",
"the",
"end",
"of",
"the",
"current",
"word",
"or",
"if",
"between",
"words",
"to",
"the",
"end",
"of",
"the",
"next",
"word",
".",
"Word",
"boundaries",
"are",
"the",
"same",
"as",
"those",
"used",
"by",
"_forward_word",
"... | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L143-L150 |
jangler/readlike | readlike.py | _transpose_chars | def _transpose_chars(text, pos):
"""
Drag the character before pos forward over the character at pos,
moving pos forward as well. If pos is at the end of text, then this
transposes the two characters before pos.
"""
if len(text) < 2 or pos == 0:
return text, pos
if pos == len(text):
... | python | def _transpose_chars(text, pos):
"""
Drag the character before pos forward over the character at pos,
moving pos forward as well. If pos is at the end of text, then this
transposes the two characters before pos.
"""
if len(text) < 2 or pos == 0:
return text, pos
if pos == len(text):
... | [
"def",
"_transpose_chars",
"(",
"text",
",",
"pos",
")",
":",
"if",
"len",
"(",
"text",
")",
"<",
"2",
"or",
"pos",
"==",
"0",
":",
"return",
"text",
",",
"pos",
"if",
"pos",
"==",
"len",
"(",
"text",
")",
":",
"return",
"text",
"[",
":",
"pos"... | Drag the character before pos forward over the character at pos,
moving pos forward as well. If pos is at the end of text, then this
transposes the two characters before pos. | [
"Drag",
"the",
"character",
"before",
"pos",
"forward",
"over",
"the",
"character",
"at",
"pos",
"moving",
"pos",
"forward",
"as",
"well",
".",
"If",
"pos",
"is",
"at",
"the",
"end",
"of",
"text",
"then",
"this",
"transposes",
"the",
"two",
"characters",
... | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L153-L163 |
jangler/readlike | readlike.py | _transpose_words | def _transpose_words(text, pos):
"""
Drag the word before pos past the word after pos, moving pos over
that word as well. If pos is at the end of text, this transposes the
last two words in text.
"""
text, end2 = _forward_word(text, pos)
text, start2 = _backward_word(text, end2)
text, st... | python | def _transpose_words(text, pos):
"""
Drag the word before pos past the word after pos, moving pos over
that word as well. If pos is at the end of text, this transposes the
last two words in text.
"""
text, end2 = _forward_word(text, pos)
text, start2 = _backward_word(text, end2)
text, st... | [
"def",
"_transpose_words",
"(",
"text",
",",
"pos",
")",
":",
"text",
",",
"end2",
"=",
"_forward_word",
"(",
"text",
",",
"pos",
")",
"text",
",",
"start2",
"=",
"_backward_word",
"(",
"text",
",",
"end2",
")",
"text",
",",
"start1",
"=",
"_backward_w... | Drag the word before pos past the word after pos, moving pos over
that word as well. If pos is at the end of text, this transposes the
last two words in text. | [
"Drag",
"the",
"word",
"before",
"pos",
"past",
"the",
"word",
"after",
"pos",
"moving",
"pos",
"over",
"that",
"word",
"as",
"well",
".",
"If",
"pos",
"is",
"at",
"the",
"end",
"of",
"text",
"this",
"transposes",
"the",
"last",
"two",
"words",
"in",
... | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L166-L179 |
jangler/readlike | readlike.py | _unix_word_rubout | def _unix_word_rubout(text, pos):
"""
Kill the word behind pos, using white space as a word boundary.
"""
words = text[:pos].rsplit(None, 1)
if len(words) < 2:
return text[pos:], 0
else:
index = text.rfind(words[1], 0, pos)
return text[:index] + text[pos:], index | python | def _unix_word_rubout(text, pos):
"""
Kill the word behind pos, using white space as a word boundary.
"""
words = text[:pos].rsplit(None, 1)
if len(words) < 2:
return text[pos:], 0
else:
index = text.rfind(words[1], 0, pos)
return text[:index] + text[pos:], index | [
"def",
"_unix_word_rubout",
"(",
"text",
",",
"pos",
")",
":",
"words",
"=",
"text",
"[",
":",
"pos",
"]",
".",
"rsplit",
"(",
"None",
",",
"1",
")",
"if",
"len",
"(",
"words",
")",
"<",
"2",
":",
"return",
"text",
"[",
"pos",
":",
"]",
",",
... | Kill the word behind pos, using white space as a word boundary. | [
"Kill",
"the",
"word",
"behind",
"pos",
"using",
"white",
"space",
"as",
"a",
"word",
"boundary",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L187-L196 |
jangler/readlike | readlike.py | _upcase_word | def _upcase_word(text, pos):
"""Uppercase the current (or following) word."""
text, new_pos = _forward_word(text, pos)
return text[:pos] + text[pos:new_pos].upper() + text[new_pos:], new_pos | python | def _upcase_word(text, pos):
"""Uppercase the current (or following) word."""
text, new_pos = _forward_word(text, pos)
return text[:pos] + text[pos:new_pos].upper() + text[new_pos:], new_pos | [
"def",
"_upcase_word",
"(",
"text",
",",
"pos",
")",
":",
"text",
",",
"new_pos",
"=",
"_forward_word",
"(",
"text",
",",
"pos",
")",
"return",
"text",
"[",
":",
"pos",
"]",
"+",
"text",
"[",
"pos",
":",
"new_pos",
"]",
".",
"upper",
"(",
")",
"+... | Uppercase the current (or following) word. | [
"Uppercase",
"the",
"current",
"(",
"or",
"following",
")",
"word",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L199-L202 |
jangler/readlike | readlike.py | edit | def edit(text, pos, key):
"""
Process a key input in the context of a line, and return the
resulting text and cursor position.
`text' and `key' must be of type str or unicode, and `pos' must be
an int in the range [0, len(text)].
If `key' is in keys(), the corresponding command is executed on ... | python | def edit(text, pos, key):
"""
Process a key input in the context of a line, and return the
resulting text and cursor position.
`text' and `key' must be of type str or unicode, and `pos' must be
an int in the range [0, len(text)].
If `key' is in keys(), the corresponding command is executed on ... | [
"def",
"edit",
"(",
"text",
",",
"pos",
",",
"key",
")",
":",
"if",
"key",
"in",
"_key_bindings",
":",
"return",
"_key_bindings",
"[",
"key",
"]",
"(",
"text",
",",
"pos",
")",
"elif",
"len",
"(",
"key",
")",
"==",
"1",
":",
"return",
"text",
"["... | Process a key input in the context of a line, and return the
resulting text and cursor position.
`text' and `key' must be of type str or unicode, and `pos' must be
an int in the range [0, len(text)].
If `key' is in keys(), the corresponding command is executed on the
line. Otherwise, if `key' is a... | [
"Process",
"a",
"key",
"input",
"in",
"the",
"context",
"of",
"a",
"line",
"and",
"return",
"the",
"resulting",
"text",
"and",
"cursor",
"position",
"."
] | train | https://github.com/jangler/readlike/blob/2901260c50bd1aecfb981c3990e0c6333de8aac8/readlike.py#L253-L271 |
discontinue/django-secure-js-login | secure_js_login/honypot/views.py | login_honeypot | def login_honeypot(request):
"""
A login honypot.
"""
status_code = None
if request.method == 'POST':
form = HoneypotForm(request.POST)
if form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password"]
# Don't s... | python | def login_honeypot(request):
"""
A login honypot.
"""
status_code = None
if request.method == 'POST':
form = HoneypotForm(request.POST)
if form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password"]
# Don't s... | [
"def",
"login_honeypot",
"(",
"request",
")",
":",
"status_code",
"=",
"None",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"form",
"=",
"HoneypotForm",
"(",
"request",
".",
"POST",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"username",
... | A login honypot. | [
"A",
"login",
"honypot",
"."
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/honypot/views.py#L27-L65 |
mitsei/dlkit | dlkit/authz_adapter/logging_/sessions.py | LogEntrySearchSession.get_log_entries_by_search | def get_log_entries_by_search(self, log_entry_query, log_entry_search):
"""Pass through to provider LogEntrySearchSession.get_log_entries_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search'... | python | def get_log_entries_by_search(self, log_entry_query, log_entry_search):
"""Pass through to provider LogEntrySearchSession.get_log_entries_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not self._can('search'... | [
"def",
"get_log_entries_by_search",
"(",
"self",
",",
"log_entry_query",
",",
"log_entry_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
"'search'",
"... | Pass through to provider LogEntrySearchSession.get_log_entries_by_search | [
"Pass",
"through",
"to",
"provider",
"LogEntrySearchSession",
".",
"get_log_entries_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/logging_/sessions.py#L415-L421 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_family | def get_family(self):
"""Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemen... | python | def get_family(self):
"""Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemen... | [
"def",
"get_family",
"(",
"self",
")",
":",
"return",
"FamilyLookupSession",
"(",
"proxy",
"=",
"self",
".",
"_proxy",
",",
"runtime",
"=",
"self",
".",
"_runtime",
")",
".",
"get_family",
"(",
"self",
".",
"_family_id",
")"
] | Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Family",
"associated",
"with",
"this",
"session",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L87-L97 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationship | def get_relationship(self, relationship_id=None):
"""Gets the ``Relationship`` specified by its ``Id``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to retrieve
return: (osid.relationship.Relationship) - the returned
``Relationship``
... | python | def get_relationship(self, relationship_id=None):
"""Gets the ``Relationship`` specified by its ``Id``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to retrieve
return: (osid.relationship.Relationship) - the returned
``Relationship``
... | [
"def",
"get_relationship",
"(",
"self",
",",
"relationship_id",
"=",
"None",
")",
":",
"if",
"relationship_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",
"self",
".",
"_catalog_id... | Gets the ``Relationship`` specified by its ``Id``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to retrieve
return: (osid.relationship.Relationship) - the returned
``Relationship``
raise: NotFound - no ``Relationship`` found with the ... | [
"Gets",
"the",
"Relationship",
"specified",
"by",
"its",
"Id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L177-L197 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_by_ids | def get_relationships_by_ids(self, relationship_ids=None):
"""Gets a ``RelationshipList`` corresponding to the given ``IdList``.
arg: relationship_ids (osid.id.IdList): the list of ``Ids``
to retrieve
return: (osid.relationship.RelationshipList) - the returned
... | python | def get_relationships_by_ids(self, relationship_ids=None):
"""Gets a ``RelationshipList`` corresponding to the given ``IdList``.
arg: relationship_ids (osid.id.IdList): the list of ``Ids``
to retrieve
return: (osid.relationship.RelationshipList) - the returned
... | [
"def",
"get_relationships_by_ids",
"(",
"self",
",",
"relationship_ids",
"=",
"None",
")",
":",
"if",
"relationship_ids",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"relationships",
"=",
"[",
"]",
"for",
"i",
"in",
"relationship_ids",
":",
"relation... | Gets a ``RelationshipList`` corresponding to the given ``IdList``.
arg: relationship_ids (osid.id.IdList): the list of ``Ids``
to retrieve
return: (osid.relationship.RelationshipList) - the returned
``Relationship list``
raise: NotFound - an ``Id`` was not fo... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"IdList",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L199-L232 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_by_genus_type | def get_relationships_by_genus_type(self, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given relationship genus ``Type``
which does not include relationships of types derived from the specified ``Type``.
arg: relationship_genus_type (osid.type.Type):... | python | def get_relationships_by_genus_type(self, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given relationship genus ``Type``
which does not include relationships of types derived from the specified ``Type``.
arg: relationship_genus_type (osid.type.Type):... | [
"def",
"get_relationships_by_genus_type",
"(",
"self",
",",
"relationship_genus_type",
"=",
"None",
")",
":",
"if",
"relationship_genus_type",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",
... | Gets a ``RelationshipList`` corresponding to the given relationship genus ``Type``
which does not include relationships of types derived from the specified ``Type``.
arg: relationship_genus_type (osid.type.Type): a relationship
genus type
return: (osid.relationship.Relati... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"relationship",
"genus",
"Type",
"which",
"does",
"not",
"include",
"relationships",
"of",
"types",
"derived",
"from",
"the",
"specified",
"Type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L234-L253 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_for_source | def get_relationships_for_source(self, source_id=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: source_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``source_id`` is ``null``
... | python | def get_relationships_for_source(self, source_id=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: source_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``source_id`` is ``null``
... | [
"def",
"get_relationships_for_source",
"(",
"self",
",",
"source_id",
"=",
"None",
")",
":",
"if",
"source_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",
"self",
".",
"_catalog_id... | Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: source_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``source_id`` is ``null``
raise: OperationFailed - unable to complete request
... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"peer",
"Id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L302-L318 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_by_genus_type_for_source | def get_relationships_by_genus_type_for_source(self, source_id=None, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In plenary mo... | python | def get_relationships_by_genus_type_for_source(self, source_id=None, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In plenary mo... | [
"def",
"get_relationships_by_genus_type_for_source",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"relationship_genus_type",
"=",
"None",
")",
":",
"if",
"source_id",
"is",
"None",
"or",
"relationship_genus_type",
"is",
"None",
":",
"raise",
"NullArgument",
"(",... | Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In plenary mode, the returned list contains all of the
relationships corresponding to the given peer, including
... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"peer",
"Id",
"and",
"relationship",
"genus",
"Type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L338-L371 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_for_destination | def get_relationships_for_destination(self, destination_id=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: destination_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``destinati... | python | def get_relationships_for_destination(self, destination_id=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: destination_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``destinati... | [
"def",
"get_relationships_for_destination",
"(",
"self",
",",
"destination_id",
"=",
"None",
")",
":",
"if",
"destination_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",
"self",
".",... | Gets a ``RelationshipList`` corresponding to the given peer ``Id``.
arg: destination_id (osid.id.Id): a peer ``Id``
return: (osid.relationship.RelationshipList) - the relationships
raise: NullArgument - ``destination_id`` is ``null``
raise: OperationFailed - unable to complete requ... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"peer",
"Id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L398-L414 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships_by_genus_type_for_destination | def get_relationships_by_genus_type_for_destination(self, destination_id=None, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In ... | python | def get_relationships_by_genus_type_for_destination(self, destination_id=None, relationship_genus_type=None):
"""Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In ... | [
"def",
"get_relationships_by_genus_type_for_destination",
"(",
"self",
",",
"destination_id",
"=",
"None",
",",
"relationship_genus_type",
"=",
"None",
")",
":",
"if",
"destination_id",
"is",
"None",
"or",
"relationship_genus_type",
"is",
"None",
":",
"raise",
"NullAr... | Gets a ``RelationshipList`` corresponding to the given peer ``Id`` and relationship genus ``Type.
Relationships`` of any genus derived from the given genus are
returned.
In plenary mode, the returned list contains all of the
relationships corresponding to the given peer, including
... | [
"Gets",
"a",
"RelationshipList",
"corresponding",
"to",
"the",
"given",
"peer",
"Id",
"and",
"relationship",
"genus",
"Type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L434-L468 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipLookupSession.get_relationships | def get_relationships(self):
"""Gets all ``Relationships``.
return: (osid.relationship.RelationshipList) - a list of
``Relationships``
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- ... | python | def get_relationships(self):
"""Gets all ``Relationships``.
return: (osid.relationship.RelationshipList) - a list of
``Relationships``
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- ... | [
"def",
"get_relationships",
"(",
"self",
")",
":",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",
"self",
".",
"_catalog_idstr",
"+",
"'/relationships'",
")",
"return",
"objects",
".",
"RelationshipList",
"(",
"self",
".",
"_get_request",
"... | Gets all ``Relationships``.
return: (osid.relationship.RelationshipList) - a list of
``Relationships``
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"all",
"Relationships",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L587-L599 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipQuerySession.get_family | def get_family(self):
"""Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemen... | python | def get_family(self):
"""Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemen... | [
"def",
"get_family",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceLookupSession.get_bin",
"from",
".",
".",
"osid",
".",
"osid_errors",
"import",
"OperationFailed",
",",
"PermissionDenied",
"from",
".",
"objects",
"import",
"Family",
"try"... | Gets the ``Family`` associated with this session.
return: (osid.relationship.Family) - the family
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Family",
"associated",
"with",
"this",
"session",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L627-L642 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipAdminSession.get_relationship_form_for_create | def get_relationship_form_for_create(self, source_id=None, destination_id=None, relationship_record_types=None):
"""Gets the relationship form for creating new relationships.
A new form should be requested for each create transaction.
arg: source_id (osid.id.Id): ``Id`` of a peer
ar... | python | def get_relationship_form_for_create(self, source_id=None, destination_id=None, relationship_record_types=None):
"""Gets the relationship form for creating new relationships.
A new form should be requested for each create transaction.
arg: source_id (osid.id.Id): ``Id`` of a peer
ar... | [
"def",
"get_relationship_form_for_create",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"destination_id",
"=",
"None",
",",
"relationship_record_types",
"=",
"None",
")",
":",
"if",
"source_id",
"is",
"None",
"or",
"destination_id",
"is",
"None",
":",
"raise... | Gets the relationship form for creating new relationships.
A new form should be requested for each create transaction.
arg: source_id (osid.id.Id): ``Id`` of a peer
arg: destination_id (osid.id.Id): ``Id`` of the related peer
arg: relationship_record_types (osid.type.Type[]): ... | [
"Gets",
"the",
"relationship",
"form",
"for",
"creating",
"new",
"relationships",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L912-L942 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipAdminSession.create_relationship | def create_relationship(self, relationship_form=None):
"""Creates a new ``Relationship``.
arg: relationship_form (osid.relationship.RelationshipForm):
the form for this ``Relationship``
return: (osid.relationship.Relationship) - the new
``Relationship``
... | python | def create_relationship(self, relationship_form=None):
"""Creates a new ``Relationship``.
arg: relationship_form (osid.relationship.RelationshipForm):
the form for this ``Relationship``
return: (osid.relationship.Relationship) - the new
``Relationship``
... | [
"def",
"create_relationship",
"(",
"self",
",",
"relationship_form",
"=",
"None",
")",
":",
"if",
"relationship_form",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"if",
"not",
"isinstance",
"(",
"relationship_form",
",",
"abc_relationship_objects",
".",
... | Creates a new ``Relationship``.
arg: relationship_form (osid.relationship.RelationshipForm):
the form for this ``Relationship``
return: (osid.relationship.Relationship) - the new
``Relationship``
raise: IllegalState - ``relationship_form`` already used in a
... | [
"Creates",
"a",
"new",
"Relationship",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L944-L984 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipAdminSession.get_relationship_form_for_update | def get_relationship_form_for_update(self, relationship_id=None):
"""Gets the relationship form for updating an existing relationship.
A new relationship form should be requested for each update
transaction.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Rela... | python | def get_relationship_form_for_update(self, relationship_id=None):
"""Gets the relationship form for updating an existing relationship.
A new relationship form should be requested for each update
transaction.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Rela... | [
"def",
"get_relationship_form_for_update",
"(",
"self",
",",
"relationship_id",
"=",
"None",
")",
":",
"if",
"relationship_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"try",
":",
"url_path",
"=",
"(",
"'/handcar/services/relationship/families/'",
"+",... | Gets the relationship form for updating an existing relationship.
A new relationship form should be requested for each update
transaction.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship``
return: (osid.relationship.RelationshipForm) - the relatio... | [
"Gets",
"the",
"relationship",
"form",
"for",
"updating",
"an",
"existing",
"relationship",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1002-L1029 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipAdminSession.update_relationship | def update_relationship(self, relationship_id=None, relationship_form=None):
"""Updates an existing relationship.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship``
arg: relationship_form (osid.relationship.RelationshipForm):
the form con... | python | def update_relationship(self, relationship_id=None, relationship_form=None):
"""Updates an existing relationship.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship``
arg: relationship_form (osid.relationship.RelationshipForm):
the form con... | [
"def",
"update_relationship",
"(",
"self",
",",
"relationship_id",
"=",
"None",
",",
"relationship_form",
"=",
"None",
")",
":",
"if",
"relationship_id",
"is",
"None",
"or",
"relationship_form",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"if",
"not"... | Updates an existing relationship.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship``
arg: relationship_form (osid.relationship.RelationshipForm):
the form containing the elements to be updated
raise: IllegalState - ``relationship_form`` ... | [
"Updates",
"an",
"existing",
"relationship",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1031-L1070 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | RelationshipAdminSession.delete_relationship | def delete_relationship(self, relationship_id=None):
"""Deletes a ``Relationship``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to remove
raise: NotFound - ``relationship_id`` not found
raise: NullArgument - ``relationship_id`` is ``null``
... | python | def delete_relationship(self, relationship_id=None):
"""Deletes a ``Relationship``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to remove
raise: NotFound - ``relationship_id`` not found
raise: NullArgument - ``relationship_id`` is ``null``
... | [
"def",
"delete_relationship",
"(",
"self",
",",
"relationship_id",
"=",
"None",
")",
":",
"if",
"relationship_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"if",
"not",
"isinstance",
"(",
"relationship_id",
",",
"Id",
")",
":",
"raise",
"Invalid... | Deletes a ``Relationship``.
arg: relationship_id (osid.id.Id): the ``Id`` of the
``Relationship`` to remove
raise: NotFound - ``relationship_id`` not found
raise: NullArgument - ``relationship_id`` is ``null``
raise: OperationFailed - unable to complete request
... | [
"Deletes",
"a",
"Relationship",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1088-L1109 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | FamilyLookupSession.get_family | def get_family(self, family_id=None):
"""Gets the ``Family`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``Family`` may have a different
``Id`` than requested, such as the case where a duplicate ``Id``
wa... | python | def get_family(self, family_id=None):
"""Gets the ``Family`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``Family`` may have a different
``Id`` than requested, such as the case where a duplicate ``Id``
wa... | [
"def",
"get_family",
"(",
"self",
",",
"family_id",
"=",
"None",
")",
":",
"if",
"family_id",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"'/handcar/services/relationship/families/'",
"+",
"str",
"(",
"family_id",
")",
"return",
"obj... | Gets the ``Family`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``Family`` may have a different
``Id`` than requested, such as the case where a duplicate ``Id``
was assigned to a ``Family`` and retained for compa... | [
"Gets",
"the",
"Family",
"specified",
"by",
"its",
"Id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1878-L1898 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | FamilyLookupSession.get_families_by_ids | def get_families_by_ids(self, family_ids=None):
"""Gets a ``FamilyList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the families
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`` ... | python | def get_families_by_ids(self, family_ids=None):
"""Gets a ``FamilyList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the families
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`` ... | [
"def",
"get_families_by_ids",
"(",
"self",
",",
"family_ids",
"=",
"None",
")",
":",
"if",
"family_ids",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"families",
"=",
"[",
"]",
"for",
"i",
"in",
"family_ids",
":",
"family",
"=",
"None",
"url_pat... | Gets a ``FamilyList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the families
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`` in the
supplied list is not found or inaccessible. ... | [
"Gets",
"a",
"FamilyList",
"corresponding",
"to",
"the",
"given",
"IdList",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1900-L1939 |
mitsei/dlkit | dlkit/handcar/relationship/sessions.py | FamilyLookupSession.get_families_by_genus_type | def get_families_by_genus_type(self, family_genus_type=None):
"""Gets a ``FamilyList`` corresponding to the given family genus ``Type`` which
does not include families of genus types derived from the specified ``Type``.
In plenary mode, the returned list contains all known families
... | python | def get_families_by_genus_type(self, family_genus_type=None):
"""Gets a ``FamilyList`` corresponding to the given family genus ``Type`` which
does not include families of genus types derived from the specified ``Type``.
In plenary mode, the returned list contains all known families
... | [
"def",
"get_families_by_genus_type",
"(",
"self",
",",
"family_genus_type",
"=",
"None",
")",
":",
"if",
"family_genus_type",
"is",
"None",
":",
"raise",
"NullArgument",
"(",
")",
"url_path",
"=",
"'/handcar/services/relationship/families'",
"families_of_type",
"=",
"... | Gets a ``FamilyList`` corresponding to the given family genus ``Type`` which
does not include families of genus types derived from the specified ``Type``.
In plenary mode, the returned list contains all known families
or an error results. Otherwise, the returned list may contain
onl... | [
"Gets",
"a",
"FamilyList",
"corresponding",
"to",
"the",
"given",
"family",
"genus",
"Type",
"which",
"does",
"not",
"include",
"families",
"of",
"genus",
"types",
"derived",
"from",
"the",
"specified",
"Type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/relationship/sessions.py#L1941-L1967 |
delfick/harpoon | harpoon/helpers.py | a_temp_file | def a_temp_file():
"""Yield the name of a temporary file and ensure it's removed after use"""
filename = None
try:
tmpfile = tempfile.NamedTemporaryFile(delete=False)
filename = tmpfile.name
yield tmpfile
finally:
if filename and os.path.exists(filename):
os.r... | python | def a_temp_file():
"""Yield the name of a temporary file and ensure it's removed after use"""
filename = None
try:
tmpfile = tempfile.NamedTemporaryFile(delete=False)
filename = tmpfile.name
yield tmpfile
finally:
if filename and os.path.exists(filename):
os.r... | [
"def",
"a_temp_file",
"(",
")",
":",
"filename",
"=",
"None",
"try",
":",
"tmpfile",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"filename",
"=",
"tmpfile",
".",
"name",
"yield",
"tmpfile",
"finally",
":",
"if",
"filename"... | Yield the name of a temporary file and ensure it's removed after use | [
"Yield",
"the",
"name",
"of",
"a",
"temporary",
"file",
"and",
"ensure",
"it",
"s",
"removed",
"after",
"use"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/helpers.py#L16-L25 |
delfick/harpoon | harpoon/helpers.py | until | def until(timeout=10, step=0.5, action=None, silent=False):
"""Yield until timeout"""
yield
started = time.time()
while True:
if action and not silent:
log.info(action)
if time.time() - started > timeout:
if action and not silent:
log.error("Time... | python | def until(timeout=10, step=0.5, action=None, silent=False):
"""Yield until timeout"""
yield
started = time.time()
while True:
if action and not silent:
log.info(action)
if time.time() - started > timeout:
if action and not silent:
log.error("Time... | [
"def",
"until",
"(",
"timeout",
"=",
"10",
",",
"step",
"=",
"0.5",
",",
"action",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"yield",
"started",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"if",
"action",
"and",
"not",
"si... | Yield until timeout | [
"Yield",
"until",
"timeout"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/helpers.py#L27-L42 |
delfick/harpoon | harpoon/helpers.py | write_to | def write_to(output, txt):
"""Write some text to some output"""
if (isinstance(txt, six.binary_type) or six.PY3 and isinstance(output, StringIO)) or isinstance(output, TextIOWrapper):
output.write(txt)
else:
output.write(txt.encode("utf-8", "replace")) | python | def write_to(output, txt):
"""Write some text to some output"""
if (isinstance(txt, six.binary_type) or six.PY3 and isinstance(output, StringIO)) or isinstance(output, TextIOWrapper):
output.write(txt)
else:
output.write(txt.encode("utf-8", "replace")) | [
"def",
"write_to",
"(",
"output",
",",
"txt",
")",
":",
"if",
"(",
"isinstance",
"(",
"txt",
",",
"six",
".",
"binary_type",
")",
"or",
"six",
".",
"PY3",
"and",
"isinstance",
"(",
"output",
",",
"StringIO",
")",
")",
"or",
"isinstance",
"(",
"output... | Write some text to some output | [
"Write",
"some",
"text",
"to",
"some",
"output"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/helpers.py#L66-L71 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteMixin.set_agnocomplete | def set_agnocomplete(self, klass_or_instance, user):
"""
Handling the assignation of the agnocomplete object inside the field.
A developer may want to use a class or an instance of an
:class:`AgnocompleteBase` class to configure her field.
Ex::
from agnocomplete imp... | python | def set_agnocomplete(self, klass_or_instance, user):
"""
Handling the assignation of the agnocomplete object inside the field.
A developer may want to use a class or an instance of an
:class:`AgnocompleteBase` class to configure her field.
Ex::
from agnocomplete imp... | [
"def",
"set_agnocomplete",
"(",
"self",
",",
"klass_or_instance",
",",
"user",
")",
":",
"# If string, use register to fetch the class",
"if",
"isinstance",
"(",
"klass_or_instance",
",",
"six",
".",
"string_types",
")",
":",
"registry",
"=",
"get_agnocomplete_registry"... | Handling the assignation of the agnocomplete object inside the field.
A developer may want to use a class or an instance of an
:class:`AgnocompleteBase` class to configure her field.
Ex::
from agnocomplete import Fields
class SearchForm(forms.Form):
sea... | [
"Handling",
"the",
"assignation",
"of",
"the",
"agnocomplete",
"object",
"inside",
"the",
"field",
".",
"A",
"developer",
"may",
"want",
"to",
"use",
"a",
"class",
"or",
"an",
"instance",
"of",
"an",
":",
"class",
":",
"AgnocompleteBase",
"class",
"to",
"c... | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L38-L76 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteMixin.transmit_agnocomplete_context | def transmit_agnocomplete_context(self):
"""
Assign the user context to the agnocomplete class, if any.
"""
# Only if the field has this attribute set.
if hasattr(self, AGNOCOMPLETE_USER_ATTRIBUTE):
user = self.get_agnocomplete_context()
if user:
... | python | def transmit_agnocomplete_context(self):
"""
Assign the user context to the agnocomplete class, if any.
"""
# Only if the field has this attribute set.
if hasattr(self, AGNOCOMPLETE_USER_ATTRIBUTE):
user = self.get_agnocomplete_context()
if user:
... | [
"def",
"transmit_agnocomplete_context",
"(",
"self",
")",
":",
"# Only if the field has this attribute set.",
"if",
"hasattr",
"(",
"self",
",",
"AGNOCOMPLETE_USER_ATTRIBUTE",
")",
":",
"user",
"=",
"self",
".",
"get_agnocomplete_context",
"(",
")",
"if",
"user",
":",... | Assign the user context to the agnocomplete class, if any. | [
"Assign",
"the",
"user",
"context",
"to",
"the",
"agnocomplete",
"class",
"if",
"any",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L84-L93 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteMixin.clean | def clean(self, *args, **kwargs):
"""
Potentially, these fields should validate against context-based
queries.
If a context variable has been transmitted to the field, it's being
used to 'reset' the queryset and make sure the chosen item fits to
the user context.
... | python | def clean(self, *args, **kwargs):
"""
Potentially, these fields should validate against context-based
queries.
If a context variable has been transmitted to the field, it's being
used to 'reset' the queryset and make sure the chosen item fits to
the user context.
... | [
"def",
"clean",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"transmit_agnocomplete_context",
"(",
")",
"return",
"super",
"(",
"AgnocompleteMixin",
",",
"self",
")",
".",
"clean",
"(",
"*",
"args",
",",
"*",
"*",
"k... | Potentially, these fields should validate against context-based
queries.
If a context variable has been transmitted to the field, it's being
used to 'reset' the queryset and make sure the chosen item fits to
the user context. | [
"Potentially",
"these",
"fields",
"should",
"validate",
"against",
"context",
"-",
"based",
"queries",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L96-L106 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteContextQuerysetMixin.transmit_agnocomplete_context | def transmit_agnocomplete_context(self):
"""
We'll reset the current queryset only if the user is set.
"""
user = super(AgnocompleteContextQuerysetMixin, self) \
.transmit_agnocomplete_context()
if user:
self.queryset = self.agnocomplete.get_queryset()
... | python | def transmit_agnocomplete_context(self):
"""
We'll reset the current queryset only if the user is set.
"""
user = super(AgnocompleteContextQuerysetMixin, self) \
.transmit_agnocomplete_context()
if user:
self.queryset = self.agnocomplete.get_queryset()
... | [
"def",
"transmit_agnocomplete_context",
"(",
"self",
")",
":",
"user",
"=",
"super",
"(",
"AgnocompleteContextQuerysetMixin",
",",
"self",
")",
".",
"transmit_agnocomplete_context",
"(",
")",
"if",
"user",
":",
"self",
".",
"queryset",
"=",
"self",
".",
"agnocom... | We'll reset the current queryset only if the user is set. | [
"We",
"ll",
"reset",
"the",
"current",
"queryset",
"only",
"if",
"the",
"user",
"is",
"set",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L110-L118 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteMultipleMixin.clear_list_value | def clear_list_value(self, value):
"""
Clean the argument value to eliminate None or Falsy values if needed.
"""
# Don't go any further: this value is empty.
if not value:
return self.empty_value
# Clean empty items if wanted
if self.clean_empty:
... | python | def clear_list_value(self, value):
"""
Clean the argument value to eliminate None or Falsy values if needed.
"""
# Don't go any further: this value is empty.
if not value:
return self.empty_value
# Clean empty items if wanted
if self.clean_empty:
... | [
"def",
"clear_list_value",
"(",
"self",
",",
"value",
")",
":",
"# Don't go any further: this value is empty.",
"if",
"not",
"value",
":",
"return",
"self",
".",
"empty_value",
"# Clean empty items if wanted",
"if",
"self",
".",
"clean_empty",
":",
"value",
"=",
"["... | Clean the argument value to eliminate None or Falsy values if needed. | [
"Clean",
"the",
"argument",
"value",
"to",
"eliminate",
"None",
"or",
"Falsy",
"values",
"if",
"needed",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L163-L173 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteModelMultipleField.create_item | def create_item(self, **kwargs):
"""
Return a model instance created from kwargs.
"""
item, created = self.queryset.model.objects.get_or_create(**kwargs)
return item | python | def create_item(self, **kwargs):
"""
Return a model instance created from kwargs.
"""
item, created = self.queryset.model.objects.get_or_create(**kwargs)
return item | [
"def",
"create_item",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"item",
",",
"created",
"=",
"self",
".",
"queryset",
".",
"model",
".",
"objects",
".",
"get_or_create",
"(",
"*",
"*",
"kwargs",
")",
"return",
"item"
] | Return a model instance created from kwargs. | [
"Return",
"a",
"model",
"instance",
"created",
"from",
"kwargs",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L200-L205 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteModelMultipleField.create_new_values | def create_new_values(self):
"""
Create values created by the user input. Return the model instances QS.
"""
model = self.queryset.model
pks = []
extra_create_kwargs = self.extra_create_kwargs()
for value in self._new_values:
create_kwargs = {self.crea... | python | def create_new_values(self):
"""
Create values created by the user input. Return the model instances QS.
"""
model = self.queryset.model
pks = []
extra_create_kwargs = self.extra_create_kwargs()
for value in self._new_values:
create_kwargs = {self.crea... | [
"def",
"create_new_values",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"queryset",
".",
"model",
"pks",
"=",
"[",
"]",
"extra_create_kwargs",
"=",
"self",
".",
"extra_create_kwargs",
"(",
")",
"for",
"value",
"in",
"self",
".",
"_new_values",
":",
... | Create values created by the user input. Return the model instances QS. | [
"Create",
"values",
"created",
"by",
"the",
"user",
"input",
".",
"Return",
"the",
"model",
"instances",
"QS",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L216-L228 |
peopledoc/django-agnocomplete | agnocomplete/fields.py | AgnocompleteModelMultipleField.clean | def clean(self, value):
"""
Clean the field values.
"""
if not self.create:
# No new value can be created, use the regular clean field
return super(AgnocompleteModelMultipleField, self).clean(value)
# We have to do this here before the call to "super".
... | python | def clean(self, value):
"""
Clean the field values.
"""
if not self.create:
# No new value can be created, use the regular clean field
return super(AgnocompleteModelMultipleField, self).clean(value)
# We have to do this here before the call to "super".
... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"create",
":",
"# No new value can be created, use the regular clean field",
"return",
"super",
"(",
"AgnocompleteModelMultipleField",
",",
"self",
")",
".",
"clean",
"(",
"value",
")",... | Clean the field values. | [
"Clean",
"the",
"field",
"values",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/agnocomplete/fields.py#L230-L249 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | sort_ranges | def sort_ranges(inranges):
"""from an array of ranges, make a sorted array of ranges
:param inranges: List of GenomicRange data
:type inranges: GenomicRange[]
:returns: a new sorted GenomicRange list
:rtype: GenomicRange[]
"""
return sorted(inranges,key=lambda x: (x.chr,x.start,x.end,x.direction)) | python | def sort_ranges(inranges):
"""from an array of ranges, make a sorted array of ranges
:param inranges: List of GenomicRange data
:type inranges: GenomicRange[]
:returns: a new sorted GenomicRange list
:rtype: GenomicRange[]
"""
return sorted(inranges,key=lambda x: (x.chr,x.start,x.end,x.direction)) | [
"def",
"sort_ranges",
"(",
"inranges",
")",
":",
"return",
"sorted",
"(",
"inranges",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"chr",
",",
"x",
".",
"start",
",",
"x",
".",
"end",
",",
"x",
".",
"direction",
")",
")"
] | from an array of ranges, make a sorted array of ranges
:param inranges: List of GenomicRange data
:type inranges: GenomicRange[]
:returns: a new sorted GenomicRange list
:rtype: GenomicRange[] | [
"from",
"an",
"array",
"of",
"ranges",
"make",
"a",
"sorted",
"array",
"of",
"ranges"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L7-L16 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | merge_ranges | def merge_ranges(inranges,already_sorted=False):
"""from a list of genomic range or bed entries, whether or not they are already sorted,
make a flattend range list of ranges where if they overlapped, they are now joined
(not yet) The new range payloads will be the previous ranges
:param inranges:
:par... | python | def merge_ranges(inranges,already_sorted=False):
"""from a list of genomic range or bed entries, whether or not they are already sorted,
make a flattend range list of ranges where if they overlapped, they are now joined
(not yet) The new range payloads will be the previous ranges
:param inranges:
:par... | [
"def",
"merge_ranges",
"(",
"inranges",
",",
"already_sorted",
"=",
"False",
")",
":",
"if",
"not",
"already_sorted",
":",
"inranges",
"=",
"sort_ranges",
"(",
"inranges",
")",
"prev",
"=",
"None",
"outputs",
"=",
"[",
"]",
"merged",
"=",
"False",
"for",
... | from a list of genomic range or bed entries, whether or not they are already sorted,
make a flattend range list of ranges where if they overlapped, they are now joined
(not yet) The new range payloads will be the previous ranges
:param inranges:
:param already_sorted: has this already been sorted (defau... | [
"from",
"a",
"list",
"of",
"genomic",
"range",
"or",
"bed",
"entries",
"whether",
"or",
"not",
"they",
"are",
"already",
"sorted",
"make",
"a",
"flattend",
"range",
"list",
"of",
"ranges",
"where",
"if",
"they",
"overlapped",
"they",
"are",
"now",
"joined"... | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L18-L52 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | pad_ranges | def pad_ranges(inranges,padding,chr_ranges=None):
"""Add the specfied amount onto the edges the transcripts
:param inranges: List of genomic ranges in Bed o GenomicRange format.
:param padding: how much to add on
:param chr_ranges: looks like the list of ranges within which to pad
:type inranges: GenomicRang... | python | def pad_ranges(inranges,padding,chr_ranges=None):
"""Add the specfied amount onto the edges the transcripts
:param inranges: List of genomic ranges in Bed o GenomicRange format.
:param padding: how much to add on
:param chr_ranges: looks like the list of ranges within which to pad
:type inranges: GenomicRang... | [
"def",
"pad_ranges",
"(",
"inranges",
",",
"padding",
",",
"chr_ranges",
"=",
"None",
")",
":",
"if",
"not",
"inranges",
":",
"return",
"outranges",
"=",
"[",
"]",
"if",
"len",
"(",
"inranges",
")",
"==",
"0",
":",
"return",
"outranges",
"chr",
"=",
... | Add the specfied amount onto the edges the transcripts
:param inranges: List of genomic ranges in Bed o GenomicRange format.
:param padding: how much to add on
:param chr_ranges: looks like the list of ranges within which to pad
:type inranges: GenomicRange[]
:type padding: int
:type chr_ranges: | [
"Add",
"the",
"specfied",
"amount",
"onto",
"the",
"edges",
"the",
"transcripts"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L54-L82 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | subtract_ranges | def subtract_ranges(r1s,r2s,already_sorted=False):
"""Subtract multiple ranges from a list of ranges
:param r1s: range list 1
:param r2s: range list 2
:param already_sorted: default (False)
:type r1s: GenomicRange[]
:type r2s: GenomicRange[]
:return: new range r1s minus r2s
:rtype: GenomicRange[]
""... | python | def subtract_ranges(r1s,r2s,already_sorted=False):
"""Subtract multiple ranges from a list of ranges
:param r1s: range list 1
:param r2s: range list 2
:param already_sorted: default (False)
:type r1s: GenomicRange[]
:type r2s: GenomicRange[]
:return: new range r1s minus r2s
:rtype: GenomicRange[]
""... | [
"def",
"subtract_ranges",
"(",
"r1s",
",",
"r2s",
",",
"already_sorted",
"=",
"False",
")",
":",
"from",
"seqtools",
".",
"stream",
"import",
"MultiLocusStream",
"if",
"not",
"already_sorted",
":",
"r1s",
"=",
"merge_ranges",
"(",
"r1s",
")",
"r2s",
"=",
"... | Subtract multiple ranges from a list of ranges
:param r1s: range list 1
:param r2s: range list 2
:param already_sorted: default (False)
:type r1s: GenomicRange[]
:type r2s: GenomicRange[]
:return: new range r1s minus r2s
:rtype: GenomicRange[] | [
"Subtract",
"multiple",
"ranges",
"from",
"a",
"list",
"of",
"ranges"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L84-L147 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | intersect_range_array | def intersect_range_array(bed1,beds2,payload=None,is_sorted=False):
""" Does not do a merge if the payload has been set
:param bed1:
:param bed2:
:param payload: payload=1 return the payload of bed1 on each of the intersect set, payload=2 return the payload of bed2 on each of the union set, payload=3 return th... | python | def intersect_range_array(bed1,beds2,payload=None,is_sorted=False):
""" Does not do a merge if the payload has been set
:param bed1:
:param bed2:
:param payload: payload=1 return the payload of bed1 on each of the intersect set, payload=2 return the payload of bed2 on each of the union set, payload=3 return th... | [
"def",
"intersect_range_array",
"(",
"bed1",
",",
"beds2",
",",
"payload",
"=",
"None",
",",
"is_sorted",
"=",
"False",
")",
":",
"if",
"not",
"is_sorted",
":",
"beds2",
"=",
"sort_ranges",
"(",
"beds2",
")",
"output",
"=",
"[",
"]",
"for",
"bed2",
"in... | Does not do a merge if the payload has been set
:param bed1:
:param bed2:
:param payload: payload=1 return the payload of bed1 on each of the intersect set, payload=2 return the payload of bed2 on each of the union set, payload=3 return the payload of bed1 and bed2 on each of the union set
:param is_sorted:
... | [
"Does",
"not",
"do",
"a",
"merge",
"if",
"the",
"payload",
"has",
"been",
"set"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L149-L175 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | subtract_range_array | def subtract_range_array(bed1,beds2,is_sorted=False):
"""subtract several ranges from a range, returns array1 - (all of array2)
:param bed1:
:param beds2: subtract all these beds from bed1
:param is_sorted: has it been sorted already? Default (False)
:type bed1: Bed or GenomicRange
:type beds2: Bed[] or G... | python | def subtract_range_array(bed1,beds2,is_sorted=False):
"""subtract several ranges from a range, returns array1 - (all of array2)
:param bed1:
:param beds2: subtract all these beds from bed1
:param is_sorted: has it been sorted already? Default (False)
:type bed1: Bed or GenomicRange
:type beds2: Bed[] or G... | [
"def",
"subtract_range_array",
"(",
"bed1",
",",
"beds2",
",",
"is_sorted",
"=",
"False",
")",
":",
"if",
"not",
"is_sorted",
":",
"beds2",
"=",
"sort_ranges",
"(",
"beds2",
")",
"output",
"=",
"[",
"bed1",
".",
"copy",
"(",
")",
"]",
"mink",
"=",
"0... | subtract several ranges from a range, returns array1 - (all of array2)
:param bed1:
:param beds2: subtract all these beds from bed1
:param is_sorted: has it been sorted already? Default (False)
:type bed1: Bed or GenomicRange
:type beds2: Bed[] or GenomicRange[]
:param is_sorted: bool | [
"subtract",
"several",
"ranges",
"from",
"a",
"range",
"returns",
"array1",
"-",
"(",
"all",
"of",
"array2",
")"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L177-L201 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | string_to_genomic_range | def string_to_genomic_range(rstring):
""" Convert a string to a genomic range
:param rstring: string representing a genomic range chr1:801-900
:type rstring:
:returns: object representing the string
:rtype: GenomicRange
"""
m = re.match('([^:]+):(\d+)-(\d+)',rstring)
if not m:
sys.stderr.write("ER... | python | def string_to_genomic_range(rstring):
""" Convert a string to a genomic range
:param rstring: string representing a genomic range chr1:801-900
:type rstring:
:returns: object representing the string
:rtype: GenomicRange
"""
m = re.match('([^:]+):(\d+)-(\d+)',rstring)
if not m:
sys.stderr.write("ER... | [
"def",
"string_to_genomic_range",
"(",
"rstring",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"'([^:]+):(\\d+)-(\\d+)'",
",",
"rstring",
")",
"if",
"not",
"m",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"ERROR: problem with range string \"",
"+",
"rstrin... | Convert a string to a genomic range
:param rstring: string representing a genomic range chr1:801-900
:type rstring:
:returns: object representing the string
:rtype: GenomicRange | [
"Convert",
"a",
"string",
"to",
"a",
"genomic",
"range"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L203-L214 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | sort_genomic_ranges | def sort_genomic_ranges(rngs):
"""sort multiple ranges"""
return sorted(rngs, key=lambda x: (x.chr, x.start, x.end)) | python | def sort_genomic_ranges(rngs):
"""sort multiple ranges"""
return sorted(rngs, key=lambda x: (x.chr, x.start, x.end)) | [
"def",
"sort_genomic_ranges",
"(",
"rngs",
")",
":",
"return",
"sorted",
"(",
"rngs",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"chr",
",",
"x",
".",
"start",
",",
"x",
".",
"end",
")",
")"
] | sort multiple ranges | [
"sort",
"multiple",
"ranges"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L216-L218 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | ranges_to_coverage | def ranges_to_coverage(rngs,threads=1):
"""take a list of ranges as an input
output a list of ranges and the coverage at each range
:param rngs: bed ranges on a single chromosome. not certain about that single chromosome requirement
:type rngs: GenomicRange[] or Bed[]
:param threads: Not currently being used
... | python | def ranges_to_coverage(rngs,threads=1):
"""take a list of ranges as an input
output a list of ranges and the coverage at each range
:param rngs: bed ranges on a single chromosome. not certain about that single chromosome requirement
:type rngs: GenomicRange[] or Bed[]
:param threads: Not currently being used
... | [
"def",
"ranges_to_coverage",
"(",
"rngs",
",",
"threads",
"=",
"1",
")",
":",
"def",
"do_chr",
"(",
"rngs",
")",
":",
"\"\"\"do one chromosomes sorting\n :param rngs:\n :type rngs: GenomicRange[]\n \"\"\"",
"#starts = sorted(range(0,len(rngs)), key=lambda x: rngs[x].start)... | take a list of ranges as an input
output a list of ranges and the coverage at each range
:param rngs: bed ranges on a single chromosome. not certain about that single chromosome requirement
:type rngs: GenomicRange[] or Bed[]
:param threads: Not currently being used
:type threads: int
:return: out is the n... | [
"take",
"a",
"list",
"of",
"ranges",
"as",
"an",
"input",
"output",
"a",
"list",
"of",
"ranges",
"and",
"the",
"coverage",
"at",
"each",
"range",
":",
"param",
"rngs",
":",
"bed",
"ranges",
"on",
"a",
"single",
"chromosome",
".",
"not",
"certain",
"abo... | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L220-L293 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | BedArrayStream.read_entry | def read_entry(self):
"""get the next value from the array, and set internal iterator so next call will be next entry
:return: The next GenomicRange entry
:rtype: GenomicRange
"""
if len(self.bedarray) <= self.curr_ind: return None
val = self.bedarray[self.curr_ind]
self.curr_ind += 1
r... | python | def read_entry(self):
"""get the next value from the array, and set internal iterator so next call will be next entry
:return: The next GenomicRange entry
:rtype: GenomicRange
"""
if len(self.bedarray) <= self.curr_ind: return None
val = self.bedarray[self.curr_ind]
self.curr_ind += 1
r... | [
"def",
"read_entry",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"bedarray",
")",
"<=",
"self",
".",
"curr_ind",
":",
"return",
"None",
"val",
"=",
"self",
".",
"bedarray",
"[",
"self",
".",
"curr_ind",
"]",
"self",
".",
"curr_ind",
"+=",
... | get the next value from the array, and set internal iterator so next call will be next entry
:return: The next GenomicRange entry
:rtype: GenomicRange | [
"get",
"the",
"next",
"value",
"from",
"the",
"array",
"and",
"set",
"internal",
"iterator",
"so",
"next",
"call",
"will",
"be",
"next",
"entry"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L307-L316 |
jason-weirather/py-seq-tools | seqtools/range/multi.py | BedStream.read_entry | def read_entry(self):
"""read the next bed entry from the stream"""
line = self.fh.readline()
if not line: return None
m = re.match('([^\t]+)\t(\d+)\t(\d+)\t*(.*)',line.rstrip())
if not m:
sys.stderr.write("ERROR: unknown line in bed format file\n"+line+"\n")
sys.exit()
g = GenomicRa... | python | def read_entry(self):
"""read the next bed entry from the stream"""
line = self.fh.readline()
if not line: return None
m = re.match('([^\t]+)\t(\d+)\t(\d+)\t*(.*)',line.rstrip())
if not m:
sys.stderr.write("ERROR: unknown line in bed format file\n"+line+"\n")
sys.exit()
g = GenomicRa... | [
"def",
"read_entry",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"fh",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"return",
"None",
"m",
"=",
"re",
".",
"match",
"(",
"'([^\\t]+)\\t(\\d+)\\t(\\d+)\\t*(.*)'",
",",
"line",
".",
"rstrip",
"... | read the next bed entry from the stream | [
"read",
"the",
"next",
"bed",
"entry",
"from",
"the",
"stream"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/range/multi.py#L334-L345 |
mitsei/dlkit | dlkit/json_/proxy/rules.py | ProxyCondition.set_http_request | def set_http_request(self, http_request):
"""Support the HTTPRequest ProxyConditionRecordType and checks for special effective agent ids"""
self._http_request = http_request
if 'HTTP_LTI_USER_ID' in http_request.META:
try:
authority = http_request.META['HTTP_LTI_TOOL_... | python | def set_http_request(self, http_request):
"""Support the HTTPRequest ProxyConditionRecordType and checks for special effective agent ids"""
self._http_request = http_request
if 'HTTP_LTI_USER_ID' in http_request.META:
try:
authority = http_request.META['HTTP_LTI_TOOL_... | [
"def",
"set_http_request",
"(",
"self",
",",
"http_request",
")",
":",
"self",
".",
"_http_request",
"=",
"http_request",
"if",
"'HTTP_LTI_USER_ID'",
"in",
"http_request",
".",
"META",
":",
"try",
":",
"authority",
"=",
"http_request",
".",
"META",
"[",
"'HTTP... | Support the HTTPRequest ProxyConditionRecordType and checks for special effective agent ids | [
"Support",
"the",
"HTTPRequest",
"ProxyConditionRecordType",
"and",
"checks",
"for",
"special",
"effective",
"agent",
"ids"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/proxy/rules.py#L358-L369 |
mitsei/dlkit | dlkit/primordium/locale/types/numeric_format.py | get_type_data | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
try:
return {
'authority': 'gnu.org',
'namespace': 'Basic Numeric Formats',
'identifier': name,
... | python | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
try:
return {
'authority': 'gnu.org',
'namespace': 'Basic Numeric Formats',
'identifier': name,
... | [
"def",
"get_type_data",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"try",
":",
"return",
"{",
"'authority'",
":",
"'gnu.org'",
",",
"'namespace'",
":",
"'Basic Numeric Formats'",
",",
"'identifier'",
":",
"name",
",",
"'domain'",
"... | Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type | [
"Return",
"dictionary",
"representation",
"of",
"type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/primordium/locale/types/numeric_format.py#L22-L42 |
anuragkumarak95/wordnet | wordnet/bin/paint.py | paint | def paint(str,color='r'):
'''Utility func, for printing colorful logs in console...
@args:
--
str : String to be modified.
color : color code to which the string will be formed. default is 'r'=RED
@returns:
--
str : final modified string with foreground color as per parameters.
''... | python | def paint(str,color='r'):
'''Utility func, for printing colorful logs in console...
@args:
--
str : String to be modified.
color : color code to which the string will be formed. default is 'r'=RED
@returns:
--
str : final modified string with foreground color as per parameters.
''... | [
"def",
"paint",
"(",
"str",
",",
"color",
"=",
"'r'",
")",
":",
"if",
"color",
"in",
"switcher",
":",
"str",
"=",
"switcher",
"[",
"color",
"]",
"+",
"str",
"+",
"colorama",
".",
"Style",
".",
"RESET_ALL",
"return",
"str"
] | Utility func, for printing colorful logs in console...
@args:
--
str : String to be modified.
color : color code to which the string will be formed. default is 'r'=RED
@returns:
--
str : final modified string with foreground color as per parameters. | [
"Utility",
"func",
"for",
"printing",
"colorful",
"logs",
"in",
"console",
"..."
] | train | https://github.com/anuragkumarak95/wordnet/blob/7aba239ddebb0971e9e76124890373b60a2573c8/wordnet/bin/paint.py#L18-L33 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LoggingSession.log | def log(self, content, content_type):
"""Logs an item.
This method is a shortcut to ``createLogEntry()``.
arg: content (object): the entry to log
arg: content_type (osid.type.Type): the type of this entry
which must be one of the types returned by
... | python | def log(self, content, content_type):
"""Logs an item.
This method is a shortcut to ``createLogEntry()``.
arg: content (object): the entry to log
arg: content_type (osid.type.Type): the type of this entry
which must be one of the types returned by
... | [
"def",
"log",
"(",
"self",
",",
"content",
",",
"content_type",
")",
":",
"if",
"content_type",
"not",
"in",
"self",
".",
"_content_types",
":",
"raise",
"errors",
".",
"Unsupported",
"(",
")",
"lefc",
"=",
"self",
".",
"_leas",
".",
"get_content_form_for_... | Logs an item.
This method is a shortcut to ``createLogEntry()``.
arg: content (object): the entry to log
arg: content_type (osid.type.Type): the type of this entry
which must be one of the types returned by
``LoggingManager.getContentTypes()``
rais... | [
"Logs",
"an",
"item",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L106-L129 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLookupSession.get_log_entry | def get_log_entry(self, log_entry_id):
"""Gets the ``LogEntry`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``LogEntry`` may have a
different ``Id`` than requested, such as the case where a
duplicate ``Id... | python | def get_log_entry(self, log_entry_id):
"""Gets the ``LogEntry`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``LogEntry`` may have a
different ``Id`` than requested, such as the case where a
duplicate ``Id... | [
"def",
"get_log_entry",
"(",
"self",
",",
"log_entry_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceLookupSession.get_resource",
"# NOTE: This implementation currently ignores plenary view",
"collection",
"=",
"JSONClientValidated",
"(",
"'logging'",
",",
... | Gets the ``LogEntry`` specified by its ``Id``.
In plenary mode, the exact ``Id`` is found or a ``NotFound``
results. Otherwise, the returned ``LogEntry`` may have a
different ``Id`` than requested, such as the case where a
duplicate ``Id`` was assigned to a ``LogEntry`` and retained for... | [
"Gets",
"the",
"LogEntry",
"specified",
"by",
"its",
"Id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L315-L343 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLookupSession.get_log_entries_by_ids | def get_log_entries_by_ids(self, log_entry_ids):
"""Gets a ``LogEntryList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the entries
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`... | python | def get_log_entries_by_ids(self, log_entry_ids):
"""Gets a ``LogEntryList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the entries
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`... | [
"def",
"get_log_entries_by_ids",
"(",
"self",
",",
"log_entry_ids",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceLookupSession.get_resources_by_ids",
"# NOTE: This implementation currently ignores plenary view",
"collection",
"=",
"JSONClientValidated",
"(",
"'... | Gets a ``LogEntryList`` corresponding to the given ``IdList``.
In plenary mode, the returned list contains all of the entries
specified in the ``Id`` list, in the order of the list,
including duplicates, or an error results if an ``Id`` in the
supplied list is not found or inaccessible.... | [
"Gets",
"a",
"LogEntryList",
"corresponding",
"to",
"the",
"given",
"IdList",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L346-L387 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLookupSession.get_log_entries_by_genus_type | def get_log_entries_by_genus_type(self, log_entry_genus_type):
"""Gets a ``LogEntryList`` corresponding to the given log entry genus ``Type`` which doe snot include entries of genus types derived form the specified ``Type``.
In plenary mode, the returned list contains all known entries or
an er... | python | def get_log_entries_by_genus_type(self, log_entry_genus_type):
"""Gets a ``LogEntryList`` corresponding to the given log entry genus ``Type`` which doe snot include entries of genus types derived form the specified ``Type``.
In plenary mode, the returned list contains all known entries or
an er... | [
"def",
"get_log_entries_by_genus_type",
"(",
"self",
",",
"log_entry_genus_type",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceLookupSession.get_resources_by_genus_type",
"# NOTE: This implementation currently ignores plenary view",
"collection",
"=",
"JSONClientVa... | Gets a ``LogEntryList`` corresponding to the given log entry genus ``Type`` which doe snot include entries of genus types derived form the specified ``Type``.
In plenary mode, the returned list contains all known entries or
an error results. Otherwise, the returned list may contain only
those e... | [
"Gets",
"a",
"LogEntryList",
"corresponding",
"to",
"the",
"given",
"log",
"entry",
"genus",
"Type",
"which",
"doe",
"snot",
"include",
"entries",
"of",
"genus",
"types",
"derived",
"form",
"the",
"specified",
"Type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L390-L416 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLookupSession.get_log_entries | def get_log_entries(self):
"""Gets all log entries.
In plenary mode, the returned list contains all known entries or
an error results. Otherwise, the returned list may contain only
those entries that are accessible through this session.
return: (osid.logging.LogEntryList) - a l... | python | def get_log_entries(self):
"""Gets all log entries.
In plenary mode, the returned list contains all known entries or
an error results. Otherwise, the returned list may contain only
those entries that are accessible through this session.
return: (osid.logging.LogEntryList) - a l... | [
"def",
"get_log_entries",
"(",
"self",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceLookupSession.get_resources",
"# NOTE: This implementation currently ignores plenary view",
"collection",
"=",
"JSONClientValidated",
"(",
"'logging'",
",",
"collection",
"=",... | Gets all log entries.
In plenary mode, the returned list contains all known entries or
an error results. Otherwise, the returned list may contain only
those entries that are accessible through this session.
return: (osid.logging.LogEntryList) - a list of log entries
raise: Ope... | [
"Gets",
"all",
"log",
"entries",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L597-L617 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryQuerySession.get_log_entries_by_query | def get_log_entries_by_query(self, log_entry_query):
"""Gets a list of log entries matching the given log entry query.
arg: log_entry_query (osid.logging.LogEntryQuery): the log
entry query
return: (osid.logging.LogEntryList) - the returned
``LogEntryList``
... | python | def get_log_entries_by_query(self, log_entry_query):
"""Gets a list of log entries matching the given log entry query.
arg: log_entry_query (osid.logging.LogEntryQuery): the log
entry query
return: (osid.logging.LogEntryList) - the returned
``LogEntryList``
... | [
"def",
"get_log_entries_by_query",
"(",
"self",
",",
"log_entry_query",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceQuerySession.get_resources_by_query",
"and_list",
"=",
"list",
"(",
")",
"or_list",
"=",
"list",
"(",
")",
"for",
"term",
"in",
... | Gets a list of log entries matching the given log entry query.
arg: log_entry_query (osid.logging.LogEntryQuery): the log
entry query
return: (osid.logging.LogEntryList) - the returned
``LogEntryList``
raise: NullArgument - ``log_entry_query`` is ``null``
... | [
"Gets",
"a",
"list",
"of",
"log",
"entries",
"matching",
"the",
"given",
"log",
"entry",
"query",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L737-L777 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.can_create_log_entry_with_record_types | def can_create_log_entry_with_record_types(self, log_entry_record_types):
"""Tests if this user can create a single ``LogEntry`` using the desired record types.
While ``LoggingManager.getLogEntryRecordTypes()`` can be used to
examine which records are supported, this method tests which
... | python | def can_create_log_entry_with_record_types(self, log_entry_record_types):
"""Tests if this user can create a single ``LogEntry`` using the desired record types.
While ``LoggingManager.getLogEntryRecordTypes()`` can be used to
examine which records are supported, this method tests which
... | [
"def",
"can_create_log_entry_with_record_types",
"(",
"self",
",",
"log_entry_record_types",
")",
":",
"# Implemented from template for",
"# osid.resource.BinAdminSession.can_create_bin_with_record_types",
"# NOTE: It is expected that real authentication hints will be",
"# handled in a service... | Tests if this user can create a single ``LogEntry`` using the desired record types.
While ``LoggingManager.getLogEntryRecordTypes()`` can be used to
examine which records are supported, this method tests which
record(s) are required for creating a specific ``LogEntry``.
Providing an emp... | [
"Tests",
"if",
"this",
"user",
"can",
"create",
"a",
"single",
"LogEntry",
"using",
"the",
"desired",
"record",
"types",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L881-L905 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.get_log_entry_form_for_create | def get_log_entry_form_for_create(self, log_entry_record_types):
"""Gets the log entry form for creating new log entries.
A new form should be requested for each create transaction.
arg: log_entry_record_types (osid.type.Type[]): array of log
entry record types
retur... | python | def get_log_entry_form_for_create(self, log_entry_record_types):
"""Gets the log entry form for creating new log entries.
A new form should be requested for each create transaction.
arg: log_entry_record_types (osid.type.Type[]): array of log
entry record types
retur... | [
"def",
"get_log_entry_form_for_create",
"(",
"self",
",",
"log_entry_record_types",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.get_resource_form_for_create_template",
"for",
"arg",
"in",
"log_entry_record_types",
":",
"if",
"not",
"isinstance... | Gets the log entry form for creating new log entries.
A new form should be requested for each create transaction.
arg: log_entry_record_types (osid.type.Type[]): array of log
entry record types
return: (osid.logging.LogEntryForm) - the log entry form
raise: NullArgu... | [
"Gets",
"the",
"log",
"entry",
"form",
"for",
"creating",
"new",
"log",
"entries",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L908-L943 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.create_log_entry | def create_log_entry(self, log_entry_form):
"""Creates a new ``LogEntry``.
arg: log_entry_form (osid.logging.LogEntryForm): the form for
this ``LogEntry``
return: (osid.logging.LogEntry) - the new ``LogEntry``
raise: IllegalState - ``log_entry_form`` already used in ... | python | def create_log_entry(self, log_entry_form):
"""Creates a new ``LogEntry``.
arg: log_entry_form (osid.logging.LogEntryForm): the form for
this ``LogEntry``
return: (osid.logging.LogEntry) - the new ``LogEntry``
raise: IllegalState - ``log_entry_form`` already used in ... | [
"def",
"create_log_entry",
"(",
"self",
",",
"log_entry_form",
")",
":",
"collection",
"=",
"JSONClientValidated",
"(",
"'logging'",
",",
"collection",
"=",
"'LogEntry'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
")",
"if",
"not",
"isinstance",
"(",
"log_e... | Creates a new ``LogEntry``.
arg: log_entry_form (osid.logging.LogEntryForm): the form for
this ``LogEntry``
return: (osid.logging.LogEntry) - the new ``LogEntry``
raise: IllegalState - ``log_entry_form`` already used in a
create transaction
raise: In... | [
"Creates",
"a",
"new",
"LogEntry",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L946-L991 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.update_log_entry | def update_log_entry(self, log_entry_form):
"""Updates an existing log entry.
arg: log_entry_form (osid.logging.LogEntryForm): the form
containing the elements to be updated
raise: IllegalState - ``log_entry_form`` already used in an
update transaction
... | python | def update_log_entry(self, log_entry_form):
"""Updates an existing log entry.
arg: log_entry_form (osid.logging.LogEntryForm): the form
containing the elements to be updated
raise: IllegalState - ``log_entry_form`` already used in an
update transaction
... | [
"def",
"update_log_entry",
"(",
"self",
",",
"log_entry_form",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.update_resource_template",
"collection",
"=",
"JSONClientValidated",
"(",
"'logging'",
",",
"collection",
"=",
"'LogEntry'",
",",
... | Updates an existing log entry.
arg: log_entry_form (osid.logging.LogEntryForm): the form
containing the elements to be updated
raise: IllegalState - ``log_entry_form`` already used in an
update transaction
raise: InvalidArgument - the form contains an invali... | [
"Updates",
"an",
"existing",
"log",
"entry",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1050-L1090 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.delete_log_entry | def delete_log_entry(self, log_entry_id):
"""Deletes a ``LogEntry``.
arg: log_entry_id (osid.id.Id): the ``Id`` of the
``log_entry_id`` to remove
raise: NotFound - ``log_entry_id`` not found
raise: NullArgument - ``log_entry_id`` is ``null``
raise: Operatio... | python | def delete_log_entry(self, log_entry_id):
"""Deletes a ``LogEntry``.
arg: log_entry_id (osid.id.Id): the ``Id`` of the
``log_entry_id`` to remove
raise: NotFound - ``log_entry_id`` not found
raise: NullArgument - ``log_entry_id`` is ``null``
raise: Operatio... | [
"def",
"delete_log_entry",
"(",
"self",
",",
"log_entry_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.delete_resource_template",
"collection",
"=",
"JSONClientValidated",
"(",
"'logging'",
",",
"collection",
"=",
"'LogEntry'",
",",
"r... | Deletes a ``LogEntry``.
arg: log_entry_id (osid.id.Id): the ``Id`` of the
``log_entry_id`` to remove
raise: NotFound - ``log_entry_id`` not found
raise: NullArgument - ``log_entry_id`` is ``null``
raise: OperationFailed - unable to complete request
raise: ... | [
"Deletes",
"a",
"LogEntry",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1115-L1139 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryAdminSession.alias_log_entry | def alias_log_entry(self, log_entry_id, alias_id):
"""Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility.
The primary ``Id`` of the ``LogEntry`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to... | python | def alias_log_entry(self, log_entry_id, alias_id):
"""Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility.
The primary ``Id`` of the ``LogEntry`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to... | [
"def",
"alias_log_entry",
"(",
"self",
",",
"log_entry_id",
",",
"alias_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceAdminSession.alias_resources_template",
"self",
".",
"_alias_id",
"(",
"primary_id",
"=",
"log_entry_id",
",",
"equivalent_id",
... | Adds an ``Id`` to a ``LogEntry`` for the purpose of creating compatibility.
The primary ``Id`` of the ``LogEntry`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to another log entry, it is
reassigned to the given log ... | [
"Adds",
"an",
"Id",
"to",
"a",
"LogEntry",
"for",
"the",
"purpose",
"of",
"creating",
"compatibility",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1160-L1181 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLogSession.get_log_entry_ids_by_log | def get_log_entry_ids_by_log(self, log_id):
"""Gets the list of ``LogEntry`` ``Ids`` associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.id.IdList) - list of related logEntry ``Ids``
raise: NotFound - ``log_id`` is not found
raise: NullAr... | python | def get_log_entry_ids_by_log(self, log_id):
"""Gets the list of ``LogEntry`` ``Ids`` associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.id.IdList) - list of related logEntry ``Ids``
raise: NotFound - ``log_id`` is not found
raise: NullAr... | [
"def",
"get_log_entry_ids_by_log",
"(",
"self",
",",
"log_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinSession.get_resource_ids_by_bin",
"id_list",
"=",
"[",
"]",
"for",
"log_entry",
"in",
"self",
".",
"get_log_entries_by_log",
"(",
"log_ids... | Gets the list of ``LogEntry`` ``Ids`` associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.id.IdList) - list of related logEntry ``Ids``
raise: NotFound - ``log_id`` is not found
raise: NullArgument - ``log_id`` is ``null``
raise: Operati... | [
"Gets",
"the",
"list",
"of",
"LogEntry",
"Ids",
"associated",
"with",
"a",
"Log",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1256-L1273 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLogSession.get_log_entries_by_log | def get_log_entries_by_log(self, log_id):
"""Gets the list of log entries associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.logging.LogEntryList) - list of related logEntry
raise: NotFound - ``log_id`` is not found
raise: NullArgument - ... | python | def get_log_entries_by_log(self, log_id):
"""Gets the list of log entries associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.logging.LogEntryList) - list of related logEntry
raise: NotFound - ``log_id`` is not found
raise: NullArgument - ... | [
"def",
"get_log_entries_by_log",
"(",
"self",
",",
"log_id",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinSession.get_resources_by_bin",
"mgr",
"=",
"self",
".",
"_get_provider_manager",
"(",
"'LOGGING'",
",",
"local",
"=",
"True",
")",
"lookup... | Gets the list of log entries associated with a ``Log``.
arg: log_id (osid.id.Id): ``Id`` of a ``Log``
return: (osid.logging.LogEntryList) - list of related logEntry
raise: NotFound - ``log_id`` is not found
raise: NullArgument - ``log_id`` is ``null``
raise: OperationFaile... | [
"Gets",
"the",
"list",
"of",
"log",
"entries",
"associated",
"with",
"a",
"Log",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1276-L1293 |
mitsei/dlkit | dlkit/json_/logging_/sessions.py | LogEntryLogSession.get_log_entrie_by_log | def get_log_entrie_by_log(self, log_ids):
"""Gets the list of log entries corresponding to a list of ``Log``.
arg: log_ids (osid.id.IdList): list of log ``Ids``
return: (osid.logging.LogEntryList) - list of log entries
raise: NullArgument - ``log_ids`` is ``null``
raise: Op... | python | def get_log_entrie_by_log(self, log_ids):
"""Gets the list of log entries corresponding to a list of ``Log``.
arg: log_ids (osid.id.IdList): list of log ``Ids``
return: (osid.logging.LogEntryList) - list of log entries
raise: NullArgument - ``log_ids`` is ``null``
raise: Op... | [
"def",
"get_log_entrie_by_log",
"(",
"self",
",",
"log_ids",
")",
":",
"# Implemented from template for",
"# osid.resource.ResourceBinSession.get_resources_by_bin",
"mgr",
"=",
"self",
".",
"_get_provider_manager",
"(",
"'LOGGING'",
",",
"local",
"=",
"True",
")",
"lookup... | Gets the list of log entries corresponding to a list of ``Log``.
arg: log_ids (osid.id.IdList): list of log ``Ids``
return: (osid.logging.LogEntryList) - list of log entries
raise: NullArgument - ``log_ids`` is ``null``
raise: OperationFailed - unable to complete request
ra... | [
"Gets",
"the",
"list",
"of",
"log",
"entries",
"corresponding",
"to",
"a",
"list",
"of",
"Log",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/logging_/sessions.py#L1315-L1331 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.