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 |
|---|---|---|---|---|---|---|---|---|---|---|
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.rpyhttp | def rpyhttp(value):
""" converts a no namespace pyuri back to a standard uri """
if value.startswith("http"):
return value
try:
parts = value.split("_")
del parts[0]
_uri = base64.b64decode(parts.pop(0)).decode()
return _uri + "_".join(... | python | def rpyhttp(value):
""" converts a no namespace pyuri back to a standard uri """
if value.startswith("http"):
return value
try:
parts = value.split("_")
del parts[0]
_uri = base64.b64decode(parts.pop(0)).decode()
return _uri + "_".join(... | [
"def",
"rpyhttp",
"(",
"value",
")",
":",
"if",
"value",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"return",
"value",
"try",
":",
"parts",
"=",
"value",
".",
"split",
"(",
"\"_\"",
")",
"del",
"parts",
"[",
"0",
"]",
"_uri",
"=",
"base64",
".",... | converts a no namespace pyuri back to a standard uri | [
"converts",
"a",
"no",
"namespace",
"pyuri",
"back",
"to",
"a",
"standard",
"uri"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L651-L662 |
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.pyhttp | def pyhttp(self, value):
""" converts a no namespaces uri to a python excessable name """
if value.startswith("pyuri_"):
return value
parts = self.parse_uri(value)
return "pyuri_%s_%s" % (base64.b64encode(bytes(parts[0],
... | python | def pyhttp(self, value):
""" converts a no namespaces uri to a python excessable name """
if value.startswith("pyuri_"):
return value
parts = self.parse_uri(value)
return "pyuri_%s_%s" % (base64.b64encode(bytes(parts[0],
... | [
"def",
"pyhttp",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
".",
"startswith",
"(",
"\"pyuri_\"",
")",
":",
"return",
"value",
"parts",
"=",
"self",
".",
"parse_uri",
"(",
"value",
")",
"return",
"\"pyuri_%s_%s\"",
"%",
"(",
"base64",
".",
"b6... | converts a no namespaces uri to a python excessable name | [
"converts",
"a",
"no",
"namespaces",
"uri",
"to",
"a",
"python",
"excessable",
"name"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L664-L671 |
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.iri | def iri(uri_string):
"""converts a string to an IRI or returns an IRI if already formated
Args:
uri_string: uri in string format
Returns:
formated uri with <>
"""
uri_string = str(uri_string)
if uri_string[:1] == "?":
return uri_strin... | python | def iri(uri_string):
"""converts a string to an IRI or returns an IRI if already formated
Args:
uri_string: uri in string format
Returns:
formated uri with <>
"""
uri_string = str(uri_string)
if uri_string[:1] == "?":
return uri_strin... | [
"def",
"iri",
"(",
"uri_string",
")",
":",
"uri_string",
"=",
"str",
"(",
"uri_string",
")",
"if",
"uri_string",
"[",
":",
"1",
"]",
"==",
"\"?\"",
":",
"return",
"uri_string",
"if",
"uri_string",
"[",
":",
"1",
"]",
"==",
"\"[\"",
":",
"return",
"ur... | converts a string to an IRI or returns an IRI if already formated
Args:
uri_string: uri in string format
Returns:
formated uri with <> | [
"converts",
"a",
"string",
"to",
"an",
"IRI",
"or",
"returns",
"an",
"IRI",
"if",
"already",
"formated"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L682-L700 |
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.convert_to_ttl | def convert_to_ttl(self, value):
''' converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is.
args:
value: the value to convert
'''
parsed = self.parse_uri(value)
try:
rtn_val = "%s:%s" % (self.uri_dict[parse... | python | def convert_to_ttl(self, value):
''' converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is.
args:
value: the value to convert
'''
parsed = self.parse_uri(value)
try:
rtn_val = "%s:%s" % (self.uri_dict[parse... | [
"def",
"convert_to_ttl",
"(",
"self",
",",
"value",
")",
":",
"parsed",
"=",
"self",
".",
"parse_uri",
"(",
"value",
")",
"try",
":",
"rtn_val",
"=",
"\"%s:%s\"",
"%",
"(",
"self",
".",
"uri_dict",
"[",
"parsed",
"[",
"0",
"]",
"]",
",",
"parsed",
... | converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is.
args:
value: the value to convert | [
"converts",
"a",
"value",
"to",
"the",
"prefixed",
"rdf",
"ns",
"equivalent",
".",
"If",
"not",
"found",
"returns",
"the",
"value",
"as",
"is",
"."
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L702-L717 |
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.convert_to_ns | def convert_to_ns(self, value):
''' converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is
args:
value: the value to convert
'''
parsed = self.parse_uri(value)
try:
rtn_val = "%s_%s" % (self.uri_dict[parsed[0... | python | def convert_to_ns(self, value):
''' converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is
args:
value: the value to convert
'''
parsed = self.parse_uri(value)
try:
rtn_val = "%s_%s" % (self.uri_dict[parsed[0... | [
"def",
"convert_to_ns",
"(",
"self",
",",
"value",
")",
":",
"parsed",
"=",
"self",
".",
"parse_uri",
"(",
"value",
")",
"try",
":",
"rtn_val",
"=",
"\"%s_%s\"",
"%",
"(",
"self",
".",
"uri_dict",
"[",
"parsed",
"[",
"0",
"]",
"]",
",",
"parsed",
"... | converts a value to the prefixed rdf ns equivalent. If not found
returns the value as is
args:
value: the value to convert | [
"converts",
"a",
"value",
"to",
"the",
"prefixed",
"rdf",
"ns",
"equivalent",
".",
"If",
"not",
"found",
"returns",
"the",
"value",
"as",
"is"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L719-L732 |
KnowledgeLinks/rdfframework | rdfframework/datatypes/namespaces.py | RdfNsManager.parse_uri | def parse_uri(value):
""" Parses a value into a head and tail pair based on the finding the
last '#' or '/' as is standard with URI fromats
args:
value: string value to parse
returns:
tuple: (lookup, end)
"""
value = RdfNsManager.clean_iri(va... | python | def parse_uri(value):
""" Parses a value into a head and tail pair based on the finding the
last '#' or '/' as is standard with URI fromats
args:
value: string value to parse
returns:
tuple: (lookup, end)
"""
value = RdfNsManager.clean_iri(va... | [
"def",
"parse_uri",
"(",
"value",
")",
":",
"value",
"=",
"RdfNsManager",
".",
"clean_iri",
"(",
"value",
")",
"lookup",
"=",
"None",
"end",
"=",
"None",
"try",
":",
"lookup",
"=",
"value",
"[",
":",
"value",
".",
"rindex",
"(",
"'#'",
")",
"+",
"1... | Parses a value into a head and tail pair based on the finding the
last '#' or '/' as is standard with URI fromats
args:
value: string value to parse
returns:
tuple: (lookup, end) | [
"Parses",
"a",
"value",
"into",
"a",
"head",
"and",
"tail",
"pair",
"based",
"on",
"the",
"finding",
"the",
"last",
"#",
"or",
"/",
"as",
"is",
"standard",
"with",
"URI",
"fromats"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datatypes/namespaces.py#L735-L768 |
Carreau/warn | warn/warn.py | warn_explicit | def warn_explicit(message, category, filename, lineno,
module=None, registry=None, module_globals=None,
emit_module=None):
"""
Low level implementation of the warning functionality.
Duplicate of the standard library `warnings.warn_explicit`,
except it accepts ... | python | def warn_explicit(message, category, filename, lineno,
module=None, registry=None, module_globals=None,
emit_module=None):
"""
Low level implementation of the warning functionality.
Duplicate of the standard library `warnings.warn_explicit`,
except it accepts ... | [
"def",
"warn_explicit",
"(",
"message",
",",
"category",
",",
"filename",
",",
"lineno",
",",
"module",
"=",
"None",
",",
"registry",
"=",
"None",
",",
"module_globals",
"=",
"None",
",",
"emit_module",
"=",
"None",
")",
":",
"lineno",
"=",
"int",
"(",
... | Low level implementation of the warning functionality.
Duplicate of the standard library `warnings.warn_explicit`,
except it accepts the following arguments:
`emit_module`: regular expression that should match the module the warnings
are emitted from. | [
"Low",
"level",
"implementation",
"of",
"the",
"warning",
"functionality",
".",
"Duplicate",
"of",
"the",
"standard",
"library",
"warnings",
".",
"warn_explicit",
"except",
"it",
"accepts",
"the",
"following",
"arguments",
":"
] | train | https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L28-L115 |
Carreau/warn | warn/warn.py | _get_stack_frame | def _get_stack_frame(stacklevel):
"""
utility functions to get a stackframe, skipping internal frames.
"""
stacklevel = stacklevel + 1
if stacklevel <= 1 or _is_internal_frame(sys._getframe(1)):
# If frame is too small to care or if the warning originated in
# internal code, then do ... | python | def _get_stack_frame(stacklevel):
"""
utility functions to get a stackframe, skipping internal frames.
"""
stacklevel = stacklevel + 1
if stacklevel <= 1 or _is_internal_frame(sys._getframe(1)):
# If frame is too small to care or if the warning originated in
# internal code, then do ... | [
"def",
"_get_stack_frame",
"(",
"stacklevel",
")",
":",
"stacklevel",
"=",
"stacklevel",
"+",
"1",
"if",
"stacklevel",
"<=",
"1",
"or",
"_is_internal_frame",
"(",
"sys",
".",
"_getframe",
"(",
"1",
")",
")",
":",
"# If frame is too small to care or if the warning ... | utility functions to get a stackframe, skipping internal frames. | [
"utility",
"functions",
"to",
"get",
"a",
"stackframe",
"skipping",
"internal",
"frames",
"."
] | train | https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L118-L134 |
Carreau/warn | warn/warn.py | warn | def warn(message, category=None, stacklevel=1, emitstacklevel=1):
"""Issue a warning, or maybe ignore it or raise an exception.
Duplicate of the standard library warn function except it takes the
following argument:
`emitstacklevel` : default to 1, number of stackframe to consider when
matching th... | python | def warn(message, category=None, stacklevel=1, emitstacklevel=1):
"""Issue a warning, or maybe ignore it or raise an exception.
Duplicate of the standard library warn function except it takes the
following argument:
`emitstacklevel` : default to 1, number of stackframe to consider when
matching th... | [
"def",
"warn",
"(",
"message",
",",
"category",
"=",
"None",
",",
"stacklevel",
"=",
"1",
",",
"emitstacklevel",
"=",
"1",
")",
":",
"# Check if message is already a Warning object",
"####################",
"### Get category ###",
"####################",
"if",
"isinstan... | Issue a warning, or maybe ignore it or raise an exception.
Duplicate of the standard library warn function except it takes the
following argument:
`emitstacklevel` : default to 1, number of stackframe to consider when
matching the module that emits this warning. | [
"Issue",
"a",
"warning",
"or",
"maybe",
"ignore",
"it",
"or",
"raise",
"an",
"exception",
"."
] | train | https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L137-L206 |
Carreau/warn | warn/warn.py | _set_proxy_filter | def _set_proxy_filter(warningstuple):
"""set up a proxy that store too long warnings in a separate map"""
if len(warningstuple) > 5:
key = len(_proxy_map)+1
_proxy_map[key] = warningstuple
# always is pass-through further in the code.
return ('always', re_matchall, ProxyWarning,... | python | def _set_proxy_filter(warningstuple):
"""set up a proxy that store too long warnings in a separate map"""
if len(warningstuple) > 5:
key = len(_proxy_map)+1
_proxy_map[key] = warningstuple
# always is pass-through further in the code.
return ('always', re_matchall, ProxyWarning,... | [
"def",
"_set_proxy_filter",
"(",
"warningstuple",
")",
":",
"if",
"len",
"(",
"warningstuple",
")",
">",
"5",
":",
"key",
"=",
"len",
"(",
"_proxy_map",
")",
"+",
"1",
"_proxy_map",
"[",
"key",
"]",
"=",
"warningstuple",
"# always is pass-through further in th... | set up a proxy that store too long warnings in a separate map | [
"set",
"up",
"a",
"proxy",
"that",
"store",
"too",
"long",
"warnings",
"in",
"a",
"separate",
"map"
] | train | https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L212-L221 |
Carreau/warn | warn/warn.py | filterwarnings | def filterwarnings(action, message="", category=Warning, module="", lineno=0,
append=False, emodule=""):
"""Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'message' -- a rege... | python | def filterwarnings(action, message="", category=Warning, module="", lineno=0,
append=False, emodule=""):
"""Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'message' -- a rege... | [
"def",
"filterwarnings",
"(",
"action",
",",
"message",
"=",
"\"\"",
",",
"category",
"=",
"Warning",
",",
"module",
"=",
"\"\"",
",",
"lineno",
"=",
"0",
",",
"append",
"=",
"False",
",",
"emodule",
"=",
"\"\"",
")",
":",
"assert",
"action",
"in",
"... | Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
or "once"
'message' -- a regex that the warning message must match
'category' -- a class that the warning must be a subclass of
'module' -- a regex that... | [
"Insert",
"an",
"entry",
"into",
"the",
"list",
"of",
"warnings",
"filters",
"(",
"at",
"the",
"front",
")",
"."
] | train | https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L233-L265 |
questrail/arghelper | tasks.py | release | def release(ctx, deploy=False, test=False, version=''):
"""Tag release, run Travis-CI, and deploy to PyPI
"""
if test:
run("python setup.py check")
run("python setup.py register sdist upload --dry-run")
if deploy:
run("python setup.py check")
if version:
run(... | python | def release(ctx, deploy=False, test=False, version=''):
"""Tag release, run Travis-CI, and deploy to PyPI
"""
if test:
run("python setup.py check")
run("python setup.py register sdist upload --dry-run")
if deploy:
run("python setup.py check")
if version:
run(... | [
"def",
"release",
"(",
"ctx",
",",
"deploy",
"=",
"False",
",",
"test",
"=",
"False",
",",
"version",
"=",
"''",
")",
":",
"if",
"test",
":",
"run",
"(",
"\"python setup.py check\"",
")",
"run",
"(",
"\"python setup.py register sdist upload --dry-run\"",
")",
... | Tag release, run Travis-CI, and deploy to PyPI | [
"Tag",
"release",
"run",
"Travis",
"-",
"CI",
"and",
"deploy",
"to",
"PyPI"
] | train | https://github.com/questrail/arghelper/blob/833d7d25a1f3daba70f186057d3d39a040c56200/tasks.py#L23-L48 |
OpenGov/python_data_wrap | datawrap/tablewrap.py | squarify_table | def squarify_table(table):
'''
Updates a table so that all rows are the same length by filling smaller
rows with 'None' objects up to the length of the largest row.
'''
max_length = 0
min_length = maxsize
for row in table:
row_len = len(row)
if row_len > max_length:
... | python | def squarify_table(table):
'''
Updates a table so that all rows are the same length by filling smaller
rows with 'None' objects up to the length of the largest row.
'''
max_length = 0
min_length = maxsize
for row in table:
row_len = len(row)
if row_len > max_length:
... | [
"def",
"squarify_table",
"(",
"table",
")",
":",
"max_length",
"=",
"0",
"min_length",
"=",
"maxsize",
"for",
"row",
"in",
"table",
":",
"row_len",
"=",
"len",
"(",
"row",
")",
"if",
"row_len",
">",
"max_length",
":",
"max_length",
"=",
"row_len",
"if",
... | Updates a table so that all rows are the same length by filling smaller
rows with 'None' objects up to the length of the largest row. | [
"Updates",
"a",
"table",
"so",
"that",
"all",
"rows",
"are",
"the",
"same",
"length",
"by",
"filling",
"smaller",
"rows",
"with",
"None",
"objects",
"up",
"to",
"the",
"length",
"of",
"the",
"largest",
"row",
"."
] | train | https://github.com/OpenGov/python_data_wrap/blob/7de38bb30d7a500adc336a4a7999528d753e5600/datawrap/tablewrap.py#L9-L26 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe.authenticate | def authenticate(self):
"""
*setup a Flickr API key to access a Flickr user account so picaxe can work on private images*
**Return:**
- ``None``
**Usage:**
To authenicate pixace against a Flickr account run the following (note this is interactive so a human nee... | python | def authenticate(self):
"""
*setup a Flickr API key to access a Flickr user account so picaxe can work on private images*
**Return:**
- ``None``
**Usage:**
To authenicate pixace against a Flickr account run the following (note this is interactive so a human nee... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``authenticate`` method'",
")",
"if",
"not",
"self",
".",
"settings",
"[",
"\"flickr\"",
"]",
"or",
"\"consumer_key\"",
"not",
"in",
"self",
".",
"settings",
"... | *setup a Flickr API key to access a Flickr user account so picaxe can work on private images*
**Return:**
- ``None``
**Usage:**
To authenicate pixace against a Flickr account run the following (note this is interactive so a human needs to be present to respond to prompts!)
... | [
"*",
"setup",
"a",
"Flickr",
"API",
"key",
"to",
"access",
"a",
"Flickr",
"user",
"account",
"so",
"picaxe",
"can",
"work",
"on",
"private",
"images",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L58-L164 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe.get_photo_metadata | def get_photo_metadata(
self,
url):
"""*get useful image metadata for the image found at a give Flickr share URL*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
**Return:**
- ``images`` -- a dictio... | python | def get_photo_metadata(
self,
url):
"""*get useful image metadata for the image found at a give Flickr share URL*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
**Return:**
- ``images`` -- a dictio... | [
"def",
"get_photo_metadata",
"(",
"self",
",",
"url",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get_photo_metadata`` method'",
")",
"photoid",
"=",
"None",
"if",
"\"flic\"",
"not",
"in",
"url",
"and",
"\"/\"",
"not",
"in",
"url",
":",
... | *get useful image metadata for the image found at a give Flickr share URL*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
**Return:**
- ``images`` -- a dictionary of the various image sizes that can be accessed (key is the width ... | [
"*",
"get",
"useful",
"image",
"metadata",
"for",
"the",
"image",
"found",
"at",
"a",
"give",
"Flickr",
"share",
"URL",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L166-L284 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe.md | def md(
self,
url,
width="original"):
"""*generate a multimarkdown image link viewable anywhere (no sign-in needed for private photos)*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
- ``width`... | python | def md(
self,
url,
width="original"):
"""*generate a multimarkdown image link viewable anywhere (no sign-in needed for private photos)*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
- ``width`... | [
"def",
"md",
"(",
"self",
",",
"url",
",",
"width",
"=",
"\"original\"",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``md_image`` method'",
")",
"images",
",",
"title",
",",
"desc",
",",
"photoId",
"=",
"self",
".",
"get_photo_metadata",... | *generate a multimarkdown image link viewable anywhere (no sign-in needed for private photos)*
**Key Arguments:**
- ``url`` -- the share URL for the flickr image (or just the unique photoid)
- ``width`` -- the pixel width of the fully resolved image. Default *original*. [75, 100, 150, ... | [
"*",
"generate",
"a",
"multimarkdown",
"image",
"link",
"viewable",
"anywhere",
"(",
"no",
"sign",
"-",
"in",
"needed",
"for",
"private",
"photos",
")",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L286-L337 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe.upload | def upload(
self,
imagePath,
title=False,
private=True,
tags=False,
description=False,
imageType="photo",
album=False,
openInBrowser=False):
"""*upload*
**Key Arguments:**
- ``imagePa... | python | def upload(
self,
imagePath,
title=False,
private=True,
tags=False,
description=False,
imageType="photo",
album=False,
openInBrowser=False):
"""*upload*
**Key Arguments:**
- ``imagePa... | [
"def",
"upload",
"(",
"self",
",",
"imagePath",
",",
"title",
"=",
"False",
",",
"private",
"=",
"True",
",",
"tags",
"=",
"False",
",",
"description",
"=",
"False",
",",
"imageType",
"=",
"\"photo\"",
",",
"album",
"=",
"False",
",",
"openInBrowser",
... | *upload*
**Key Arguments:**
- ``imagePath`` -- path to the image to upload
- ``title`` -- title of the image. Default **False** to just use filename
- ``private`` -- is photo private?, Default **True**
- ``tags`` -- a comma separated string. Default **False**
... | [
"*",
"upload",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L339-L465 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe.list_album_titles | def list_album_titles(
self):
"""*list all of the albums (photosets) in the Flickr account*
**Return:**
- ``albumList`` -- the list of album names
**Usage:**
.. code-block:: python
from picaxe import picaxe
flickr = picaxe(... | python | def list_album_titles(
self):
"""*list all of the albums (photosets) in the Flickr account*
**Return:**
- ``albumList`` -- the list of album names
**Usage:**
.. code-block:: python
from picaxe import picaxe
flickr = picaxe(... | [
"def",
"list_album_titles",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``list_album_titles`` method'",
")",
"albumList",
"=",
"[",
"]",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"\"https://api.flickr... | *list all of the albums (photosets) in the Flickr account*
**Return:**
- ``albumList`` -- the list of album names
**Usage:**
.. code-block:: python
from picaxe import picaxe
flickr = picaxe(
log=log,
set... | [
"*",
"list",
"all",
"of",
"the",
"albums",
"(",
"photosets",
")",
"in",
"the",
"Flickr",
"account",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L467-L513 |
thespacedoctor/picaxe | picaxe/picaxe.py | picaxe._add_photo_to_album | def _add_photo_to_album(
self,
photoId,
album):
"""*add a photo with the given photo ID to a named album*
**Key Arguments:**
- ``photoId`` -- the ID of the photo to add to the album
- ``album`` -- the name of the album to add the photo to
... | python | def _add_photo_to_album(
self,
photoId,
album):
"""*add a photo with the given photo ID to a named album*
**Key Arguments:**
- ``photoId`` -- the ID of the photo to add to the album
- ``album`` -- the name of the album to add the photo to
... | [
"def",
"_add_photo_to_album",
"(",
"self",
",",
"photoId",
",",
"album",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``_add_photo_to_album`` method'",
")",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"\"https://api.... | *add a photo with the given photo ID to a named album*
**Key Arguments:**
- ``photoId`` -- the ID of the photo to add to the album
- ``album`` -- the name of the album to add the photo to
**Return:**
- None
**Usage:**
.. todo::
... | [
"*",
"add",
"a",
"photo",
"with",
"the",
"given",
"photo",
"ID",
"to",
"a",
"named",
"album",
"*"
] | train | https://github.com/thespacedoctor/picaxe/blob/0817e2fc6bfdd8101764f6e7fb8ee30e5d6a1fa8/picaxe/picaxe.py#L516-L594 |
praekelt/django-section | section/context_processors.py | section | def section(request):
"""
Determines the current site section from resolved view pattern and adds
it to context['section']. Section defaults to the first specified section.
"""
# If SECTIONS setting is not specified, don't do anything.
try:
sections = settings.SECTIONS
except Attribu... | python | def section(request):
"""
Determines the current site section from resolved view pattern and adds
it to context['section']. Section defaults to the first specified section.
"""
# If SECTIONS setting is not specified, don't do anything.
try:
sections = settings.SECTIONS
except Attribu... | [
"def",
"section",
"(",
"request",
")",
":",
"# If SECTIONS setting is not specified, don't do anything.",
"try",
":",
"sections",
"=",
"settings",
".",
"SECTIONS",
"except",
"AttributeError",
":",
"return",
"{",
"}",
"# Default return is first section.",
"section",
"=",
... | Determines the current site section from resolved view pattern and adds
it to context['section']. Section defaults to the first specified section. | [
"Determines",
"the",
"current",
"site",
"section",
"from",
"resolved",
"view",
"pattern",
"and",
"adds",
"it",
"to",
"context",
"[",
"section",
"]",
".",
"Section",
"defaults",
"to",
"the",
"first",
"specified",
"section",
"."
] | train | https://github.com/praekelt/django-section/blob/20f946fceb7acdf45f2c3b9dc2a65070f1abad37/section/context_processors.py#L7-L31 |
xtrementl/focus | focus/plugin/modules/apps.py | _get_process_cwd | def _get_process_cwd(pid):
""" Returns the working directory for the provided process identifier.
`pid`
System process identifier.
Returns string or ``None``.
Note this is used as a workaround, since `psutil` isn't consistent on
being able to provide this path in all c... | python | def _get_process_cwd(pid):
""" Returns the working directory for the provided process identifier.
`pid`
System process identifier.
Returns string or ``None``.
Note this is used as a workaround, since `psutil` isn't consistent on
being able to provide this path in all c... | [
"def",
"_get_process_cwd",
"(",
"pid",
")",
":",
"cmd",
"=",
"'lsof -a -p {0} -d cwd -Fn'",
".",
"format",
"(",
"pid",
")",
"data",
"=",
"common",
".",
"shell_process",
"(",
"cmd",
")",
"if",
"not",
"data",
"is",
"None",
":",
"lines",
"=",
"str",
"(",
... | Returns the working directory for the provided process identifier.
`pid`
System process identifier.
Returns string or ``None``.
Note this is used as a workaround, since `psutil` isn't consistent on
being able to provide this path in all cases, especially MacOS X. | [
"Returns",
"the",
"working",
"directory",
"for",
"the",
"provided",
"process",
"identifier",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L24-L47 |
xtrementl/focus | focus/plugin/modules/apps.py | _get_checksum | def _get_checksum(path):
""" Generates a md5 checksum of the file at the specified path.
`path`
Path to file for checksum.
Returns string or ``None``
"""
# md5 uses a 512-bit digest blocks, let's scale by defined block_size
_md5 = hashlib.md5()
chunk_size = 128 * _... | python | def _get_checksum(path):
""" Generates a md5 checksum of the file at the specified path.
`path`
Path to file for checksum.
Returns string or ``None``
"""
# md5 uses a 512-bit digest blocks, let's scale by defined block_size
_md5 = hashlib.md5()
chunk_size = 128 * _... | [
"def",
"_get_checksum",
"(",
"path",
")",
":",
"# md5 uses a 512-bit digest blocks, let's scale by defined block_size",
"_md5",
"=",
"hashlib",
".",
"md5",
"(",
")",
"chunk_size",
"=",
"128",
"*",
"_md5",
".",
"block_size",
"try",
":",
"with",
"open",
"(",
"path",... | Generates a md5 checksum of the file at the specified path.
`path`
Path to file for checksum.
Returns string or ``None`` | [
"Generates",
"a",
"md5",
"checksum",
"of",
"the",
"file",
"at",
"the",
"specified",
"path",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L50-L70 |
xtrementl/focus | focus/plugin/modules/apps.py | _get_user_processes | def _get_user_processes():
""" Gets process information owned by the current user.
Returns generator of tuples: (``psutil.Process`` instance, path).
"""
uid = os.getuid()
for proc in psutil.process_iter():
try:
# yield processes that match current user
if p... | python | def _get_user_processes():
""" Gets process information owned by the current user.
Returns generator of tuples: (``psutil.Process`` instance, path).
"""
uid = os.getuid()
for proc in psutil.process_iter():
try:
# yield processes that match current user
if p... | [
"def",
"_get_user_processes",
"(",
")",
":",
"uid",
"=",
"os",
".",
"getuid",
"(",
")",
"for",
"proc",
"in",
"psutil",
".",
"process_iter",
"(",
")",
":",
"try",
":",
"# yield processes that match current user",
"if",
"proc",
".",
"uids",
".",
"real",
"=="... | Gets process information owned by the current user.
Returns generator of tuples: (``psutil.Process`` instance, path). | [
"Gets",
"process",
"information",
"owned",
"by",
"the",
"current",
"user",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L73-L107 |
xtrementl/focus | focus/plugin/modules/apps.py | _stop_processes | def _stop_processes(paths):
""" Scans process list trying to terminate processes matching paths
specified. Uses checksums to identify processes that are duplicates of
those specified to terminate.
`paths`
List of full paths to executables for processes to terminate.
"""
... | python | def _stop_processes(paths):
""" Scans process list trying to terminate processes matching paths
specified. Uses checksums to identify processes that are duplicates of
those specified to terminate.
`paths`
List of full paths to executables for processes to terminate.
"""
... | [
"def",
"_stop_processes",
"(",
"paths",
")",
":",
"def",
"cache_checksum",
"(",
"path",
")",
":",
"\"\"\" Checksum provided path, cache, and return value.\n \"\"\"",
"if",
"not",
"path",
":",
"return",
"None",
"if",
"not",
"path",
"in",
"_process_checksums",
... | Scans process list trying to terminate processes matching paths
specified. Uses checksums to identify processes that are duplicates of
those specified to terminate.
`paths`
List of full paths to executables for processes to terminate. | [
"Scans",
"process",
"list",
"trying",
"to",
"terminate",
"processes",
"matching",
"paths",
"specified",
".",
"Uses",
"checksums",
"to",
"identify",
"processes",
"that",
"are",
"duplicates",
"of",
"those",
"specified",
"to",
"terminate",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L110-L145 |
xtrementl/focus | focus/plugin/modules/apps.py | AppRun._run_apps | def _run_apps(self, paths):
""" Runs apps for the provided paths.
"""
for path in paths:
common.shell_process(path, background=True)
time.sleep(0.2) | python | def _run_apps(self, paths):
""" Runs apps for the provided paths.
"""
for path in paths:
common.shell_process(path, background=True)
time.sleep(0.2) | [
"def",
"_run_apps",
"(",
"self",
",",
"paths",
")",
":",
"for",
"path",
"in",
"paths",
":",
"common",
".",
"shell_process",
"(",
"path",
",",
"background",
"=",
"True",
")",
"time",
".",
"sleep",
"(",
"0.2",
")"
] | Runs apps for the provided paths. | [
"Runs",
"apps",
"for",
"the",
"provided",
"paths",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L180-L186 |
xtrementl/focus | focus/plugin/modules/apps.py | AppRun.parse_option | def parse_option(self, option, block_name, *values):
""" Parse app path values for option.
"""
if option == 'run':
option = 'start_' + option
key = option.split('_', 1)[0]
self.paths[key] = set(common.extract_app_paths(values)) | python | def parse_option(self, option, block_name, *values):
""" Parse app path values for option.
"""
if option == 'run':
option = 'start_' + option
key = option.split('_', 1)[0]
self.paths[key] = set(common.extract_app_paths(values)) | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"if",
"option",
"==",
"'run'",
":",
"option",
"=",
"'start_'",
"+",
"option",
"key",
"=",
"option",
".",
"split",
"(",
"'_'",
",",
"1",
")",
"[",
"0... | Parse app path values for option. | [
"Parse",
"app",
"path",
"values",
"for",
"option",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L188-L195 |
xtrementl/focus | focus/plugin/modules/apps.py | AppClose.parse_option | def parse_option(self, option, block_name, *values):
""" Parse app path values for option.
"""
# treat arguments as part of the program name (support spaces in name)
values = [x.replace(' ', '\\ ') if not x.startswith(os.sep) else x
for x in [str(v) for v in values... | python | def parse_option(self, option, block_name, *values):
""" Parse app path values for option.
"""
# treat arguments as part of the program name (support spaces in name)
values = [x.replace(' ', '\\ ') if not x.startswith(os.sep) else x
for x in [str(v) for v in values... | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"# treat arguments as part of the program name (support spaces in name)",
"values",
"=",
"[",
"x",
".",
"replace",
"(",
"' '",
",",
"'\\\\ '",
")",
"if",
"not",
"... | Parse app path values for option. | [
"Parse",
"app",
"path",
"values",
"for",
"option",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/apps.py#L239-L251 |
ulf1/oxyba | oxyba/norm_mle.py | norm_mle | def norm_mle(data, algorithm='Nelder-Mead', debug=False):
"""Estimate Mean and Std.Dev. of the Normal Distribution
Parameters:
-----------
data : list, tuple, ndarray
vector with samples, observations that are
assumed to follow a Normal distribution.
algorithm : str
Optiona... | python | def norm_mle(data, algorithm='Nelder-Mead', debug=False):
"""Estimate Mean and Std.Dev. of the Normal Distribution
Parameters:
-----------
data : list, tuple, ndarray
vector with samples, observations that are
assumed to follow a Normal distribution.
algorithm : str
Optiona... | [
"def",
"norm_mle",
"(",
"data",
",",
"algorithm",
"=",
"'Nelder-Mead'",
",",
"debug",
"=",
"False",
")",
":",
"import",
"scipy",
".",
"stats",
"as",
"sstat",
"import",
"scipy",
".",
"optimize",
"as",
"sopt",
"def",
"objective_nll_norm_uni",
"(",
"theta",
"... | Estimate Mean and Std.Dev. of the Normal Distribution
Parameters:
-----------
data : list, tuple, ndarray
vector with samples, observations that are
assumed to follow a Normal distribution.
algorithm : str
Optional. Default 'Nelder-Mead' (Simplex).
The algorithm used in... | [
"Estimate",
"Mean",
"and",
"Std",
".",
"Dev",
".",
"of",
"the",
"Normal",
"Distribution"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/norm_mle.py#L2-L59 |
KnowledgeLinks/rdfframework | rdfframework/utilities/frameworkutilities.py | DataStatus.get | def get(self, status_item):
""" queries the database and returns that status of the item.
args:
status_item: the name of the item to check
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
sparql = '''
... | python | def get(self, status_item):
""" queries the database and returns that status of the item.
args:
status_item: the name of the item to check
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLevel(self.log_level)
sparql = '''
... | [
"def",
"get",
"(",
"self",
",",
"status_item",
")",
":",
"lg",
"=",
"logging",
".",
"getLogger",
"(",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"ln",
",",
"inspect",
".",
"stack",
"(",
")",
"[",
"0",
"]",
"[",
"3",
"]",
")",
")",
"lg",
".",
"setLevel... | queries the database and returns that status of the item.
args:
status_item: the name of the item to check | [
"queries",
"the",
"database",
"and",
"returns",
"that",
"status",
"of",
"the",
"item",
"."
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/frameworkutilities.py#L71-L90 |
KnowledgeLinks/rdfframework | rdfframework/utilities/frameworkutilities.py | DataStatus.set | def set(self, status_item, status):
""" sets the status item to the passed in paramaters
args:
status_item: the name if the item to set
status: boolean value to set the item
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLeve... | python | def set(self, status_item, status):
""" sets the status item to the passed in paramaters
args:
status_item: the name if the item to set
status: boolean value to set the item
"""
lg = logging.getLogger("%s.%s" % (self.ln, inspect.stack()[0][3]))
lg.setLeve... | [
"def",
"set",
"(",
"self",
",",
"status_item",
",",
"status",
")",
":",
"lg",
"=",
"logging",
".",
"getLogger",
"(",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"ln",
",",
"inspect",
".",
"stack",
"(",
")",
"[",
"0",
"]",
"[",
"3",
"]",
")",
")",
"lg",... | sets the status item to the passed in paramaters
args:
status_item: the name if the item to set
status: boolean value to set the item | [
"sets",
"the",
"status",
"item",
"to",
"the",
"passed",
"in",
"paramaters"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/frameworkutilities.py#L92-L114 |
gebn/nibble | setup.py | _read_file | def _read_file(name, encoding='utf-8'):
"""
Read the contents of a file.
:param name: The name of the file in the current directory.
:param encoding: The encoding of the file; defaults to utf-8.
:return: The contents of the file.
"""
with codecs.open(name, encoding=encoding) as f:
r... | python | def _read_file(name, encoding='utf-8'):
"""
Read the contents of a file.
:param name: The name of the file in the current directory.
:param encoding: The encoding of the file; defaults to utf-8.
:return: The contents of the file.
"""
with codecs.open(name, encoding=encoding) as f:
r... | [
"def",
"_read_file",
"(",
"name",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"name",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
")"
] | Read the contents of a file.
:param name: The name of the file in the current directory.
:param encoding: The encoding of the file; defaults to utf-8.
:return: The contents of the file. | [
"Read",
"the",
"contents",
"of",
"a",
"file",
"."
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/setup.py#L7-L16 |
malthe/pop | src/pop/utils.py | local_machine_uuid | def local_machine_uuid():
"""Return local machine unique identifier.
>>> uuid = local_machine_uuid()
"""
result = subprocess.check_output(
'hal-get-property --udi '
'/org/freedesktop/Hal/devices/computer '
'--key system.hardware.uuid'.split()
).strip()
return uuid... | python | def local_machine_uuid():
"""Return local machine unique identifier.
>>> uuid = local_machine_uuid()
"""
result = subprocess.check_output(
'hal-get-property --udi '
'/org/freedesktop/Hal/devices/computer '
'--key system.hardware.uuid'.split()
).strip()
return uuid... | [
"def",
"local_machine_uuid",
"(",
")",
":",
"result",
"=",
"subprocess",
".",
"check_output",
"(",
"'hal-get-property --udi '",
"'/org/freedesktop/Hal/devices/computer '",
"'--key system.hardware.uuid'",
".",
"split",
"(",
")",
")",
".",
"strip",
"(",
")",
"return",
"... | Return local machine unique identifier.
>>> uuid = local_machine_uuid() | [
"Return",
"local",
"machine",
"unique",
"identifier",
"."
] | train | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/utils.py#L26-L39 |
malthe/pop | src/pop/utils.py | YAMLState.read | def read(self, required=False):
"""Read Zookeeper state.
Read in the current Zookeeper state for this node. This
operation should be called prior to other interactions with
this object.
`required`: boolean indicating if the node existence should be
required at read time... | python | def read(self, required=False):
"""Read Zookeeper state.
Read in the current Zookeeper state for this node. This
operation should be called prior to other interactions with
this object.
`required`: boolean indicating if the node existence should be
required at read time... | [
"def",
"read",
"(",
"self",
",",
"required",
"=",
"False",
")",
":",
"self",
".",
"_pristine_cache",
"=",
"{",
"}",
"self",
".",
"_cache",
"=",
"{",
"}",
"try",
":",
"data",
",",
"stat",
"=",
"yield",
"self",
".",
"_client",
".",
"get",
"(",
"sel... | Read Zookeeper state.
Read in the current Zookeeper state for this node. This
operation should be called prior to other interactions with
this object.
`required`: boolean indicating if the node existence should be
required at read time. Normally write will create the node if
... | [
"Read",
"Zookeeper",
"state",
"."
] | train | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/utils.py#L96-L119 |
malthe/pop | src/pop/utils.py | YAMLState.write | def write(self):
"""Write object state to Zookeeper.
This will write the current state of the object to Zookeeper,
taking the final merged state as the new one, and resetting
any write buffers.
"""
self._check()
cache = self._cache
pristine_cache = self._... | python | def write(self):
"""Write object state to Zookeeper.
This will write the current state of the object to Zookeeper,
taking the final merged state as the new one, and resetting
any write buffers.
"""
self._check()
cache = self._cache
pristine_cache = self._... | [
"def",
"write",
"(",
"self",
")",
":",
"self",
".",
"_check",
"(",
")",
"cache",
"=",
"self",
".",
"_cache",
"pristine_cache",
"=",
"self",
".",
"_pristine_cache",
"self",
".",
"_pristine_cache",
"=",
"cache",
".",
"copy",
"(",
")",
"# Used by `apply_chang... | Write object state to Zookeeper.
This will write the current state of the object to Zookeeper,
taking the final merged state as the new one, and resetting
any write buffers. | [
"Write",
"object",
"state",
"to",
"Zookeeper",
"."
] | train | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/utils.py#L145-L184 |
ONSdigital/requestsdefaulter | features/steps/patcher.py | set_default_headers | def set_default_headers(context):
"""
:type context: behave.runner.Context
"""
headers = row_table(context)
def default_headers_function():
return headers
requestsdefaulter.default_headers(default_headers_function) | python | def set_default_headers(context):
"""
:type context: behave.runner.Context
"""
headers = row_table(context)
def default_headers_function():
return headers
requestsdefaulter.default_headers(default_headers_function) | [
"def",
"set_default_headers",
"(",
"context",
")",
":",
"headers",
"=",
"row_table",
"(",
"context",
")",
"def",
"default_headers_function",
"(",
")",
":",
"return",
"headers",
"requestsdefaulter",
".",
"default_headers",
"(",
"default_headers_function",
")"
] | :type context: behave.runner.Context | [
":",
"type",
"context",
":",
"behave",
".",
"runner",
".",
"Context"
] | train | https://github.com/ONSdigital/requestsdefaulter/blob/e0559466f5f63dcc17e2cb1f0963169af5fbc019/features/steps/patcher.py#L10-L19 |
ONSdigital/requestsdefaulter | features/steps/patcher.py | assert_headers | def assert_headers(context):
"""
:type context: behave.runner.Context
"""
expected_headers = [(k, v) for k, v in row_table(context).items()]
request = httpretty.last_request()
actual_headers = request.headers.items()
for expected_header in expected_headers:
assert_in(expected_hea... | python | def assert_headers(context):
"""
:type context: behave.runner.Context
"""
expected_headers = [(k, v) for k, v in row_table(context).items()]
request = httpretty.last_request()
actual_headers = request.headers.items()
for expected_header in expected_headers:
assert_in(expected_hea... | [
"def",
"assert_headers",
"(",
"context",
")",
":",
"expected_headers",
"=",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"row_table",
"(",
"context",
")",
".",
"items",
"(",
")",
"]",
"request",
"=",
"httpretty",
".",
"last_request",
"("... | :type context: behave.runner.Context | [
":",
"type",
"context",
":",
"behave",
".",
"runner",
".",
"Context"
] | train | https://github.com/ONSdigital/requestsdefaulter/blob/e0559466f5f63dcc17e2cb1f0963169af5fbc019/features/steps/patcher.py#L38-L47 |
ONSdigital/requestsdefaulter | features/steps/patcher.py | make_request_with_headers | def make_request_with_headers(context):
"""
:type context: behave.runner.Context
"""
headers = row_table(context)
requests.get(context.mock_url, headers=headers) | python | def make_request_with_headers(context):
"""
:type context: behave.runner.Context
"""
headers = row_table(context)
requests.get(context.mock_url, headers=headers) | [
"def",
"make_request_with_headers",
"(",
"context",
")",
":",
"headers",
"=",
"row_table",
"(",
"context",
")",
"requests",
".",
"get",
"(",
"context",
".",
"mock_url",
",",
"headers",
"=",
"headers",
")"
] | :type context: behave.runner.Context | [
":",
"type",
"context",
":",
"behave",
".",
"runner",
".",
"Context"
] | train | https://github.com/ONSdigital/requestsdefaulter/blob/e0559466f5f63dcc17e2cb1f0963169af5fbc019/features/steps/patcher.py#L51-L56 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.__get_data_en_intervalo | def __get_data_en_intervalo(self, d0=None, df=None):
"""
Obtiene los datos en bruto de la red realizando múltiples requests al tiempo
Procesa los datos en bruto obtenidos de la red convirtiendo a Pandas DataFrame
"""
params = {'date_fmt': self.DATE_FMT,
'usar_m... | python | def __get_data_en_intervalo(self, d0=None, df=None):
"""
Obtiene los datos en bruto de la red realizando múltiples requests al tiempo
Procesa los datos en bruto obtenidos de la red convirtiendo a Pandas DataFrame
"""
params = {'date_fmt': self.DATE_FMT,
'usar_m... | [
"def",
"__get_data_en_intervalo",
"(",
"self",
",",
"d0",
"=",
"None",
",",
"df",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'date_fmt'",
":",
"self",
".",
"DATE_FMT",
",",
"'usar_multithread'",
":",
"self",
".",
"USAR_MULTITHREAD",
",",
"'max_threads_reque... | Obtiene los datos en bruto de la red realizando múltiples requests al tiempo
Procesa los datos en bruto obtenidos de la red convirtiendo a Pandas DataFrame | [
"Obtiene",
"los",
"datos",
"en",
"bruto",
"de",
"la",
"red",
"realizando",
"múltiples",
"requests",
"al",
"tiempo",
"Procesa",
"los",
"datos",
"en",
"bruto",
"obtenidos",
"de",
"la",
"red",
"convirtiendo",
"a",
"Pandas",
"DataFrame"
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L105-L128 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.last_entry | def last_entry(self, data_revisar=None, key_revisar=None):
"""
Obtiene el Timestamp del último valor de la base de datos seleecionada,
junto con el nº de entradas (filas) total de dicho paquete de datos.
:param data_revisar: (OPC) Se puede pasar un dataframe específico
:param ke... | python | def last_entry(self, data_revisar=None, key_revisar=None):
"""
Obtiene el Timestamp del último valor de la base de datos seleecionada,
junto con el nº de entradas (filas) total de dicho paquete de datos.
:param data_revisar: (OPC) Se puede pasar un dataframe específico
:param ke... | [
"def",
"last_entry",
"(",
"self",
",",
"data_revisar",
"=",
"None",
",",
"key_revisar",
"=",
"None",
")",
":",
"key_revisar",
"=",
"key_revisar",
"or",
"self",
".",
"masterkey",
"data_revisar",
"=",
"self",
".",
"data",
"if",
"data_revisar",
"is",
"None",
... | Obtiene el Timestamp del último valor de la base de datos seleecionada,
junto con el nº de entradas (filas) total de dicho paquete de datos.
:param data_revisar: (OPC) Se puede pasar un dataframe específico
:param key_revisar: (OPC) Normalmente, para utilizar 'dem'
:return: tmax, num_en... | [
"Obtiene",
"el",
"Timestamp",
"del",
"último",
"valor",
"de",
"la",
"base",
"de",
"datos",
"seleecionada",
"junto",
"con",
"el",
"nº",
"de",
"entradas",
"(",
"filas",
")",
"total",
"de",
"dicho",
"paquete",
"de",
"datos",
"."
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L130-L146 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.printif | def printif(self, obj_print, tipo_print=None):
"""Color output & logging."""
if self.verbose:
print(obj_print)
if tipo_print == 'ok':
logging.info(obj_print)
elif tipo_print == 'error':
logging.error(obj_print)
elif tipo_print == 'warning':
... | python | def printif(self, obj_print, tipo_print=None):
"""Color output & logging."""
if self.verbose:
print(obj_print)
if tipo_print == 'ok':
logging.info(obj_print)
elif tipo_print == 'error':
logging.error(obj_print)
elif tipo_print == 'warning':
... | [
"def",
"printif",
"(",
"self",
",",
"obj_print",
",",
"tipo_print",
"=",
"None",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"obj_print",
")",
"if",
"tipo_print",
"==",
"'ok'",
":",
"logging",
".",
"info",
"(",
"obj_print",
")",
"elif",
... | Color output & logging. | [
"Color",
"output",
"&",
"logging",
"."
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L148-L157 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.update_data | def update_data(self, forzar_update=False):
"""Check/Lectura de base de datos hdf en disco (local)."""
try:
if forzar_update:
self.printif('Se procede a actualizar TODOS los datos (force update ON)', 'info')
assert()
self.load_data()
tm... | python | def update_data(self, forzar_update=False):
"""Check/Lectura de base de datos hdf en disco (local)."""
try:
if forzar_update:
self.printif('Se procede a actualizar TODOS los datos (force update ON)', 'info')
assert()
self.load_data()
tm... | [
"def",
"update_data",
"(",
"self",
",",
"forzar_update",
"=",
"False",
")",
":",
"try",
":",
"if",
"forzar_update",
":",
"self",
".",
"printif",
"(",
"'Se procede a actualizar TODOS los datos (force update ON)'",
",",
"'info'",
")",
"assert",
"(",
")",
"self",
"... | Check/Lectura de base de datos hdf en disco (local). | [
"Check",
"/",
"Lectura",
"de",
"base",
"de",
"datos",
"hdf",
"en",
"disco",
"(",
"local",
")",
"."
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L185-L213 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.integridad_data | def integridad_data(self, data_integr=None, key=None):
"""
Comprueba que el index de cada dataframe de la base de datos sea de fechas, único (sin duplicados) y creciente
:param data_integr:
:param key:
"""
def _assert_integridad(df):
if df is not None and not ... | python | def integridad_data(self, data_integr=None, key=None):
"""
Comprueba que el index de cada dataframe de la base de datos sea de fechas, único (sin duplicados) y creciente
:param data_integr:
:param key:
"""
def _assert_integridad(df):
if df is not None and not ... | [
"def",
"integridad_data",
"(",
"self",
",",
"data_integr",
"=",
"None",
",",
"key",
"=",
"None",
")",
":",
"def",
"_assert_integridad",
"(",
"df",
")",
":",
"if",
"df",
"is",
"not",
"None",
"and",
"not",
"df",
".",
"empty",
":",
"assert",
"(",
"df",
... | Comprueba que el index de cada dataframe de la base de datos sea de fechas, único (sin duplicados) y creciente
:param data_integr:
:param key: | [
"Comprueba",
"que",
"el",
"index",
"de",
"cada",
"dataframe",
"de",
"la",
"base",
"de",
"datos",
"sea",
"de",
"fechas",
"único",
"(",
"sin",
"duplicados",
")",
"y",
"creciente",
":",
"param",
"data_integr",
":",
":",
"param",
"key",
":"
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L215-L234 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.info_data | def info_data(self, data_info=None, completo=True, key=None, verbose=True):
"""Show some info."""
def _info_dataframe(data_frame):
if completo:
print('\n', data_frame.info(), '\n', data_frame.describe(), '\n')
print(data_frame.head())
print(data_frame... | python | def info_data(self, data_info=None, completo=True, key=None, verbose=True):
"""Show some info."""
def _info_dataframe(data_frame):
if completo:
print('\n', data_frame.info(), '\n', data_frame.describe(), '\n')
print(data_frame.head())
print(data_frame... | [
"def",
"info_data",
"(",
"self",
",",
"data_info",
"=",
"None",
",",
"completo",
"=",
"True",
",",
"key",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"def",
"_info_dataframe",
"(",
"data_frame",
")",
":",
"if",
"completo",
":",
"print",
"(",
... | Show some info. | [
"Show",
"some",
"info",
"."
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L236-L251 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.save_data | def save_data(self, dataframe=None, key_data=None):
""" Guarda en disco la información
:param dataframe:
:param key_data:
"""
def _save_data_en_key(store, key_save, data_save, func_err):
try:
# TODO Revisar errores grabación HDF5 mode table vs fixed:
... | python | def save_data(self, dataframe=None, key_data=None):
""" Guarda en disco la información
:param dataframe:
:param key_data:
"""
def _save_data_en_key(store, key_save, data_save, func_err):
try:
# TODO Revisar errores grabación HDF5 mode table vs fixed:
... | [
"def",
"save_data",
"(",
"self",
",",
"dataframe",
"=",
"None",
",",
"key_data",
"=",
"None",
")",
":",
"def",
"_save_data_en_key",
"(",
"store",
",",
"key_save",
",",
"data_save",
",",
"func_err",
")",
":",
"try",
":",
"# TODO Revisar errores grabación HDF5 m... | Guarda en disco la información
:param dataframe:
:param key_data: | [
"Guarda",
"en",
"disco",
"la",
"información",
":",
"param",
"dataframe",
":",
":",
"param",
"key_data",
":"
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L264-L291 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.load_data | def load_data(self, key=None, **kwargs):
""" Lee de disco la información y la devuelve
:param key:
"""
self.store.open()
if key:
return pd.read_hdf(self.PATH_DATABASE, key, **kwargs)
else:
data_load = dict()
for k in self.store.keys():
... | python | def load_data(self, key=None, **kwargs):
""" Lee de disco la información y la devuelve
:param key:
"""
self.store.open()
if key:
return pd.read_hdf(self.PATH_DATABASE, key, **kwargs)
else:
data_load = dict()
for k in self.store.keys():
... | [
"def",
"load_data",
"(",
"self",
",",
"key",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"store",
".",
"open",
"(",
")",
"if",
"key",
":",
"return",
"pd",
".",
"read_hdf",
"(",
"self",
".",
"PATH_DATABASE",
",",
"key",
",",
"*",
... | Lee de disco la información y la devuelve
:param key: | [
"Lee",
"de",
"disco",
"la",
"información",
"y",
"la",
"devuelve",
":",
"param",
"key",
":"
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L293-L308 |
azogue/dataweb | dataweb/classdataweb.py | DataWeb.append_delta_index | def append_delta_index(self, ts_data=None, data_delta=None, key=KEY_DATA):
"""Append columns with ∆T between rows to data."""
reasign = False
if data_delta is None:
if self.data is not None:
data_delta = self.data[key]
else:
self.printif('N... | python | def append_delta_index(self, ts_data=None, data_delta=None, key=KEY_DATA):
"""Append columns with ∆T between rows to data."""
reasign = False
if data_delta is None:
if self.data is not None:
data_delta = self.data[key]
else:
self.printif('N... | [
"def",
"append_delta_index",
"(",
"self",
",",
"ts_data",
"=",
"None",
",",
"data_delta",
"=",
"None",
",",
"key",
"=",
"KEY_DATA",
")",
":",
"reasign",
"=",
"False",
"if",
"data_delta",
"is",
"None",
":",
"if",
"self",
".",
"data",
"is",
"not",
"None"... | Append columns with ∆T between rows to data. | [
"Append",
"columns",
"with",
"∆T",
"between",
"rows",
"to",
"data",
"."
] | train | https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/classdataweb.py#L310-L329 |
MitalAshok/objecttools | objecttools/singletons.py | Singleton.create | def create(mcs, name, dict=None, object_name=None):
"""
Create a new :class:`Singleton` class
:param name: Name of the new class (Used in its __repr__ if no object_name)
:type name: str
:param dict: Optional dictionary of the classes' attributes
:type dict: Optional[Dict... | python | def create(mcs, name, dict=None, object_name=None):
"""
Create a new :class:`Singleton` class
:param name: Name of the new class (Used in its __repr__ if no object_name)
:type name: str
:param dict: Optional dictionary of the classes' attributes
:type dict: Optional[Dict... | [
"def",
"create",
"(",
"mcs",
",",
"name",
",",
"dict",
"=",
"None",
",",
"object_name",
"=",
"None",
")",
":",
"if",
"dict",
"is",
"None",
":",
"dict",
"=",
"{",
"}",
"_repr",
"=",
"name",
"+",
"'()'",
"if",
"object_name",
"is",
"None",
"else",
"... | Create a new :class:`Singleton` class
:param name: Name of the new class (Used in its __repr__ if no object_name)
:type name: str
:param dict: Optional dictionary of the classes' attributes
:type dict: Optional[Dict[str, Any]]
:param object_name: Name of an instance of the singl... | [
"Create",
"a",
"new",
":",
"class",
":",
"Singleton",
"class"
] | train | https://github.com/MitalAshok/objecttools/blob/bddd14d1f702c8b559d3fcc2099bc22370e16de7/objecttools/singletons.py#L57-L77 |
MitalAshok/objecttools | objecttools/singletons.py | Singleton.as_decorator | def as_decorator(mcs, cls):
"""
Use :class:`Singleton` as a decorator for Python 2/3 compatibility::
@Singleton.as_decorator
class SingletonType(object):
def __repr__(self):
return 'singleton'
singleton = SingletonType()
... | python | def as_decorator(mcs, cls):
"""
Use :class:`Singleton` as a decorator for Python 2/3 compatibility::
@Singleton.as_decorator
class SingletonType(object):
def __repr__(self):
return 'singleton'
singleton = SingletonType()
... | [
"def",
"as_decorator",
"(",
"mcs",
",",
"cls",
")",
":",
"return",
"mcs",
"(",
"cls",
".",
"__name__",
",",
"cls",
".",
"__bases__",
",",
"cls",
".",
"__dict__",
".",
"copy",
"(",
")",
")"
] | Use :class:`Singleton` as a decorator for Python 2/3 compatibility::
@Singleton.as_decorator
class SingletonType(object):
def __repr__(self):
return 'singleton'
singleton = SingletonType()
:param cls: Class to become a singleton
... | [
"Use",
":",
"class",
":",
"Singleton",
"as",
"a",
"decorator",
"for",
"Python",
"2",
"/",
"3",
"compatibility",
"::"
] | train | https://github.com/MitalAshok/objecttools/blob/bddd14d1f702c8b559d3fcc2099bc22370e16de7/objecttools/singletons.py#L80-L96 |
jabbas/pynapi | pynapi/__init__.py | list_services | def list_services():
""" returns list of available services """
for importer, modname, ispkg in pkgutil.iter_modules(services.__path__):
if ispkg is False:
importer.find_module(modname).load_module(modname)
services_list = list()
for s in services.serviceBase.__subclasses__():
... | python | def list_services():
""" returns list of available services """
for importer, modname, ispkg in pkgutil.iter_modules(services.__path__):
if ispkg is False:
importer.find_module(modname).load_module(modname)
services_list = list()
for s in services.serviceBase.__subclasses__():
... | [
"def",
"list_services",
"(",
")",
":",
"for",
"importer",
",",
"modname",
",",
"ispkg",
"in",
"pkgutil",
".",
"iter_modules",
"(",
"services",
".",
"__path__",
")",
":",
"if",
"ispkg",
"is",
"False",
":",
"importer",
".",
"find_module",
"(",
"modname",
"... | returns list of available services | [
"returns",
"list",
"of",
"available",
"services"
] | train | https://github.com/jabbas/pynapi/blob/d9b3b4d9cd05501c14fe5cc5903b1c21e1905753/pynapi/__init__.py#L9-L19 |
minhhoit/yacms | yacms/utils/conf.py | set_dynamic_settings | def set_dynamic_settings(s):
"""
Called at the end of the project's settings module, and is passed
its globals dict for updating with some final tweaks for settings
that generally aren't specified, but can be given some better
defaults based on other settings that have been specified. Broken
out... | python | def set_dynamic_settings(s):
"""
Called at the end of the project's settings module, and is passed
its globals dict for updating with some final tweaks for settings
that generally aren't specified, but can be given some better
defaults based on other settings that have been specified. Broken
out... | [
"def",
"set_dynamic_settings",
"(",
"s",
")",
":",
"# Moves an existing list setting value to a different position.",
"move",
"=",
"lambda",
"n",
",",
"k",
",",
"i",
":",
"s",
"[",
"n",
"]",
".",
"insert",
"(",
"i",
",",
"s",
"[",
"n",
"]",
".",
"pop",
"... | Called at the end of the project's settings module, and is passed
its globals dict for updating with some final tweaks for settings
that generally aren't specified, but can be given some better
defaults based on other settings that have been specified. Broken
out into its own function so that the code n... | [
"Called",
"at",
"the",
"end",
"of",
"the",
"project",
"s",
"settings",
"module",
"and",
"is",
"passed",
"its",
"globals",
"dict",
"for",
"updating",
"with",
"some",
"final",
"tweaks",
"for",
"settings",
"that",
"generally",
"aren",
"t",
"specified",
"but",
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/conf.py#L35-L232 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.create_model_class | def create_model_class(cls, name, table_name, attrs, validations=None, *, otherattrs=None,
other_bases=None):
"""Creates a new class derived from ModelBase."""
members = dict(table_name=table_name, attrs=attrs, validations=validations or [])
if otherattrs:
members.update(other... | python | def create_model_class(cls, name, table_name, attrs, validations=None, *, otherattrs=None,
other_bases=None):
"""Creates a new class derived from ModelBase."""
members = dict(table_name=table_name, attrs=attrs, validations=validations or [])
if otherattrs:
members.update(other... | [
"def",
"create_model_class",
"(",
"cls",
",",
"name",
",",
"table_name",
",",
"attrs",
",",
"validations",
"=",
"None",
",",
"*",
",",
"otherattrs",
"=",
"None",
",",
"other_bases",
"=",
"None",
")",
":",
"members",
"=",
"dict",
"(",
"table_name",
"=",
... | Creates a new class derived from ModelBase. | [
"Creates",
"a",
"new",
"class",
"derived",
"from",
"ModelBase",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L33-L39 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.has_attr | def has_attr(cls, attr_name):
"""Check to see if an attribute is defined for the model."""
if attr_name in cls.attrs:
return True
if isinstance(cls.primary_key_name, str) and cls.primary_key_name == attr_name:
return True
if isinstance(cls.primary_key_name, tuple) and attr_name in cls.prim... | python | def has_attr(cls, attr_name):
"""Check to see if an attribute is defined for the model."""
if attr_name in cls.attrs:
return True
if isinstance(cls.primary_key_name, str) and cls.primary_key_name == attr_name:
return True
if isinstance(cls.primary_key_name, tuple) and attr_name in cls.prim... | [
"def",
"has_attr",
"(",
"cls",
",",
"attr_name",
")",
":",
"if",
"attr_name",
"in",
"cls",
".",
"attrs",
":",
"return",
"True",
"if",
"isinstance",
"(",
"cls",
".",
"primary_key_name",
",",
"str",
")",
"and",
"cls",
".",
"primary_key_name",
"==",
"attr_n... | Check to see if an attribute is defined for the model. | [
"Check",
"to",
"see",
"if",
"an",
"attribute",
"is",
"defined",
"for",
"the",
"model",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L42-L56 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.primary_key | def primary_key(self):
"""Returns either the primary key value, or a tuple containing the primary key values in the
case of a composite primary key.
"""
pkname = self.primary_key_name
if pkname is None:
return None
elif isinstance(pkname, str):
return getattr(self, pkname)
else:
... | python | def primary_key(self):
"""Returns either the primary key value, or a tuple containing the primary key values in the
case of a composite primary key.
"""
pkname = self.primary_key_name
if pkname is None:
return None
elif isinstance(pkname, str):
return getattr(self, pkname)
else:
... | [
"def",
"primary_key",
"(",
"self",
")",
":",
"pkname",
"=",
"self",
".",
"primary_key_name",
"if",
"pkname",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"pkname",
",",
"str",
")",
":",
"return",
"getattr",
"(",
"self",
",",
"pkname",
... | Returns either the primary key value, or a tuple containing the primary key values in the
case of a composite primary key. | [
"Returns",
"either",
"the",
"primary",
"key",
"value",
"or",
"a",
"tuple",
"containing",
"the",
"primary",
"key",
"values",
"in",
"the",
"case",
"of",
"a",
"composite",
"primary",
"key",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L59-L69 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.validate | def validate(self, data_access=None):
"""Run the class validations against the instance. If the validations require database access,
pass in a DataAccess derived instance.
"""
self.clear_errors()
self.before_validation()
self.validator.validate(self, data_access)
return not self.has_errors | python | def validate(self, data_access=None):
"""Run the class validations against the instance. If the validations require database access,
pass in a DataAccess derived instance.
"""
self.clear_errors()
self.before_validation()
self.validator.validate(self, data_access)
return not self.has_errors | [
"def",
"validate",
"(",
"self",
",",
"data_access",
"=",
"None",
")",
":",
"self",
".",
"clear_errors",
"(",
")",
"self",
".",
"before_validation",
"(",
")",
"self",
".",
"validator",
".",
"validate",
"(",
"self",
",",
"data_access",
")",
"return",
"not"... | Run the class validations against the instance. If the validations require database access,
pass in a DataAccess derived instance. | [
"Run",
"the",
"class",
"validations",
"against",
"the",
"instance",
".",
"If",
"the",
"validations",
"require",
"database",
"access",
"pass",
"in",
"a",
"DataAccess",
"derived",
"instance",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L84-L91 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.add_error | def add_error(self, property_name, message):
"""Add an error for the given property."""
if property_name not in self.errors:
self.errors[property_name] = []
self.errors[property_name].append(message) | python | def add_error(self, property_name, message):
"""Add an error for the given property."""
if property_name not in self.errors:
self.errors[property_name] = []
self.errors[property_name].append(message) | [
"def",
"add_error",
"(",
"self",
",",
"property_name",
",",
"message",
")",
":",
"if",
"property_name",
"not",
"in",
"self",
".",
"errors",
":",
"self",
".",
"errors",
"[",
"property_name",
"]",
"=",
"[",
"]",
"self",
".",
"errors",
"[",
"property_name",... | Add an error for the given property. | [
"Add",
"an",
"error",
"for",
"the",
"given",
"property",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L98-L102 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.all_errors | def all_errors(self, joiner="; "):
"""Returns a string representation of all errors recorded for the instance."""
parts = []
for pname, errs in self.errors.items():
for err in errs:
parts.append("{0}: {1}".format(pname, err))
return joiner.join(parts) | python | def all_errors(self, joiner="; "):
"""Returns a string representation of all errors recorded for the instance."""
parts = []
for pname, errs in self.errors.items():
for err in errs:
parts.append("{0}: {1}".format(pname, err))
return joiner.join(parts) | [
"def",
"all_errors",
"(",
"self",
",",
"joiner",
"=",
"\"; \"",
")",
":",
"parts",
"=",
"[",
"]",
"for",
"pname",
",",
"errs",
"in",
"self",
".",
"errors",
".",
"items",
"(",
")",
":",
"for",
"err",
"in",
"errs",
":",
"parts",
".",
"append",
"(",... | Returns a string representation of all errors recorded for the instance. | [
"Returns",
"a",
"string",
"representation",
"of",
"all",
"errors",
"recorded",
"for",
"the",
"instance",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L108-L114 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.to_dict | def to_dict(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True):
"""Converts the class to a dictionary.
:include_keys: if not None, only the attrs given will be included.
:exclude_keys: if not None, all attrs except those listed will be included, with respect to
use_default_exclud... | python | def to_dict(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True):
"""Converts the class to a dictionary.
:include_keys: if not None, only the attrs given will be included.
:exclude_keys: if not None, all attrs except those listed will be included, with respect to
use_default_exclud... | [
"def",
"to_dict",
"(",
"self",
",",
"*",
",",
"include_keys",
"=",
"None",
",",
"exclude_keys",
"=",
"None",
",",
"use_default_excludes",
"=",
"True",
")",
":",
"data",
"=",
"self",
".",
"__dict__",
"if",
"include_keys",
":",
"return",
"pick",
"(",
"data... | Converts the class to a dictionary.
:include_keys: if not None, only the attrs given will be included.
:exclude_keys: if not None, all attrs except those listed will be included, with respect to
use_default_excludes.
:use_default_excludes: if True, then the class-level exclude_keys_serialize will be co... | [
"Converts",
"the",
"class",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L116-L136 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.to_json | def to_json(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True,
pretty=False):
"""Converts the response from to_dict to a JSON string. If pretty is True then newlines,
indentation and key sorting are used.
"""
return to_json(
self.to_dict(
include_keys=i... | python | def to_json(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True,
pretty=False):
"""Converts the response from to_dict to a JSON string. If pretty is True then newlines,
indentation and key sorting are used.
"""
return to_json(
self.to_dict(
include_keys=i... | [
"def",
"to_json",
"(",
"self",
",",
"*",
",",
"include_keys",
"=",
"None",
",",
"exclude_keys",
"=",
"None",
",",
"use_default_excludes",
"=",
"True",
",",
"pretty",
"=",
"False",
")",
":",
"return",
"to_json",
"(",
"self",
".",
"to_dict",
"(",
"include_... | Converts the response from to_dict to a JSON string. If pretty is True then newlines,
indentation and key sorting are used. | [
"Converts",
"the",
"response",
"from",
"to_dict",
"to",
"a",
"JSON",
"string",
".",
"If",
"pretty",
"is",
"True",
"then",
"newlines",
"indentation",
"and",
"key",
"sorting",
"are",
"used",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L138-L148 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase.update | def update(self, data_=None, **kwargs):
"""Update the object with the given data object, and with any other key-value args. Returns a
set containing all the property names that were changed.
"""
if data_ is None:
data_ = dict()
else:
data_ = dict(data_)
data_.update(**kwargs)
cha... | python | def update(self, data_=None, **kwargs):
"""Update the object with the given data object, and with any other key-value args. Returns a
set containing all the property names that were changed.
"""
if data_ is None:
data_ = dict()
else:
data_ = dict(data_)
data_.update(**kwargs)
cha... | [
"def",
"update",
"(",
"self",
",",
"data_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"data_",
"is",
"None",
":",
"data_",
"=",
"dict",
"(",
")",
"else",
":",
"data_",
"=",
"dict",
"(",
"data_",
")",
"data_",
".",
"update",
"(",
"*"... | Update the object with the given data object, and with any other key-value args. Returns a
set containing all the property names that were changed. | [
"Update",
"the",
"object",
"with",
"the",
"given",
"data",
"object",
"and",
"with",
"any",
"other",
"key",
"-",
"value",
"args",
".",
"Returns",
"a",
"set",
"containing",
"all",
"the",
"property",
"names",
"that",
"were",
"changed",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L150-L168 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase._initialize_attributes | def _initialize_attributes(self, data):
"""Initializes the class with the given data. Used by __init__."""
attrs = dict(self.attrs)
if self.primary_key_name is None:
pass
elif isinstance(self.primary_key_name, str):
if self.primary_key_name not in attrs:
attrs[self.primary_key_name]... | python | def _initialize_attributes(self, data):
"""Initializes the class with the given data. Used by __init__."""
attrs = dict(self.attrs)
if self.primary_key_name is None:
pass
elif isinstance(self.primary_key_name, str):
if self.primary_key_name not in attrs:
attrs[self.primary_key_name]... | [
"def",
"_initialize_attributes",
"(",
"self",
",",
"data",
")",
":",
"attrs",
"=",
"dict",
"(",
"self",
".",
"attrs",
")",
"if",
"self",
".",
"primary_key_name",
"is",
"None",
":",
"pass",
"elif",
"isinstance",
"(",
"self",
".",
"primary_key_name",
",",
... | Initializes the class with the given data. Used by __init__. | [
"Initializes",
"the",
"class",
"with",
"the",
"given",
"data",
".",
"Used",
"by",
"__init__",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L170-L190 |
treycucco/bidon | bidon/db/model/model_base.py | ModelBase._other_to_dict | def _other_to_dict(self, other):
"""When serializing models, this allows attached models (children, parents, etc.) to also be
serialized.
"""
if isinstance(other, ModelBase):
return other.to_dict()
elif isinstance(other, list):
# TODO: what if it's not a list?
return [self._other_t... | python | def _other_to_dict(self, other):
"""When serializing models, this allows attached models (children, parents, etc.) to also be
serialized.
"""
if isinstance(other, ModelBase):
return other.to_dict()
elif isinstance(other, list):
# TODO: what if it's not a list?
return [self._other_t... | [
"def",
"_other_to_dict",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"ModelBase",
")",
":",
"return",
"other",
".",
"to_dict",
"(",
")",
"elif",
"isinstance",
"(",
"other",
",",
"list",
")",
":",
"# TODO: what if it's not a ... | When serializing models, this allows attached models (children, parents, etc.) to also be
serialized. | [
"When",
"serializing",
"models",
"this",
"allows",
"attached",
"models",
"(",
"children",
"parents",
"etc",
".",
")",
"to",
"also",
"be",
"serialized",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/model_base.py#L192-L202 |
drastus/unicover | unicover/unicover.py | UniCover.dispatch | def dispatch(self, args):
"""
Calls proper method depending on command-line arguments.
"""
if not args.list and not args.group:
if not args.font and not args.char and not args.block:
self.info()
return
else:
args.lis... | python | def dispatch(self, args):
"""
Calls proper method depending on command-line arguments.
"""
if not args.list and not args.group:
if not args.font and not args.char and not args.block:
self.info()
return
else:
args.lis... | [
"def",
"dispatch",
"(",
"self",
",",
"args",
")",
":",
"if",
"not",
"args",
".",
"list",
"and",
"not",
"args",
".",
"group",
":",
"if",
"not",
"args",
".",
"font",
"and",
"not",
"args",
".",
"char",
"and",
"not",
"args",
".",
"block",
":",
"self"... | Calls proper method depending on command-line arguments. | [
"Calls",
"proper",
"method",
"depending",
"on",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L55-L74 |
drastus/unicover | unicover/unicover.py | UniCover.chars | def chars(self, font, block):
"""
Analyses characters in single font or all fonts.
"""
if font:
font_files = self._getFont(font)
else:
font_files = fc.query()
code_points = self._getFontChars(font_files)
if not block:
blocks = ... | python | def chars(self, font, block):
"""
Analyses characters in single font or all fonts.
"""
if font:
font_files = self._getFont(font)
else:
font_files = fc.query()
code_points = self._getFontChars(font_files)
if not block:
blocks = ... | [
"def",
"chars",
"(",
"self",
",",
"font",
",",
"block",
")",
":",
"if",
"font",
":",
"font_files",
"=",
"self",
".",
"_getFont",
"(",
"font",
")",
"else",
":",
"font_files",
"=",
"fc",
".",
"query",
"(",
")",
"code_points",
"=",
"self",
".",
"_getF... | Analyses characters in single font or all fonts. | [
"Analyses",
"characters",
"in",
"single",
"font",
"or",
"all",
"fonts",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L83-L118 |
drastus/unicover | unicover/unicover.py | UniCover.char | def char(self, char):
"""
Shows all system fonts that contain given character.
"""
font_files = fc.query()
if self._display['group']:
font_files = self._getCharFont(font_files, char)
font_families = self._groupFontByFamily(font_files)
for font_... | python | def char(self, char):
"""
Shows all system fonts that contain given character.
"""
font_files = fc.query()
if self._display['group']:
font_files = self._getCharFont(font_files, char)
font_families = self._groupFontByFamily(font_files)
for font_... | [
"def",
"char",
"(",
"self",
",",
"char",
")",
":",
"font_files",
"=",
"fc",
".",
"query",
"(",
")",
"if",
"self",
".",
"_display",
"[",
"'group'",
"]",
":",
"font_files",
"=",
"self",
".",
"_getCharFont",
"(",
"font_files",
",",
"char",
")",
"font_fa... | Shows all system fonts that contain given character. | [
"Shows",
"all",
"system",
"fonts",
"that",
"contain",
"given",
"character",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L120-L138 |
drastus/unicover | unicover/unicover.py | UniCover.fontChar | def fontChar(self, font, char):
"""
Checks if characters occurs in the given font.
"""
font_files = self._getCharFont(self._getFont(font), char)
print('The character is {0}present in this font.'.format('' if font_files else 'not ')) | python | def fontChar(self, font, char):
"""
Checks if characters occurs in the given font.
"""
font_files = self._getCharFont(self._getFont(font), char)
print('The character is {0}present in this font.'.format('' if font_files else 'not ')) | [
"def",
"fontChar",
"(",
"self",
",",
"font",
",",
"char",
")",
":",
"font_files",
"=",
"self",
".",
"_getCharFont",
"(",
"self",
".",
"_getFont",
"(",
"font",
")",
",",
"char",
")",
"print",
"(",
"'The character is {0}present in this font.'",
".",
"format",
... | Checks if characters occurs in the given font. | [
"Checks",
"if",
"characters",
"occurs",
"in",
"the",
"given",
"font",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L140-L145 |
drastus/unicover | unicover/unicover.py | UniCover._charInfo | def _charInfo(self, point, padding):
"""
Displays character info.
"""
print('{0:0>4X} '.format(point).rjust(padding), ud.name(chr(point), '<code point {0:0>4X}>'.format(point))) | python | def _charInfo(self, point, padding):
"""
Displays character info.
"""
print('{0:0>4X} '.format(point).rjust(padding), ud.name(chr(point), '<code point {0:0>4X}>'.format(point))) | [
"def",
"_charInfo",
"(",
"self",
",",
"point",
",",
"padding",
")",
":",
"print",
"(",
"'{0:0>4X} '",
".",
"format",
"(",
"point",
")",
".",
"rjust",
"(",
"padding",
")",
",",
"ud",
".",
"name",
"(",
"chr",
"(",
"point",
")",
",",
"'<code point {0:0>... | Displays character info. | [
"Displays",
"character",
"info",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L147-L151 |
drastus/unicover | unicover/unicover.py | UniCover._charSummary | def _charSummary(self, char_count, block_count=None):
"""
Displays characters summary.
"""
if not self._display['omit_summary']:
if block_count is None:
print('Total code points:', char_count)
else:
print('Total {0} code point{1} in... | python | def _charSummary(self, char_count, block_count=None):
"""
Displays characters summary.
"""
if not self._display['omit_summary']:
if block_count is None:
print('Total code points:', char_count)
else:
print('Total {0} code point{1} in... | [
"def",
"_charSummary",
"(",
"self",
",",
"char_count",
",",
"block_count",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_display",
"[",
"'omit_summary'",
"]",
":",
"if",
"block_count",
"is",
"None",
":",
"print",
"(",
"'Total code points:'",
",",
"cha... | Displays characters summary. | [
"Displays",
"characters",
"summary",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L153-L166 |
drastus/unicover | unicover/unicover.py | UniCover._fontSummary | def _fontSummary(self, font_file_count, font_family_count=None):
"""
Displays fonts summary.
"""
if not self._display['omit_summary']:
if font_family_count is None:
print('Total font files:', font_file_count)
else:
print('The charac... | python | def _fontSummary(self, font_file_count, font_family_count=None):
"""
Displays fonts summary.
"""
if not self._display['omit_summary']:
if font_family_count is None:
print('Total font files:', font_file_count)
else:
print('The charac... | [
"def",
"_fontSummary",
"(",
"self",
",",
"font_file_count",
",",
"font_family_count",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_display",
"[",
"'omit_summary'",
"]",
":",
"if",
"font_family_count",
"is",
"None",
":",
"print",
"(",
"'Total font files:'... | Displays fonts summary. | [
"Displays",
"fonts",
"summary",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L168-L181 |
drastus/unicover | unicover/unicover.py | UniCover._getChar | def _getChar(self, char_spec):
"""
Returns character from given code point or character.
"""
if len(char_spec) >= 4 and all(c in string.hexdigits for c in char_spec):
char_number = int(char_spec, 16)
if char_number not in range(0x110000):
raise Val... | python | def _getChar(self, char_spec):
"""
Returns character from given code point or character.
"""
if len(char_spec) >= 4 and all(c in string.hexdigits for c in char_spec):
char_number = int(char_spec, 16)
if char_number not in range(0x110000):
raise Val... | [
"def",
"_getChar",
"(",
"self",
",",
"char_spec",
")",
":",
"if",
"len",
"(",
"char_spec",
")",
">=",
"4",
"and",
"all",
"(",
"c",
"in",
"string",
".",
"hexdigits",
"for",
"c",
"in",
"char_spec",
")",
":",
"char_number",
"=",
"int",
"(",
"char_spec",... | Returns character from given code point or character. | [
"Returns",
"character",
"from",
"given",
"code",
"point",
"or",
"character",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L183-L195 |
drastus/unicover | unicover/unicover.py | UniCover._getBlock | def _getBlock(self, block_spec):
"""
Returns block info from given block start code point or block name.
"""
if block_spec is None:
return
if all(c in string.hexdigits for c in block_spec):
block_spec = block_spec.upper()
ix = 0
else:
... | python | def _getBlock(self, block_spec):
"""
Returns block info from given block start code point or block name.
"""
if block_spec is None:
return
if all(c in string.hexdigits for c in block_spec):
block_spec = block_spec.upper()
ix = 0
else:
... | [
"def",
"_getBlock",
"(",
"self",
",",
"block_spec",
")",
":",
"if",
"block_spec",
"is",
"None",
":",
"return",
"if",
"all",
"(",
"c",
"in",
"string",
".",
"hexdigits",
"for",
"c",
"in",
"block_spec",
")",
":",
"block_spec",
"=",
"block_spec",
".",
"upp... | Returns block info from given block start code point or block name. | [
"Returns",
"block",
"info",
"from",
"given",
"block",
"start",
"code",
"point",
"or",
"block",
"name",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L197-L211 |
drastus/unicover | unicover/unicover.py | UniCover._getFont | def _getFont(self, font):
"""
Returns font paths from font name or path
"""
if os.path.isfile(font):
font_files = [font]
else:
font_files = fc.query(family=font)
if not font_files:
raise ValueError('No such font')
return... | python | def _getFont(self, font):
"""
Returns font paths from font name or path
"""
if os.path.isfile(font):
font_files = [font]
else:
font_files = fc.query(family=font)
if not font_files:
raise ValueError('No such font')
return... | [
"def",
"_getFont",
"(",
"self",
",",
"font",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"font",
")",
":",
"font_files",
"=",
"[",
"font",
"]",
"else",
":",
"font_files",
"=",
"fc",
".",
"query",
"(",
"family",
"=",
"font",
")",
"if",
... | Returns font paths from font name or path | [
"Returns",
"font",
"paths",
"from",
"font",
"name",
"or",
"path"
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L213-L223 |
drastus/unicover | unicover/unicover.py | UniCover._getFontChars | def _getFontChars(self, font_files):
"""
Returns code points of characters included in given font files.
"""
code_points = set()
for font_file in font_files:
face = ft.Face(font_file)
charcode, agindex = face.get_first_char()
while agindex != 0... | python | def _getFontChars(self, font_files):
"""
Returns code points of characters included in given font files.
"""
code_points = set()
for font_file in font_files:
face = ft.Face(font_file)
charcode, agindex = face.get_first_char()
while agindex != 0... | [
"def",
"_getFontChars",
"(",
"self",
",",
"font_files",
")",
":",
"code_points",
"=",
"set",
"(",
")",
"for",
"font_file",
"in",
"font_files",
":",
"face",
"=",
"ft",
".",
"Face",
"(",
"font_file",
")",
"charcode",
",",
"agindex",
"=",
"face",
".",
"ge... | Returns code points of characters included in given font files. | [
"Returns",
"code",
"points",
"of",
"characters",
"included",
"in",
"given",
"font",
"files",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L225-L236 |
drastus/unicover | unicover/unicover.py | UniCover._getCharFont | def _getCharFont(self, font_files, code_point):
"""
Returns font files containing given code point.
"""
return_font_files = []
for font_file in font_files:
face = ft.Face(font_file)
if face.get_char_index(code_point):
return_font_files.appe... | python | def _getCharFont(self, font_files, code_point):
"""
Returns font files containing given code point.
"""
return_font_files = []
for font_file in font_files:
face = ft.Face(font_file)
if face.get_char_index(code_point):
return_font_files.appe... | [
"def",
"_getCharFont",
"(",
"self",
",",
"font_files",
",",
"code_point",
")",
":",
"return_font_files",
"=",
"[",
"]",
"for",
"font_file",
"in",
"font_files",
":",
"face",
"=",
"ft",
".",
"Face",
"(",
"font_file",
")",
"if",
"face",
".",
"get_char_index",... | Returns font files containing given code point. | [
"Returns",
"font",
"files",
"containing",
"given",
"code",
"point",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L238-L247 |
drastus/unicover | unicover/unicover.py | UniCover._groupFontByFamily | def _groupFontByFamily(self, font_files):
"""
Returns font files grouped in dict by font family.
"""
font_families = defaultdict(list)
for font_file in font_files:
font = fc.FcFont(font_file)
font_families[font.family[0][1]].append(font_file)
retur... | python | def _groupFontByFamily(self, font_files):
"""
Returns font files grouped in dict by font family.
"""
font_families = defaultdict(list)
for font_file in font_files:
font = fc.FcFont(font_file)
font_families[font.family[0][1]].append(font_file)
retur... | [
"def",
"_groupFontByFamily",
"(",
"self",
",",
"font_files",
")",
":",
"font_families",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"font_file",
"in",
"font_files",
":",
"font",
"=",
"fc",
".",
"FcFont",
"(",
"font_file",
")",
"font_families",
"[",
"font",
... | Returns font files grouped in dict by font family. | [
"Returns",
"font",
"files",
"grouped",
"in",
"dict",
"by",
"font",
"family",
"."
] | train | https://github.com/drastus/unicover/blob/4702d0151c63d525c25718a838396afe62302255/unicover/unicover.py#L249-L257 |
PSU-OIT-ARC/elasticmodels | elasticmodels/fields.py | ListField | def ListField(field):
"""
This wraps a field so that when get_from_instance is called, the field's
values are iterated over
"""
# alter the original field's get_from_instance so it iterates over the
# values that the field's get_from_instance() method returns
original_get_from_instance = fie... | python | def ListField(field):
"""
This wraps a field so that when get_from_instance is called, the field's
values are iterated over
"""
# alter the original field's get_from_instance so it iterates over the
# values that the field's get_from_instance() method returns
original_get_from_instance = fie... | [
"def",
"ListField",
"(",
"field",
")",
":",
"# alter the original field's get_from_instance so it iterates over the",
"# values that the field's get_from_instance() method returns",
"original_get_from_instance",
"=",
"field",
".",
"get_from_instance",
"def",
"get_from_instance",
"(",
... | This wraps a field so that when get_from_instance is called, the field's
values are iterated over | [
"This",
"wraps",
"a",
"field",
"so",
"that",
"when",
"get_from_instance",
"is",
"called",
"the",
"field",
"s",
"values",
"are",
"iterated",
"over"
] | train | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/fields.py#L88-L103 |
PSU-OIT-ARC/elasticmodels | elasticmodels/fields.py | EMField.get_from_instance | def get_from_instance(self, instance):
"""
Given an object to index with ES, return the value that should be put
into ES for this field
"""
# walk the attribute path to get the value. Similarly to Django, first
# try getting the value from a dict, then as a attribute look... | python | def get_from_instance(self, instance):
"""
Given an object to index with ES, return the value that should be put
into ES for this field
"""
# walk the attribute path to get the value. Similarly to Django, first
# try getting the value from a dict, then as a attribute look... | [
"def",
"get_from_instance",
"(",
"self",
",",
"instance",
")",
":",
"# walk the attribute path to get the value. Similarly to Django, first",
"# try getting the value from a dict, then as a attribute lookup, and",
"# then as a list index",
"for",
"attr",
"in",
"self",
".",
"_path",
... | Given an object to index with ES, return the value that should be put
into ES for this field | [
"Given",
"an",
"object",
"to",
"index",
"with",
"ES",
"return",
"the",
"value",
"that",
"should",
"be",
"put",
"into",
"ES",
"for",
"this",
"field"
] | train | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/fields.py#L26-L54 |
KnowledgeLinks/rdfframework | rdfframework/sparql/querygenerator.py | run_query_series | def run_query_series(queries, conn):
"""
Iterates through a list of queries and runs them through the connection
Args:
-----
queries: list of strings or tuples containing (query_string, kwargs)
conn: the triplestore connection to use
"""
results = []
for item in queries:
... | python | def run_query_series(queries, conn):
"""
Iterates through a list of queries and runs them through the connection
Args:
-----
queries: list of strings or tuples containing (query_string, kwargs)
conn: the triplestore connection to use
"""
results = []
for item in queries:
... | [
"def",
"run_query_series",
"(",
"queries",
",",
"conn",
")",
":",
"results",
"=",
"[",
"]",
"for",
"item",
"in",
"queries",
":",
"qry",
"=",
"item",
"kwargs",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"item",
",",
"tuple",
")",
":",
"qry",
"=",
"item... | Iterates through a list of queries and runs them through the connection
Args:
-----
queries: list of strings or tuples containing (query_string, kwargs)
conn: the triplestore connection to use | [
"Iterates",
"through",
"a",
"list",
"of",
"queries",
"and",
"runs",
"them",
"through",
"the",
"connection"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/sparql/querygenerator.py#L14-L33 |
KnowledgeLinks/rdfframework | rdfframework/sparql/querygenerator.py | get_all_item_data | def get_all_item_data(items, conn, graph=None, output='json', **kwargs):
""" queries a triplestore with the provided template or uses a generic
template that returns triples 3 edges out in either direction from the
provided item_uri
args:
items: the starting uri or list of uris to the query
... | python | def get_all_item_data(items, conn, graph=None, output='json', **kwargs):
""" queries a triplestore with the provided template or uses a generic
template that returns triples 3 edges out in either direction from the
provided item_uri
args:
items: the starting uri or list of uris to the query
... | [
"def",
"get_all_item_data",
"(",
"items",
",",
"conn",
",",
"graph",
"=",
"None",
",",
"output",
"=",
"'json'",
",",
"*",
"*",
"kwargs",
")",
":",
"# set the jinja2 template to use",
"if",
"kwargs",
".",
"get",
"(",
"'template'",
")",
":",
"template",
"=",... | queries a triplestore with the provided template or uses a generic
template that returns triples 3 edges out in either direction from the
provided item_uri
args:
items: the starting uri or list of uris to the query
conn: the rdfframework triplestore connection to query against
outpu... | [
"queries",
"a",
"triplestore",
"with",
"the",
"provided",
"template",
"or",
"uses",
"a",
"generic",
"template",
"that",
"returns",
"triples",
"3",
"edges",
"out",
"in",
"either",
"direction",
"from",
"the",
"provided",
"item_uri"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/sparql/querygenerator.py#L35-L69 |
KnowledgeLinks/rdfframework | rdfframework/sparql/querygenerator.py | get_graph | def get_graph(graph, conn, **kwargs):
""" Returns all the triples for a specific are graph
args:
graph: the URI of the graph to retreive
conn: the rdfframework triplestore connection
"""
sparql = render_without_request("sparqlGraphDataTemplate.rq",
pr... | python | def get_graph(graph, conn, **kwargs):
""" Returns all the triples for a specific are graph
args:
graph: the URI of the graph to retreive
conn: the rdfframework triplestore connection
"""
sparql = render_without_request("sparqlGraphDataTemplate.rq",
pr... | [
"def",
"get_graph",
"(",
"graph",
",",
"conn",
",",
"*",
"*",
"kwargs",
")",
":",
"sparql",
"=",
"render_without_request",
"(",
"\"sparqlGraphDataTemplate.rq\"",
",",
"prefix",
"=",
"NSM",
".",
"prefix",
"(",
")",
",",
"graph",
"=",
"graph",
")",
"return",... | Returns all the triples for a specific are graph
args:
graph: the URI of the graph to retreive
conn: the rdfframework triplestore connection | [
"Returns",
"all",
"the",
"triples",
"for",
"a",
"specific",
"are",
"graph"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/sparql/querygenerator.py#L71-L81 |
KnowledgeLinks/rdfframework | rdfframework/sparql/querygenerator.py | make_sparql_filter | def make_sparql_filter(filters):
""" Make the filter section for a query template
args:
filters: list of dictionaries to generate the filter
example:
filters = [{'variable': 'p',
'operator': '=',
'union_type': '||',
'values': ['rd... | python | def make_sparql_filter(filters):
""" Make the filter section for a query template
args:
filters: list of dictionaries to generate the filter
example:
filters = [{'variable': 'p',
'operator': '=',
'union_type': '||',
'values': ['rd... | [
"def",
"make_sparql_filter",
"(",
"filters",
")",
":",
"def",
"make_filter_str",
"(",
"variable",
",",
"operator",
",",
"union_type",
",",
"values",
")",
":",
"\"\"\" generates a filter string for a sparql query\n\n args:\n variable: the variable to reference\n ... | Make the filter section for a query template
args:
filters: list of dictionaries to generate the filter
example:
filters = [{'variable': 'p',
'operator': '=',
'union_type': '||',
'values': ['rdf:type', 'rdfs:label']}] | [
"Make",
"the",
"filter",
"section",
"for",
"a",
"query",
"template"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/sparql/querygenerator.py#L83-L120 |
KnowledgeLinks/rdfframework | rdfframework/sparql/querygenerator.py | add_sparql_line_nums | def add_sparql_line_nums(sparql):
"""
Returns a sparql query with line numbers prepended
"""
lines = sparql.split("\n")
return "\n".join(["%s %s" % (i + 1, line) for i, line in enumerate(lines)]) | python | def add_sparql_line_nums(sparql):
"""
Returns a sparql query with line numbers prepended
"""
lines = sparql.split("\n")
return "\n".join(["%s %s" % (i + 1, line) for i, line in enumerate(lines)]) | [
"def",
"add_sparql_line_nums",
"(",
"sparql",
")",
":",
"lines",
"=",
"sparql",
".",
"split",
"(",
"\"\\n\"",
")",
"return",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"%s %s\"",
"%",
"(",
"i",
"+",
"1",
",",
"line",
")",
"for",
"i",
",",
"line",
"in",
"e... | Returns a sparql query with line numbers prepended | [
"Returns",
"a",
"sparql",
"query",
"with",
"line",
"numbers",
"prepended"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/sparql/querygenerator.py#L122-L127 |
gabrielfalcao/dominic | dominic/xpath/expr.py | string_value | def string_value(node):
"""Compute the string-value of a node."""
if (node.nodeType == node.DOCUMENT_NODE or
node.nodeType == node.ELEMENT_NODE):
s = u''
for n in axes['descendant'](node):
if n.nodeType == n.TEXT_NODE:
s += n.data
return s
elif no... | python | def string_value(node):
"""Compute the string-value of a node."""
if (node.nodeType == node.DOCUMENT_NODE or
node.nodeType == node.ELEMENT_NODE):
s = u''
for n in axes['descendant'](node):
if n.nodeType == n.TEXT_NODE:
s += n.data
return s
elif no... | [
"def",
"string_value",
"(",
"node",
")",
":",
"if",
"(",
"node",
".",
"nodeType",
"==",
"node",
".",
"DOCUMENT_NODE",
"or",
"node",
".",
"nodeType",
"==",
"node",
".",
"ELEMENT_NODE",
")",
":",
"s",
"=",
"u''",
"for",
"n",
"in",
"axes",
"[",
"'descen... | Compute the string-value of a node. | [
"Compute",
"the",
"string",
"-",
"value",
"of",
"a",
"node",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L17-L33 |
gabrielfalcao/dominic | dominic/xpath/expr.py | document_order | def document_order(node):
"""Compute a document order value for the node.
cmp(document_order(a), document_order(b)) will return -1, 0, or 1 if
a is before, identical to, or after b in the document respectively.
We represent document order as a list of sibling indexes. That is,
the third child of ... | python | def document_order(node):
"""Compute a document order value for the node.
cmp(document_order(a), document_order(b)) will return -1, 0, or 1 if
a is before, identical to, or after b in the document respectively.
We represent document order as a list of sibling indexes. That is,
the third child of ... | [
"def",
"document_order",
"(",
"node",
")",
":",
"# Attributes: parent-order + [-1, attribute-name]",
"if",
"node",
".",
"nodeType",
"==",
"node",
".",
"ATTRIBUTE_NODE",
":",
"order",
"=",
"document_order",
"(",
"node",
".",
"ownerElement",
")",
"order",
".",
"exte... | Compute a document order value for the node.
cmp(document_order(a), document_order(b)) will return -1, 0, or 1 if
a is before, identical to, or after b in the document respectively.
We represent document order as a list of sibling indexes. That is,
the third child of the document node has an order of... | [
"Compute",
"a",
"document",
"order",
"value",
"for",
"the",
"node",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L35-L70 |
gabrielfalcao/dominic | dominic/xpath/expr.py | string | def string(v):
"""Convert a value to a string."""
if nodesetp(v):
if not v:
return u''
return string_value(v[0])
elif numberp(v):
if v == float('inf'):
return u'Infinity'
elif v == float('-inf'):
return u'-Infinity'
elif str(v) == '... | python | def string(v):
"""Convert a value to a string."""
if nodesetp(v):
if not v:
return u''
return string_value(v[0])
elif numberp(v):
if v == float('inf'):
return u'Infinity'
elif v == float('-inf'):
return u'-Infinity'
elif str(v) == '... | [
"def",
"string",
"(",
"v",
")",
":",
"if",
"nodesetp",
"(",
"v",
")",
":",
"if",
"not",
"v",
":",
"return",
"u''",
"return",
"string_value",
"(",
"v",
"[",
"0",
"]",
")",
"elif",
"numberp",
"(",
"v",
")",
":",
"if",
"v",
"==",
"float",
"(",
"... | Convert a value to a string. | [
"Convert",
"a",
"value",
"to",
"a",
"string",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L93-L111 |
gabrielfalcao/dominic | dominic/xpath/expr.py | boolean | def boolean(v):
"""Convert a value to a boolean."""
if nodesetp(v):
return len(v) > 0
elif numberp(v):
if v == 0 or v != v:
return False
return True
elif stringp(v):
return v != ''
return v | python | def boolean(v):
"""Convert a value to a boolean."""
if nodesetp(v):
return len(v) > 0
elif numberp(v):
if v == 0 or v != v:
return False
return True
elif stringp(v):
return v != ''
return v | [
"def",
"boolean",
"(",
"v",
")",
":",
"if",
"nodesetp",
"(",
"v",
")",
":",
"return",
"len",
"(",
"v",
")",
">",
"0",
"elif",
"numberp",
"(",
"v",
")",
":",
"if",
"v",
"==",
"0",
"or",
"v",
"!=",
"v",
":",
"return",
"False",
"return",
"True",... | Convert a value to a boolean. | [
"Convert",
"a",
"value",
"to",
"a",
"boolean",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L117-L127 |
gabrielfalcao/dominic | dominic/xpath/expr.py | number | def number(v):
"""Convert a value to a number."""
if nodesetp(v):
v = string(v)
try:
return float(v)
except ValueError:
return float('NaN') | python | def number(v):
"""Convert a value to a number."""
if nodesetp(v):
v = string(v)
try:
return float(v)
except ValueError:
return float('NaN') | [
"def",
"number",
"(",
"v",
")",
":",
"if",
"nodesetp",
"(",
"v",
")",
":",
"v",
"=",
"string",
"(",
"v",
")",
"try",
":",
"return",
"float",
"(",
"v",
")",
"except",
"ValueError",
":",
"return",
"float",
"(",
"'NaN'",
")"
] | Convert a value to a number. | [
"Convert",
"a",
"value",
"to",
"a",
"number",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L133-L140 |
gabrielfalcao/dominic | dominic/xpath/expr.py | numberp | def numberp(v):
"""Return true iff 'v' is a number."""
return (not(isinstance(v, bool)) and
(isinstance(v, int) or isinstance(v, float))) | python | def numberp(v):
"""Return true iff 'v' is a number."""
return (not(isinstance(v, bool)) and
(isinstance(v, int) or isinstance(v, float))) | [
"def",
"numberp",
"(",
"v",
")",
":",
"return",
"(",
"not",
"(",
"isinstance",
"(",
"v",
",",
"bool",
")",
")",
"and",
"(",
"isinstance",
"(",
"v",
",",
"int",
")",
"or",
"isinstance",
"(",
"v",
",",
"float",
")",
")",
")"
] | Return true iff 'v' is a number. | [
"Return",
"true",
"iff",
"v",
"is",
"a",
"number",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L142-L145 |
gabrielfalcao/dominic | dominic/xpath/expr.py | axisfn | def axisfn(reverse=False, principal_node_type=xml.dom.Node.ELEMENT_NODE):
"""Axis function decorator.
An axis function will take a node as an argument and return a sequence
over the nodes along an XPath axis. Axis functions have two extra
attributes indicating the axis direction and principal node typ... | python | def axisfn(reverse=False, principal_node_type=xml.dom.Node.ELEMENT_NODE):
"""Axis function decorator.
An axis function will take a node as an argument and return a sequence
over the nodes along an XPath axis. Axis functions have two extra
attributes indicating the axis direction and principal node typ... | [
"def",
"axisfn",
"(",
"reverse",
"=",
"False",
",",
"principal_node_type",
"=",
"xml",
".",
"dom",
".",
"Node",
".",
"ELEMENT_NODE",
")",
":",
"def",
"decorate",
"(",
"f",
")",
":",
"f",
".",
"__name__",
"=",
"f",
".",
"__name__",
".",
"replace",
"("... | Axis function decorator.
An axis function will take a node as an argument and return a sequence
over the nodes along an XPath axis. Axis functions have two extra
attributes indicating the axis direction and principal node type. | [
"Axis",
"function",
"decorator",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L580-L592 |
gabrielfalcao/dominic | dominic/xpath/expr.py | make_axes | def make_axes():
"""Define functions to walk each of the possible XPath axes."""
@axisfn()
def child(node):
return node.childNodes
@axisfn()
def descendant(node):
for child in node.childNodes:
for node in descendant_or_self(child):
yield node
@axisf... | python | def make_axes():
"""Define functions to walk each of the possible XPath axes."""
@axisfn()
def child(node):
return node.childNodes
@axisfn()
def descendant(node):
for child in node.childNodes:
for node in descendant_or_self(child):
yield node
@axisf... | [
"def",
"make_axes",
"(",
")",
":",
"@",
"axisfn",
"(",
")",
"def",
"child",
"(",
"node",
")",
":",
"return",
"node",
".",
"childNodes",
"@",
"axisfn",
"(",
")",
"def",
"descendant",
"(",
"node",
")",
":",
"for",
"child",
"in",
"node",
".",
"childNo... | Define functions to walk each of the possible XPath axes. | [
"Define",
"functions",
"to",
"walk",
"each",
"of",
"the",
"possible",
"XPath",
"axes",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L594-L677 |
gabrielfalcao/dominic | dominic/xpath/expr.py | merge_into_nodeset | def merge_into_nodeset(target, source):
"""Place all the nodes from the source node-set into the target
node-set, preserving document order. Both node-sets must be in
document order to begin with.
"""
if len(target) == 0:
target.extend(source)
return
source = [n for n in sourc... | python | def merge_into_nodeset(target, source):
"""Place all the nodes from the source node-set into the target
node-set, preserving document order. Both node-sets must be in
document order to begin with.
"""
if len(target) == 0:
target.extend(source)
return
source = [n for n in sourc... | [
"def",
"merge_into_nodeset",
"(",
"target",
",",
"source",
")",
":",
"if",
"len",
"(",
"target",
")",
"==",
"0",
":",
"target",
".",
"extend",
"(",
"source",
")",
"return",
"source",
"=",
"[",
"n",
"for",
"n",
"in",
"source",
"if",
"n",
"not",
"in"... | Place all the nodes from the source node-set into the target
node-set, preserving document order. Both node-sets must be in
document order to begin with. | [
"Place",
"all",
"the",
"nodes",
"from",
"the",
"source",
"node",
"-",
"set",
"into",
"the",
"target",
"node",
"-",
"set",
"preserving",
"document",
"order",
".",
"Both",
"node",
"-",
"sets",
"must",
"be",
"in",
"document",
"order",
"to",
"begin",
"with",... | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L681-L704 |
gabrielfalcao/dominic | dominic/xpath/expr.py | Function.function | def function(minargs, maxargs, implicit=False, first=False, convert=None):
"""Function decorator.
minargs -- Minimum number of arguments taken by the function.
maxargs -- Maximum number of arguments taken by the function.
implicit -- True for functions which operate on a nodeset consist... | python | def function(minargs, maxargs, implicit=False, first=False, convert=None):
"""Function decorator.
minargs -- Minimum number of arguments taken by the function.
maxargs -- Maximum number of arguments taken by the function.
implicit -- True for functions which operate on a nodeset consist... | [
"def",
"function",
"(",
"minargs",
",",
"maxargs",
",",
"implicit",
"=",
"False",
",",
"first",
"=",
"False",
",",
"convert",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"def",
"new_f",
"(",
"self",
",",
"node",
",",
"pos",
",",
... | Function decorator.
minargs -- Minimum number of arguments taken by the function.
maxargs -- Maximum number of arguments taken by the function.
implicit -- True for functions which operate on a nodeset consisting
of the current context node when passed no argument.
... | [
"Function",
"decorator",
"."
] | train | https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/expr.py#L344-L376 |
edeposit/edeposit.amqp.pdfgen | src/edeposit/amqp/pdfgen/__init__.py | reactToAMQPMessage | def reactToAMQPMessage(message, sender):
"""
React to given (AMQP) message. `message` is usually expected to be
:py:func:`collections.namedtuple` structure filled with all necessary data.
Args:
message (\*Request class): One of the structures defined in
:mod:`.requests`.
... | python | def reactToAMQPMessage(message, sender):
"""
React to given (AMQP) message. `message` is usually expected to be
:py:func:`collections.namedtuple` structure filled with all necessary data.
Args:
message (\*Request class): One of the structures defined in
:mod:`.requests`.
... | [
"def",
"reactToAMQPMessage",
"(",
"message",
",",
"sender",
")",
":",
"if",
"_instanceof",
"(",
"message",
",",
"GenerateContract",
")",
":",
"return",
"pdf_from_file",
"(",
"# TODO: rewrite to decorator",
"get_contract",
"(",
"*",
"*",
"message",
".",
"_asdict",
... | React to given (AMQP) message. `message` is usually expected to be
:py:func:`collections.namedtuple` structure filled with all necessary data.
Args:
message (\*Request class): One of the structures defined in
:mod:`.requests`.
sender (fn reference): Reference to function for res... | [
"React",
"to",
"given",
"(",
"AMQP",
")",
"message",
".",
"message",
"is",
"usually",
"expected",
"to",
"be",
":",
"py",
":",
"func",
":",
"collections",
".",
"namedtuple",
"structure",
"filled",
"with",
"all",
"necessary",
"data",
"."
] | train | https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/__init__.py#L24-L58 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Requester.on_stop | def on_stop(self):
"""
stop requester
"""
LOGGER.debug("natsd.Requester.on_stop")
self.is_started = False
try:
LOGGER.debug("natsd.Requester.on_stop - unsubscribe from " + str(self.responseQS))
next(self.nc.unsubscribe(self.responseQS))
exc... | python | def on_stop(self):
"""
stop requester
"""
LOGGER.debug("natsd.Requester.on_stop")
self.is_started = False
try:
LOGGER.debug("natsd.Requester.on_stop - unsubscribe from " + str(self.responseQS))
next(self.nc.unsubscribe(self.responseQS))
exc... | [
"def",
"on_stop",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Requester.on_stop\"",
")",
"self",
".",
"is_started",
"=",
"False",
"try",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Requester.on_stop - unsubscribe from \"",
"+",
"str",
"(",
"self"... | stop requester | [
"stop",
"requester"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L156-L202 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Requester.on_response | def on_response(self, msg):
"""
setup response if correlation id is the good one
"""
LOGGER.debug("natsd.Requester.on_response: " + str(sys.getsizeof(msg)) + " bytes received")
working_response = json.loads(msg.data.decode())
working_properties = DriverTools.json2properti... | python | def on_response(self, msg):
"""
setup response if correlation id is the good one
"""
LOGGER.debug("natsd.Requester.on_response: " + str(sys.getsizeof(msg)) + " bytes received")
working_response = json.loads(msg.data.decode())
working_properties = DriverTools.json2properti... | [
"def",
"on_response",
"(",
"self",
",",
"msg",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Requester.on_response: \"",
"+",
"str",
"(",
"sys",
".",
"getsizeof",
"(",
"msg",
")",
")",
"+",
"\" bytes received\"",
")",
"working_response",
"=",
"json",
".",
... | setup response if correlation id is the good one | [
"setup",
"response",
"if",
"correlation",
"id",
"is",
"the",
"good",
"one"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L243-L308 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Requester.call | def call(self, my_args=None):
"""
setup the request and call the remote service. Wait the answer (blocking call)
:param my_args: dict like {properties, body}
:return response
"""
if not self.is_started:
raise ArianeError('natsd.Requester.call',
... | python | def call(self, my_args=None):
"""
setup the request and call the remote service. Wait the answer (blocking call)
:param my_args: dict like {properties, body}
:return response
"""
if not self.is_started:
raise ArianeError('natsd.Requester.call',
... | [
"def",
"call",
"(",
"self",
",",
"my_args",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"is_started",
":",
"raise",
"ArianeError",
"(",
"'natsd.Requester.call'",
",",
"'Requester not started !'",
")",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Requester.call\"",... | setup the request and call the remote service. Wait the answer (blocking call)
:param my_args: dict like {properties, body}
:return response | [
"setup",
"the",
"request",
"and",
"call",
"the",
"remote",
"service",
".",
"Wait",
"the",
"answer",
"(",
"blocking",
"call",
")",
":",
"param",
"my_args",
":",
"dict",
"like",
"{",
"properties",
"body",
"}",
":",
"return",
"response"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L455-L629 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Service.on_request | def on_request(self, msg):
"""
message consumed treatment through provided callback and basic ack
"""
LOGGER.debug("natsd.Service.on_request - request " + str(msg) + " received")
try:
working_response = json.loads(msg.data.decode())
working_properties = Dr... | python | def on_request(self, msg):
"""
message consumed treatment through provided callback and basic ack
"""
LOGGER.debug("natsd.Service.on_request - request " + str(msg) + " received")
try:
working_response = json.loads(msg.data.decode())
working_properties = Dr... | [
"def",
"on_request",
"(",
"self",
",",
"msg",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Service.on_request - request \"",
"+",
"str",
"(",
"msg",
")",
"+",
"\" received\"",
")",
"try",
":",
"working_response",
"=",
"json",
".",
"loads",
"(",
"msg",
"... | message consumed treatment through provided callback and basic ack | [
"message",
"consumed",
"treatment",
"through",
"provided",
"callback",
"and",
"basic",
"ack"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L680-L694 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Service.on_start | def on_start(self):
"""
start the service
"""
LOGGER.debug("natsd.Service.on_start")
self.service = threading.Thread(target=self.run_event_loop, name=self.serviceQ + " service thread")
self.service.start()
while not self.is_started:
time.sleep(0.01) | python | def on_start(self):
"""
start the service
"""
LOGGER.debug("natsd.Service.on_start")
self.service = threading.Thread(target=self.run_event_loop, name=self.serviceQ + " service thread")
self.service.start()
while not self.is_started:
time.sleep(0.01) | [
"def",
"on_start",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Service.on_start\"",
")",
"self",
".",
"service",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"run_event_loop",
",",
"name",
"=",
"self",
".",
"serviceQ",... | start the service | [
"start",
"the",
"service"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L722-L730 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Service.on_stop | def on_stop(self):
"""
stop the service
"""
LOGGER.debug("natsd.Service.on_stop")
self.is_started = False
try:
next(self.nc.unsubscribe(self.serviceQS))
except StopIteration as e:
pass
try:
next(self.nc.close())
... | python | def on_stop(self):
"""
stop the service
"""
LOGGER.debug("natsd.Service.on_stop")
self.is_started = False
try:
next(self.nc.unsubscribe(self.serviceQS))
except StopIteration as e:
pass
try:
next(self.nc.close())
... | [
"def",
"on_stop",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Service.on_stop\"",
")",
"self",
".",
"is_started",
"=",
"False",
"try",
":",
"next",
"(",
"self",
".",
"nc",
".",
"unsubscribe",
"(",
"self",
".",
"serviceQS",
")",
")",
"e... | stop the service | [
"stop",
"the",
"service"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L732-L755 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Driver.stop | def stop(self):
"""
Stop services and requestors and then connection.
:return: self
"""
LOGGER.debug("natsd.Driver.stop")
for requester in self.requester_registry:
requester.stop()
self.requester_registry.clear()
for service in self.services_r... | python | def stop(self):
"""
Stop services and requestors and then connection.
:return: self
"""
LOGGER.debug("natsd.Driver.stop")
for requester in self.requester_registry:
requester.stop()
self.requester_registry.clear()
for service in self.services_r... | [
"def",
"stop",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Driver.stop\"",
")",
"for",
"requester",
"in",
"self",
".",
"requester_registry",
":",
"requester",
".",
"stop",
"(",
")",
"self",
".",
"requester_registry",
".",
"clear",
"(",
")"... | Stop services and requestors and then connection.
:return: self | [
"Stop",
"services",
"and",
"requestors",
"and",
"then",
"connection",
".",
":",
"return",
":",
"self"
] | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L844-L859 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/natsd/driver.py | Driver.make_service | def make_service(self, my_args=None):
"""
make a new service instance and handle it from driver
:param my_args: dict like {service_q, treatment_callback [, service_name] }. Default : None
:return: created service proxy
"""
LOGGER.debug("natsd.Driver.make_service")
... | python | def make_service(self, my_args=None):
"""
make a new service instance and handle it from driver
:param my_args: dict like {service_q, treatment_callback [, service_name] }. Default : None
:return: created service proxy
"""
LOGGER.debug("natsd.Driver.make_service")
... | [
"def",
"make_service",
"(",
"self",
",",
"my_args",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"natsd.Driver.make_service\"",
")",
"if",
"my_args",
"is",
"None",
":",
"raise",
"exceptions",
".",
"ArianeConfError",
"(",
"'service factory arguments'",
"... | make a new service instance and handle it from driver
:param my_args: dict like {service_q, treatment_callback [, service_name] }. Default : None
:return: created service proxy | [
"make",
"a",
"new",
"service",
"instance",
"and",
"handle",
"it",
"from",
"driver",
":",
"param",
"my_args",
":",
"dict",
"like",
"{",
"service_q",
"treatment_callback",
"[",
"service_name",
"]",
"}",
".",
"Default",
":",
"None",
":",
"return",
":",
"creat... | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/natsd/driver.py#L861-L874 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.