repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
thespacedoctor/qubits | qubits/datagenerator.py | generate_single_kcorrection_polynomial | def generate_single_kcorrection_polynomial(
log,
model,
pathToOutputDirectory,
redshift,
ffilter,
restFrameFilter,
kCorPolyOrder=3,
kCorMinimumDataPoints=3,
plot=False):
"""
*Given a the k-correction lightcurve, convert it to a polynomial, ... | python | def generate_single_kcorrection_polynomial(
log,
model,
pathToOutputDirectory,
redshift,
ffilter,
restFrameFilter,
kCorPolyOrder=3,
kCorMinimumDataPoints=3,
plot=False):
"""
*Given a the k-correction lightcurve, convert it to a polynomial, ... | [
"def",
"generate_single_kcorrection_polynomial",
"(",
"log",
",",
"model",
",",
"pathToOutputDirectory",
",",
"redshift",
",",
"ffilter",
",",
"restFrameFilter",
",",
"kCorPolyOrder",
"=",
"3",
",",
"kCorMinimumDataPoints",
"=",
"3",
",",
"plot",
"=",
"False",
")"... | *Given a the k-correction lightcurve, convert it to a polynomial, plot if requested and dump to a separate file.*
**Key Arguments:**
- ``log`` -- logger
- ``model`` -- the transient model name
- ``pathToOutputDirectory`` -- path to the output directory (provided by the user)
- ``red... | [
"*",
"Given",
"a",
"the",
"k",
"-",
"correction",
"lightcurve",
"convert",
"it",
"to",
"a",
"polynomial",
"plot",
"if",
"requested",
"and",
"dump",
"to",
"a",
"separate",
"file",
".",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L875-L997 |
thespacedoctor/qubits | qubits/datagenerator.py | generate_kcorrection_polynomial_database | def generate_kcorrection_polynomial_database(
log,
restFrameFilter,
pathToOutputDirectory,
kCorPolyOrder=3,
kCorMinimumDataPoints=3,
redshiftResolution=0.1,
redshiftLower=0.0,
redshiftUpper=1.0,
plot=False):
"""
*Generate the Kg* k-correcti... | python | def generate_kcorrection_polynomial_database(
log,
restFrameFilter,
pathToOutputDirectory,
kCorPolyOrder=3,
kCorMinimumDataPoints=3,
redshiftResolution=0.1,
redshiftLower=0.0,
redshiftUpper=1.0,
plot=False):
"""
*Generate the Kg* k-correcti... | [
"def",
"generate_kcorrection_polynomial_database",
"(",
"log",
",",
"restFrameFilter",
",",
"pathToOutputDirectory",
",",
"kCorPolyOrder",
"=",
"3",
",",
"kCorMinimumDataPoints",
"=",
"3",
",",
"redshiftResolution",
"=",
"0.1",
",",
"redshiftLower",
"=",
"0.0",
",",
... | *Generate the Kg* k-correction polynoimal for a range of redshifts given a list of spectra*
**Key Arguments:**
- ``log`` -- logger
- ``restFrameFilter`` -- the observed frame filter with which to calculate k-corrections with
- ``pathToOutputDirectory`` -- path to the output directory (provi... | [
"*",
"Generate",
"the",
"Kg",
"*",
"k",
"-",
"correction",
"polynoimal",
"for",
"a",
"range",
"of",
"redshifts",
"given",
"a",
"list",
"of",
"spectra",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L1003-L1065 |
bsmithyman/galoshes | galoshes/meta.py | BaseSCCache.clearCache | def clearCache(self):
'Clears cached items (e.g., when model is reset).'
for attr in self.cacheItems:
if hasattr(self, attr):
delattr(self, attr) | python | def clearCache(self):
'Clears cached items (e.g., when model is reset).'
for attr in self.cacheItems:
if hasattr(self, attr):
delattr(self, attr) | [
"def",
"clearCache",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"self",
".",
"cacheItems",
":",
"if",
"hasattr",
"(",
"self",
",",
"attr",
")",
":",
"delattr",
"(",
"self",
",",
"attr",
")"
] | Clears cached items (e.g., when model is reset). | [
"Clears",
"cached",
"items",
"(",
"e",
".",
"g",
".",
"when",
"model",
"is",
"reset",
")",
"."
] | train | https://github.com/bsmithyman/galoshes/blob/fb47b574f63b97a736999fc6adaf47f039df4e24/galoshes/meta.py#L231-L235 |
unixorn/haze | haze/cli/conductor.py | hazeDriver | def hazeDriver():
"""
Process the command line arguments and run the appropriate haze subcommand.
We want to be able to do git-style handoffs to subcommands where if we
do `haze aws foo bar` and the executable haze-aws-foo exists, we'll call
it with the argument bar.
We deliberately don't do anything with... | python | def hazeDriver():
"""
Process the command line arguments and run the appropriate haze subcommand.
We want to be able to do git-style handoffs to subcommands where if we
do `haze aws foo bar` and the executable haze-aws-foo exists, we'll call
it with the argument bar.
We deliberately don't do anything with... | [
"def",
"hazeDriver",
"(",
")",
":",
"try",
":",
"(",
"command",
",",
"args",
")",
"=",
"findSubCommand",
"(",
"sys",
".",
"argv",
")",
"# If we can't construct a subcommand from sys.argv, it'll still be able",
"# to find this haze driver script, and re-running ourself isn't u... | Process the command line arguments and run the appropriate haze subcommand.
We want to be able to do git-style handoffs to subcommands where if we
do `haze aws foo bar` and the executable haze-aws-foo exists, we'll call
it with the argument bar.
We deliberately don't do anything with the arguments other than ... | [
"Process",
"the",
"command",
"line",
"arguments",
"and",
"run",
"the",
"appropriate",
"haze",
"subcommand",
"."
] | train | https://github.com/unixorn/haze/blob/77692b18e6574ac356e3e16659b96505c733afff/haze/cli/conductor.py#L29-L52 |
klmitch/aversion | aversion.py | quoted_split | def quoted_split(string, sep, quotes='"'):
"""
Split a string on the given separation character, but respecting
double-quoted sections of the string. Returns an iterator.
:param string: The string to split.
:param sep: The character separating sections of the string.
:param quotes: A string sp... | python | def quoted_split(string, sep, quotes='"'):
"""
Split a string on the given separation character, but respecting
double-quoted sections of the string. Returns an iterator.
:param string: The string to split.
:param sep: The character separating sections of the string.
:param quotes: A string sp... | [
"def",
"quoted_split",
"(",
"string",
",",
"sep",
",",
"quotes",
"=",
"'\"'",
")",
":",
"# Initialize the algorithm",
"start",
"=",
"None",
"escape",
"=",
"False",
"quote",
"=",
"False",
"# Walk through the string",
"for",
"i",
",",
"c",
"in",
"enumerate",
"... | Split a string on the given separation character, but respecting
double-quoted sections of the string. Returns an iterator.
:param string: The string to split.
:param sep: The character separating sections of the string.
:param quotes: A string specifying all legal quote characters.
:returns: An ... | [
"Split",
"a",
"string",
"on",
"the",
"given",
"separation",
"character",
"but",
"respecting",
"double",
"-",
"quoted",
"sections",
"of",
"the",
"string",
".",
"Returns",
"an",
"iterator",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L29-L75 |
klmitch/aversion | aversion.py | parse_ctype | def parse_ctype(ctype):
"""
Parse a content type.
:param ctype: The content type, with corresponding parameters.
:returns: A tuple of the content type and a dictionary containing
the content type parameters. The content type will
additionally be available in the dictionary... | python | def parse_ctype(ctype):
"""
Parse a content type.
:param ctype: The content type, with corresponding parameters.
:returns: A tuple of the content type and a dictionary containing
the content type parameters. The content type will
additionally be available in the dictionary... | [
"def",
"parse_ctype",
"(",
"ctype",
")",
":",
"result_ctype",
"=",
"None",
"result",
"=",
"{",
"}",
"for",
"part",
"in",
"quoted_split",
"(",
"ctype",
",",
"';'",
")",
":",
"# Extract the content type first",
"if",
"result_ctype",
"is",
"None",
":",
"result_... | Parse a content type.
:param ctype: The content type, with corresponding parameters.
:returns: A tuple of the content type and a dictionary containing
the content type parameters. The content type will
additionally be available in the dictionary as the '_'
key. | [
"Parse",
"a",
"content",
"type",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L98-L134 |
klmitch/aversion | aversion.py | _match_mask | def _match_mask(mask, ctype):
"""
Determine if a content type mask matches a given content type.
:param mask: The content type mask, taken from the Accept
header.
:param ctype: The content type to match to the mask.
"""
# Handle the simple cases first
if '*' not in mask:
... | python | def _match_mask(mask, ctype):
"""
Determine if a content type mask matches a given content type.
:param mask: The content type mask, taken from the Accept
header.
:param ctype: The content type to match to the mask.
"""
# Handle the simple cases first
if '*' not in mask:
... | [
"def",
"_match_mask",
"(",
"mask",
",",
"ctype",
")",
":",
"# Handle the simple cases first",
"if",
"'*'",
"not",
"in",
"mask",
":",
"return",
"ctype",
"==",
"mask",
"elif",
"mask",
"==",
"'*/*'",
":",
"return",
"True",
"elif",
"not",
"mask",
".",
"endswit... | Determine if a content type mask matches a given content type.
:param mask: The content type mask, taken from the Accept
header.
:param ctype: The content type to match to the mask. | [
"Determine",
"if",
"a",
"content",
"type",
"mask",
"matches",
"a",
"given",
"content",
"type",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L137-L156 |
klmitch/aversion | aversion.py | best_match | def best_match(requested, allowed):
"""
Determine the best content type to use for the request.
:param ctypes: A list of the available content types.
:returns: A tuple of the best match content type and the
parameters for that content type.
"""
requested = [parse_ctype(ctype) fo... | python | def best_match(requested, allowed):
"""
Determine the best content type to use for the request.
:param ctypes: A list of the available content types.
:returns: A tuple of the best match content type and the
parameters for that content type.
"""
requested = [parse_ctype(ctype) fo... | [
"def",
"best_match",
"(",
"requested",
",",
"allowed",
")",
":",
"requested",
"=",
"[",
"parse_ctype",
"(",
"ctype",
")",
"for",
"ctype",
"in",
"quoted_split",
"(",
"requested",
",",
"','",
")",
"]",
"best_q",
"=",
"-",
"1",
"best_ctype",
"=",
"''",
"b... | Determine the best content type to use for the request.
:param ctypes: A list of the available content types.
:returns: A tuple of the best match content type and the
parameters for that content type. | [
"Determine",
"the",
"best",
"content",
"type",
"to",
"use",
"for",
"the",
"request",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L159-L202 |
klmitch/aversion | aversion.py | _set_key | def _set_key(log_prefix, result_dict, key, value, desc="parameter"):
"""
Helper to set a key value in a dictionary. This function issues a
warning if the key has already been set, and issues a warning and
returns without setting the value if the value is not surrounded
by parentheses. This is used... | python | def _set_key(log_prefix, result_dict, key, value, desc="parameter"):
"""
Helper to set a key value in a dictionary. This function issues a
warning if the key has already been set, and issues a warning and
returns without setting the value if the value is not surrounded
by parentheses. This is used... | [
"def",
"_set_key",
"(",
"log_prefix",
",",
"result_dict",
",",
"key",
",",
"value",
",",
"desc",
"=",
"\"parameter\"",
")",
":",
"if",
"key",
"in",
"result_dict",
":",
"LOG",
".",
"warn",
"(",
"\"%s: Duplicate value for %s %r\"",
"%",
"(",
"log_prefix",
",",... | Helper to set a key value in a dictionary. This function issues a
warning if the key has already been set, and issues a warning and
returns without setting the value if the value is not surrounded
by parentheses. This is used to eliminate duplicated code from
the rule parsers below.
:param log_pr... | [
"Helper",
"to",
"set",
"a",
"key",
"value",
"in",
"a",
"dictionary",
".",
"This",
"function",
"issues",
"a",
"warning",
"if",
"the",
"key",
"has",
"already",
"been",
"set",
"and",
"issues",
"a",
"warning",
"and",
"returns",
"without",
"setting",
"the",
"... | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L309-L344 |
klmitch/aversion | aversion.py | _parse_version_rule | def _parse_version_rule(loader, version, verspec):
"""
Parse a version rule. The first token is the name of the
application implementing that API version. The remaining tokens
are key="quoted value" pairs that specify parameters; these
parameters are ignored by AVersion, but may be used by the
... | python | def _parse_version_rule(loader, version, verspec):
"""
Parse a version rule. The first token is the name of the
application implementing that API version. The remaining tokens
are key="quoted value" pairs that specify parameters; these
parameters are ignored by AVersion, but may be used by the
... | [
"def",
"_parse_version_rule",
"(",
"loader",
",",
"version",
",",
"verspec",
")",
":",
"result",
"=",
"dict",
"(",
"name",
"=",
"version",
",",
"params",
"=",
"{",
"}",
")",
"for",
"token",
"in",
"quoted_split",
"(",
"verspec",
",",
"' '",
",",
"quotes... | Parse a version rule. The first token is the name of the
application implementing that API version. The remaining tokens
are key="quoted value" pairs that specify parameters; these
parameters are ignored by AVersion, but may be used by the
application.
:param loader: An object with a get_app() me... | [
"Parse",
"a",
"version",
"rule",
".",
"The",
"first",
"token",
"is",
"the",
"name",
"of",
"the",
"application",
"implementing",
"that",
"API",
"version",
".",
"The",
"remaining",
"tokens",
"are",
"key",
"=",
"quoted",
"value",
"pairs",
"that",
"specify",
"... | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L347-L385 |
klmitch/aversion | aversion.py | _parse_alias_rule | def _parse_alias_rule(alias, alias_spec):
"""
Parse an alias rule. The first token is the canonical name of the
version. The remaining tokens are key="quoted value" pairs that
specify parameters; these parameters are ignored by AVersion, but
may be used by the application.
:param alias: The a... | python | def _parse_alias_rule(alias, alias_spec):
"""
Parse an alias rule. The first token is the canonical name of the
version. The remaining tokens are key="quoted value" pairs that
specify parameters; these parameters are ignored by AVersion, but
may be used by the application.
:param alias: The a... | [
"def",
"_parse_alias_rule",
"(",
"alias",
",",
"alias_spec",
")",
":",
"result",
"=",
"dict",
"(",
"alias",
"=",
"alias",
",",
"params",
"=",
"{",
"}",
")",
"for",
"token",
"in",
"quoted_split",
"(",
"alias_spec",
",",
"' '",
",",
"quotes",
"=",
"'\"\\... | Parse an alias rule. The first token is the canonical name of the
version. The remaining tokens are key="quoted value" pairs that
specify parameters; these parameters are ignored by AVersion, but
may be used by the application.
:param alias: The alias name.
:param alias_spec: The alias text, desc... | [
"Parse",
"an",
"alias",
"rule",
".",
"The",
"first",
"token",
"is",
"the",
"canonical",
"name",
"of",
"the",
"version",
".",
"The",
"remaining",
"tokens",
"are",
"key",
"=",
"quoted",
"value",
"pairs",
"that",
"specify",
"parameters",
";",
"these",
"parame... | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L388-L424 |
klmitch/aversion | aversion.py | _parse_type_rule | def _parse_type_rule(ctype, typespec):
"""
Parse a content type rule. Unlike the other rules, content type
rules are more complex, since both selected content type and API
version must be expressed by one rule. The rule is split on
whitespace, then the components beginning with "type:" and
"ve... | python | def _parse_type_rule(ctype, typespec):
"""
Parse a content type rule. Unlike the other rules, content type
rules are more complex, since both selected content type and API
version must be expressed by one rule. The rule is split on
whitespace, then the components beginning with "type:" and
"ve... | [
"def",
"_parse_type_rule",
"(",
"ctype",
",",
"typespec",
")",
":",
"params",
"=",
"{",
"'param'",
":",
"{",
"}",
"}",
"for",
"token",
"in",
"quoted_split",
"(",
"typespec",
",",
"' '",
",",
"quotes",
"=",
"'\"\\''",
")",
":",
"if",
"not",
"token",
"... | Parse a content type rule. Unlike the other rules, content type
rules are more complex, since both selected content type and API
version must be expressed by one rule. The rule is split on
whitespace, then the components beginning with "type:" and
"version:" are selected; in both cases, the text follo... | [
"Parse",
"a",
"content",
"type",
"rule",
".",
"Unlike",
"the",
"other",
"rules",
"content",
"type",
"rules",
"are",
"more",
"complex",
"since",
"both",
"selected",
"content",
"type",
"and",
"API",
"version",
"must",
"be",
"expressed",
"by",
"one",
"rule",
... | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L427-L475 |
klmitch/aversion | aversion.py | Result.set_ctype | def set_ctype(self, ctype, orig_ctype=None):
"""
Set the selected content type. Will not override the value of
the content type if that has already been determined.
:param ctype: The content type string to set.
:param orig_ctype: The original content type, as found in the
... | python | def set_ctype(self, ctype, orig_ctype=None):
"""
Set the selected content type. Will not override the value of
the content type if that has already been determined.
:param ctype: The content type string to set.
:param orig_ctype: The original content type, as found in the
... | [
"def",
"set_ctype",
"(",
"self",
",",
"ctype",
",",
"orig_ctype",
"=",
"None",
")",
":",
"if",
"self",
".",
"ctype",
"is",
"None",
":",
"self",
".",
"ctype",
"=",
"ctype",
"self",
".",
"orig_ctype",
"=",
"orig_ctype"
] | Set the selected content type. Will not override the value of
the content type if that has already been determined.
:param ctype: The content type string to set.
:param orig_ctype: The original content type, as found in the
configuration. | [
"Set",
"the",
"selected",
"content",
"type",
".",
"Will",
"not",
"override",
"the",
"value",
"of",
"the",
"content",
"type",
"if",
"that",
"has",
"already",
"been",
"determined",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L293-L306 |
klmitch/aversion | aversion.py | AVersion._process | def _process(self, request, result=None):
"""
Process the rules for the request.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. If
None, one will be allocated.
:returns: A Result object, co... | python | def _process(self, request, result=None):
"""
Process the rules for the request.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. If
None, one will be allocated.
:returns: A Result object, co... | [
"def",
"_process",
"(",
"self",
",",
"request",
",",
"result",
"=",
"None",
")",
":",
"# Allocate a result and process all the rules",
"result",
"=",
"result",
"if",
"result",
"is",
"not",
"None",
"else",
"Result",
"(",
")",
"self",
".",
"_proc_uri",
"(",
"r... | Process the rules for the request.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. If
None, one will be allocated.
:returns: A Result object, containing the selected version and
content ty... | [
"Process",
"the",
"rules",
"for",
"the",
"request",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L640-L658 |
klmitch/aversion | aversion.py | AVersion._proc_uri | def _proc_uri(self, request, result):
"""
Process the URI rules for the request. Both the desired API
version and desired content type can be determined from those
rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the... | python | def _proc_uri(self, request, result):
"""
Process the URI rules for the request. Both the desired API
version and desired content type can be determined from those
rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the... | [
"def",
"_proc_uri",
"(",
"self",
",",
"request",
",",
"result",
")",
":",
"if",
"result",
":",
"# Result has already been fully determined",
"return",
"# First, determine the version based on the URI prefix",
"for",
"prefix",
",",
"version",
"in",
"self",
".",
"uris",
... | Process the URI rules for the request. Both the desired API
version and desired content type can be determined from those
rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. | [
"Process",
"the",
"URI",
"rules",
"for",
"the",
"request",
".",
"Both",
"the",
"desired",
"API",
"version",
"and",
"desired",
"content",
"type",
"can",
"be",
"determined",
"from",
"those",
"rules",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L660-L694 |
klmitch/aversion | aversion.py | AVersion._proc_ctype_header | def _proc_ctype_header(self, request, result):
"""
Process the Content-Type header rules for the request. Only
the desired API version can be determined from those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results... | python | def _proc_ctype_header(self, request, result):
"""
Process the Content-Type header rules for the request. Only
the desired API version can be determined from those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results... | [
"def",
"_proc_ctype_header",
"(",
"self",
",",
"request",
",",
"result",
")",
":",
"if",
"result",
":",
"# Result has already been fully determined",
"return",
"try",
":",
"ctype",
"=",
"request",
".",
"headers",
"[",
"'content-type'",
"]",
"except",
"KeyError",
... | Process the Content-Type header rules for the request. Only
the desired API version can be determined from those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. | [
"Process",
"the",
"Content",
"-",
"Type",
"header",
"rules",
"for",
"the",
"request",
".",
"Only",
"the",
"desired",
"API",
"version",
"can",
"be",
"determined",
"from",
"those",
"rules",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L696-L734 |
klmitch/aversion | aversion.py | AVersion._proc_accept_header | def _proc_accept_header(self, request, result):
"""
Process the Accept header rules for the request. Both the
desired API version and content type can be determined from
those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object ... | python | def _proc_accept_header(self, request, result):
"""
Process the Accept header rules for the request. Both the
desired API version and content type can be determined from
those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object ... | [
"def",
"_proc_accept_header",
"(",
"self",
",",
"request",
",",
"result",
")",
":",
"if",
"result",
":",
"# Result has already been fully determined",
"return",
"try",
":",
"accept",
"=",
"request",
".",
"headers",
"[",
"'accept'",
"]",
"except",
"KeyError",
":"... | Process the Accept header rules for the request. Both the
desired API version and content type can be determined from
those rules.
:param request: The Request object provided by WebOb.
:param result: The Result object to store the results in. | [
"Process",
"the",
"Accept",
"header",
"rules",
"for",
"the",
"request",
".",
"Both",
"the",
"desired",
"API",
"version",
"and",
"content",
"type",
"can",
"be",
"determined",
"from",
"those",
"rules",
"."
] | train | https://github.com/klmitch/aversion/blob/90ca68e7d6426a77db8a926171f8d3bbeb00ee4c/aversion.py#L736-L770 |
andrewjsledge/django-hash-filter | django_hash_filter/templatetags/__init__.py | get_available_hashes | def get_available_hashes():
"""
Returns a tuple of the available hashes
"""
if sys.version_info >= (3,2):
return hashlib.algorithms_available
elif sys.version_info >= (2,7) and sys.version_info < (3,0):
return hashlib.algorithms
else:
return 'md5', 'sha1', 'sha224', 'sha2... | python | def get_available_hashes():
"""
Returns a tuple of the available hashes
"""
if sys.version_info >= (3,2):
return hashlib.algorithms_available
elif sys.version_info >= (2,7) and sys.version_info < (3,0):
return hashlib.algorithms
else:
return 'md5', 'sha1', 'sha224', 'sha2... | [
"def",
"get_available_hashes",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"2",
")",
":",
"return",
"hashlib",
".",
"algorithms_available",
"elif",
"sys",
".",
"version_info",
">=",
"(",
"2",
",",
"7",
")",
"and",
"sys",
".",
... | Returns a tuple of the available hashes | [
"Returns",
"a",
"tuple",
"of",
"the",
"available",
"hashes"
] | train | https://github.com/andrewjsledge/django-hash-filter/blob/ea90b2903938e0733d3abfafed308a8d041d9fe7/django_hash_filter/templatetags/__init__.py#L8-L17 |
fedora-infra/fmn.lib | fmn/lib/defaults.py | create_defaults_for | def create_defaults_for(session, user, only_for=None, detail_values=None):
""" Create a sizable amount of defaults for a new user. """
detail_values = detail_values or {}
if not user.openid.endswith('.fedoraproject.org'):
log.warn("New user not from fedoraproject.org. No defaults set.")
r... | python | def create_defaults_for(session, user, only_for=None, detail_values=None):
""" Create a sizable amount of defaults for a new user. """
detail_values = detail_values or {}
if not user.openid.endswith('.fedoraproject.org'):
log.warn("New user not from fedoraproject.org. No defaults set.")
r... | [
"def",
"create_defaults_for",
"(",
"session",
",",
"user",
",",
"only_for",
"=",
"None",
",",
"detail_values",
"=",
"None",
")",
":",
"detail_values",
"=",
"detail_values",
"or",
"{",
"}",
"if",
"not",
"user",
".",
"openid",
".",
"endswith",
"(",
"'.fedora... | Create a sizable amount of defaults for a new user. | [
"Create",
"a",
"sizable",
"amount",
"of",
"defaults",
"for",
"a",
"new",
"user",
"."
] | train | https://github.com/fedora-infra/fmn.lib/blob/3120725556153d07c1809530f0fadcf250439110/fmn/lib/defaults.py#L219-L317 |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/models.py | SectionManager.get_queryset | def get_queryset(self): # DROP_WITH_DJANGO15
"""Use the same ordering as TreeManager"""
args = (self.model._mptt_meta.tree_id_attr,
self.model._mptt_meta.left_attr)
method = 'get_query_set' if django.VERSION < (1, 6) else 'get_queryset'
return getattr(super(SectionManag... | python | def get_queryset(self): # DROP_WITH_DJANGO15
"""Use the same ordering as TreeManager"""
args = (self.model._mptt_meta.tree_id_attr,
self.model._mptt_meta.left_attr)
method = 'get_query_set' if django.VERSION < (1, 6) else 'get_queryset'
return getattr(super(SectionManag... | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"# DROP_WITH_DJANGO15",
"args",
"=",
"(",
"self",
".",
"model",
".",
"_mptt_meta",
".",
"tree_id_attr",
",",
"self",
".",
"model",
".",
"_mptt_meta",
".",
"left_attr",
")",
"method",
"=",
"'get_query_set'",
"if",... | Use the same ordering as TreeManager | [
"Use",
"the",
"same",
"ordering",
"as",
"TreeManager"
] | train | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/models.py#L23-L29 |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/models.py | BaseSection.item_related_name | def item_related_name(self):
"""
The ManyToMany field on the item class pointing to this class.
If there is more than one field, this value will be None.
"""
if not hasattr(self, '_item_related_name'):
many_to_many_rels = \
get_section_many_to_many_re... | python | def item_related_name(self):
"""
The ManyToMany field on the item class pointing to this class.
If there is more than one field, this value will be None.
"""
if not hasattr(self, '_item_related_name'):
many_to_many_rels = \
get_section_many_to_many_re... | [
"def",
"item_related_name",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_item_related_name'",
")",
":",
"many_to_many_rels",
"=",
"get_section_many_to_many_relations",
"(",
"self",
".",
"__class__",
")",
"if",
"len",
"(",
"many_to_many_rels"... | The ManyToMany field on the item class pointing to this class.
If there is more than one field, this value will be None. | [
"The",
"ManyToMany",
"field",
"on",
"the",
"item",
"class",
"pointing",
"to",
"this",
"class",
"."
] | train | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/models.py#L92-L105 |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/models.py | BaseSection.add_item | def add_item(self, item, field_name=None):
"""
Add the item to the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined.
"""
field_name = self._choose_field_name(field_name)
related_manager ... | python | def add_item(self, item, field_name=None):
"""
Add the item to the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined.
"""
field_name = self._choose_field_name(field_name)
related_manager ... | [
"def",
"add_item",
"(",
"self",
",",
"item",
",",
"field_name",
"=",
"None",
")",
":",
"field_name",
"=",
"self",
".",
"_choose_field_name",
"(",
"field_name",
")",
"related_manager",
"=",
"getattr",
"(",
"item",
",",
"field_name",
")",
"related_manager",
".... | Add the item to the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined. | [
"Add",
"the",
"item",
"to",
"the",
"specified",
"section",
"."
] | train | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/models.py#L131-L140 |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/models.py | BaseSection.remove_item | def remove_item(self, item, field_name=None):
"""
Remove the item from the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined.
"""
field_name = self._choose_field_name(field_name)
related_... | python | def remove_item(self, item, field_name=None):
"""
Remove the item from the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined.
"""
field_name = self._choose_field_name(field_name)
related_... | [
"def",
"remove_item",
"(",
"self",
",",
"item",
",",
"field_name",
"=",
"None",
")",
":",
"field_name",
"=",
"self",
".",
"_choose_field_name",
"(",
"field_name",
")",
"related_manager",
"=",
"getattr",
"(",
"item",
",",
"field_name",
")",
"related_manager",
... | Remove the item from the specified section.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior on other items is undefined. | [
"Remove",
"the",
"item",
"from",
"the",
"specified",
"section",
"."
] | train | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/models.py#L142-L151 |
armstrong/armstrong.core.arm_sections | armstrong/core/arm_sections/models.py | BaseSection.toggle_item | def toggle_item(self, item, test_func, field_name=None):
"""
Toggles the section based on test_func.
test_func takes an item and returns a boolean. If it returns True, the
item will be added to the given section. It will be removed from the
section otherwise.
Intended f... | python | def toggle_item(self, item, test_func, field_name=None):
"""
Toggles the section based on test_func.
test_func takes an item and returns a boolean. If it returns True, the
item will be added to the given section. It will be removed from the
section otherwise.
Intended f... | [
"def",
"toggle_item",
"(",
"self",
",",
"item",
",",
"test_func",
",",
"field_name",
"=",
"None",
")",
":",
"if",
"test_func",
"(",
"item",
")",
":",
"self",
".",
"add_item",
"(",
"item",
",",
"field_name",
")",
"return",
"True",
"else",
":",
"self",
... | Toggles the section based on test_func.
test_func takes an item and returns a boolean. If it returns True, the
item will be added to the given section. It will be removed from the
section otherwise.
Intended for use with items of settings.ARMSTRONG_SECTION_ITEM_MODEL.
Behavior ... | [
"Toggles",
"the",
"section",
"based",
"on",
"test_func",
"."
] | train | https://github.com/armstrong/armstrong.core.arm_sections/blob/39c999c93771da909359e53b35afefe4846f77cb/armstrong/core/arm_sections/models.py#L153-L169 |
samirelanduk/quickplots | quickplots/charts.py | determine_ticks | def determine_ticks(low, high):
"""The function used to auto-generate ticks for an axis, based on its
range of values.
:param Number low: The lower bound of the axis.
:param Number high: The upper bound of the axis.
:rtype: ``tuple``"""
range_ = high - low
tick_difference = 10 ** math.... | python | def determine_ticks(low, high):
"""The function used to auto-generate ticks for an axis, based on its
range of values.
:param Number low: The lower bound of the axis.
:param Number high: The upper bound of the axis.
:rtype: ``tuple``"""
range_ = high - low
tick_difference = 10 ** math.... | [
"def",
"determine_ticks",
"(",
"low",
",",
"high",
")",
":",
"range_",
"=",
"high",
"-",
"low",
"tick_difference",
"=",
"10",
"**",
"math",
".",
"floor",
"(",
"math",
".",
"log10",
"(",
"range_",
"/",
"1.25",
")",
")",
"low_tick",
"=",
"math",
".",
... | The function used to auto-generate ticks for an axis, based on its
range of values.
:param Number low: The lower bound of the axis.
:param Number high: The upper bound of the axis.
:rtype: ``tuple`` | [
"The",
"function",
"used",
"to",
"auto",
"-",
"generate",
"ticks",
"for",
"an",
"axis",
"based",
"on",
"its",
"range",
"of",
"values",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L694-L708 |
samirelanduk/quickplots | quickplots/charts.py | Chart.title | def title(self, title=None):
"""Returns or sets (if a value is provided) the chart's title.
:param str title: If given, the chart's title will be set to this.
:rtype: ``str``"""
if title is None:
return self._title
else:
if not isinstance(title, str):
... | python | def title(self, title=None):
"""Returns or sets (if a value is provided) the chart's title.
:param str title: If given, the chart's title will be set to this.
:rtype: ``str``"""
if title is None:
return self._title
else:
if not isinstance(title, str):
... | [
"def",
"title",
"(",
"self",
",",
"title",
"=",
"None",
")",
":",
"if",
"title",
"is",
"None",
":",
"return",
"self",
".",
"_title",
"else",
":",
"if",
"not",
"isinstance",
"(",
"title",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"title must ... | Returns or sets (if a value is provided) the chart's title.
:param str title: If given, the chart's title will be set to this.
:rtype: ``str`` | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"title",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L34-L45 |
samirelanduk/quickplots | quickplots/charts.py | Chart.width | def width(self, width=None):
"""Returns or sets (if a value is provided) the chart's width.
:param width: If given, the chart's width will be set to this."""
if width is None:
return self._width
else:
if not is_numeric(width):
raise TypeError("wi... | python | def width(self, width=None):
"""Returns or sets (if a value is provided) the chart's width.
:param width: If given, the chart's width will be set to this."""
if width is None:
return self._width
else:
if not is_numeric(width):
raise TypeError("wi... | [
"def",
"width",
"(",
"self",
",",
"width",
"=",
"None",
")",
":",
"if",
"width",
"is",
"None",
":",
"return",
"self",
".",
"_width",
"else",
":",
"if",
"not",
"is_numeric",
"(",
"width",
")",
":",
"raise",
"TypeError",
"(",
"\"width must be numeric, not ... | Returns or sets (if a value is provided) the chart's width.
:param width: If given, the chart's width will be set to this. | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"width",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L48-L58 |
samirelanduk/quickplots | quickplots/charts.py | Chart.height | def height(self, height=None):
"""Returns or sets (if a value is provided) the chart's height.
:param height: If given, the chart's height will be set to this."""
if height is None:
return self._height
else:
if not is_numeric(height):
raise TypeE... | python | def height(self, height=None):
"""Returns or sets (if a value is provided) the chart's height.
:param height: If given, the chart's height will be set to this."""
if height is None:
return self._height
else:
if not is_numeric(height):
raise TypeE... | [
"def",
"height",
"(",
"self",
",",
"height",
"=",
"None",
")",
":",
"if",
"height",
"is",
"None",
":",
"return",
"self",
".",
"_height",
"else",
":",
"if",
"not",
"is_numeric",
"(",
"height",
")",
":",
"raise",
"TypeError",
"(",
"\"height must be numeric... | Returns or sets (if a value is provided) the chart's height.
:param height: If given, the chart's height will be set to this. | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"height",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L61-L71 |
samirelanduk/quickplots | quickplots/charts.py | Chart.create | def create(self):
"""Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `r... | python | def create(self):
"""Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `r... | [
"def",
"create",
"(",
"self",
")",
":",
"canvas",
"=",
"Canvas",
"(",
"self",
".",
"width",
"(",
")",
",",
"self",
".",
"height",
"(",
")",
")",
"canvas",
".",
"add_text",
"(",
"self",
".",
"width",
"(",
")",
"/",
"2",
",",
"0",
",",
"self",
... | Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `rendered <https://\
om... | [
"Renders",
"the",
"chart",
"to",
"an",
"OmniCanvas",
"canvas",
"<https",
":",
"//",
"omnicanvas",
".",
"readt",
"\\",
"hedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"api",
"/",
"canvas",
".",
"html#omnicanvas",
".",
"canvas",
".",
"Canvas",
">",
"... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L74-L87 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.add_series | def add_series(self, series):
"""Adds a :py:class:`.Series` to the chart.
:param Series series: The :py:class:`.Series` to add."""
if not isinstance(series, Series):
raise TypeError("'%s' is not a Series" % str(series))
self._all_series.append(series)
series._chart ... | python | def add_series(self, series):
"""Adds a :py:class:`.Series` to the chart.
:param Series series: The :py:class:`.Series` to add."""
if not isinstance(series, Series):
raise TypeError("'%s' is not a Series" % str(series))
self._all_series.append(series)
series._chart ... | [
"def",
"add_series",
"(",
"self",
",",
"series",
")",
":",
"if",
"not",
"isinstance",
"(",
"series",
",",
"Series",
")",
":",
"raise",
"TypeError",
"(",
"\"'%s' is not a Series\"",
"%",
"str",
"(",
"series",
")",
")",
"self",
".",
"_all_series",
".",
"ap... | Adds a :py:class:`.Series` to the chart.
:param Series series: The :py:class:`.Series` to add. | [
"Adds",
"a",
":",
"py",
":",
"class",
":",
".",
"Series",
"to",
"the",
"chart",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L164-L172 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.remove_series | def remove_series(self, series):
"""Removes a :py:class:`.Series` from the chart.
:param Series series: The :py:class:`.Series` to remove.
:raises ValueError: if you try to remove the last\
:py:class:`.Series`."""
if len(self.all_series()) == 1:
raise ValueError("Ca... | python | def remove_series(self, series):
"""Removes a :py:class:`.Series` from the chart.
:param Series series: The :py:class:`.Series` to remove.
:raises ValueError: if you try to remove the last\
:py:class:`.Series`."""
if len(self.all_series()) == 1:
raise ValueError("Ca... | [
"def",
"remove_series",
"(",
"self",
",",
"series",
")",
":",
"if",
"len",
"(",
"self",
".",
"all_series",
"(",
")",
")",
"==",
"1",
":",
"raise",
"ValueError",
"(",
"\"Cannot remove last series from %s\"",
"%",
"str",
"(",
"self",
")",
")",
"self",
".",... | Removes a :py:class:`.Series` from the chart.
:param Series series: The :py:class:`.Series` to remove.
:raises ValueError: if you try to remove the last\
:py:class:`.Series`. | [
"Removes",
"a",
":",
"py",
":",
"class",
":",
".",
"Series",
"from",
"the",
"chart",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L175-L185 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.line | def line(self, *args, **kwargs):
"""Adds a :py:class:`.LineSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str color: T... | python | def line(self, *args, **kwargs):
"""Adds a :py:class:`.LineSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str color: T... | [
"def",
"line",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"color\"",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"\"color\"",
"]",
"=",
"self",
".",
"next_color",
"(",
")",
"series",
"=",
"LineSeries",
"(",
"*",
"args"... | Adds a :py:class:`.LineSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str color: The hex colour of the line.
:param st... | [
"Adds",
"a",
":",
"py",
":",
"class",
":",
".",
"LineSeries",
"to",
"the",
"chart",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L196-L214 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.scatter | def scatter(self, *args, **kwargs):
"""Adds a :py:class:`.ScatterSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str co... | python | def scatter(self, *args, **kwargs):
"""Adds a :py:class:`.ScatterSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str co... | [
"def",
"scatter",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"color\"",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"\"color\"",
"]",
"=",
"self",
".",
"next_color",
"(",
")",
"series",
"=",
"ScatterSeries",
"(",
"*",
... | Adds a :py:class:`.ScatterSeries` to the chart.
:param \*data: The data for the series as either (x,y) values or two big\
tuples/lists of x and y values respectively.
:param str name: The name to be associated with the series.
:param str color: The hex colour of the line.
:param... | [
"Adds",
"a",
":",
"py",
":",
"class",
":",
".",
"ScatterSeries",
"to",
"the",
"chart",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L217-L232 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.get_series_by_name | def get_series_by_name(self, name):
"""Returns the first :py:class:`.Series` of a given name, or ``None``.
:param str name: The name to search by."""
if not isinstance(name, str):
raise TypeError(
"Can only search series by str name, not '%s'" % str(name)
)... | python | def get_series_by_name(self, name):
"""Returns the first :py:class:`.Series` of a given name, or ``None``.
:param str name: The name to search by."""
if not isinstance(name, str):
raise TypeError(
"Can only search series by str name, not '%s'" % str(name)
)... | [
"def",
"get_series_by_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"Can only search series by str name, not '%s'\"",
"%",
"str",
"(",
"name",
")",
")",
"for",
"series",
... | Returns the first :py:class:`.Series` of a given name, or ``None``.
:param str name: The name to search by. | [
"Returns",
"the",
"first",
":",
"py",
":",
"class",
":",
".",
"Series",
"of",
"a",
"given",
"name",
"or",
"None",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L235-L246 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.x_label | def x_label(self, x_label=None):
"""Returns or sets (if a value is provided) the chart's x-axis label.
:param str x_label: If given, the chart's x_label will be set to this.
:rtype: ``str``"""
if x_label is None:
return self._x_label
else:
if not isinsta... | python | def x_label(self, x_label=None):
"""Returns or sets (if a value is provided) the chart's x-axis label.
:param str x_label: If given, the chart's x_label will be set to this.
:rtype: ``str``"""
if x_label is None:
return self._x_label
else:
if not isinsta... | [
"def",
"x_label",
"(",
"self",
",",
"x_label",
"=",
"None",
")",
":",
"if",
"x_label",
"is",
"None",
":",
"return",
"self",
".",
"_x_label",
"else",
":",
"if",
"not",
"isinstance",
"(",
"x_label",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"x... | Returns or sets (if a value is provided) the chart's x-axis label.
:param str x_label: If given, the chart's x_label will be set to this.
:rtype: ``str`` | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"x",
"-",
"axis",
"label",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L249-L260 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.y_label | def y_label(self, y_label=None):
"""Returns or sets (if a value is provided) the chart's y-axis label.
:param str y_label: If given, the chart's y_label will be set to this.
:rtype: ``str``"""
if y_label is None:
return self._y_label
else:
if not isinsta... | python | def y_label(self, y_label=None):
"""Returns or sets (if a value is provided) the chart's y-axis label.
:param str y_label: If given, the chart's y_label will be set to this.
:rtype: ``str``"""
if y_label is None:
return self._y_label
else:
if not isinsta... | [
"def",
"y_label",
"(",
"self",
",",
"y_label",
"=",
"None",
")",
":",
"if",
"y_label",
"is",
"None",
":",
"return",
"self",
".",
"_y_label",
"else",
":",
"if",
"not",
"isinstance",
"(",
"y_label",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"y... | Returns or sets (if a value is provided) the chart's y-axis label.
:param str y_label: If given, the chart's y_label will be set to this.
:rtype: ``str`` | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"y",
"-",
"axis",
"label",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L263-L274 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.horizontal_padding | def horizontal_padding(self, padding=None):
"""Returns or sets (if a value is provided) the chart's horizontal
padding. This determines how much space will be on either side of the
display area, as a proportion of overall width, and should be a value
between 0 and 0.5
:param flo... | python | def horizontal_padding(self, padding=None):
"""Returns or sets (if a value is provided) the chart's horizontal
padding. This determines how much space will be on either side of the
display area, as a proportion of overall width, and should be a value
between 0 and 0.5
:param flo... | [
"def",
"horizontal_padding",
"(",
"self",
",",
"padding",
"=",
"None",
")",
":",
"if",
"padding",
"is",
"None",
":",
"return",
"self",
".",
"_horizontal_padding",
"else",
":",
"if",
"not",
"isinstance",
"(",
"padding",
",",
"float",
")",
":",
"raise",
"T... | Returns or sets (if a value is provided) the chart's horizontal
padding. This determines how much space will be on either side of the
display area, as a proportion of overall width, and should be a value
between 0 and 0.5
:param float padding: If given, the chart's horizontal_padding\
... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"horizontal",
"padding",
".",
"This",
"determines",
"how",
"much",
"space",
"will",
"be",
"on",
"either",
"side",
"of",
"the",
"display",
"area",
"as",
"a",
"... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L277-L297 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.vertical_padding | def vertical_padding(self, padding=None):
"""Returns or sets (if a value is provided) the chart's vertical
padding. This determines how much space will be above and below the
display area, as a proportion of overall height, and should be a value
between 0 and 0.5
:param float pa... | python | def vertical_padding(self, padding=None):
"""Returns or sets (if a value is provided) the chart's vertical
padding. This determines how much space will be above and below the
display area, as a proportion of overall height, and should be a value
between 0 and 0.5
:param float pa... | [
"def",
"vertical_padding",
"(",
"self",
",",
"padding",
"=",
"None",
")",
":",
"if",
"padding",
"is",
"None",
":",
"return",
"self",
".",
"_vertical_padding",
"else",
":",
"if",
"not",
"isinstance",
"(",
"padding",
",",
"float",
")",
":",
"raise",
"TypeE... | Returns or sets (if a value is provided) the chart's vertical
padding. This determines how much space will be above and below the
display area, as a proportion of overall height, and should be a value
between 0 and 0.5
:param float padding: If given, the chart's vertical_padding\
... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"chart",
"s",
"vertical",
"padding",
".",
"This",
"determines",
"how",
"much",
"space",
"will",
"be",
"above",
"and",
"below",
"the",
"display",
"area",
"as",
"a",
"proportio... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L300-L320 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.x_lower_limit | def x_lower_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
x-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's x_lower_limit will be set to this.
:raises ValueError: if ... | python | def x_lower_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
x-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's x_lower_limit will be set to this.
:raises ValueError: if ... | [
"def",
"x_lower_limit",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"None",
":",
"if",
"self",
".",
"_x_lower_limit",
"is",
"None",
":",
"if",
"self",
".",
"smallest_x",
"(",
")",
"<",
"0",
":",
"if",
"self",
".",
"smalle... | Returns or sets (if a value is provided) the value at which the
x-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's x_lower_limit will be set to this.
:raises ValueError: if you try to make the lower limit larger than the\... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"value",
"at",
"which",
"the",
"x",
"-",
"axis",
"should",
"start",
".",
"By",
"default",
"this",
"is",
"zero",
"(",
"unless",
"there",
"are",
"negative",
"values",
")",
... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L359-L390 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.y_lower_limit | def y_lower_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
y-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's y_lower_limit will be set to this.
:raises ValueError: if ... | python | def y_lower_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
y-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's y_lower_limit will be set to this.
:raises ValueError: if ... | [
"def",
"y_lower_limit",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"None",
":",
"if",
"self",
".",
"_y_lower_limit",
"is",
"None",
":",
"if",
"self",
".",
"smallest_y",
"(",
")",
"<",
"0",
":",
"if",
"self",
".",
"smalle... | Returns or sets (if a value is provided) the value at which the
y-axis should start. By default this is zero (unless there are negative
values).
:param limit: If given, the chart's y_lower_limit will be set to this.
:raises ValueError: if you try to make the lower limit larger than the\... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"value",
"at",
"which",
"the",
"y",
"-",
"axis",
"should",
"start",
".",
"By",
"default",
"this",
"is",
"zero",
"(",
"unless",
"there",
"are",
"negative",
"values",
")",
... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L393-L424 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.x_upper_limit | def x_upper_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
x-axis should end. By default this is the highest x value in the
associated series.
:param limit: If given, the chart's x_upper_limit will be set to this.
:raises ValueError: ... | python | def x_upper_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
x-axis should end. By default this is the highest x value in the
associated series.
:param limit: If given, the chart's x_upper_limit will be set to this.
:raises ValueError: ... | [
"def",
"x_upper_limit",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"None",
":",
"if",
"self",
".",
"_x_upper_limit",
"is",
"None",
":",
"if",
"self",
".",
"smallest_x",
"(",
")",
"==",
"self",
".",
"largest_x",
"(",
")",
... | Returns or sets (if a value is provided) the value at which the
x-axis should end. By default this is the highest x value in the
associated series.
:param limit: If given, the chart's x_upper_limit will be set to this.
:raises ValueError: if you try to make the upper limit smaller than ... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"value",
"at",
"which",
"the",
"x",
"-",
"axis",
"should",
"end",
".",
"By",
"default",
"this",
"is",
"the",
"highest",
"x",
"value",
"in",
"the",
"associated",
"series",
... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L427-L458 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.y_upper_limit | def y_upper_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
y-axis should end. By default this is the highest y value in the
associated series.
:param limit: If given, the chart's y_upper_limit will be set to this.
:raises ValueError: ... | python | def y_upper_limit(self, limit=None):
"""Returns or sets (if a value is provided) the value at which the
y-axis should end. By default this is the highest y value in the
associated series.
:param limit: If given, the chart's y_upper_limit will be set to this.
:raises ValueError: ... | [
"def",
"y_upper_limit",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"if",
"limit",
"is",
"None",
":",
"if",
"self",
".",
"_y_upper_limit",
"is",
"None",
":",
"if",
"self",
".",
"smallest_y",
"(",
")",
"==",
"self",
".",
"largest_y",
"(",
")",
... | Returns or sets (if a value is provided) the value at which the
y-axis should end. By default this is the highest y value in the
associated series.
:param limit: If given, the chart's y_upper_limit will be set to this.
:raises ValueError: if you try to make the upper limit smaller than ... | [
"Returns",
"or",
"sets",
"(",
"if",
"a",
"value",
"is",
"provided",
")",
"the",
"value",
"at",
"which",
"the",
"y",
"-",
"axis",
"should",
"end",
".",
"By",
"default",
"this",
"is",
"the",
"highest",
"y",
"value",
"in",
"the",
"associated",
"series",
... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L461-L492 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.x_ticks | def x_ticks(self, *ticks):
"""The points on the x-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-tic... | python | def x_ticks(self, *ticks):
"""The points on the x-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-tic... | [
"def",
"x_ticks",
"(",
"self",
",",
"*",
"ticks",
")",
":",
"if",
"ticks",
":",
"for",
"tick",
"in",
"ticks",
":",
"if",
"not",
"is_numeric",
"(",
"tick",
")",
":",
"raise",
"TypeError",
"(",
"\"'%s' is not a numeric tick\"",
"%",
"str",
"(",
"tick",
"... | The points on the x-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-ticks.
:rtype: ``tuple`` | [
"The",
"points",
"on",
"the",
"x",
"-",
"axis",
"for",
"which",
"there",
"are",
"markers",
"and",
"grid",
"lines",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L495-L513 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.y_ticks | def y_ticks(self, *ticks):
"""The points on the y-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-tic... | python | def y_ticks(self, *ticks):
"""The points on the y-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-tic... | [
"def",
"y_ticks",
"(",
"self",
",",
"*",
"ticks",
")",
":",
"if",
"ticks",
":",
"for",
"tick",
"in",
"ticks",
":",
"if",
"not",
"is_numeric",
"(",
"tick",
")",
":",
"raise",
"TypeError",
"(",
"\"'%s' is not a numeric tick\"",
"%",
"str",
"(",
"tick",
"... | The points on the y-axis for which there are markers and grid lines.
There are default ticks, but you can pass values to this method to
override the defaults. Otherwise the method will return the ticks.
:param \*ticks: if given, these will be chart's x-ticks.
:rtype: ``tuple`` | [
"The",
"points",
"on",
"the",
"y",
"-",
"axis",
"for",
"which",
"there",
"are",
"markers",
"and",
"grid",
"lines",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L516-L534 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.x_grid | def x_grid(self, grid=None):
"""The horizontal lines that run accross the chart from the x-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtyp... | python | def x_grid(self, grid=None):
"""The horizontal lines that run accross the chart from the x-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtyp... | [
"def",
"x_grid",
"(",
"self",
",",
"grid",
"=",
"None",
")",
":",
"if",
"grid",
"is",
"None",
":",
"return",
"self",
".",
"_x_grid",
"else",
":",
"if",
"not",
"isinstance",
"(",
"grid",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"grid must b... | The horizontal lines that run accross the chart from the x-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtype: ``bool`` | [
"The",
"horizontal",
"lines",
"that",
"run",
"accross",
"the",
"chart",
"from",
"the",
"x",
"-",
"ticks",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L537-L551 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.y_grid | def y_grid(self, grid=None):
"""The vertical lines that run accross the chart from the y-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtype:... | python | def y_grid(self, grid=None):
"""The vertical lines that run accross the chart from the y-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtype:... | [
"def",
"y_grid",
"(",
"self",
",",
"grid",
"=",
"None",
")",
":",
"if",
"grid",
"is",
"None",
":",
"return",
"self",
".",
"_y_grid",
"else",
":",
"if",
"not",
"isinstance",
"(",
"grid",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"grid must b... | The vertical lines that run accross the chart from the y-ticks.
If a boolean value is given, these gridlines will be turned on or off.
Otherwise, the method will return their current state.
:param bool grid: Turns the gridlines on or off.
:rtype: ``bool`` | [
"The",
"vertical",
"lines",
"that",
"run",
"accross",
"the",
"chart",
"from",
"the",
"y",
"-",
"ticks",
"."
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L554-L568 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.grid | def grid(self, grid):
"""Turns all gridlines on or off
:param bool grid: turns the gridlines on if ``True``, off if ``False``"""
if not isinstance(grid, bool):
raise TypeError("grid must be boolean, not '%s'" % grid)
self._x_grid = self._y_grid = grid | python | def grid(self, grid):
"""Turns all gridlines on or off
:param bool grid: turns the gridlines on if ``True``, off if ``False``"""
if not isinstance(grid, bool):
raise TypeError("grid must be boolean, not '%s'" % grid)
self._x_grid = self._y_grid = grid | [
"def",
"grid",
"(",
"self",
",",
"grid",
")",
":",
"if",
"not",
"isinstance",
"(",
"grid",
",",
"bool",
")",
":",
"raise",
"TypeError",
"(",
"\"grid must be boolean, not '%s'\"",
"%",
"grid",
")",
"self",
".",
"_x_grid",
"=",
"self",
".",
"_y_grid",
"=",... | Turns all gridlines on or off
:param bool grid: turns the gridlines on if ``True``, off if ``False`` | [
"Turns",
"all",
"gridlines",
"on",
"or",
"off"
] | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L571-L578 |
samirelanduk/quickplots | quickplots/charts.py | AxisChart.create | def create(self):
"""Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `r... | python | def create(self):
"""Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `r... | [
"def",
"create",
"(",
"self",
")",
":",
"canvas",
"=",
"Chart",
".",
"create",
"(",
"self",
")",
"for",
"index",
",",
"series",
"in",
"enumerate",
"(",
"self",
".",
"all_series",
"(",
")",
",",
"start",
"=",
"1",
")",
":",
"series",
".",
"write_to_... | Renders the chart to an OmniCanvas `canvas <https://omnicanvas.readt\
hedocs.io/en/latest/api/canvas.html#omnicanvas.canvas.Canvas>`_. This
object can then be `saved <https://omnicanvas.readthedocs.io/en/latest/\
api/canvas.html#omnicanvas.canvas.Canvas.save>`_ or `rendered <https://\
om... | [
"Renders",
"the",
"chart",
"to",
"an",
"OmniCanvas",
"canvas",
"<https",
":",
"//",
"omnicanvas",
".",
"readt",
"\\",
"hedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"api",
"/",
"canvas",
".",
"html#omnicanvas",
".",
"canvas",
".",
"Canvas",
">",
"... | train | https://github.com/samirelanduk/quickplots/blob/59f5e6ff367b2c1c24ba7cf1805d03552034c6d8/quickplots/charts.py#L581-L690 |
geertj/looping | lib/looping/events.py | DefaultEventLoopPolicy.get_event_loop | def get_event_loop(self):
"""Get the event loop.
This may be None or an instance of EventLoop.
"""
if (self._event_loop is None and
threading.current_thread().name == 'MainThread'):
self._event_loop = self.new_event_loop()
return self._event_loop | python | def get_event_loop(self):
"""Get the event loop.
This may be None or an instance of EventLoop.
"""
if (self._event_loop is None and
threading.current_thread().name == 'MainThread'):
self._event_loop = self.new_event_loop()
return self._event_loop | [
"def",
"get_event_loop",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_event_loop",
"is",
"None",
"and",
"threading",
".",
"current_thread",
"(",
")",
".",
"name",
"==",
"'MainThread'",
")",
":",
"self",
".",
"_event_loop",
"=",
"self",
".",
"new_even... | Get the event loop.
This may be None or an instance of EventLoop. | [
"Get",
"the",
"event",
"loop",
"."
] | train | https://github.com/geertj/looping/blob/b60303714685aede18b37c0d80f8f55175ad7a65/lib/looping/events.py#L276-L284 |
geertj/looping | lib/looping/events.py | DefaultEventLoopPolicy.set_event_loop | def set_event_loop(self, event_loop):
"""Set the event loop."""
assert event_loop is None or isinstance(event_loop, AbstractEventLoop)
self._event_loop = event_loop | python | def set_event_loop(self, event_loop):
"""Set the event loop."""
assert event_loop is None or isinstance(event_loop, AbstractEventLoop)
self._event_loop = event_loop | [
"def",
"set_event_loop",
"(",
"self",
",",
"event_loop",
")",
":",
"assert",
"event_loop",
"is",
"None",
"or",
"isinstance",
"(",
"event_loop",
",",
"AbstractEventLoop",
")",
"self",
".",
"_event_loop",
"=",
"event_loop"
] | Set the event loop. | [
"Set",
"the",
"event",
"loop",
"."
] | train | https://github.com/geertj/looping/blob/b60303714685aede18b37c0d80f8f55175ad7a65/lib/looping/events.py#L286-L289 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/__init__.py | _iiOfAny | def _iiOfAny(instance, classes):
"""
Returns true, if `instance` is instance of any (_iiOfAny) of the `classes`.
This function doesn't use :func:`isinstance` check, it just compares the
class names.
This can be generally dangerous, but it is really useful when you are
comparing class serialize... | python | def _iiOfAny(instance, classes):
"""
Returns true, if `instance` is instance of any (_iiOfAny) of the `classes`.
This function doesn't use :func:`isinstance` check, it just compares the
class names.
This can be generally dangerous, but it is really useful when you are
comparing class serialize... | [
"def",
"_iiOfAny",
"(",
"instance",
",",
"classes",
")",
":",
"if",
"type",
"(",
"classes",
")",
"not",
"in",
"[",
"list",
",",
"tuple",
"]",
":",
"classes",
"=",
"[",
"classes",
"]",
"return",
"any",
"(",
"map",
"(",
"lambda",
"x",
":",
"type",
... | Returns true, if `instance` is instance of any (_iiOfAny) of the `classes`.
This function doesn't use :func:`isinstance` check, it just compares the
class names.
This can be generally dangerous, but it is really useful when you are
comparing class serialized in one module and deserialized in another.
... | [
"Returns",
"true",
"if",
"instance",
"is",
"instance",
"of",
"any",
"(",
"_iiOfAny",
")",
"of",
"the",
"classes",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/__init__.py#L359-L387 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/__init__.py | reactToAMQPMessage | def reactToAMQPMessage(req, send_back):
"""
React to given (AMQP) message.
This function is used by :mod:`edeposit.amqp.alephdaemon`. It works as
highlevel wrapper for whole module.
Example:
>>> import aleph
>>> request = aleph.SearchRequest(
... aleph.ISBNQuery("80-25... | python | def reactToAMQPMessage(req, send_back):
"""
React to given (AMQP) message.
This function is used by :mod:`edeposit.amqp.alephdaemon`. It works as
highlevel wrapper for whole module.
Example:
>>> import aleph
>>> request = aleph.SearchRequest(
... aleph.ISBNQuery("80-25... | [
"def",
"reactToAMQPMessage",
"(",
"req",
",",
"send_back",
")",
":",
"if",
"not",
"_iiOfAny",
"(",
"req",
",",
"REQUEST_TYPES",
")",
":",
"raise",
"ValueError",
"(",
"\"Unknown type of request: '\"",
"+",
"str",
"(",
"type",
"(",
"req",
")",
")",
"+",
"\"'... | React to given (AMQP) message.
This function is used by :mod:`edeposit.amqp.alephdaemon`. It works as
highlevel wrapper for whole module.
Example:
>>> import aleph
>>> request = aleph.SearchRequest(
... aleph.ISBNQuery("80-251-0225-4")
... )
>>> request
... | [
"React",
"to",
"given",
"(",
"AMQP",
")",
"message",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/__init__.py#L391-L490 |
edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/__init__.py | DocumentQuery.getSearchResult | def getSearchResult(self):
"""
Returns:
object: :class:`SearchResult` document with given `doc_id`.
Raises:
aleph.DocumentNotFoundException: When document is not found.
"""
xml = aleph.downloadMARCOAI(self.doc_id, self.library)
return SearchResul... | python | def getSearchResult(self):
"""
Returns:
object: :class:`SearchResult` document with given `doc_id`.
Raises:
aleph.DocumentNotFoundException: When document is not found.
"""
xml = aleph.downloadMARCOAI(self.doc_id, self.library)
return SearchResul... | [
"def",
"getSearchResult",
"(",
"self",
")",
":",
"xml",
"=",
"aleph",
".",
"downloadMARCOAI",
"(",
"self",
".",
"doc_id",
",",
"self",
".",
"library",
")",
"return",
"SearchResult",
"(",
"[",
"AlephRecord",
"(",
"None",
",",
"self",
".",
"library",
",",
... | Returns:
object: :class:`SearchResult` document with given `doc_id`.
Raises:
aleph.DocumentNotFoundException: When document is not found. | [
"Returns",
":",
"object",
":",
":",
"class",
":",
"SearchResult",
"document",
"with",
"given",
"doc_id",
"."
] | train | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/__init__.py#L205-L222 |
ganow/gq | gq/core.py | mtable_to_dict | def mtable_to_dict(maf_id_file):
""" maf_id_tableからdictへの変換
"""
out = []
pattern = re.compile(r'(?P<id>\d+)\t\{(?P<json>.+)\}')
for line in maf_id_file:
m = pattern.match(line)
text = '{"id": ' + m.group('id') + ', ' + m.group('json').replace("'", '"') + '}'
out.append( jso... | python | def mtable_to_dict(maf_id_file):
""" maf_id_tableからdictへの変換
"""
out = []
pattern = re.compile(r'(?P<id>\d+)\t\{(?P<json>.+)\}')
for line in maf_id_file:
m = pattern.match(line)
text = '{"id": ' + m.group('id') + ', ' + m.group('json').replace("'", '"') + '}'
out.append( jso... | [
"def",
"mtable_to_dict",
"(",
"maf_id_file",
")",
":",
"out",
"=",
"[",
"]",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'(?P<id>\\d+)\\t\\{(?P<json>.+)\\}'",
")",
"for",
"line",
"in",
"maf_id_file",
":",
"m",
"=",
"pattern",
".",
"match",
"(",
"line",
")... | maf_id_tableからdictへの変換 | [
"maf_id_tableからdictへの変換"
] | train | https://github.com/ganow/gq/blob/4f0be98f21c137df605aa175469fd4777861e85a/gq/core.py#L15-L27 |
PyTables/datasette-connectors | datasette_connectors/monkey.py | patch_datasette | def patch_datasette():
"""
Monkey patching for original Datasette
"""
def inspect(self):
" Inspect the database and return a dictionary of table metadata "
if self._inspect:
return self._inspect
_inspect = {}
files = self.files
for filename in files... | python | def patch_datasette():
"""
Monkey patching for original Datasette
"""
def inspect(self):
" Inspect the database and return a dictionary of table metadata "
if self._inspect:
return self._inspect
_inspect = {}
files = self.files
for filename in files... | [
"def",
"patch_datasette",
"(",
")",
":",
"def",
"inspect",
"(",
"self",
")",
":",
"\" Inspect the database and return a dictionary of table metadata \"",
"if",
"self",
".",
"_inspect",
":",
"return",
"self",
".",
"_inspect",
"_inspect",
"=",
"{",
"}",
"files",
"="... | Monkey patching for original Datasette | [
"Monkey",
"patching",
"for",
"original",
"Datasette"
] | train | https://github.com/PyTables/datasette-connectors/blob/b0802bdb9d86cd65524d6ffa7afb66488d167b1e/datasette_connectors/monkey.py#L12-L87 |
arozumenko/pybench | webbench/webbench.py | bench | def bench(host, port, uri, method, headers, body, verbocity, http_version, protocol):
"""
The benchmark method
:param host str: - host to run tests agains
:param port int: - port to connect
:param uri str: - URI to send in message
:param method str: - http method
:param headers str: - format... | python | def bench(host, port, uri, method, headers, body, verbocity, http_version, protocol):
"""
The benchmark method
:param host str: - host to run tests agains
:param port int: - port to connect
:param uri str: - URI to send in message
:param method str: - http method
:param headers str: - format... | [
"def",
"bench",
"(",
"host",
",",
"port",
",",
"uri",
",",
"method",
",",
"headers",
",",
"body",
",",
"verbocity",
",",
"http_version",
",",
"protocol",
")",
":",
"t1",
"=",
"time",
".",
"time",
"(",
")",
"s",
"=",
"create_connction",
"(",
"host",
... | The benchmark method
:param host str: - host to run tests agains
:param port int: - port to connect
:param uri str: - URI to send in message
:param method str: - http method
:param headers str: - formatted headers for message
:param body str: - body of message
:param verbocity int [0-1]: - p... | [
"The",
"benchmark",
"method",
":",
"param",
"host",
"str",
":",
"-",
"host",
"to",
"run",
"tests",
"agains",
":",
"param",
"port",
"int",
":",
"-",
"port",
"to",
"connect",
":",
"param",
"uri",
"str",
":",
"-",
"URI",
"to",
"send",
"in",
"message",
... | train | https://github.com/arozumenko/pybench/blob/669cbd02aae03cbb988c85156510268b33163ee3/webbench/webbench.py#L53-L97 |
arozumenko/pybench | webbench/webbench.py | create_connction | def create_connction(host, port, protocol):
"""
Create connection to socket host/port
:param host srt: - host to connect
:param port int: - port to connect
:return socket: - open connection
"""
ai_list = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket... | python | def create_connction(host, port, protocol):
"""
Create connection to socket host/port
:param host srt: - host to connect
:param port int: - port to connect
:return socket: - open connection
"""
ai_list = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket... | [
"def",
"create_connction",
"(",
"host",
",",
"port",
",",
"protocol",
")",
":",
"ai_list",
"=",
"socket",
".",
"getaddrinfo",
"(",
"host",
",",
"port",
",",
"socket",
".",
"AF_UNSPEC",
",",
"socket",
".",
"SOCK_STREAM",
")",
"for",
"(",
"family",
",",
... | Create connection to socket host/port
:param host srt: - host to connect
:param port int: - port to connect
:return socket: - open connection | [
"Create",
"connection",
"to",
"socket",
"host",
"/",
"port",
":",
"param",
"host",
"srt",
":",
"-",
"host",
"to",
"connect",
":",
"param",
"port",
"int",
":",
"-",
"port",
"to",
"connect",
":",
"return",
"socket",
":",
"-",
"open",
"connection"
] | train | https://github.com/arozumenko/pybench/blob/669cbd02aae03cbb988c85156510268b33163ee3/webbench/webbench.py#L100-L115 |
arozumenko/pybench | webbench/webbench.py | main | def main():
"""Mein methos of pybench executor"""
parser = argparse.ArgumentParser(description='webBench is an alternative to ab in python')
parser.add_argument('-n', dest='requests', type=int,
help='Number of requests to perform')
parser.add_argument('-c', dest='concurrency', t... | python | def main():
"""Mein methos of pybench executor"""
parser = argparse.ArgumentParser(description='webBench is an alternative to ab in python')
parser.add_argument('-n', dest='requests', type=int,
help='Number of requests to perform')
parser.add_argument('-c', dest='concurrency', t... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'webBench is an alternative to ab in python'",
")",
"parser",
".",
"add_argument",
"(",
"'-n'",
",",
"dest",
"=",
"'requests'",
",",
"type",
"=",
"int",
"... | Mein methos of pybench executor | [
"Mein",
"methos",
"of",
"pybench",
"executor"
] | train | https://github.com/arozumenko/pybench/blob/669cbd02aae03cbb988c85156510268b33163ee3/webbench/webbench.py#L118-L260 |
fedora-infra/fmn.rules | fmn/rules/utils.py | get_fas | def get_fas(config):
""" Return a fedora.client.fas2.AccountSystem object if the provided
configuration contains a FAS username and password.
"""
global _FAS
if _FAS is not None:
return _FAS
# In some development environments, having fas_credentials around is a
# pain.. so, let thin... | python | def get_fas(config):
""" Return a fedora.client.fas2.AccountSystem object if the provided
configuration contains a FAS username and password.
"""
global _FAS
if _FAS is not None:
return _FAS
# In some development environments, having fas_credentials around is a
# pain.. so, let thin... | [
"def",
"get_fas",
"(",
"config",
")",
":",
"global",
"_FAS",
"if",
"_FAS",
"is",
"not",
"None",
":",
"return",
"_FAS",
"# In some development environments, having fas_credentials around is a",
"# pain.. so, let things proceed here, but emit a warning.",
"try",
":",
"creds",
... | Return a fedora.client.fas2.AccountSystem object if the provided
configuration contains a FAS username and password. | [
"Return",
"a",
"fedora",
".",
"client",
".",
"fas2",
".",
"AccountSystem",
"object",
"if",
"the",
"provided",
"configuration",
"contains",
"a",
"FAS",
"username",
"and",
"password",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L40-L66 |
fedora-infra/fmn.rules | fmn/rules/utils.py | get_packagers_of_package | def get_packagers_of_package(config, package):
""" Retrieve the list of users who have commit on a package.
:arg config: a dict containing the fedmsg config
:arg package: the package you are interested in.
:return: a set listing all the fas usernames that have some ACL on package.
"""
if not _... | python | def get_packagers_of_package(config, package):
""" Retrieve the list of users who have commit on a package.
:arg config: a dict containing the fedmsg config
:arg package: the package you are interested in.
:return: a set listing all the fas usernames that have some ACL on package.
"""
if not _... | [
"def",
"get_packagers_of_package",
"(",
"config",
",",
"package",
")",
":",
"if",
"not",
"_cache",
".",
"is_configured",
":",
"_cache",
".",
"configure",
"(",
"*",
"*",
"config",
"[",
"'fmn.rules.cache'",
"]",
")",
"key",
"=",
"cache_key_generator",
"(",
"ge... | Retrieve the list of users who have commit on a package.
:arg config: a dict containing the fedmsg config
:arg package: the package you are interested in.
:return: a set listing all the fas usernames that have some ACL on package. | [
"Retrieve",
"the",
"list",
"of",
"users",
"who",
"have",
"commit",
"on",
"a",
"package",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L69-L82 |
fedora-infra/fmn.rules | fmn/rules/utils.py | get_packages_of_user | def get_packages_of_user(config, username, flags):
""" Retrieve the list of packages where the specified user some acl.
:arg config: a dict containing the fedmsg config
:arg username: the fas username of the packager whose packages are of
interest.
:return: a set listing all the packages where ... | python | def get_packages_of_user(config, username, flags):
""" Retrieve the list of packages where the specified user some acl.
:arg config: a dict containing the fedmsg config
:arg username: the fas username of the packager whose packages are of
interest.
:return: a set listing all the packages where ... | [
"def",
"get_packages_of_user",
"(",
"config",
",",
"username",
",",
"flags",
")",
":",
"if",
"not",
"_cache",
".",
"is_configured",
":",
"_cache",
".",
"configure",
"(",
"*",
"*",
"config",
"[",
"'fmn.rules.cache'",
"]",
")",
"packages",
"=",
"[",
"]",
"... | Retrieve the list of packages where the specified user some acl.
:arg config: a dict containing the fedmsg config
:arg username: the fas username of the packager whose packages are of
interest.
:return: a set listing all the packages where the specified user has
some ACL. | [
"Retrieve",
"the",
"list",
"of",
"packages",
"where",
"the",
"specified",
"user",
"some",
"acl",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L123-L148 |
fedora-infra/fmn.rules | fmn/rules/utils.py | get_user_of_group | def get_user_of_group(config, fas, groupname):
''' Return the list of users in the specified group.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg groupname: the name of the group for which we want to re... | python | def get_user_of_group(config, fas, groupname):
''' Return the list of users in the specified group.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg groupname: the name of the group for which we want to re... | [
"def",
"get_user_of_group",
"(",
"config",
",",
"fas",
",",
"groupname",
")",
":",
"if",
"not",
"_cache",
".",
"is_configured",
":",
"_cache",
".",
"configure",
"(",
"*",
"*",
"config",
"[",
"'fmn.rules.cache'",
"]",
")",
"key",
"=",
"cache_key_generator",
... | Return the list of users in the specified group.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg groupname: the name of the group for which we want to retrieve the
members.
:return: a list of FAS ... | [
"Return",
"the",
"list",
"of",
"users",
"in",
"the",
"specified",
"group",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L186-L205 |
fedora-infra/fmn.rules | fmn/rules/utils.py | get_groups_of_user | def get_groups_of_user(config, fas, username):
''' Return the list of (pkgdb) groups to which the user belongs.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg username: the name of a user for which we wa... | python | def get_groups_of_user(config, fas, username):
''' Return the list of (pkgdb) groups to which the user belongs.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg username: the name of a user for which we wa... | [
"def",
"get_groups_of_user",
"(",
"config",
",",
"fas",
",",
"username",
")",
":",
"if",
"not",
"_cache",
".",
"is_configured",
":",
"_cache",
".",
"configure",
"(",
"*",
"*",
"config",
"[",
"'fmn.rules.cache'",
"]",
")",
"key",
"=",
"cache_key_generator",
... | Return the list of (pkgdb) groups to which the user belongs.
:arg config: a dict containing the fedmsg config
:arg fas: a fedora.client.fas2.AccountSystem object instanciated and loged
into FAS.
:arg username: the name of a user for which we want to retrieve groups
:return: a list of FAS groups... | [
"Return",
"the",
"list",
"of",
"(",
"pkgdb",
")",
"groups",
"to",
"which",
"the",
"user",
"belongs",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L208-L232 |
fedora-infra/fmn.rules | fmn/rules/utils.py | msg2usernames | def msg2usernames(msg, **config):
''' Return cached fedmsg.meta.msg2usernames(...) '''
if not _cache.is_configured:
_cache.configure(**config['fmn.rules.cache'])
key = "|".join(['usernames', msg['msg_id']]).encode('utf-8')
creator = lambda: fedmsg.meta.msg2usernames(msg, **config)
return _... | python | def msg2usernames(msg, **config):
''' Return cached fedmsg.meta.msg2usernames(...) '''
if not _cache.is_configured:
_cache.configure(**config['fmn.rules.cache'])
key = "|".join(['usernames', msg['msg_id']]).encode('utf-8')
creator = lambda: fedmsg.meta.msg2usernames(msg, **config)
return _... | [
"def",
"msg2usernames",
"(",
"msg",
",",
"*",
"*",
"config",
")",
":",
"if",
"not",
"_cache",
".",
"is_configured",
":",
"_cache",
".",
"configure",
"(",
"*",
"*",
"config",
"[",
"'fmn.rules.cache'",
"]",
")",
"key",
"=",
"\"|\"",
".",
"join",
"(",
"... | Return cached fedmsg.meta.msg2usernames(...) | [
"Return",
"cached",
"fedmsg",
".",
"meta",
".",
"msg2usernames",
"(",
"...",
")"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/utils.py#L235-L243 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | delist | def delist(target):
''' for any "list" found, replace with a single entry if the list has exactly one entry '''
result = target
if type(target) is dict:
for key in target:
target[key] = delist(target[key])
if type(target) is list:
if len(target)==0:
result = None
... | python | def delist(target):
''' for any "list" found, replace with a single entry if the list has exactly one entry '''
result = target
if type(target) is dict:
for key in target:
target[key] = delist(target[key])
if type(target) is list:
if len(target)==0:
result = None
... | [
"def",
"delist",
"(",
"target",
")",
":",
"result",
"=",
"target",
"if",
"type",
"(",
"target",
")",
"is",
"dict",
":",
"for",
"key",
"in",
"target",
":",
"target",
"[",
"key",
"]",
"=",
"delist",
"(",
"target",
"[",
"key",
"]",
")",
"if",
"type"... | for any "list" found, replace with a single entry if the list has exactly one entry | [
"for",
"any",
"list",
"found",
"replace",
"with",
"a",
"single",
"entry",
"if",
"the",
"list",
"has",
"exactly",
"one",
"entry"
] | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L189-L202 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | value_output | def value_output(value, quote_method='all', none_handle='strict'):
'''
Format types:
'all'.
(default) everything is embraced with quotes
'needed'.
Quote only if needed. Values are on placed in quotes if:
a. the value contains a quote
b. there is whitespace at the beginning or... | python | def value_output(value, quote_method='all', none_handle='strict'):
'''
Format types:
'all'.
(default) everything is embraced with quotes
'needed'.
Quote only if needed. Values are on placed in quotes if:
a. the value contains a quote
b. there is whitespace at the beginning or... | [
"def",
"value_output",
"(",
"value",
",",
"quote_method",
"=",
"'all'",
",",
"none_handle",
"=",
"'strict'",
")",
":",
"p",
"=",
"str",
"(",
"value",
")",
"if",
"value",
"is",
"None",
":",
"if",
"none_handle",
"==",
"'strict'",
":",
"return",
"\"\"",
"... | Format types:
'all'.
(default) everything is embraced with quotes
'needed'.
Quote only if needed. Values are on placed in quotes if:
a. the value contains a quote
b. there is whitespace at the beginning or end of string
'none'.
Quote nothing. | [
"Format",
"types",
":",
"all",
".",
"(",
"default",
")",
"everything",
"is",
"embraced",
"with",
"quotes",
"needed",
".",
"Quote",
"only",
"if",
"needed",
".",
"Values",
"are",
"on",
"placed",
"in",
"quotes",
"if",
":",
"a",
".",
"the",
"value",
"conta... | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L204-L238 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | schema_rolne_check | def schema_rolne_check(doc, schema):
'''
CHECK THE DOCUMENT AGAINST IT'S SCHEMA
returns: cleaned-up-document, error_list
'''
import standard_types as st
error_list = []
#
# PASS ONE: FORWARD CHECK OF DOC
#
# this pass verifies that each entry in the document
# has a corr... | python | def schema_rolne_check(doc, schema):
'''
CHECK THE DOCUMENT AGAINST IT'S SCHEMA
returns: cleaned-up-document, error_list
'''
import standard_types as st
error_list = []
#
# PASS ONE: FORWARD CHECK OF DOC
#
# this pass verifies that each entry in the document
# has a corr... | [
"def",
"schema_rolne_check",
"(",
"doc",
",",
"schema",
")",
":",
"import",
"standard_types",
"as",
"st",
"error_list",
"=",
"[",
"]",
"#",
"# PASS ONE: FORWARD CHECK OF DOC",
"#",
"# this pass verifies that each entry in the document",
"# has a corresponding entry in the sch... | CHECK THE DOCUMENT AGAINST IT'S SCHEMA
returns: cleaned-up-document, error_list | [
"CHECK",
"THE",
"DOCUMENT",
"AGAINST",
"IT",
"S",
"SCHEMA",
"returns",
":",
"cleaned",
"-",
"up",
"-",
"document",
"error_list"
] | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L573-L620 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | check_schema_coverage | def check_schema_coverage(doc, schema):
'''
FORWARD CHECK OF DOCUMENT
This routine looks at each element in the doc, and makes sure there
is a matching 'name' in the schema at that level.
'''
error_list = []
to_delete = []
for entry in doc.list_tuples():
(name, value, index,... | python | def check_schema_coverage(doc, schema):
'''
FORWARD CHECK OF DOCUMENT
This routine looks at each element in the doc, and makes sure there
is a matching 'name' in the schema at that level.
'''
error_list = []
to_delete = []
for entry in doc.list_tuples():
(name, value, index,... | [
"def",
"check_schema_coverage",
"(",
"doc",
",",
"schema",
")",
":",
"error_list",
"=",
"[",
"]",
"to_delete",
"=",
"[",
"]",
"for",
"entry",
"in",
"doc",
".",
"list_tuples",
"(",
")",
":",
"(",
"name",
",",
"value",
",",
"index",
",",
"seq",
")",
... | FORWARD CHECK OF DOCUMENT
This routine looks at each element in the doc, and makes sure there
is a matching 'name' in the schema at that level. | [
"FORWARD",
"CHECK",
"OF",
"DOCUMENT",
"This",
"routine",
"looks",
"at",
"each",
"element",
"in",
"the",
"doc",
"and",
"makes",
"sure",
"there",
"is",
"a",
"matching",
"name",
"in",
"the",
"schema",
"at",
"that",
"level",
"."
] | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L622-L643 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | schema_match_up | def schema_match_up(doc, schema):
'''
SCHEMA mini-recompile for:
each SEARCH then MATCH function
each TYPE then CHOICE function
given the doc, it returns a schema copy that implements the match
'''
copy = schema.copy(seq_prefix="", seq_suffix="")
copy = _schema_match_up_search(... | python | def schema_match_up(doc, schema):
'''
SCHEMA mini-recompile for:
each SEARCH then MATCH function
each TYPE then CHOICE function
given the doc, it returns a schema copy that implements the match
'''
copy = schema.copy(seq_prefix="", seq_suffix="")
copy = _schema_match_up_search(... | [
"def",
"schema_match_up",
"(",
"doc",
",",
"schema",
")",
":",
"copy",
"=",
"schema",
".",
"copy",
"(",
"seq_prefix",
"=",
"\"\"",
",",
"seq_suffix",
"=",
"\"\"",
")",
"copy",
"=",
"_schema_match_up_search",
"(",
"doc",
",",
"copy",
")",
"copy",
"=",
"... | SCHEMA mini-recompile for:
each SEARCH then MATCH function
each TYPE then CHOICE function
given the doc, it returns a schema copy that implements the match | [
"SCHEMA",
"mini",
"-",
"recompile",
"for",
":"
] | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L645-L657 |
MakerReduxCorp/MARDS | MARDS/mards_library.py | sub_schema_raises | def sub_schema_raises(doc, schema):
'''
Look for "raise_error", "raise_warning", and "raise_log"
'''
error_list = []
temp_schema = schema_match_up(doc, schema)
for msg in temp_schema.list_values("raise_error"):
error_list.append( ("[error]", "doc", doc.seq, "'{}'".format(msg)) )
... | python | def sub_schema_raises(doc, schema):
'''
Look for "raise_error", "raise_warning", and "raise_log"
'''
error_list = []
temp_schema = schema_match_up(doc, schema)
for msg in temp_schema.list_values("raise_error"):
error_list.append( ("[error]", "doc", doc.seq, "'{}'".format(msg)) )
... | [
"def",
"sub_schema_raises",
"(",
"doc",
",",
"schema",
")",
":",
"error_list",
"=",
"[",
"]",
"temp_schema",
"=",
"schema_match_up",
"(",
"doc",
",",
"schema",
")",
"for",
"msg",
"in",
"temp_schema",
".",
"list_values",
"(",
"\"raise_error\"",
")",
":",
"e... | Look for "raise_error", "raise_warning", and "raise_log" | [
"Look",
"for",
"raise_error",
"raise_warning",
"and",
"raise_log"
] | train | https://github.com/MakerReduxCorp/MARDS/blob/f8ddecc70f2ce1703984cb403c9d5417895170d6/MARDS/mards_library.py#L777-L794 |
etscrivner/nose-perfdump | perfdump/models.py | BaseTimeModel.create | def create(cls, file, module, cls_name, func, elapsed):
"""Inserts a new time sample into the database with the given information.
:param file: The file the sample is from
:type file: str
:param module: The module the sample is from
:type module: str
:param cls_n... | python | def create(cls, file, module, cls_name, func, elapsed):
"""Inserts a new time sample into the database with the given information.
:param file: The file the sample is from
:type file: str
:param module: The module the sample is from
:type module: str
:param cls_n... | [
"def",
"create",
"(",
"cls",
",",
"file",
",",
"module",
",",
"cls_name",
",",
"func",
",",
"elapsed",
")",
":",
"q",
"=",
"\"INSERT INTO {} VALUES('{}', '{}', '{}', '{}', {})\"",
"SqliteConnection",
".",
"get",
"(",
")",
".",
"execute",
"(",
"q",
".",
"form... | Inserts a new time sample into the database with the given information.
:param file: The file the sample is from
:type file: str
:param module: The module the sample is from
:type module: str
:param cls_name: The name of the class the sample is from
:type cls_nam... | [
"Inserts",
"a",
"new",
"time",
"sample",
"into",
"the",
"database",
"with",
"the",
"given",
"information",
".",
":",
"param",
"file",
":",
"The",
"file",
"the",
"sample",
"is",
"from",
":",
"type",
"file",
":",
"str",
":",
"param",
"module",
":",
"The"... | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/models.py#L127-L148 |
etscrivner/nose-perfdump | perfdump/models.py | BaseTimeModel.is_valid_row | def is_valid_row(cls, row):
"""Indicates whether or not the given row contains valid data."""
for k in row.keys():
if row[k] is None:
return False
return True | python | def is_valid_row(cls, row):
"""Indicates whether or not the given row contains valid data."""
for k in row.keys():
if row[k] is None:
return False
return True | [
"def",
"is_valid_row",
"(",
"cls",
",",
"row",
")",
":",
"for",
"k",
"in",
"row",
".",
"keys",
"(",
")",
":",
"if",
"row",
"[",
"k",
"]",
"is",
"None",
":",
"return",
"False",
"return",
"True"
] | Indicates whether or not the given row contains valid data. | [
"Indicates",
"whether",
"or",
"not",
"the",
"given",
"row",
"contains",
"valid",
"data",
"."
] | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/models.py#L151-L156 |
etscrivner/nose-perfdump | perfdump/models.py | BaseTimeModel.get_cursor | def get_cursor(cls):
"""Return a message list cursor that returns sqlite3.Row objects"""
db = SqliteConnection.get()
db.row_factory = sqlite3.Row
return db.cursor() | python | def get_cursor(cls):
"""Return a message list cursor that returns sqlite3.Row objects"""
db = SqliteConnection.get()
db.row_factory = sqlite3.Row
return db.cursor() | [
"def",
"get_cursor",
"(",
"cls",
")",
":",
"db",
"=",
"SqliteConnection",
".",
"get",
"(",
")",
"db",
".",
"row_factory",
"=",
"sqlite3",
".",
"Row",
"return",
"db",
".",
"cursor",
"(",
")"
] | Return a message list cursor that returns sqlite3.Row objects | [
"Return",
"a",
"message",
"list",
"cursor",
"that",
"returns",
"sqlite3",
".",
"Row",
"objects"
] | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/models.py#L159-L163 |
etscrivner/nose-perfdump | perfdump/models.py | BaseTimeModel.get_slowest_files | def get_slowest_files(cls, num=10):
"""Returns the slowest num files.
:param num: The maximum number of results to be returned
:type num: int
"""
cur = cls.get_cursor()
q = (
"SELECT file, SUM(elapsed) as sum_elapsed FROM {} GROUP BY file"
... | python | def get_slowest_files(cls, num=10):
"""Returns the slowest num files.
:param num: The maximum number of results to be returned
:type num: int
"""
cur = cls.get_cursor()
q = (
"SELECT file, SUM(elapsed) as sum_elapsed FROM {} GROUP BY file"
... | [
"def",
"get_slowest_files",
"(",
"cls",
",",
"num",
"=",
"10",
")",
":",
"cur",
"=",
"cls",
".",
"get_cursor",
"(",
")",
"q",
"=",
"(",
"\"SELECT file, SUM(elapsed) as sum_elapsed FROM {} GROUP BY file\"",
"\" ORDER BY sum_elapsed DESC LIMIT {}\"",
")",
"cur",
".",
... | Returns the slowest num files.
:param num: The maximum number of results to be returned
:type num: int | [
"Returns",
"the",
"slowest",
"num",
"files",
".",
":",
"param",
"num",
":",
"The",
"maximum",
"number",
"of",
"results",
"to",
"be",
"returned",
":",
"type",
"num",
":",
"int"
] | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/models.py#L183-L200 |
etscrivner/nose-perfdump | perfdump/models.py | BaseTimeModel.get_total_time | def get_total_time(cls):
"""Returns the total time taken across all results.
:rtype: float
"""
cur = cls.get_cursor()
q = "SELECT SUM(elapsed) FROM {}"
cur.execute(q.format(cls.meta['table']))
result = cur.fetchone()['SUM(elapsed)']
return result ... | python | def get_total_time(cls):
"""Returns the total time taken across all results.
:rtype: float
"""
cur = cls.get_cursor()
q = "SELECT SUM(elapsed) FROM {}"
cur.execute(q.format(cls.meta['table']))
result = cur.fetchone()['SUM(elapsed)']
return result ... | [
"def",
"get_total_time",
"(",
"cls",
")",
":",
"cur",
"=",
"cls",
".",
"get_cursor",
"(",
")",
"q",
"=",
"\"SELECT SUM(elapsed) FROM {}\"",
"cur",
".",
"execute",
"(",
"q",
".",
"format",
"(",
"cls",
".",
"meta",
"[",
"'table'",
"]",
")",
")",
"result"... | Returns the total time taken across all results.
:rtype: float | [
"Returns",
"the",
"total",
"time",
"taken",
"across",
"all",
"results",
".",
":",
"rtype",
":",
"float"
] | train | https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/models.py#L203-L212 |
awacha/credolib | credolib/utils.py | putlogo | def putlogo(figure=None):
"""Puts the CREDO logo at the bottom right of the current figure (or
the figure given by the ``figure`` argument if supplied).
"""
ip = get_ipython()
if figure is None:
figure=plt.gcf()
curraxis= figure.gca()
logoaxis = figure.add_axes([0.89, 0.01, 0.1, 0.1]... | python | def putlogo(figure=None):
"""Puts the CREDO logo at the bottom right of the current figure (or
the figure given by the ``figure`` argument if supplied).
"""
ip = get_ipython()
if figure is None:
figure=plt.gcf()
curraxis= figure.gca()
logoaxis = figure.add_axes([0.89, 0.01, 0.1, 0.1]... | [
"def",
"putlogo",
"(",
"figure",
"=",
"None",
")",
":",
"ip",
"=",
"get_ipython",
"(",
")",
"if",
"figure",
"is",
"None",
":",
"figure",
"=",
"plt",
".",
"gcf",
"(",
")",
"curraxis",
"=",
"figure",
".",
"gca",
"(",
")",
"logoaxis",
"=",
"figure",
... | Puts the CREDO logo at the bottom right of the current figure (or
the figure given by the ``figure`` argument if supplied). | [
"Puts",
"the",
"CREDO",
"logo",
"at",
"the",
"bottom",
"right",
"of",
"the",
"current",
"figure",
"(",
"or",
"the",
"figure",
"given",
"by",
"the",
"figure",
"argument",
"if",
"supplied",
")",
"."
] | train | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/utils.py#L16-L30 |
qbicsoftware/mtb-parser-lib | mtbparser/snv_parser.py | SnvParser._parse_header | def _parse_header(self, header_string):
"""
Parses the header and determines the column type
and its column index.
"""
header_content = header_string.strip().split('\t')
if len(header_content) != self._snv_enum.HEADER_LEN.value:
raise MTBParserException(
... | python | def _parse_header(self, header_string):
"""
Parses the header and determines the column type
and its column index.
"""
header_content = header_string.strip().split('\t')
if len(header_content) != self._snv_enum.HEADER_LEN.value:
raise MTBParserException(
... | [
"def",
"_parse_header",
"(",
"self",
",",
"header_string",
")",
":",
"header_content",
"=",
"header_string",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\t'",
")",
"if",
"len",
"(",
"header_content",
")",
"!=",
"self",
".",
"_snv_enum",
".",
"HEADER_LEN"... | Parses the header and determines the column type
and its column index. | [
"Parses",
"the",
"header",
"and",
"determines",
"the",
"column",
"type",
"and",
"its",
"column",
"index",
"."
] | train | https://github.com/qbicsoftware/mtb-parser-lib/blob/e8b96e34b27e457ea7def2927fe44017fa173ba7/mtbparser/snv_parser.py#L26-L48 |
qbicsoftware/mtb-parser-lib | mtbparser/snv_parser.py | SnvParser._parse_content | def _parse_content(self, snv_entries):
"""
Parses SNV entries to SNVItems, objects
representing the content for every entry, that
can be used for further processing.
"""
if len(snv_entries) == 1:
return
for line in snv_entries[1:]:
info_dic... | python | def _parse_content(self, snv_entries):
"""
Parses SNV entries to SNVItems, objects
representing the content for every entry, that
can be used for further processing.
"""
if len(snv_entries) == 1:
return
for line in snv_entries[1:]:
info_dic... | [
"def",
"_parse_content",
"(",
"self",
",",
"snv_entries",
")",
":",
"if",
"len",
"(",
"snv_entries",
")",
"==",
"1",
":",
"return",
"for",
"line",
"in",
"snv_entries",
"[",
"1",
":",
"]",
":",
"info_dict",
"=",
"self",
".",
"_map_info_to_col",
"(",
"li... | Parses SNV entries to SNVItems, objects
representing the content for every entry, that
can be used for further processing. | [
"Parses",
"SNV",
"entries",
"to",
"SNVItems",
"objects",
"representing",
"the",
"content",
"for",
"every",
"entry",
"that",
"can",
"be",
"used",
"for",
"further",
"processing",
"."
] | train | https://github.com/qbicsoftware/mtb-parser-lib/blob/e8b96e34b27e457ea7def2927fe44017fa173ba7/mtbparser/snv_parser.py#L50-L60 |
iamsteadman/bambu-mail | bambu_mail/shortcuts.py | render_to_mail | def render_to_mail(subject, template, context, recipient, fail_silently = False, headers = None):
"""
:param subject: The subject line of the email
:param template: The name of the template to render the HTML email with
:param context: The context data to pass to the template
:param recipient: The e... | python | def render_to_mail(subject, template, context, recipient, fail_silently = False, headers = None):
"""
:param subject: The subject line of the email
:param template: The name of the template to render the HTML email with
:param context: The context data to pass to the template
:param recipient: The e... | [
"def",
"render_to_mail",
"(",
"subject",
",",
"template",
",",
"context",
",",
"recipient",
",",
"fail_silently",
"=",
"False",
",",
"headers",
"=",
"None",
")",
":",
"if",
"'djcelery'",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"render_to_mail_task",
".",... | :param subject: The subject line of the email
:param template: The name of the template to render the HTML email with
:param context: The context data to pass to the template
:param recipient: The email address or ``django.contrib.auth.User`` object to send the email to
:param fail_silently: Set to ``Tr... | [
":",
"param",
"subject",
":",
"The",
"subject",
"line",
"of",
"the",
"email",
":",
"param",
"template",
":",
"The",
"name",
"of",
"the",
"template",
"to",
"render",
"the",
"HTML",
"email",
"with",
":",
"param",
"context",
":",
"The",
"context",
"data",
... | train | https://github.com/iamsteadman/bambu-mail/blob/5298e6ab861cabc8859c8356ccb2354b1b902cd1/bambu_mail/shortcuts.py#L4-L36 |
iamsteadman/bambu-mail | bambu_mail/shortcuts.py | subscribe | def subscribe(email, **kwargs):
"""
:param email: The email address of the user to add to the mailing list
:param kwargs: Keyword arguments to pass to the individual newsletter provider
This function acts as an alias to one of two functions, depending on your setup. If you use
`Celery <http://www.c... | python | def subscribe(email, **kwargs):
"""
:param email: The email address of the user to add to the mailing list
:param kwargs: Keyword arguments to pass to the individual newsletter provider
This function acts as an alias to one of two functions, depending on your setup. If you use
`Celery <http://www.c... | [
"def",
"subscribe",
"(",
"email",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'djcelery'",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"subscribe_task",
".",
"delay",
"(",
"email",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
"subscribe_task",
"(",
"email"... | :param email: The email address of the user to add to the mailing list
:param kwargs: Keyword arguments to pass to the individual newsletter provider
This function acts as an alias to one of two functions, depending on your setup. If you use
`Celery <http://www.celeryproject.org/>`_,
this function will... | [
":",
"param",
"email",
":",
"The",
"email",
"address",
"of",
"the",
"user",
"to",
"add",
"to",
"the",
"mailing",
"list",
":",
"param",
"kwargs",
":",
"Keyword",
"arguments",
"to",
"pass",
"to",
"the",
"individual",
"newsletter",
"provider"
] | train | https://github.com/iamsteadman/bambu-mail/blob/5298e6ab861cabc8859c8356ccb2354b1b902cd1/bambu_mail/shortcuts.py#L38-L57 |
b3j0f/utils | b3j0f/utils/chaining.py | _process_function | def _process_function(chaining, routine):
"""Chain function which returns a function.
:param routine: routine to process.
:return: routine embedding execution function.
"""
def processing(*args, **kwargs):
"""Execute routine with input args and kwargs and add reuslt in
chaining.___... | python | def _process_function(chaining, routine):
"""Chain function which returns a function.
:param routine: routine to process.
:return: routine embedding execution function.
"""
def processing(*args, **kwargs):
"""Execute routine with input args and kwargs and add reuslt in
chaining.___... | [
"def",
"_process_function",
"(",
"chaining",
",",
"routine",
")",
":",
"def",
"processing",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Execute routine with input args and kwargs and add reuslt in\n chaining.___.\n\n :param tuple args: routine vara... | Chain function which returns a function.
:param routine: routine to process.
:return: routine embedding execution function. | [
"Chain",
"function",
"which",
"returns",
"a",
"function",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/chaining.py#L99-L121 |
b3j0f/utils | b3j0f/utils/chaining.py | _process_function_list | def _process_function_list(self, routines):
"""Chain function which returns a function.
:param routines: routines to process.
"""
def processing(*args, **kwargs):
"""Execute routines with input args and kwargs and add result in
chaining.___.
:param tuple args: routines varargs... | python | def _process_function_list(self, routines):
"""Chain function which returns a function.
:param routines: routines to process.
"""
def processing(*args, **kwargs):
"""Execute routines with input args and kwargs and add result in
chaining.___.
:param tuple args: routines varargs... | [
"def",
"_process_function_list",
"(",
"self",
",",
"routines",
")",
":",
"def",
"processing",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Execute routines with input args and kwargs and add result in\n chaining.___.\n\n :param tuple args: routines ... | Chain function which returns a function.
:param routines: routines to process. | [
"Chain",
"function",
"which",
"returns",
"a",
"function",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/chaining.py#L180-L210 |
muneeb-ali/commontools | commontools/commontools.py | setup_logging | def setup_logging(
file_name='logging.json',
default_level=logging.INFO,
):
"""
Setup logging configuration
"""
current_dir = os.path.abspath(os.path.dirname(__file__))
file_path = current_dir + '/' + file_name
if os.path.exists(file_path):
with open(file_path, 'rt'... | python | def setup_logging(
file_name='logging.json',
default_level=logging.INFO,
):
"""
Setup logging configuration
"""
current_dir = os.path.abspath(os.path.dirname(__file__))
file_path = current_dir + '/' + file_name
if os.path.exists(file_path):
with open(file_path, 'rt'... | [
"def",
"setup_logging",
"(",
"file_name",
"=",
"'logging.json'",
",",
"default_level",
"=",
"logging",
".",
"INFO",
",",
")",
":",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
... | Setup logging configuration | [
"Setup",
"logging",
"configuration"
] | train | https://github.com/muneeb-ali/commontools/blob/62ad02e085838f5400924a6884f25018a4a410de/commontools/commontools.py#L18-L40 |
alexhayes/django-toolkit | django_toolkit/templatetags/actions.py | actions | def actions(obj, **kwargs):
"""
Return actions available for an object
"""
if 'exclude' in kwargs:
kwargs['exclude'] = kwargs['exclude'].split(',')
actions = obj.get_actions(**kwargs)
if isinstance(actions, dict):
actions = actions.values()
buttons = "".join("%s" % action.ren... | python | def actions(obj, **kwargs):
"""
Return actions available for an object
"""
if 'exclude' in kwargs:
kwargs['exclude'] = kwargs['exclude'].split(',')
actions = obj.get_actions(**kwargs)
if isinstance(actions, dict):
actions = actions.values()
buttons = "".join("%s" % action.ren... | [
"def",
"actions",
"(",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'exclude'",
"in",
"kwargs",
":",
"kwargs",
"[",
"'exclude'",
"]",
"=",
"kwargs",
"[",
"'exclude'",
"]",
".",
"split",
"(",
"','",
")",
"actions",
"=",
"obj",
".",
"get_actions",
... | Return actions available for an object | [
"Return",
"actions",
"available",
"for",
"an",
"object"
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/templatetags/actions.py#L8-L18 |
heikomuller/sco-engine | scoengine/__init__.py | init_registry | def init_registry(mongo, model_defs, clear_collection=False):
"""Initialize a model registry with a list of model definitions in Json
format.
Parameters
----------
mongo : scodata.MongoDBFactory
Connector for MongoDB
model_defs : list()
List of model definitions in Json-like for... | python | def init_registry(mongo, model_defs, clear_collection=False):
"""Initialize a model registry with a list of model definitions in Json
format.
Parameters
----------
mongo : scodata.MongoDBFactory
Connector for MongoDB
model_defs : list()
List of model definitions in Json-like for... | [
"def",
"init_registry",
"(",
"mongo",
",",
"model_defs",
",",
"clear_collection",
"=",
"False",
")",
":",
"# Create model registry",
"registry",
"=",
"SCOEngine",
"(",
"mongo",
")",
".",
"registry",
"# Drop collection if clear flag is set to True",
"if",
"clear_collecti... | Initialize a model registry with a list of model definitions in Json
format.
Parameters
----------
mongo : scodata.MongoDBFactory
Connector for MongoDB
model_defs : list()
List of model definitions in Json-like format
clear_collection : boolean
If true, collection will b... | [
"Initialize",
"a",
"model",
"registry",
"with",
"a",
"list",
"of",
"model",
"definitions",
"in",
"Json",
"format",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L506-L532 |
heikomuller/sco-engine | scoengine/__init__.py | SCOEngine.list_models | def list_models(self, limit=-1, offset=-1):
"""Get a list of models in the registry.
Parameters
----------
limit : int
Limit number of items in the result set
offset : int
Set offset in list (order as defined by object store)
Returns
-------
li... | python | def list_models(self, limit=-1, offset=-1):
"""Get a list of models in the registry.
Parameters
----------
limit : int
Limit number of items in the result set
offset : int
Set offset in list (order as defined by object store)
Returns
-------
li... | [
"def",
"list_models",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"registry",
".",
"list_models",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")"
] | Get a list of models in the registry.
Parameters
----------
limit : int
Limit number of items in the result set
offset : int
Set offset in list (order as defined by object store)
Returns
-------
list(ModelHandle) | [
"Get",
"a",
"list",
"of",
"models",
"in",
"the",
"registry",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L94-L108 |
heikomuller/sco-engine | scoengine/__init__.py | SCOEngine.register_model | def register_model(self, model_id, properties, parameters, outputs, connector):
"""Register a new model with the engine. Expects connection information
for RabbitMQ to submit model run requests to workers.
Raises ValueError if the given model identifier is not unique.
Parameters
... | python | def register_model(self, model_id, properties, parameters, outputs, connector):
"""Register a new model with the engine. Expects connection information
for RabbitMQ to submit model run requests to workers.
Raises ValueError if the given model identifier is not unique.
Parameters
... | [
"def",
"register_model",
"(",
"self",
",",
"model_id",
",",
"properties",
",",
"parameters",
",",
"outputs",
",",
"connector",
")",
":",
"# Validate the given connector information",
"self",
".",
"validate_connector",
"(",
"connector",
")",
"# Connector information is v... | Register a new model with the engine. Expects connection information
for RabbitMQ to submit model run requests to workers.
Raises ValueError if the given model identifier is not unique.
Parameters
----------
model_id : string
Unique model identifier
properti... | [
"Register",
"a",
"new",
"model",
"with",
"the",
"engine",
".",
"Expects",
"connection",
"information",
"for",
"RabbitMQ",
"to",
"submit",
"model",
"run",
"requests",
"to",
"workers",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L110-L148 |
heikomuller/sco-engine | scoengine/__init__.py | SCOEngine.run_model | def run_model(self, model_run, run_url):
"""Execute the given model run.
Throws a ValueError if the given run specifies an unknown model or if
the model connector is invalid. An EngineException is thrown if running
the model (i.e., communication with the backend) fails.
Paramet... | python | def run_model(self, model_run, run_url):
"""Execute the given model run.
Throws a ValueError if the given run specifies an unknown model or if
the model connector is invalid. An EngineException is thrown if running
the model (i.e., communication with the backend) fails.
Paramet... | [
"def",
"run_model",
"(",
"self",
",",
"model_run",
",",
"run_url",
")",
":",
"# Get model to verify that it exists and to get connector information",
"model",
"=",
"self",
".",
"get_model",
"(",
"model_run",
".",
"model_id",
")",
"if",
"model",
"is",
"None",
":",
... | Execute the given model run.
Throws a ValueError if the given run specifies an unknown model or if
the model connector is invalid. An EngineException is thrown if running
the model (i.e., communication with the backend) fails.
Parameters
----------
model_run : ModelRunH... | [
"Execute",
"the",
"given",
"model",
"run",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L150-L170 |
heikomuller/sco-engine | scoengine/__init__.py | SCOEngine.update_model_connector | def update_model_connector(self, model_id, connector):
"""Update the connector information for a given model.
Returns None if the specified model not exist.
Parameters
----------
model_id : string
Unique model identifier
connector : dict
New conn... | python | def update_model_connector(self, model_id, connector):
"""Update the connector information for a given model.
Returns None if the specified model not exist.
Parameters
----------
model_id : string
Unique model identifier
connector : dict
New conn... | [
"def",
"update_model_connector",
"(",
"self",
",",
"model_id",
",",
"connector",
")",
":",
"# Validate the given connector information",
"self",
".",
"validate_connector",
"(",
"connector",
")",
"# Connector information is valid. Ok to update the model.",
"return",
"self",
".... | Update the connector information for a given model.
Returns None if the specified model not exist.
Parameters
----------
model_id : string
Unique model identifier
connector : dict
New connection information
Returns
-------
ModelH... | [
"Update",
"the",
"connector",
"information",
"for",
"a",
"given",
"model",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L172-L191 |
heikomuller/sco-engine | scoengine/__init__.py | SCOEngine.validate_connector | def validate_connector(self, connector):
"""Validate a given connector. Raises ValueError if the connector is not
valid.
Parameters
----------
connector : dict
Connection information
"""
if not 'connector' in connector:
raise ValueError('m... | python | def validate_connector(self, connector):
"""Validate a given connector. Raises ValueError if the connector is not
valid.
Parameters
----------
connector : dict
Connection information
"""
if not 'connector' in connector:
raise ValueError('m... | [
"def",
"validate_connector",
"(",
"self",
",",
"connector",
")",
":",
"if",
"not",
"'connector'",
"in",
"connector",
":",
"raise",
"ValueError",
"(",
"'missing connector name'",
")",
"elif",
"connector",
"[",
"'connector'",
"]",
"!=",
"CONNECTOR_RABBITMQ",
":",
... | Validate a given connector. Raises ValueError if the connector is not
valid.
Parameters
----------
connector : dict
Connection information | [
"Validate",
"a",
"given",
"connector",
".",
"Raises",
"ValueError",
"if",
"the",
"connector",
"is",
"not",
"valid",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L214-L229 |
heikomuller/sco-engine | scoengine/__init__.py | RabbitMQConnector.run_model | def run_model(self, model_run, run_url):
"""Run model by sending message to RabbitMQ queue containing the
run end experiment identifier. Messages are persistent to ensure that
a worker will process process the run request at some point.
Throws a EngineException if communication with the... | python | def run_model(self, model_run, run_url):
"""Run model by sending message to RabbitMQ queue containing the
run end experiment identifier. Messages are persistent to ensure that
a worker will process process the run request at some point.
Throws a EngineException if communication with the... | [
"def",
"run_model",
"(",
"self",
",",
"model_run",
",",
"run_url",
")",
":",
"# Open connection to RabbitMQ server. Will raise an exception if the",
"# server is not running. In this case we raise an EngineException to",
"# allow caller to delete model run.",
"try",
":",
"credentials",... | Run model by sending message to RabbitMQ queue containing the
run end experiment identifier. Messages are persistent to ensure that
a worker will process process the run request at some point.
Throws a EngineException if communication with the server fails.
Parameters
---------... | [
"Run",
"model",
"by",
"sending",
"message",
"to",
"RabbitMQ",
"queue",
"containing",
"the",
"run",
"end",
"experiment",
"identifier",
".",
"Messages",
"are",
"persistent",
"to",
"ensure",
"that",
"a",
"worker",
"will",
"process",
"process",
"the",
"run",
"requ... | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L278-L323 |
heikomuller/sco-engine | scoengine/__init__.py | BufferedConnector.run_model | def run_model(self, model_run, run_url):
"""Create entry in run request buffer.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run information
"""
# Create model run request
requ... | python | def run_model(self, model_run, run_url):
"""Create entry in run request buffer.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run information
"""
# Create model run request
requ... | [
"def",
"run_model",
"(",
"self",
",",
"model_run",
",",
"run_url",
")",
":",
"# Create model run request",
"request",
"=",
"RequestFactory",
"(",
")",
".",
"get_request",
"(",
"model_run",
",",
"run_url",
")",
"# Write request and connector information into buffer",
"... | Create entry in run request buffer.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run information | [
"Create",
"entry",
"in",
"run",
"request",
"buffer",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L357-L373 |
heikomuller/sco-engine | scoengine/__init__.py | RequestFactory.get_request | def get_request(self, model_run, run_url):
"""Create request object to run model. Requests are handled by SCO
worker implementations.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run informati... | python | def get_request(self, model_run, run_url):
"""Create request object to run model. Requests are handled by SCO
worker implementations.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run informati... | [
"def",
"get_request",
"(",
"self",
",",
"model_run",
",",
"run_url",
")",
":",
"return",
"ModelRunRequest",
"(",
"model_run",
".",
"identifier",
",",
"model_run",
".",
"experiment_id",
",",
"run_url",
")"
] | Create request object to run model. Requests are handled by SCO
worker implementations.
Parameters
----------
model_run : ModelRunHandle
Handle to model run
run_url : string
URL for model run information
Returns
-------
ModelRunRe... | [
"Create",
"request",
"object",
"to",
"run",
"model",
".",
"Requests",
"are",
"handled",
"by",
"SCO",
"worker",
"implementations",
"."
] | train | https://github.com/heikomuller/sco-engine/blob/3e7782d059ec808d930f0992794b6f5a8fd73c2c/scoengine/__init__.py#L383-L403 |
thomasvandoren/bugzscout-py | bugzscout/ext/celery_app.py | submit_error | def submit_error(url, user, project, area, description,
extra=None, default_message=None):
"""Celery task for submitting errors asynchronously.
:param url: string URL for bugzscout
:param user: string fogbugz user to designate when submitting
via bugzscout
:param proje... | python | def submit_error(url, user, project, area, description,
extra=None, default_message=None):
"""Celery task for submitting errors asynchronously.
:param url: string URL for bugzscout
:param user: string fogbugz user to designate when submitting
via bugzscout
:param proje... | [
"def",
"submit_error",
"(",
"url",
",",
"user",
",",
"project",
",",
"area",
",",
"description",
",",
"extra",
"=",
"None",
",",
"default_message",
"=",
"None",
")",
":",
"LOG",
".",
"debug",
"(",
"'Creating new BugzScout instance.'",
")",
"client",
"=",
"... | Celery task for submitting errors asynchronously.
:param url: string URL for bugzscout
:param user: string fogbugz user to designate when submitting
via bugzscout
:param project: string fogbugz project to designate for cases
:param area: string fogbugz area to designate for cases
:... | [
"Celery",
"task",
"for",
"submitting",
"errors",
"asynchronously",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/bugzscout/ext/celery_app.py#L30-L49 |
wheeler-microfluidics/nested-structures | nested_structures/__init__.py | apply_depth_first | def apply_depth_first(nodes, func, depth=0, as_dict=False, parents=None):
'''
Given a structure such as the application menu layout described above, we
may want to apply an operation to each entry to create a transformed
version of the structure.
For example, let's convert all entries in the applic... | python | def apply_depth_first(nodes, func, depth=0, as_dict=False, parents=None):
'''
Given a structure such as the application menu layout described above, we
may want to apply an operation to each entry to create a transformed
version of the structure.
For example, let's convert all entries in the applic... | [
"def",
"apply_depth_first",
"(",
"nodes",
",",
"func",
",",
"depth",
"=",
"0",
",",
"as_dict",
"=",
"False",
",",
"parents",
"=",
"None",
")",
":",
"if",
"as_dict",
":",
"items",
"=",
"OrderedDict",
"(",
")",
"else",
":",
"items",
"=",
"[",
"]",
"i... | Given a structure such as the application menu layout described above, we
may want to apply an operation to each entry to create a transformed
version of the structure.
For example, let's convert all entries in the application menu layout from
above to upper-case:
>>> pprint(apply_depth_first(menu... | [
"Given",
"a",
"structure",
"such",
"as",
"the",
"application",
"menu",
"layout",
"described",
"above",
"we",
"may",
"want",
"to",
"apply",
"an",
"operation",
"to",
"each",
"entry",
"to",
"create",
"a",
"transformed",
"version",
"of",
"the",
"structure",
"."
... | train | https://github.com/wheeler-microfluidics/nested-structures/blob/e3586bcca01c59f18ae16b8240e6e49197b63ecb/nested_structures/__init__.py#L51-L146 |
wheeler-microfluidics/nested-structures | nested_structures/__init__.py | apply_dict_depth_first | def apply_dict_depth_first(nodes, func, depth=0, as_dict=True, parents=None, pre=None, post=None):
'''
This function is similar to the `apply_depth_first` except that it operates
on the `OrderedDict`-based structure returned from `apply_depth_first` when
`as_dict=True`.
Note that if `as_dict` is `F... | python | def apply_dict_depth_first(nodes, func, depth=0, as_dict=True, parents=None, pre=None, post=None):
'''
This function is similar to the `apply_depth_first` except that it operates
on the `OrderedDict`-based structure returned from `apply_depth_first` when
`as_dict=True`.
Note that if `as_dict` is `F... | [
"def",
"apply_dict_depth_first",
"(",
"nodes",
",",
"func",
",",
"depth",
"=",
"0",
",",
"as_dict",
"=",
"True",
",",
"parents",
"=",
"None",
",",
"pre",
"=",
"None",
",",
"post",
"=",
"None",
")",
":",
"if",
"as_dict",
":",
"items",
"=",
"OrderedDic... | This function is similar to the `apply_depth_first` except that it operates
on the `OrderedDict`-based structure returned from `apply_depth_first` when
`as_dict=True`.
Note that if `as_dict` is `False`, the result of this function is given in
the entry/tuple form. | [
"This",
"function",
"is",
"similar",
"to",
"the",
"apply_depth_first",
"except",
"that",
"it",
"operates",
"on",
"the",
"OrderedDict",
"-",
"based",
"structure",
"returned",
"from",
"apply_depth_first",
"when",
"as_dict",
"=",
"True",
"."
] | train | https://github.com/wheeler-microfluidics/nested-structures/blob/e3586bcca01c59f18ae16b8240e6e49197b63ecb/nested_structures/__init__.py#L149-L190 |
wheeler-microfluidics/nested-structures | nested_structures/__init__.py | collect | def collect(nested_nodes, transform=None):
'''
Return list containing the result of the `transform` function applied to
each item in the supplied list of nested nodes.
A custom transform function may be applied to each entry during the
flattening by specifying a function through the `transform` key... | python | def collect(nested_nodes, transform=None):
'''
Return list containing the result of the `transform` function applied to
each item in the supplied list of nested nodes.
A custom transform function may be applied to each entry during the
flattening by specifying a function through the `transform` key... | [
"def",
"collect",
"(",
"nested_nodes",
",",
"transform",
"=",
"None",
")",
":",
"items",
"=",
"[",
"]",
"if",
"transform",
"is",
"None",
":",
"transform",
"=",
"lambda",
"node",
",",
"parents",
",",
"nodes",
",",
"*",
"args",
":",
"node",
"def",
"__c... | Return list containing the result of the `transform` function applied to
each item in the supplied list of nested nodes.
A custom transform function may be applied to each entry during the
flattening by specifying a function through the `transform` keyword
argument. The `transform` function will be pa... | [
"Return",
"list",
"containing",
"the",
"result",
"of",
"the",
"transform",
"function",
"applied",
"to",
"each",
"item",
"in",
"the",
"supplied",
"list",
"of",
"nested",
"nodes",
"."
] | train | https://github.com/wheeler-microfluidics/nested-structures/blob/e3586bcca01c59f18ae16b8240e6e49197b63ecb/nested_structures/__init__.py#L193-L218 |
ramrod-project/database-brain | schema/brain/binary/decorators.py | wrap_name_to_id | def wrap_name_to_id(func_, *args, **kwargs):
"""
destination (rethinkdb) needs the id field as primary key
put the Name field into the ID field
:param func_:
:param args:
:param kwargs:
:return:
"""
assert isinstance(args[0], dict)
args[0][PRIMARY_KEY] = args[0].get(PRIMARY_FIELD... | python | def wrap_name_to_id(func_, *args, **kwargs):
"""
destination (rethinkdb) needs the id field as primary key
put the Name field into the ID field
:param func_:
:param args:
:param kwargs:
:return:
"""
assert isinstance(args[0], dict)
args[0][PRIMARY_KEY] = args[0].get(PRIMARY_FIELD... | [
"def",
"wrap_name_to_id",
"(",
"func_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"dict",
")",
"args",
"[",
"0",
"]",
"[",
"PRIMARY_KEY",
"]",
"=",
"args",
"[",
"0",
"]",
".",
... | destination (rethinkdb) needs the id field as primary key
put the Name field into the ID field
:param func_:
:param args:
:param kwargs:
:return: | [
"destination",
"(",
"rethinkdb",
")",
"needs",
"the",
"id",
"field",
"as",
"primary",
"key",
"put",
"the",
"Name",
"field",
"into",
"the",
"ID",
"field",
":",
"param",
"func_",
":",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":",
":",
"return",... | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/binary/decorators.py#L20-L31 |
ramrod-project/database-brain | schema/brain/binary/decorators.py | wrap_split_big_content | def wrap_split_big_content(func_, *args, **kwargs):
"""
chunk the content into smaller binary blobs before inserting
this function should chunk in such a way that this
is completely transparent to the user.
:param func_:
:param args:
:param kwargs:
:return: <dict> RethinkDB dict from i... | python | def wrap_split_big_content(func_, *args, **kwargs):
"""
chunk the content into smaller binary blobs before inserting
this function should chunk in such a way that this
is completely transparent to the user.
:param func_:
:param args:
:param kwargs:
:return: <dict> RethinkDB dict from i... | [
"def",
"wrap_split_big_content",
"(",
"func_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj_dict",
"=",
"args",
"[",
"0",
"]",
"if",
"len",
"(",
"obj_dict",
"[",
"CONTENT_FIELD",
"]",
")",
"<",
"MAX_PUT",
":",
"obj_dict",
"[",
"PART_FIELD"... | chunk the content into smaller binary blobs before inserting
this function should chunk in such a way that this
is completely transparent to the user.
:param func_:
:param args:
:param kwargs:
:return: <dict> RethinkDB dict from insert | [
"chunk",
"the",
"content",
"into",
"smaller",
"binary",
"blobs",
"before",
"inserting"
] | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/binary/decorators.py#L35-L52 |
ramrod-project/database-brain | schema/brain/binary/decorators.py | _only_if_file_not_exist | def _only_if_file_not_exist(func_, *args, **kwargs):
"""
horribly non-atomic
:param func_:
:param args:
:param kwargs:
:return:
"""
obj_dict = args[1]
conn = args[-1]
try:
RBF.get(obj_dict[PRIMARY_FIELD]).pluck(PRIMARY_FIELD).run(conn)
err_str = "Duplicate primar... | python | def _only_if_file_not_exist(func_, *args, **kwargs):
"""
horribly non-atomic
:param func_:
:param args:
:param kwargs:
:return:
"""
obj_dict = args[1]
conn = args[-1]
try:
RBF.get(obj_dict[PRIMARY_FIELD]).pluck(PRIMARY_FIELD).run(conn)
err_str = "Duplicate primar... | [
"def",
"_only_if_file_not_exist",
"(",
"func_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj_dict",
"=",
"args",
"[",
"1",
"]",
"conn",
"=",
"args",
"[",
"-",
"1",
"]",
"try",
":",
"RBF",
".",
"get",
"(",
"obj_dict",
"[",
"PRIMARY_FIEL... | horribly non-atomic
:param func_:
:param args:
:param kwargs:
:return: | [
"horribly",
"non",
"-",
"atomic"
] | train | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/binary/decorators.py#L56-L74 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.