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 |
|---|---|---|---|---|---|---|---|---|---|---|
abe-winter/pg13-py | pg13/diff.py | subslice | def subslice(inner,outer,section):
'helper for rediff\
outer is a slice (2-tuple, not an official python slice) in global coordinates\
inner is a slice (2-tuple) on that slice\
returns the result of sub-slicing outer by inner'
# todo: think about constraints here. inner and outer ordered, inner[1] less t... | python | def subslice(inner,outer,section):
'helper for rediff\
outer is a slice (2-tuple, not an official python slice) in global coordinates\
inner is a slice (2-tuple) on that slice\
returns the result of sub-slicing outer by inner'
# todo: think about constraints here. inner and outer ordered, inner[1] less t... | [
"def",
"subslice",
"(",
"inner",
",",
"outer",
",",
"section",
")",
":",
"# todo: think about constraints here. inner and outer ordered, inner[1] less than outer[1]-outer[0]\r",
"# todo: this would make more sense as a member of a Slice class\r",
"if",
"section",
"==",
"'head'",
":",... | helper for rediff\
outer is a slice (2-tuple, not an official python slice) in global coordinates\
inner is a slice (2-tuple) on that slice\
returns the result of sub-slicing outer by inner | [
"helper",
"for",
"rediff",
"\\",
"outer",
"is",
"a",
"slice",
"(",
"2",
"-",
"tuple",
"not",
"an",
"official",
"python",
"slice",
")",
"in",
"global",
"coordinates",
"\\",
"inner",
"is",
"a",
"slice",
"(",
"2",
"-",
"tuple",
")",
"on",
"that",
"slice... | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L84-L94 |
abe-winter/pg13-py | pg13/diff.py | rediff | def rediff(a,b,global_a_slice=None):
"recursive diff (splits around longest substring and runs diff on head and tail remnants).\
global_a_slice is used for recursion and should be left undefined in outer call.\
returns a list of Delta tuples."
if not (a or b): return []
global_a_slice=global_a_slice or (... | python | def rediff(a,b,global_a_slice=None):
"recursive diff (splits around longest substring and runs diff on head and tail remnants).\
global_a_slice is used for recursion and should be left undefined in outer call.\
returns a list of Delta tuples."
if not (a or b): return []
global_a_slice=global_a_slice or (... | [
"def",
"rediff",
"(",
"a",
",",
"b",
",",
"global_a_slice",
"=",
"None",
")",
":",
"if",
"not",
"(",
"a",
"or",
"b",
")",
":",
"return",
"[",
"]",
"global_a_slice",
"=",
"global_a_slice",
"or",
"(",
"0",
",",
"len",
"(",
"a",
")",
")",
"csresult"... | recursive diff (splits around longest substring and runs diff on head and tail remnants).\
global_a_slice is used for recursion and should be left undefined in outer call.\
returns a list of Delta tuples. | [
"recursive",
"diff",
"(",
"splits",
"around",
"longest",
"substring",
"and",
"runs",
"diff",
"on",
"head",
"and",
"tail",
"remnants",
")",
".",
"\\",
"global_a_slice",
"is",
"used",
"for",
"recursion",
"and",
"should",
"be",
"left",
"undefined",
"in",
"outer... | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L96-L108 |
abe-winter/pg13-py | pg13/diff.py | translate_diff | def translate_diff(origtext,deltas):
'take diff run on separated words and convert the deltas to character offsets'
lens=[0]+cumsum(map(len,splitpreserve(origtext))) # [0] at the head for like 'length before'
return [Delta(lens[a],lens[b],''.join(replace)) for a,b,replace in deltas] | python | def translate_diff(origtext,deltas):
'take diff run on separated words and convert the deltas to character offsets'
lens=[0]+cumsum(map(len,splitpreserve(origtext))) # [0] at the head for like 'length before'
return [Delta(lens[a],lens[b],''.join(replace)) for a,b,replace in deltas] | [
"def",
"translate_diff",
"(",
"origtext",
",",
"deltas",
")",
":",
"lens",
"=",
"[",
"0",
"]",
"+",
"cumsum",
"(",
"map",
"(",
"len",
",",
"splitpreserve",
"(",
"origtext",
")",
")",
")",
"# [0] at the head for like 'length before'\r",
"return",
"[",
"Delta"... | take diff run on separated words and convert the deltas to character offsets | [
"take",
"diff",
"run",
"on",
"separated",
"words",
"and",
"convert",
"the",
"deltas",
"to",
"character",
"offsets"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L115-L118 |
abe-winter/pg13-py | pg13/diff.py | word_diff | def word_diff(a,b):
'do diff on words but return character offsets'
return translate_diff(a,rediff(splitpreserve(a),splitpreserve(b))) | python | def word_diff(a,b):
'do diff on words but return character offsets'
return translate_diff(a,rediff(splitpreserve(a),splitpreserve(b))) | [
"def",
"word_diff",
"(",
"a",
",",
"b",
")",
":",
"return",
"translate_diff",
"(",
"a",
",",
"rediff",
"(",
"splitpreserve",
"(",
"a",
")",
",",
"splitpreserve",
"(",
"b",
")",
")",
")"
] | do diff on words but return character offsets | [
"do",
"diff",
"on",
"words",
"but",
"return",
"character",
"offsets"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L120-L122 |
abe-winter/pg13-py | pg13/diff.py | checkdiff | def checkdiff(a,b,sp=True):
'take diff of a to b, apply to a, return the applied diff so external code can check it against b'
if sp: a=splitpreserve(a); b=splitpreserve(b)
res=applydiff(a,rediff(a,b))
if sp: res=''.join(res)
return res | python | def checkdiff(a,b,sp=True):
'take diff of a to b, apply to a, return the applied diff so external code can check it against b'
if sp: a=splitpreserve(a); b=splitpreserve(b)
res=applydiff(a,rediff(a,b))
if sp: res=''.join(res)
return res | [
"def",
"checkdiff",
"(",
"a",
",",
"b",
",",
"sp",
"=",
"True",
")",
":",
"if",
"sp",
":",
"a",
"=",
"splitpreserve",
"(",
"a",
")",
"b",
"=",
"splitpreserve",
"(",
"b",
")",
"res",
"=",
"applydiff",
"(",
"a",
",",
"rediff",
"(",
"a",
",",
"b... | take diff of a to b, apply to a, return the applied diff so external code can check it against b | [
"take",
"diff",
"of",
"a",
"to",
"b",
"apply",
"to",
"a",
"return",
"the",
"applied",
"diff",
"so",
"external",
"code",
"can",
"check",
"it",
"against",
"b"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L124-L129 |
treycucco/bidon | bidon/db/model/foreign_model_wrapper.py | ForeignModelWrapper.create | def create(cls, source, *, transform_args=None):
"""Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args.
"""
if transform_args is None:
transform_args = cls.transform_args
return cls(get_obj(source, *transf... | python | def create(cls, source, *, transform_args=None):
"""Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args.
"""
if transform_args is None:
transform_args = cls.transform_args
return cls(get_obj(source, *transf... | [
"def",
"create",
"(",
"cls",
",",
"source",
",",
"*",
",",
"transform_args",
"=",
"None",
")",
":",
"if",
"transform_args",
"is",
"None",
":",
"transform_args",
"=",
"cls",
".",
"transform_args",
"return",
"cls",
"(",
"get_obj",
"(",
"source",
",",
"*",
... | Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args. | [
"Create",
"an",
"instance",
"of",
"the",
"class",
"from",
"the",
"source",
".",
"By",
"default",
"cls",
".",
"transform_args",
"is",
"used",
"but",
"can",
"be",
"overridden",
"by",
"passing",
"in",
"transform_args",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/foreign_model_wrapper.py#L20-L27 |
treycucco/bidon | bidon/db/model/foreign_model_wrapper.py | ForeignModelWrapper.map | def map(cls, sources, *, transform_args=None):
"""Generates instances from the sources using either cls.transform_args or transform_args
argument if present.
"""
for idx, source in enumerate(sources):
try:
yield cls.create(source, transform_args=transform_args)
except Exception as ex... | python | def map(cls, sources, *, transform_args=None):
"""Generates instances from the sources using either cls.transform_args or transform_args
argument if present.
"""
for idx, source in enumerate(sources):
try:
yield cls.create(source, transform_args=transform_args)
except Exception as ex... | [
"def",
"map",
"(",
"cls",
",",
"sources",
",",
"*",
",",
"transform_args",
"=",
"None",
")",
":",
"for",
"idx",
",",
"source",
"in",
"enumerate",
"(",
"sources",
")",
":",
"try",
":",
"yield",
"cls",
".",
"create",
"(",
"source",
",",
"transform_args... | Generates instances from the sources using either cls.transform_args or transform_args
argument if present. | [
"Generates",
"instances",
"from",
"the",
"sources",
"using",
"either",
"cls",
".",
"transform_args",
"or",
"transform_args",
"argument",
"if",
"present",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/foreign_model_wrapper.py#L30-L38 |
minhhoit/yacms | yacms/generic/models.py | ThreadedComment.save | def save(self, *args, **kwargs):
"""
Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``.
"""
if not self.id:
self.is_public = settings.COMMENTS_DEFAULT_APPROVED
self.site_id = current_site_id()
super(Threa... | python | def save(self, *args, **kwargs):
"""
Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``.
"""
if not self.id:
self.is_public = settings.COMMENTS_DEFAULT_APPROVED
self.site_id = current_site_id()
super(Threa... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"id",
":",
"self",
".",
"is_public",
"=",
"settings",
".",
"COMMENTS_DEFAULT_APPROVED",
"self",
".",
"site_id",
"=",
"current_site_id",
"(",
")",... | Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``. | [
"Set",
"the",
"current",
"site",
"ID",
"and",
"is_public",
"based",
"on",
"the",
"setting",
"COMMENTS_DEFAULT_APPROVED",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/models.py#L50-L58 |
minhhoit/yacms | yacms/generic/models.py | Rating.save | def save(self, *args, **kwargs):
"""
Validate that the rating falls between the min and max values.
"""
valid = map(str, settings.RATINGS_RANGE)
if str(self.value) not in valid:
raise ValueError("Invalid rating. %s is not in %s" % (self.value,
", ".joi... | python | def save(self, *args, **kwargs):
"""
Validate that the rating falls between the min and max values.
"""
valid = map(str, settings.RATINGS_RANGE)
if str(self.value) not in valid:
raise ValueError("Invalid rating. %s is not in %s" % (self.value,
", ".joi... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"valid",
"=",
"map",
"(",
"str",
",",
"settings",
".",
"RATINGS_RANGE",
")",
"if",
"str",
"(",
"self",
".",
"value",
")",
"not",
"in",
"valid",
":",
"raise",
"ValueE... | Validate that the rating falls between the min and max values. | [
"Validate",
"that",
"the",
"rating",
"falls",
"between",
"the",
"min",
"and",
"max",
"values",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/models.py#L140-L148 |
kaniblu/pyaap | yaap/__init__.py | ArgParser.add_mutex_switch | def add_mutex_switch(parser, dest, arguments=set(), default=None,
single_arg=False, required=False):
"""Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts.
... | python | def add_mutex_switch(parser, dest, arguments=set(), default=None,
single_arg=False, required=False):
"""Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts.
... | [
"def",
"add_mutex_switch",
"(",
"parser",
",",
"dest",
",",
"arguments",
"=",
"set",
"(",
")",
",",
"default",
"=",
"None",
",",
"single_arg",
"=",
"False",
",",
"required",
"=",
"False",
")",
":",
"if",
"default",
"is",
"not",
"None",
":",
"assert",
... | Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts. | [
"Adds",
"mutually",
"exclusive",
"switch",
"arguments",
"."
] | train | https://github.com/kaniblu/pyaap/blob/fbf8370a49f86b160009ddf30f30f22bb4aba9b9/yaap/__init__.py#L68-L110 |
sci-bots/mpm | mpm/api.py | _islinklike | def _islinklike(dir_path):
'''
Parameters
----------
dir_path : str
Directory path.
Returns
-------
bool
``True`` if :data:`dir_path` is a link *or* junction.
'''
dir_path = ph.path(dir_path)
if platform.system() == 'Windows':
if dir_path.isjunction():
... | python | def _islinklike(dir_path):
'''
Parameters
----------
dir_path : str
Directory path.
Returns
-------
bool
``True`` if :data:`dir_path` is a link *or* junction.
'''
dir_path = ph.path(dir_path)
if platform.system() == 'Windows':
if dir_path.isjunction():
... | [
"def",
"_islinklike",
"(",
"dir_path",
")",
":",
"dir_path",
"=",
"ph",
".",
"path",
"(",
"dir_path",
")",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"if",
"dir_path",
".",
"isjunction",
"(",
")",
":",
"return",
"True",
"elif",
... | Parameters
----------
dir_path : str
Directory path.
Returns
-------
bool
``True`` if :data:`dir_path` is a link *or* junction. | [
"Parameters",
"----------",
"dir_path",
":",
"str",
"Directory",
"path",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L36-L54 |
sci-bots/mpm | mpm/api.py | _save_action | def _save_action(extra_context=None):
'''
Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stor... | python | def _save_action(extra_context=None):
'''
Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stor... | [
"def",
"_save_action",
"(",
"extra_context",
"=",
"None",
")",
":",
"# Get list of revisions to Conda environment since creation.",
"revisions_js",
"=",
"ch",
".",
"conda_exec",
"(",
"'list'",
",",
"'--revisions'",
",",
"'--json'",
",",
"verbose",
"=",
"False",
")",
... | Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stored action revision.
Returns
-------
p... | [
"Save",
"list",
"of",
"revisions",
"revisions",
"for",
"active",
"Conda",
"environment",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L57-L91 |
sci-bots/mpm | mpm/api.py | _remove_broken_links | def _remove_broken_links():
'''
Remove broken links in `<conda prefix>/etc/microdrop/plugins/enabled/`.
Returns
-------
list
List of links removed (if any).
'''
enabled_dir = MICRODROP_CONDA_PLUGINS.joinpath('enabled')
if not enabled_dir.isdir():
return []
broken_li... | python | def _remove_broken_links():
'''
Remove broken links in `<conda prefix>/etc/microdrop/plugins/enabled/`.
Returns
-------
list
List of links removed (if any).
'''
enabled_dir = MICRODROP_CONDA_PLUGINS.joinpath('enabled')
if not enabled_dir.isdir():
return []
broken_li... | [
"def",
"_remove_broken_links",
"(",
")",
":",
"enabled_dir",
"=",
"MICRODROP_CONDA_PLUGINS",
".",
"joinpath",
"(",
"'enabled'",
")",
"if",
"not",
"enabled_dir",
".",
"isdir",
"(",
")",
":",
"return",
"[",
"]",
"broken_links",
"=",
"[",
"]",
"for",
"dir_i",
... | Remove broken links in `<conda prefix>/etc/microdrop/plugins/enabled/`.
Returns
-------
list
List of links removed (if any). | [
"Remove",
"broken",
"links",
"in",
"<conda",
"prefix",
">",
"/",
"etc",
"/",
"microdrop",
"/",
"plugins",
"/",
"enabled",
"/",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L94-L124 |
sci-bots/mpm | mpm/api.py | available_packages | def available_packages(*args, **kwargs):
'''
Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages ... | python | def available_packages(*args, **kwargs):
'''
Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages ... | [
"def",
"available_packages",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get list of available MicroDrop plugins, i.e., Conda packages that start",
"# with the prefix `microdrop.`.",
"try",
":",
"plugin_packages_info_json",
"=",
"ch",
".",
"conda_exec",
"(",
"'s... | Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages beginning with ``microdrop.`` prefix from all
... | [
"Query",
"available",
"plugin",
"packages",
"based",
"on",
"specified",
"Conda",
"channels",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L136-L192 |
sci-bots/mpm | mpm/api.py | install | def install(plugin_name, *args, **kwargs):
'''
Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
... | python | def install(plugin_name, *args, **kwargs):
'''
Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
... | [
"def",
"install",
"(",
"plugin_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"# Perform installation",
"conda_args"... | Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
Note that channels can still be explicitly set... | [
"Install",
"plugin",
"packages",
"based",
"on",
"specified",
"Conda",
"channels",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L196-L234 |
sci-bots/mpm | mpm/api.py | rollback | def rollback(*args, **kwargs):
'''
Restore previous revision of Conda environment according to most recent
action in :attr:`MICRODROP_CONDA_ACTIONS`.
.. versionchanged:: 0.18
Add support for action revision files compressed using ``bz2``.
.. versionchanged:: 0.24
Remove channels ar... | python | def rollback(*args, **kwargs):
'''
Restore previous revision of Conda environment according to most recent
action in :attr:`MICRODROP_CONDA_ACTIONS`.
.. versionchanged:: 0.18
Add support for action revision files compressed using ``bz2``.
.. versionchanged:: 0.24
Remove channels ar... | [
"def",
"rollback",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"action_files",
"=",
"MICRODROP_CONDA_ACTIONS",
".",
"files",
"(",
")",
"if",
"not",
"action_files",
":",
"# No action files, return current revision.",
"logger",
".",
"debug",
"(",
"'No rol... | Restore previous revision of Conda environment according to most recent
action in :attr:`MICRODROP_CONDA_ACTIONS`.
.. versionchanged:: 0.18
Add support for action revision files compressed using ``bz2``.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured i... | [
"Restore",
"previous",
"revision",
"of",
"Conda",
"environment",
"according",
"to",
"most",
"recent",
"action",
"in",
":",
"attr",
":",
"MICRODROP_CONDA_ACTIONS",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L240-L299 |
sci-bots/mpm | mpm/api.py | uninstall | def uninstall(plugin_name, *args):
'''
Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin pa... | python | def uninstall(plugin_name, *args):
'''
Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin pa... | [
"def",
"uninstall",
"(",
"plugin_name",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"available_path",
"=",
"MICRODROP_CONDA_SHARE",
".",
"joinpath"... | Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin package(s) to uninstall.
*args
Extra ... | [
"Uninstall",
"plugin",
"packages",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L304-L345 |
sci-bots/mpm | mpm/api.py | enable_plugin | def enable_plugin(plugin_name):
'''
Enable installed plugin package(s).
Each plugin package must have a directory with the same name as the package
in the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
... | python | def enable_plugin(plugin_name):
'''
Enable installed plugin package(s).
Each plugin package must have a directory with the same name as the package
in the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
... | [
"def",
"enable_plugin",
"(",
"plugin_name",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"singleton",
"=",
"True",
"else",
":",
"singleton",
"=",
"False",
"# Conda-... | Enable installed plugin package(s).
Each plugin package must have a directory with the same name as the package
in the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin package(s) to enable.
Returns
... | [
"Enable",
"installed",
"plugin",
"package",
"(",
"s",
")",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L349-L425 |
sci-bots/mpm | mpm/api.py | disable_plugin | def disable_plugin(plugin_name):
'''
Disable plugin package(s).
Parameters
----------
plugin_name : str or list
Plugin package(s) to disable.
Raises
------
IOError
If plugin is not enabled.
'''
if isinstance(plugin_name, types.StringTypes):
plugin_name =... | python | def disable_plugin(plugin_name):
'''
Disable plugin package(s).
Parameters
----------
plugin_name : str or list
Plugin package(s) to disable.
Raises
------
IOError
If plugin is not enabled.
'''
if isinstance(plugin_name, types.StringTypes):
plugin_name =... | [
"def",
"disable_plugin",
"(",
"plugin_name",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"# Verify all specified plugins are currently enabled.",
"enabled_path",
"=",
"MICRO... | Disable plugin package(s).
Parameters
----------
plugin_name : str or list
Plugin package(s) to disable.
Raises
------
IOError
If plugin is not enabled. | [
"Disable",
"plugin",
"package",
"(",
"s",
")",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L428-L461 |
sci-bots/mpm | mpm/api.py | update | def update(*args, **kwargs):
'''
Update installed plugin package(s).
Each plugin package must have a directory (**NOT** a link) containing a
``properties.yml`` file with a ``package_name`` value in the following
directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
... | python | def update(*args, **kwargs):
'''
Update installed plugin package(s).
Each plugin package must have a directory (**NOT** a link) containing a
``properties.yml`` file with a ``package_name`` value in the following
directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
... | [
"def",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"package_name",
"=",
"kwargs",
".",
"pop",
"(",
"'package_name'",
",",
"None",
")",
"# Only consider **installed** plugins (see `installed_plugins()` docstring).",
"installed_plugins_",
"=",
"instal... | Update installed plugin package(s).
Each plugin package must have a directory (**NOT** a link) containing a
``properties.yml`` file with a ``package_name`` value in the following
directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
*args
Extra arg... | [
"Update",
"installed",
"plugin",
"package",
"(",
"s",
")",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L464-L539 |
sci-bots/mpm | mpm/api.py | import_plugin | def import_plugin(package_name, include_available=False):
'''
Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
... | python | def import_plugin(package_name, include_available=False):
'''
Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
... | [
"def",
"import_plugin",
"(",
"package_name",
",",
"include_available",
"=",
"False",
")",
":",
"available_plugins_dir",
"=",
"MICRODROP_CONDA_SHARE",
".",
"joinpath",
"(",
"'plugins'",
",",
"'available'",
")",
"enabled_plugins_dir",
"=",
"MICRODROP_CONDA_ETC",
".",
"j... | Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
ones).
By default, only the ``<conda>/etc/microdrop/plugins/... | [
"Import",
"MicroDrop",
"plugin",
"."
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L542-L575 |
sci-bots/mpm | mpm/api.py | installed_plugins | def installed_plugins(only_conda=False):
'''
.. versionadded:: 0.20
Parameters
----------
only_conda : bool, optional
Only consider plugins that are installed **as Conda packages**.
.. versionadded:: 0.22
Returns
-------
list
List of properties corresponding to... | python | def installed_plugins(only_conda=False):
'''
.. versionadded:: 0.20
Parameters
----------
only_conda : bool, optional
Only consider plugins that are installed **as Conda packages**.
.. versionadded:: 0.22
Returns
-------
list
List of properties corresponding to... | [
"def",
"installed_plugins",
"(",
"only_conda",
"=",
"False",
")",
":",
"available_path",
"=",
"MICRODROP_CONDA_SHARE",
".",
"joinpath",
"(",
"'plugins'",
",",
"'available'",
")",
"if",
"not",
"available_path",
".",
"isdir",
"(",
")",
":",
"return",
"[",
"]",
... | .. versionadded:: 0.20
Parameters
----------
only_conda : bool, optional
Only consider plugins that are installed **as Conda packages**.
.. versionadded:: 0.22
Returns
-------
list
List of properties corresponding to each available plugin that is
**installed**.... | [
"..",
"versionadded",
"::",
"0",
".",
"20"
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L578-L643 |
sci-bots/mpm | mpm/api.py | enabled_plugins | def enabled_plugins(installed_only=True):
'''
.. versionadded:: 0.21
Parameters
----------
installed_only : bool, optional
Only consider enabled plugins that are installed in the Conda
environment.
Returns
-------
list
List of properties corresponding to each pl... | python | def enabled_plugins(installed_only=True):
'''
.. versionadded:: 0.21
Parameters
----------
installed_only : bool, optional
Only consider enabled plugins that are installed in the Conda
environment.
Returns
-------
list
List of properties corresponding to each pl... | [
"def",
"enabled_plugins",
"(",
"installed_only",
"=",
"True",
")",
":",
"enabled_path",
"=",
"MICRODROP_CONDA_PLUGINS",
".",
"joinpath",
"(",
"'enabled'",
")",
"if",
"not",
"enabled_path",
".",
"isdir",
"(",
")",
":",
"return",
"[",
"]",
"# Construct list of pro... | .. versionadded:: 0.21
Parameters
----------
installed_only : bool, optional
Only consider enabled plugins that are installed in the Conda
environment.
Returns
-------
list
List of properties corresponding to each plugin that is **enabled**.
If :data:`installed... | [
"..",
"versionadded",
"::",
"0",
".",
"21"
] | train | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L646-L721 |
alexhayes/django-toolkit | django_toolkit/email.py | EmailMultiRelated.attach_related | def attach_related(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the... | python | def attach_related(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the... | [
"def",
"attach_related",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"content",
"=",
"None",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"MIMEBase",
")",
":",
"assert",
"content",
"==",
"mimetype",
"==",
"None",
... | Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulting message attachments. | [
"Attaches",
"a",
"file",
"with",
"the",
"given",
"filename",
"and",
"content",
".",
"The",
"filename",
"can",
"be",
"omitted",
"and",
"the",
"mimetype",
"is",
"guessed",
"if",
"not",
"provided",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/email.py#L24-L37 |
alexhayes/django-toolkit | django_toolkit/email.py | EmailMultiRelated.attach_related_file | def attach_related_file(self, path, mimetype=None):
"""Attaches a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, 'rb').read()
self.attach_related(filename, content, mimetype) | python | def attach_related_file(self, path, mimetype=None):
"""Attaches a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, 'rb').read()
self.attach_related(filename, content, mimetype) | [
"def",
"attach_related_file",
"(",
"self",
",",
"path",
",",
"mimetype",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"content",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
".",
"read",
"(",
")",
"se... | Attaches a file from the filesystem. | [
"Attaches",
"a",
"file",
"from",
"the",
"filesystem",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/email.py#L39-L43 |
alexhayes/django-toolkit | django_toolkit/email.py | EmailMultiRelated._create_related_attachment | def _create_related_attachment(self, filename, content, mimetype=None):
"""
Convert the filename, content, mimetype triple into a MIME attachment
object. Adjust headers to use Content-ID where applicable.
Taken from http://code.djangoproject.com/ticket/4771
"""
attachment... | python | def _create_related_attachment(self, filename, content, mimetype=None):
"""
Convert the filename, content, mimetype triple into a MIME attachment
object. Adjust headers to use Content-ID where applicable.
Taken from http://code.djangoproject.com/ticket/4771
"""
attachment... | [
"def",
"_create_related_attachment",
"(",
"self",
",",
"filename",
",",
"content",
",",
"mimetype",
"=",
"None",
")",
":",
"attachment",
"=",
"super",
"(",
"EmailMultiRelated",
",",
"self",
")",
".",
"_create_attachment",
"(",
"filename",
",",
"content",
",",
... | Convert the filename, content, mimetype triple into a MIME attachment
object. Adjust headers to use Content-ID where applicable.
Taken from http://code.djangoproject.com/ticket/4771 | [
"Convert",
"the",
"filename",
"content",
"mimetype",
"triple",
"into",
"a",
"MIME",
"attachment",
"object",
".",
"Adjust",
"headers",
"to",
"use",
"Content",
"-",
"ID",
"where",
"applicable",
".",
"Taken",
"from",
"http",
":",
"//",
"code",
".",
"djangoproje... | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/email.py#L76-L90 |
calvinku96/labreporthelper | labreporthelper/datafile.py | CustomDataFile.create_dat_file | def create_dat_file(self):
"""
Create and write empty data file in the data directory
"""
output = "## {}\n".format(self.name)
try:
kwargs_items = self.kwargs.iteritems()
except AttributeError:
kwargs_items = self.kwargs.items()
for key, va... | python | def create_dat_file(self):
"""
Create and write empty data file in the data directory
"""
output = "## {}\n".format(self.name)
try:
kwargs_items = self.kwargs.iteritems()
except AttributeError:
kwargs_items = self.kwargs.items()
for key, va... | [
"def",
"create_dat_file",
"(",
"self",
")",
":",
"output",
"=",
"\"## {}\\n\"",
".",
"format",
"(",
"self",
".",
"name",
")",
"try",
":",
"kwargs_items",
"=",
"self",
".",
"kwargs",
".",
"iteritems",
"(",
")",
"except",
"AttributeError",
":",
"kwargs_items... | Create and write empty data file in the data directory | [
"Create",
"and",
"write",
"empty",
"data",
"file",
"in",
"the",
"data",
"directory"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L66-L95 |
calvinku96/labreporthelper | labreporthelper/datafile.py | CustomDataFile.parse_data_to_internal | def parse_data_to_internal(self, data=None):
"""
Parse data and save to pickle/hickle
"""
if data is None:
data = parse.getdata(open(self.location_dat, "rb"),
argnum=self.argnum, close=True)
if self.filetype is "pickle":
pi... | python | def parse_data_to_internal(self, data=None):
"""
Parse data and save to pickle/hickle
"""
if data is None:
data = parse.getdata(open(self.location_dat, "rb"),
argnum=self.argnum, close=True)
if self.filetype is "pickle":
pi... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"parse",
".",
"getdata",
"(",
"open",
"(",
"self",
".",
"location_dat",
",",
"\"rb\"",
")",
",",
"argnum",
"=",
"self",
".... | Parse data and save to pickle/hickle | [
"Parse",
"data",
"and",
"save",
"to",
"pickle",
"/",
"hickle"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L97-L114 |
calvinku96/labreporthelper | labreporthelper/datafile.py | CustomDataFile.get_internal_data | def get_internal_data(self):
"""
Get data that is saved in pickle/hickle
"""
if self.filetype is "pickle":
return pickle.load(open(self.location_internal, "rb"))
elif self.filetype is "hickle":
import hickle
return hickle.load(open(self.locatio... | python | def get_internal_data(self):
"""
Get data that is saved in pickle/hickle
"""
if self.filetype is "pickle":
return pickle.load(open(self.location_internal, "rb"))
elif self.filetype is "hickle":
import hickle
return hickle.load(open(self.locatio... | [
"def",
"get_internal_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"filetype",
"is",
"\"pickle\"",
":",
"return",
"pickle",
".",
"load",
"(",
"open",
"(",
"self",
".",
"location_internal",
",",
"\"rb\"",
")",
")",
"elif",
"self",
".",
"filetype",
"is"... | Get data that is saved in pickle/hickle | [
"Get",
"data",
"that",
"is",
"saved",
"in",
"pickle",
"/",
"hickle"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L116-L130 |
calvinku96/labreporthelper | labreporthelper/datafile.py | MCADataFile.save_to_internal | def save_to_internal(self, data):
"""save
"""
if self.filetype is "pickle":
pickle.dump(data, open(self.location_internal, "wb"))
elif self.filetype is "hickle":
import hickle
hickle.dump(data, open(self.location_internal, "wb"))
else:
... | python | def save_to_internal(self, data):
"""save
"""
if self.filetype is "pickle":
pickle.dump(data, open(self.location_internal, "wb"))
elif self.filetype is "hickle":
import hickle
hickle.dump(data, open(self.location_internal, "wb"))
else:
... | [
"def",
"save_to_internal",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"filetype",
"is",
"\"pickle\"",
":",
"pickle",
".",
"dump",
"(",
"data",
",",
"open",
"(",
"self",
".",
"location_internal",
",",
"\"wb\"",
")",
")",
"elif",
"self",
".",... | save | [
"save"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L142-L155 |
calvinku96/labreporthelper | labreporthelper/datafile.py | MCADataFile.parse_data_to_internal | def parse_data_to_internal(self, data=None):
"""parse to internal
"""
if data is None:
f = open(self.location_dat, "rb")
data = {
"PMCA SPECTRUM": {},
"DATA": [],
"DP5 CONFIGURATION": {},
"DPP STATUS": {}
... | python | def parse_data_to_internal(self, data=None):
"""parse to internal
"""
if data is None:
f = open(self.location_dat, "rb")
data = {
"PMCA SPECTRUM": {},
"DATA": [],
"DP5 CONFIGURATION": {},
"DPP STATUS": {}
... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"f",
"=",
"open",
"(",
"self",
".",
"location_dat",
",",
"\"rb\"",
")",
"data",
"=",
"{",
"\"PMCA SPECTRUM\"",
":",
"{",
"}",
",",
"\"D... | parse to internal | [
"parse",
"to",
"internal"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L157-L204 |
calvinku96/labreporthelper | labreporthelper/datafile.py | DataFile.parse_data_to_internal | def parse_data_to_internal(self, data=None):
"""Use numpy loadtxt
"""
if data is None:
kwargs = self.kwargs
data = np.loadtxt(
open(self.location_dat, "rb"), **kwargs
)
if self.filetype is "pickle":
pickle.dump(data, open(se... | python | def parse_data_to_internal(self, data=None):
"""Use numpy loadtxt
"""
if data is None:
kwargs = self.kwargs
data = np.loadtxt(
open(self.location_dat, "rb"), **kwargs
)
if self.filetype is "pickle":
pickle.dump(data, open(se... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"kwargs",
"=",
"self",
".",
"kwargs",
"data",
"=",
"np",
".",
"loadtxt",
"(",
"open",
"(",
"self",
".",
"location_dat",
",",
"\"rb\"",
... | Use numpy loadtxt | [
"Use",
"numpy",
"loadtxt"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L216-L234 |
bwesterb/mirte | src/core.py | Manager._get_all | def _get_all(self, _type):
""" Gets all instances implementing type <_type> """
if _type not in self.modules:
raise ValueError("No such module, %s" % _type)
if not self.insts_implementing.get(_type, None):
raise ValueError("No instance implementing %s" % _type)
re... | python | def _get_all(self, _type):
""" Gets all instances implementing type <_type> """
if _type not in self.modules:
raise ValueError("No such module, %s" % _type)
if not self.insts_implementing.get(_type, None):
raise ValueError("No instance implementing %s" % _type)
re... | [
"def",
"_get_all",
"(",
"self",
",",
"_type",
")",
":",
"if",
"_type",
"not",
"in",
"self",
".",
"modules",
":",
"raise",
"ValueError",
"(",
"\"No such module, %s\"",
"%",
"_type",
")",
"if",
"not",
"self",
".",
"insts_implementing",
".",
"get",
"(",
"_t... | Gets all instances implementing type <_type> | [
"Gets",
"all",
"instances",
"implementing",
"type",
"<_type",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L69-L75 |
bwesterb/mirte | src/core.py | Manager._get_a | def _get_a(self, _type):
""" Gets an instance implementing type <_type> """
tmp = self._get_all(_type)
ret = pick(tmp)
if len(tmp) != 1:
self.l.warn(("get_a: %s all implement %s; " +
"picking %s") % (tmp, _type, ret))
return ret | python | def _get_a(self, _type):
""" Gets an instance implementing type <_type> """
tmp = self._get_all(_type)
ret = pick(tmp)
if len(tmp) != 1:
self.l.warn(("get_a: %s all implement %s; " +
"picking %s") % (tmp, _type, ret))
return ret | [
"def",
"_get_a",
"(",
"self",
",",
"_type",
")",
":",
"tmp",
"=",
"self",
".",
"_get_all",
"(",
"_type",
")",
"ret",
"=",
"pick",
"(",
"tmp",
")",
"if",
"len",
"(",
"tmp",
")",
"!=",
"1",
":",
"self",
".",
"l",
".",
"warn",
"(",
"(",
"\"get_a... | Gets an instance implementing type <_type> | [
"Gets",
"an",
"instance",
"implementing",
"type",
"<_type",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L81-L88 |
bwesterb/mirte | src/core.py | Manager.got_a | def got_a(self, _type):
""" Returns whether there is an instance implementing <_type>
"""
if _type not in self.modules:
raise ValueError("No such module, %s" % _type)
return (_type in self.insts_implementing and
self.insts_implementing[_type]) | python | def got_a(self, _type):
""" Returns whether there is an instance implementing <_type>
"""
if _type not in self.modules:
raise ValueError("No such module, %s" % _type)
return (_type in self.insts_implementing and
self.insts_implementing[_type]) | [
"def",
"got_a",
"(",
"self",
",",
"_type",
")",
":",
"if",
"_type",
"not",
"in",
"self",
".",
"modules",
":",
"raise",
"ValueError",
"(",
"\"No such module, %s\"",
"%",
"_type",
")",
"return",
"(",
"_type",
"in",
"self",
".",
"insts_implementing",
"and",
... | Returns whether there is an instance implementing <_type> | [
"Returns",
"whether",
"there",
"is",
"an",
"instance",
"implementing",
"<_type",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L90-L96 |
bwesterb/mirte | src/core.py | Manager._get_or_create_a | def _get_or_create_a(self, _type):
""" Gets or creates an instance of type <_type> """
self.l.debug("get_or_create_a: %s" % _type)
stack = [Manager.GoCa_Plan(self, {_type: ()})]
while stack:
p = stack.pop()
if p.finished:
p.execute()
... | python | def _get_or_create_a(self, _type):
""" Gets or creates an instance of type <_type> """
self.l.debug("get_or_create_a: %s" % _type)
stack = [Manager.GoCa_Plan(self, {_type: ()})]
while stack:
p = stack.pop()
if p.finished:
p.execute()
... | [
"def",
"_get_or_create_a",
"(",
"self",
",",
"_type",
")",
":",
"self",
".",
"l",
".",
"debug",
"(",
"\"get_or_create_a: %s\"",
"%",
"_type",
")",
"stack",
"=",
"[",
"Manager",
".",
"GoCa_Plan",
"(",
"self",
",",
"{",
"_type",
":",
"(",
")",
"}",
")"... | Gets or creates an instance of type <_type> | [
"Gets",
"or",
"creates",
"an",
"instance",
"of",
"type",
"<_type",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L201-L212 |
bwesterb/mirte | src/core.py | Manager.update_instance | def update_instance(self, name, settings):
""" Updates settings of instance <name> with the
dictionary <settings>. """
if name not in self.insts:
raise ValueError("There's no instance named %s" % name)
if 'module' in settings:
raise ValueError(("Can't change m... | python | def update_instance(self, name, settings):
""" Updates settings of instance <name> with the
dictionary <settings>. """
if name not in self.insts:
raise ValueError("There's no instance named %s" % name)
if 'module' in settings:
raise ValueError(("Can't change m... | [
"def",
"update_instance",
"(",
"self",
",",
"name",
",",
"settings",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"insts",
":",
"raise",
"ValueError",
"(",
"\"There's no instance named %s\"",
"%",
"name",
")",
"if",
"'module'",
"in",
"settings",
":",
... | Updates settings of instance <name> with the
dictionary <settings>. | [
"Updates",
"settings",
"of",
"instance",
"<name",
">",
"with",
"the",
"dictionary",
"<settings",
">",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L235-L245 |
bwesterb/mirte | src/core.py | Manager.create_instance | def create_instance(self, name, moduleName, settings):
""" Creates an instance of <moduleName> at <name> with
<settings>. """
if name in self.insts:
raise ValueError("There's already an instance named %s" %
name)
if moduleName not in self.modu... | python | def create_instance(self, name, moduleName, settings):
""" Creates an instance of <moduleName> at <name> with
<settings>. """
if name in self.insts:
raise ValueError("There's already an instance named %s" %
name)
if moduleName not in self.modu... | [
"def",
"create_instance",
"(",
"self",
",",
"name",
",",
"moduleName",
",",
"settings",
")",
":",
"if",
"name",
"in",
"self",
".",
"insts",
":",
"raise",
"ValueError",
"(",
"\"There's already an instance named %s\"",
"%",
"name",
")",
"if",
"moduleName",
"not"... | Creates an instance of <moduleName> at <name> with
<settings>. | [
"Creates",
"an",
"instance",
"of",
"<moduleName",
">",
"at",
"<name",
">",
"with",
"<settings",
">",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L247-L278 |
bwesterb/mirte | src/core.py | Manager.change_setting | def change_setting(self, instance_name, key, raw_value):
""" Change the settings <key> to <raw_value> of an instance
named <instance_name>. <raw_value> should be a string and
is properly converted. """
ii = self.insts[instance_name]
mo = self.modules[ii.module]
i... | python | def change_setting(self, instance_name, key, raw_value):
""" Change the settings <key> to <raw_value> of an instance
named <instance_name>. <raw_value> should be a string and
is properly converted. """
ii = self.insts[instance_name]
mo = self.modules[ii.module]
i... | [
"def",
"change_setting",
"(",
"self",
",",
"instance_name",
",",
"key",
",",
"raw_value",
")",
":",
"ii",
"=",
"self",
".",
"insts",
"[",
"instance_name",
"]",
"mo",
"=",
"self",
".",
"modules",
"[",
"ii",
".",
"module",
"]",
"if",
"key",
"in",
"mo",... | Change the settings <key> to <raw_value> of an instance
named <instance_name>. <raw_value> should be a string and
is properly converted. | [
"Change",
"the",
"settings",
"<key",
">",
"to",
"<raw_value",
">",
"of",
"an",
"instance",
"named",
"<instance_name",
">",
".",
"<raw_value",
">",
"should",
"be",
"a",
"string",
"and",
"is",
"properly",
"converted",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/core.py#L333-L358 |
klen/muffin-jade | muffin_jade.py | Plugin.setup | def setup(self, app):
""" Setup the plugin from an application. """
super().setup(app)
if isinstance(self.cfg.template_folders, str):
self.cfg.template_folders = [self.cfg.template_folders]
else:
self.cfg.template_folders = list(self.cfg.template_folders)
... | python | def setup(self, app):
""" Setup the plugin from an application. """
super().setup(app)
if isinstance(self.cfg.template_folders, str):
self.cfg.template_folders = [self.cfg.template_folders]
else:
self.cfg.template_folders = list(self.cfg.template_folders)
... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"super",
"(",
")",
".",
"setup",
"(",
"app",
")",
"if",
"isinstance",
"(",
"self",
".",
"cfg",
".",
"template_folders",
",",
"str",
")",
":",
"self",
".",
"cfg",
".",
"template_folders",
"=",
"[",
... | Setup the plugin from an application. | [
"Setup",
"the",
"plugin",
"from",
"an",
"application",
"."
] | train | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L46-L57 |
klen/muffin-jade | muffin_jade.py | Plugin.ctx_provider | def ctx_provider(self, func):
""" Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return func | python | def ctx_provider(self, func):
""" Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return func | [
"def",
"ctx_provider",
"(",
"self",
",",
"func",
")",
":",
"func",
"=",
"to_coroutine",
"(",
"func",
")",
"self",
".",
"providers",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...} | [
"Decorator",
"for",
"adding",
"a",
"context",
"provider",
"."
] | train | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L59-L69 |
klen/muffin-jade | muffin_jade.py | Plugin.register | def register(self, func):
""" Register function to templates. """
if callable(func):
self.functions[func.__name__] = func
return func | python | def register(self, func):
""" Register function to templates. """
if callable(func):
self.functions[func.__name__] = func
return func | [
"def",
"register",
"(",
"self",
",",
"func",
")",
":",
"if",
"callable",
"(",
"func",
")",
":",
"self",
".",
"functions",
"[",
"func",
".",
"__name__",
"]",
"=",
"func",
"return",
"func"
] | Register function to templates. | [
"Register",
"function",
"to",
"templates",
"."
] | train | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L71-L75 |
klen/muffin-jade | muffin_jade.py | Plugin.render | def render(self, path, **context):
""" Render a template with context. """
funcs = self.functions
ctx = dict(self.functions, jdebug=lambda: dict(
(k, v) for k, v in ctx.items() if k not in funcs and k != 'jdebug'))
for provider in self.providers:
_ctx = yield from... | python | def render(self, path, **context):
""" Render a template with context. """
funcs = self.functions
ctx = dict(self.functions, jdebug=lambda: dict(
(k, v) for k, v in ctx.items() if k not in funcs and k != 'jdebug'))
for provider in self.providers:
_ctx = yield from... | [
"def",
"render",
"(",
"self",
",",
"path",
",",
"*",
"*",
"context",
")",
":",
"funcs",
"=",
"self",
".",
"functions",
"ctx",
"=",
"dict",
"(",
"self",
".",
"functions",
",",
"jdebug",
"=",
"lambda",
":",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"... | Render a template with context. | [
"Render",
"a",
"template",
"with",
"context",
"."
] | train | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L78-L88 |
klen/muffin-jade | muffin_jade.py | Environment.load_template | def load_template(self, path):
""" Load and compile a template. """
if not path.startswith('/'):
for folder in self.options['template_folders']:
fullpath = op.join(folder, path)
if op.exists(fullpath):
path = fullpath
br... | python | def load_template(self, path):
""" Load and compile a template. """
if not path.startswith('/'):
for folder in self.options['template_folders']:
fullpath = op.join(folder, path)
if op.exists(fullpath):
path = fullpath
br... | [
"def",
"load_template",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"for",
"folder",
"in",
"self",
".",
"options",
"[",
"'template_folders'",
"]",
":",
"fullpath",
"=",
"op",
".",
"join",
"(",
"fo... | Load and compile a template. | [
"Load",
"and",
"compile",
"a",
"template",
"."
] | train | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L142-L159 |
pydsigner/taskit | taskit/common.py | FirstBytesProtocol.set_size | def set_size(self, data_size):
"""
Set the data slice size.
"""
if len(str(data_size)) > self.first:
raise ValueError(
'Send size is too large for message size-field width!')
self.data_size = data_size | python | def set_size(self, data_size):
"""
Set the data slice size.
"""
if len(str(data_size)) > self.first:
raise ValueError(
'Send size is too large for message size-field width!')
self.data_size = data_size | [
"def",
"set_size",
"(",
"self",
",",
"data_size",
")",
":",
"if",
"len",
"(",
"str",
"(",
"data_size",
")",
")",
">",
"self",
".",
"first",
":",
"raise",
"ValueError",
"(",
"'Send size is too large for message size-field width!'",
")",
"self",
".",
"data_size"... | Set the data slice size. | [
"Set",
"the",
"data",
"slice",
"size",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/common.py#L81-L89 |
jldantas/libmft | parallel.py | MFT._is_related | def _is_related(parent_entry, child_entry):
'''This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers.'''
if parent_entry.header.mft_record == child_entry.header.base_record_ref and \
parent_entry.header.seq_n... | python | def _is_related(parent_entry, child_entry):
'''This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers.'''
if parent_entry.header.mft_record == child_entry.header.base_record_ref and \
parent_entry.header.seq_n... | [
"def",
"_is_related",
"(",
"parent_entry",
",",
"child_entry",
")",
":",
"if",
"parent_entry",
".",
"header",
".",
"mft_record",
"==",
"child_entry",
".",
"header",
".",
"base_record_ref",
"and",
"parent_entry",
".",
"header",
".",
"seq_number",
"==",
"child_ent... | This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers. | [
"This",
"function",
"checks",
"if",
"a",
"child",
"entry",
"is",
"related",
"to",
"the",
"parent",
"entry",
".",
"This",
"is",
"done",
"by",
"comparing",
"the",
"reference",
"and",
"sequence",
"numbers",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/parallel.py#L132-L139 |
jldantas/libmft | parallel.py | MFT.load_mp | def load_mp(cls, file_pointer, _mft_config=None):
'''The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provid... | python | def load_mp(cls, file_pointer, _mft_config=None):
'''The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provid... | [
"def",
"load_mp",
"(",
"cls",
",",
"file_pointer",
",",
"_mft_config",
"=",
"None",
")",
":",
"import",
"multiprocessing",
"import",
"queue",
"mft_config",
"=",
"_mft_config",
"if",
"_mft_config",
"is",
"not",
"None",
"else",
"MFT",
".",
"mft_config",
"mft_ent... | The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provided, the class will try to auto detect
it. | [
"The",
"initialization",
"process",
"takes",
"a",
"file",
"like",
"object",
"file_pointer",
"and",
"loads",
"it",
"in",
"the",
"internal",
"structures",
".",
"use_cores",
"can",
"be",
"definied",
"if",
"multiple",
"cores",
"are",
"to",
"be",
"used",
".",
"Th... | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/parallel.py#L142-L202 |
ryanjdillon/pyotelem | pyotelem/dives.py | finddives2 | def finddives2(depths, min_dive_thresh=10):
'''Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
... | python | def finddives2(depths, min_dive_thresh=10):
'''Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
... | [
"def",
"finddives2",
"(",
"depths",
",",
"min_dive_thresh",
"=",
"10",
")",
":",
"import",
"numpy",
"import",
"pandas",
"from",
".",
"import",
"utils",
"# Get start and stop indices for each dive above `min_dive_thresh`",
"condition",
"=",
"depths",
">",
"min_dive_thres... | Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
Dive summary information in a numpy record arra... | [
"Find",
"dives",
"in",
"depth",
"data",
"below",
"a",
"minimum",
"dive",
"threshold"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L2-L81 |
ryanjdillon/pyotelem | pyotelem/dives.py | get_des_asc2 | def get_des_asc2(depths, dive_mask, pitch, cutoff, fs, order=5):
'''Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch a... | python | def get_des_asc2(depths, dive_mask, pitch, cutoff, fs, order=5):
'''Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch a... | [
"def",
"get_des_asc2",
"(",
"depths",
",",
"dive_mask",
",",
"pitch",
",",
"cutoff",
",",
"fs",
",",
"order",
"=",
"5",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"dsp",
"asc_mask",
"=",
"numpy",
".",
"zeros",
"(",
"len",
"(",
"depths",
")",... | Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch angle in radians
cutoff: float
Cutoff frequency at which sign... | [
"Get",
"boolean",
"masks",
"of",
"descents",
"and",
"ascents",
"in",
"the",
"depth",
"data"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L84-L126 |
ryanjdillon/pyotelem | pyotelem/dives.py | rm_incomplete_des_asc | def rm_incomplete_des_asc(des_mask, asc_mask):
'''Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mas... | python | def rm_incomplete_des_asc(des_mask, asc_mask):
'''Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mas... | [
"def",
"rm_incomplete_des_asc",
"(",
"des_mask",
",",
"asc_mask",
")",
":",
"from",
".",
"import",
"utils",
"# Get start/stop indices for descents and ascents",
"des_start",
",",
"des_stop",
"=",
"utils",
".",
"contiguous_regions",
"(",
"des_mask",
")",
"asc_start",
"... | Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mask: ndarray
Boolean mask of descents with erron... | [
"Remove",
"descents",
"-",
"ascents",
"that",
"have",
"no",
"corresponding",
"ascent",
"-",
"descent"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L129-L155 |
ryanjdillon/pyotelem | pyotelem/dives.py | get_bottom | def get_bottom(depths, des_mask, asc_mask):
'''Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: nd... | python | def get_bottom(depths, des_mask, asc_mask):
'''Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: nd... | [
"def",
"get_bottom",
"(",
"depths",
",",
"des_mask",
",",
"asc_mask",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"utils",
"# Get start/stop indices for descents and ascents",
"des_start",
",",
"des_stop",
"=",
"utils",
".",
"contiguous_regions",
"(",
"des_m... | Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: ndarray (n,4)
Indices and depths for when the... | [
"Get",
"boolean",
"mask",
"of",
"regions",
"in",
"depths",
"the",
"animal",
"is",
"at",
"the",
"bottom"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L158-L207 |
ryanjdillon/pyotelem | pyotelem/dives.py | get_phase | def get_phase(n_samples, des_mask, asc_mask):
'''Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,... | python | def get_phase(n_samples, des_mask, asc_mask):
'''Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,... | [
"def",
"get_phase",
"(",
"n_samples",
",",
"des_mask",
",",
"asc_mask",
")",
":",
"import",
"numpy",
"phase",
"=",
"numpy",
".",
"zeros",
"(",
"n_samples",
",",
"dtype",
"=",
"int",
")",
"phase",
"[",
"asc_mask",
"]",
"=",
"1",
"phase",
"[",
"des_mask"... | Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,)
Boolean mask of values where animal is asce... | [
"Get",
"the",
"directional",
"phase",
"sign",
"for",
"each",
"sample",
"in",
"depths"
] | train | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L210-L239 |
alexhayes/django-toolkit | django_toolkit/file.py | tempfilename | def tempfilename(**kwargs):
"""
Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed.
"""
kwargs.update(delete=False)
try:
f = NamedTemporar... | python | def tempfilename(**kwargs):
"""
Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed.
"""
kwargs.update(delete=False)
try:
f = NamedTemporar... | [
"def",
"tempfilename",
"(",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"delete",
"=",
"False",
")",
"try",
":",
"f",
"=",
"NamedTemporaryFile",
"(",
"*",
"*",
"kwargs",
")",
"f",
".",
"close",
"(",
")",
"yield",
"f",
".",
"name",
... | Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed. | [
"Reserve",
"a",
"temporary",
"file",
"for",
"future",
"use",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/file.py#L37-L53 |
alexhayes/django-toolkit | django_toolkit/file.py | makedirs | def makedirs(p):
"""
A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.
"""
try:
os.makedirs(p, settings.FILE_UPLOAD_PERMISSIONS)
except OSError:
# Perhaps someone beat us to the punch?
if not os.path.isdir(p):
... | python | def makedirs(p):
"""
A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.
"""
try:
os.makedirs(p, settings.FILE_UPLOAD_PERMISSIONS)
except OSError:
# Perhaps someone beat us to the punch?
if not os.path.isdir(p):
... | [
"def",
"makedirs",
"(",
"p",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"p",
",",
"settings",
".",
"FILE_UPLOAD_PERMISSIONS",
")",
"except",
"OSError",
":",
"# Perhaps someone beat us to the punch?",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
... | A makedirs that avoids a race conditions for multiple processes attempting to create the same directory. | [
"A",
"makedirs",
"that",
"avoids",
"a",
"race",
"conditions",
"for",
"multiple",
"processes",
"attempting",
"to",
"create",
"the",
"same",
"directory",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/file.py#L80-L90 |
rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.control_high_limit | def control_high_limit(self) -> Optional[Union[int, float]]:
"""
Control high limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_HIGH_LIMIT) | python | def control_high_limit(self) -> Optional[Union[int, float]]:
"""
Control high limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_HIGH_LIMIT) | [
"def",
"control_high_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CONTROL_HIGH_LIMIT",
")"
] | Control high limit setting for a special sensor.
For LS-10/LS-20 base units only. | [
"Control",
"high",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L344-L350 |
rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.control_low_limit | def control_low_limit(self) -> Optional[Union[int, float]]:
"""
Control low limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_LOW_LIMIT) | python | def control_low_limit(self) -> Optional[Union[int, float]]:
"""
Control low limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_LOW_LIMIT) | [
"def",
"control_low_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CONTROL_LOW_LIMIT",
")"
] | Control low limit setting for a special sensor.
For LS-10/LS-20 base units only. | [
"Control",
"low",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L365-L371 |
rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.current_reading | def current_reading(self) -> Optional[Union[int, float]]:
"""Current reading for a special sensor."""
return self._get_field_value(SpecialDevice.PROP_CURRENT_READING) | python | def current_reading(self) -> Optional[Union[int, float]]:
"""Current reading for a special sensor."""
return self._get_field_value(SpecialDevice.PROP_CURRENT_READING) | [
"def",
"current_reading",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CURRENT_READING",
")"
] | Current reading for a special sensor. | [
"Current",
"reading",
"for",
"a",
"special",
"sensor",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L374-L376 |
rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.high_limit | def high_limit(self) -> Optional[Union[int, float]]:
"""
High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag.
... | python | def high_limit(self) -> Optional[Union[int, float]]:
"""
High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag.
... | [
"def",
"high_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_HIGH_LIMIT",
")"
] | High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag. | [
"High",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L379-L387 |
rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.low_limit | def low_limit(self) -> Optional[Union[int, float]]:
"""
Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag.
... | python | def low_limit(self) -> Optional[Union[int, float]]:
"""
Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag.
... | [
"def",
"low_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_LOW_LIMIT",
")"
] | Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag. | [
"Low",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L390-L398 |
rorr73/LifeSOSpy | lifesospy/device.py | DeviceCollection.get | def get(self, device_id: int) -> Optional[Device]:
"""Get device using the specified ID, or None if not found."""
return self._devices.get(device_id) | python | def get(self, device_id: int) -> Optional[Device]:
"""Get device using the specified ID, or None if not found."""
return self._devices.get(device_id) | [
"def",
"get",
"(",
"self",
",",
"device_id",
":",
"int",
")",
"->",
"Optional",
"[",
"Device",
"]",
":",
"return",
"self",
".",
"_devices",
".",
"get",
"(",
"device_id",
")"
] | Get device using the specified ID, or None if not found. | [
"Get",
"device",
"using",
"the",
"specified",
"ID",
"or",
"None",
"if",
"not",
"found",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L511-L513 |
coopie/ttv | ttv.py | make_ttv_yaml | def make_ttv_yaml(corpora, path_to_ttv_file, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False):
""" Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Ar... | python | def make_ttv_yaml(corpora, path_to_ttv_file, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False):
""" Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Ar... | [
"def",
"make_ttv_yaml",
"(",
"corpora",
",",
"path_to_ttv_file",
",",
"ttv_ratio",
"=",
"DEFAULT_TTV_RATIO",
",",
"deterministic",
"=",
"False",
")",
":",
"dataset",
"=",
"get_dataset",
"(",
"corpora",
")",
"data_sets",
"=",
"make_ttv",
"(",
"dataset",
",",
"t... | Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Arguments;
corpora: a list of the paths to corpora used (these have to be formatted accoring to no... | [
"Create",
"a",
"test",
"train",
"validation",
"from",
"the",
"corpora",
"given",
"and",
"saves",
"it",
"as",
"a",
"YAML",
"filename",
"."
] | train | https://github.com/coopie/ttv/blob/43e2bcddf58945f27665d4db1362473842eb26f3/ttv.py#L28-L65 |
coopie/ttv | ttv.py | make_ttv | def make_ttv(dataset, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False, limit_per_set=None):
"""
Return a dict of test,train,validation sets with information regarding the split (lists of paths to data).
Currently only separates by subjectID.
Prioitises having a diverse set than a well fitting set. Th... | python | def make_ttv(dataset, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False, limit_per_set=None):
"""
Return a dict of test,train,validation sets with information regarding the split (lists of paths to data).
Currently only separates by subjectID.
Prioitises having a diverse set than a well fitting set. Th... | [
"def",
"make_ttv",
"(",
"dataset",
",",
"ttv_ratio",
"=",
"DEFAULT_TTV_RATIO",
",",
"deterministic",
"=",
"False",
",",
"limit_per_set",
"=",
"None",
")",
":",
"sizes_and_ids",
"=",
"[",
"(",
"len",
"(",
"dataset",
"[",
"key",
"]",
")",
",",
"key",
")",
... | Return a dict of test,train,validation sets with information regarding the split (lists of paths to data).
Currently only separates by subjectID.
Prioitises having a diverse set than a well fitting set. This means that the
'knapsacking' is done by subjects with the least videos first, so that each set can... | [
"Return",
"a",
"dict",
"of",
"test",
"train",
"validation",
"sets",
"with",
"information",
"regarding",
"the",
"split",
"(",
"lists",
"of",
"paths",
"to",
"data",
")",
"."
] | train | https://github.com/coopie/ttv/blob/43e2bcddf58945f27665d4db1362473842eb26f3/ttv.py#L68-L132 |
coopie/ttv | ttv.py | get_dataset | def get_dataset(corpora):
"""
Return a dictionary of subjectID -> [path_to_resource].
"""
# TODO: make filter methods for the files
def make_posix_path(dirpath, filename):
dirpath = posixpath.sep.join(dirpath.split(os.sep))
return posixpath.join(dirpath, filename)
wav_files_in_... | python | def get_dataset(corpora):
"""
Return a dictionary of subjectID -> [path_to_resource].
"""
# TODO: make filter methods for the files
def make_posix_path(dirpath, filename):
dirpath = posixpath.sep.join(dirpath.split(os.sep))
return posixpath.join(dirpath, filename)
wav_files_in_... | [
"def",
"get_dataset",
"(",
"corpora",
")",
":",
"# TODO: make filter methods for the files",
"def",
"make_posix_path",
"(",
"dirpath",
",",
"filename",
")",
":",
"dirpath",
"=",
"posixpath",
".",
"sep",
".",
"join",
"(",
"dirpath",
".",
"split",
"(",
"os",
"."... | Return a dictionary of subjectID -> [path_to_resource]. | [
"Return",
"a",
"dictionary",
"of",
"subjectID",
"-",
">",
"[",
"path_to_resource",
"]",
"."
] | train | https://github.com/coopie/ttv/blob/43e2bcddf58945f27665d4db1362473842eb26f3/ttv.py#L140-L167 |
naphatkrit/easyci | easyci/user_config.py | load_user_config | def load_user_config(vcs):
"""Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError
"""
config_path = os.path.join(vcs.path, 'eci.yaml')
if not ... | python | def load_user_config(vcs):
"""Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError
"""
config_path = os.path.join(vcs.path, 'eci.yaml')
if not ... | [
"def",
"load_user_config",
"(",
"vcs",
")",
":",
"config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"vcs",
".",
"path",
",",
"'eci.yaml'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
")",
":",
"raise",
"ConfigNotFoundE... | Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError | [
"Load",
"the",
"user",
"config"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/user_config.py#L27-L55 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | authenticate | def authenticate(func, c, expose_request=False):
"""
A decorator that facilitates authentication per method. Setting
C{expose_request} to C{True} will set the underlying request object (if
there is one), usually HTTP and set it to the first argument of the
authenticating callable. If there is no req... | python | def authenticate(func, c, expose_request=False):
"""
A decorator that facilitates authentication per method. Setting
C{expose_request} to C{True} will set the underlying request object (if
there is one), usually HTTP and set it to the first argument of the
authenticating callable. If there is no req... | [
"def",
"authenticate",
"(",
"func",
",",
"c",
",",
"expose_request",
"=",
"False",
")",
":",
"if",
"not",
"python",
".",
"callable",
"(",
"func",
")",
":",
"raise",
"TypeError",
"(",
"'func must be callable'",
")",
"if",
"not",
"python",
".",
"callable",
... | A decorator that facilitates authentication per method. Setting
C{expose_request} to C{True} will set the underlying request object (if
there is one), usually HTTP and set it to the first argument of the
authenticating callable. If there is no request object, the default is
C{None}.
@raise TypeErro... | [
"A",
"decorator",
"that",
"facilitates",
"authentication",
"per",
"method",
".",
"Setting",
"C",
"{",
"expose_request",
"}",
"to",
"C",
"{",
"True",
"}",
"will",
"set",
"the",
"underlying",
"request",
"object",
"(",
"if",
"there",
"is",
"one",
")",
"usuall... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L516-L542 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | expose_request | def expose_request(func):
"""
A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable.
"""
if not python.callable(func):
raise TypeError("func must be callable")
if isinstance(func, types.UnboundMethodType):
setattr(fu... | python | def expose_request(func):
"""
A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable.
"""
if not python.callable(func):
raise TypeError("func must be callable")
if isinstance(func, types.UnboundMethodType):
setattr(fu... | [
"def",
"expose_request",
"(",
"func",
")",
":",
"if",
"not",
"python",
".",
"callable",
"(",
"func",
")",
":",
"raise",
"TypeError",
"(",
"\"func must be callable\"",
")",
"if",
"isinstance",
"(",
"func",
",",
"types",
".",
"UnboundMethodType",
")",
":",
"... | A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable. | [
"A",
"decorator",
"that",
"adds",
"an",
"expose_request",
"flag",
"to",
"the",
"underlying",
"callable",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L545-L559 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | ServiceWrapper.getMethods | def getMethods(self):
"""
Gets a C{dict} of valid method callables for the underlying service
object.
"""
callables = {}
for name in dir(self.service):
method = getattr(self.service, name)
if name.startswith('_') or not python.callable(method):
... | python | def getMethods(self):
"""
Gets a C{dict} of valid method callables for the underlying service
object.
"""
callables = {}
for name in dir(self.service):
method = getattr(self.service, name)
if name.startswith('_') or not python.callable(method):
... | [
"def",
"getMethods",
"(",
"self",
")",
":",
"callables",
"=",
"{",
"}",
"for",
"name",
"in",
"dir",
"(",
"self",
".",
"service",
")",
":",
"method",
"=",
"getattr",
"(",
"self",
".",
"service",
",",
"name",
")",
"if",
"name",
".",
"startswith",
"("... | Gets a C{dict} of valid method callables for the underlying service
object. | [
"Gets",
"a",
"C",
"{",
"dict",
"}",
"of",
"valid",
"method",
"callables",
"for",
"the",
"underlying",
"service",
"object",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L135-L150 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.addService | def addService(self, service, name=None, description=None,
authenticator=None, expose_request=None, preprocessor=None):
"""
Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param na... | python | def addService(self, service, name=None, description=None,
authenticator=None, expose_request=None, preprocessor=None):
"""
Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param na... | [
"def",
"addService",
"(",
"self",
",",
"service",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"authenticator",
"=",
"None",
",",
"expose_request",
"=",
"None",
",",
"preprocessor",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"serv... | Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param name: The name of the service.
@type name: C{str}
@raise pyamf.remoting.RemotingError: Service already exists.
@raise TypeErro... | [
"Adds",
"a",
"service",
"to",
"the",
"gateway",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L298-L335 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.removeService | def removeService(self, service):
"""
Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found.
"""
... | python | def removeService(self, service):
"""
Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found.
"""
... | [
"def",
"removeService",
"(",
"self",
",",
"service",
")",
":",
"for",
"name",
",",
"wrapper",
"in",
"self",
".",
"services",
".",
"iteritems",
"(",
")",
":",
"if",
"service",
"in",
"(",
"name",
",",
"wrapper",
".",
"service",
")",
":",
"del",
"self",... | Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found. | [
"Removes",
"a",
"service",
"from",
"the",
"gateway",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L346-L360 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getServiceRequest | def getServiceRequest(self, request, target):
"""
Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest}
"""
try:
... | python | def getServiceRequest(self, request, target):
"""
Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest}
"""
try:
... | [
"def",
"getServiceRequest",
"(",
"self",
",",
"request",
",",
"target",
")",
":",
"try",
":",
"return",
"self",
".",
"_request_class",
"(",
"request",
".",
"envelope",
",",
"self",
".",
"services",
"[",
"target",
"]",
",",
"None",
")",
"except",
"KeyErro... | Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest} | [
"Returns",
"a",
"service",
"based",
"on",
"the",
"message",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L362-L386 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getProcessor | def getProcessor(self, request):
"""
Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>}
"""
if request.target == 'null' or not request.target:
from pyamf.remoting import amf3
return amf3.Reques... | python | def getProcessor(self, request):
"""
Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>}
"""
if request.target == 'null' or not request.target:
from pyamf.remoting import amf3
return amf3.Reques... | [
"def",
"getProcessor",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"target",
"==",
"'null'",
"or",
"not",
"request",
".",
"target",
":",
"from",
"pyamf",
".",
"remoting",
"import",
"amf3",
"return",
"amf3",
".",
"RequestProcessor",
"(",
... | Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>} | [
"Returns",
"request",
"processor",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L388-L402 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.mustExposeRequest | def mustExposeRequest(self, service_request):
"""
Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@r... | python | def mustExposeRequest(self, service_request):
"""
Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@r... | [
"def",
"mustExposeRequest",
"(",
"self",
",",
"service_request",
")",
":",
"expose_request",
"=",
"service_request",
".",
"service",
".",
"mustExposeRequest",
"(",
"service_request",
")",
"if",
"expose_request",
"is",
"None",
":",
"if",
"self",
".",
"expose_reques... | Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@rtype: C{bool} | [
"Decides",
"whether",
"the",
"underlying",
"http",
"request",
"should",
"be",
"exposed",
"as",
"the",
"first",
"argument",
"to",
"the",
"method",
"call",
".",
"This",
"is",
"granular",
"looking",
"at",
"the",
"service",
"method",
"first",
"then",
"at",
"the"... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L418-L435 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getAuthenticator | def getAuthenticator(self, service_request):
"""
Gets an authenticator callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global authenticator function
for the gateway. Returns C... | python | def getAuthenticator(self, service_request):
"""
Gets an authenticator callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global authenticator function
for the gateway. Returns C... | [
"def",
"getAuthenticator",
"(",
"self",
",",
"service_request",
")",
":",
"auth",
"=",
"service_request",
".",
"service",
".",
"getAuthenticator",
"(",
"service_request",
")",
"if",
"auth",
"is",
"None",
":",
"return",
"self",
".",
"authenticator",
"return",
"... | Gets an authenticator callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global authenticator function
for the gateway. Returns C{None} if one could not be found. | [
"Gets",
"an",
"authenticator",
"callable",
"based",
"on",
"the",
"service_request",
".",
"This",
"is",
"granular",
"looking",
"at",
"the",
"service",
"method",
"first",
"then",
"at",
"the",
"service",
"level",
"and",
"finally",
"to",
"see",
"if",
"there",
"i... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L437-L449 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.authenticateRequest | def authenticateRequest(self, service_request, username, password, **kwargs):
"""
Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: Returns a C{bool} based on the result of authorization. A
value of C{False} will sto... | python | def authenticateRequest(self, service_request, username, password, **kwargs):
"""
Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: Returns a C{bool} based on the result of authorization. A
value of C{False} will sto... | [
"def",
"authenticateRequest",
"(",
"self",
",",
"service_request",
",",
"username",
",",
"password",
",",
"*",
"*",
"kwargs",
")",
":",
"authenticator",
"=",
"self",
".",
"getAuthenticator",
"(",
"service_request",
")",
"if",
"authenticator",
"is",
"None",
":"... | Processes an authentication request. If no authenticator is supplied,
then authentication succeeds.
@return: Returns a C{bool} based on the result of authorization. A
value of C{False} will stop processing the request and return an
error to the client.
@rtype: C{bool} | [
"Processes",
"an",
"authentication",
"request",
".",
"If",
"no",
"authenticator",
"is",
"supplied",
"then",
"authentication",
"succeeds",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L451-L472 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getPreprocessor | def getPreprocessor(self, service_request):
"""
Gets a preprocessor callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global preprocessor function
for the gateway. Returns C{Non... | python | def getPreprocessor(self, service_request):
"""
Gets a preprocessor callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global preprocessor function
for the gateway. Returns C{Non... | [
"def",
"getPreprocessor",
"(",
"self",
",",
"service_request",
")",
":",
"preproc",
"=",
"service_request",
".",
"service",
".",
"getPreprocessor",
"(",
"service_request",
")",
"if",
"preproc",
"is",
"None",
":",
"return",
"self",
".",
"preprocessor",
"return",
... | Gets a preprocessor callable based on the service_request. This is
granular, looking at the service method first, then at the service
level and finally to see if there is a global preprocessor function
for the gateway. Returns C{None} if one could not be found. | [
"Gets",
"a",
"preprocessor",
"callable",
"based",
"on",
"the",
"service_request",
".",
"This",
"is",
"granular",
"looking",
"at",
"the",
"service",
"method",
"first",
"then",
"at",
"the",
"service",
"level",
"and",
"finally",
"to",
"see",
"if",
"there",
"is"... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L474-L486 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.preprocessRequest | def preprocessRequest(self, service_request, *args, **kwargs):
"""
Preprocesses a request.
"""
processor = self.getPreprocessor(service_request)
if processor is None:
return
args = (service_request,) + args
if hasattr(processor, '_pyamf_expose_reque... | python | def preprocessRequest(self, service_request, *args, **kwargs):
"""
Preprocesses a request.
"""
processor = self.getPreprocessor(service_request)
if processor is None:
return
args = (service_request,) + args
if hasattr(processor, '_pyamf_expose_reque... | [
"def",
"preprocessRequest",
"(",
"self",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"processor",
"=",
"self",
".",
"getPreprocessor",
"(",
"service_request",
")",
"if",
"processor",
"is",
"None",
":",
"return",
"args",
"="... | Preprocesses a request. | [
"Preprocesses",
"a",
"request",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L488-L503 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.callServiceRequest | def callServiceRequest(self, service_request, *args, **kwargs):
"""
Executes the service_request call
"""
if self.mustExposeRequest(service_request):
http_request = kwargs.get('http_request', None)
args = (http_request,) + args
return service_request(*arg... | python | def callServiceRequest(self, service_request, *args, **kwargs):
"""
Executes the service_request call
"""
if self.mustExposeRequest(service_request):
http_request = kwargs.get('http_request', None)
args = (http_request,) + args
return service_request(*arg... | [
"def",
"callServiceRequest",
"(",
"self",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"mustExposeRequest",
"(",
"service_request",
")",
":",
"http_request",
"=",
"kwargs",
".",
"get",
"(",
"'http_request'",... | Executes the service_request call | [
"Executes",
"the",
"service_request",
"call"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L505-L513 |
joshblum/beanstalk-dispatch | beanstalk_dispatch/client.py | schedule_function | def schedule_function(queue_name, function_name, *args, **kwargs):
"""
Schedule a function named `function_name` to be run by workers on
the queue `queue_name` with *args and **kwargs as specified by that
function.
"""
body = create_request_body(function_name, *args, **kwargs)
if getattr(set... | python | def schedule_function(queue_name, function_name, *args, **kwargs):
"""
Schedule a function named `function_name` to be run by workers on
the queue `queue_name` with *args and **kwargs as specified by that
function.
"""
body = create_request_body(function_name, *args, **kwargs)
if getattr(set... | [
"def",
"schedule_function",
"(",
"queue_name",
",",
"function_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"create_request_body",
"(",
"function_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"getattr",
"(",
"set... | Schedule a function named `function_name` to be run by workers on
the queue `queue_name` with *args and **kwargs as specified by that
function. | [
"Schedule",
"a",
"function",
"named",
"function_name",
"to",
"be",
"run",
"by",
"workers",
"on",
"the",
"queue",
"queue_name",
"with",
"*",
"args",
"and",
"**",
"kwargs",
"as",
"specified",
"by",
"that",
"function",
"."
] | train | https://github.com/joshblum/beanstalk-dispatch/blob/1cc57e5496bb7114dba6de7c7988e5680d791603/beanstalk_dispatch/client.py#L10-L28 |
joshblum/beanstalk-dispatch | beanstalk_dispatch/execution.py | execute_function | def execute_function(function_request):
"""
Given a request created by
`beanstalk_dispatch.common.create_request_body`, executes the
request. This function is to be run on a beanstalk worker.
"""
dispatch_table = getattr(settings, 'BEANSTALK_DISPATCH_TABLE', None)
if dispatch_table is None... | python | def execute_function(function_request):
"""
Given a request created by
`beanstalk_dispatch.common.create_request_body`, executes the
request. This function is to be run on a beanstalk worker.
"""
dispatch_table = getattr(settings, 'BEANSTALK_DISPATCH_TABLE', None)
if dispatch_table is None... | [
"def",
"execute_function",
"(",
"function_request",
")",
":",
"dispatch_table",
"=",
"getattr",
"(",
"settings",
",",
"'BEANSTALK_DISPATCH_TABLE'",
",",
"None",
")",
"if",
"dispatch_table",
"is",
"None",
":",
"raise",
"BeanstalkDispatchError",
"(",
"'No beanstalk disp... | Given a request created by
`beanstalk_dispatch.common.create_request_body`, executes the
request. This function is to be run on a beanstalk worker. | [
"Given",
"a",
"request",
"created",
"by",
"beanstalk_dispatch",
".",
"common",
".",
"create_request_body",
"executes",
"the",
"request",
".",
"This",
"function",
"is",
"to",
"be",
"run",
"on",
"a",
"beanstalk",
"worker",
"."
] | train | https://github.com/joshblum/beanstalk-dispatch/blob/1cc57e5496bb7114dba6de7c7988e5680d791603/beanstalk_dispatch/execution.py#L13-L54 |
etcher-be/elib_config | elib_config/_value/_config_value_float.py | ConfigValueFloat.set_limits | def set_limits(self, min_: typing.Optional[float] = None, max_: typing.Optional[float] = None):
"""
Sets limits for this config value
If the resulting integer is outside those limits, an exception will be raised
:param min_: minima
:param max_: maxima
"""
self._... | python | def set_limits(self, min_: typing.Optional[float] = None, max_: typing.Optional[float] = None):
"""
Sets limits for this config value
If the resulting integer is outside those limits, an exception will be raised
:param min_: minima
:param max_: maxima
"""
self._... | [
"def",
"set_limits",
"(",
"self",
",",
"min_",
":",
"typing",
".",
"Optional",
"[",
"float",
"]",
"=",
"None",
",",
"max_",
":",
"typing",
".",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
":",
"self",
".",
"_min",
",",
"self",
".",
"_max",
"... | Sets limits for this config value
If the resulting integer is outside those limits, an exception will be raised
:param min_: minima
:param max_: maxima | [
"Sets",
"limits",
"for",
"this",
"config",
"value"
] | train | https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_value/_config_value_float.py#L37-L46 |
jkenlooper/chill | src/chill/operate.py | node_input | def node_input():
"""
Get a valid node id from the user.
Return -1 if invalid
"""
try:
node = int(raw_input("Node id: "))
except ValueError:
node = INVALID_NODE
print 'invalid node id: %s' % node
return node | python | def node_input():
"""
Get a valid node id from the user.
Return -1 if invalid
"""
try:
node = int(raw_input("Node id: "))
except ValueError:
node = INVALID_NODE
print 'invalid node id: %s' % node
return node | [
"def",
"node_input",
"(",
")",
":",
"try",
":",
"node",
"=",
"int",
"(",
"raw_input",
"(",
"\"Node id: \"",
")",
")",
"except",
"ValueError",
":",
"node",
"=",
"INVALID_NODE",
"print",
"'invalid node id: %s'",
"%",
"node",
"return",
"node"
] | Get a valid node id from the user.
Return -1 if invalid | [
"Get",
"a",
"valid",
"node",
"id",
"from",
"the",
"user",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L38-L49 |
jkenlooper/chill | src/chill/operate.py | existing_node_input | def existing_node_input():
"""
Get an existing node id by name or id.
Return -1 if invalid
"""
input_from_user = raw_input("Existing node name or id: ")
node_id = INVALID_NODE
if not input_from_user:
return node_id
# int or str?
try:
parsed_input = int(input_from_u... | python | def existing_node_input():
"""
Get an existing node id by name or id.
Return -1 if invalid
"""
input_from_user = raw_input("Existing node name or id: ")
node_id = INVALID_NODE
if not input_from_user:
return node_id
# int or str?
try:
parsed_input = int(input_from_u... | [
"def",
"existing_node_input",
"(",
")",
":",
"input_from_user",
"=",
"raw_input",
"(",
"\"Existing node name or id: \"",
")",
"node_id",
"=",
"INVALID_NODE",
"if",
"not",
"input_from_user",
":",
"return",
"node_id",
"# int or str?",
"try",
":",
"parsed_input",
"=",
... | Get an existing node id by name or id.
Return -1 if invalid | [
"Get",
"an",
"existing",
"node",
"id",
"by",
"name",
"or",
"id",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L51-L107 |
jkenlooper/chill | src/chill/operate.py | render_value_for_node | def render_value_for_node(node_id):
"""
Wrap render_node for usage in operate scripts. Returns without template
rendered.
"""
value = None
result = []
try:
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), node_id=node_id).fetchall()
except DatabaseError a... | python | def render_value_for_node(node_id):
"""
Wrap render_node for usage in operate scripts. Returns without template
rendered.
"""
value = None
result = []
try:
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), node_id=node_id).fetchall()
except DatabaseError a... | [
"def",
"render_value_for_node",
"(",
"node_id",
")",
":",
"value",
"=",
"None",
"result",
"=",
"[",
"]",
"try",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'select_node_from_id.sql'",
")",
")",
",",
"node_id",
"=... | Wrap render_node for usage in operate scripts. Returns without template
rendered. | [
"Wrap",
"render_node",
"for",
"usage",
"in",
"operate",
"scripts",
".",
"Returns",
"without",
"template",
"rendered",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L109-L125 |
jkenlooper/chill | src/chill/operate.py | purge_collection | def purge_collection(keys):
"Recursive purge of nodes with name and id"
for key in keys:
m = re.match(r'(.*) \((\d+)\)', key)
name = m.group(1)
node_id = m.group(2)
value = render_value_for_node(node_id)
print 'remove node with name:{0} and id:{1}'.format(name, node_id)
... | python | def purge_collection(keys):
"Recursive purge of nodes with name and id"
for key in keys:
m = re.match(r'(.*) \((\d+)\)', key)
name = m.group(1)
node_id = m.group(2)
value = render_value_for_node(node_id)
print 'remove node with name:{0} and id:{1}'.format(name, node_id)
... | [
"def",
"purge_collection",
"(",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'(.*) \\((\\d+)\\)'",
",",
"key",
")",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
"node_id",
"=",
"m",
".",
"group",
"(",
... | Recursive purge of nodes with name and id | [
"Recursive",
"purge",
"of",
"nodes",
"with",
"name",
"and",
"id"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L144-L155 |
jkenlooper/chill | src/chill/operate.py | mode_collection | def mode_collection():
"""
Manage an existing collection node.
"""
print globals()['mode_collection'].__doc__
collection_node_id = existing_node_input()
value = render_value_for_node(collection_node_id)
if not value:
return None
print "Collection length: {0}".format(len(value))
... | python | def mode_collection():
"""
Manage an existing collection node.
"""
print globals()['mode_collection'].__doc__
collection_node_id = existing_node_input()
value = render_value_for_node(collection_node_id)
if not value:
return None
print "Collection length: {0}".format(len(value))
... | [
"def",
"mode_collection",
"(",
")",
":",
"print",
"globals",
"(",
")",
"[",
"'mode_collection'",
"]",
".",
"__doc__",
"collection_node_id",
"=",
"existing_node_input",
"(",
")",
"value",
"=",
"render_value_for_node",
"(",
"collection_node_id",
")",
"if",
"not",
... | Manage an existing collection node. | [
"Manage",
"an",
"existing",
"collection",
"node",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L161-L245 |
jkenlooper/chill | src/chill/operate.py | mode_new_collection | def mode_new_collection():
"""
Create a new collection of items with common attributes.
"""
print globals()['mode_new_collection'].__doc__
collection_name = raw_input("Collection name: ")
item_attr_list = []
collection_node_id = None
if collection_name:
collection_node_id = inse... | python | def mode_new_collection():
"""
Create a new collection of items with common attributes.
"""
print globals()['mode_new_collection'].__doc__
collection_name = raw_input("Collection name: ")
item_attr_list = []
collection_node_id = None
if collection_name:
collection_node_id = inse... | [
"def",
"mode_new_collection",
"(",
")",
":",
"print",
"globals",
"(",
")",
"[",
"'mode_new_collection'",
"]",
".",
"__doc__",
"collection_name",
"=",
"raw_input",
"(",
"\"Collection name: \"",
")",
"item_attr_list",
"=",
"[",
"]",
"collection_node_id",
"=",
"None"... | Create a new collection of items with common attributes. | [
"Create",
"a",
"new",
"collection",
"of",
"items",
"with",
"common",
"attributes",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L259-L292 |
jkenlooper/chill | src/chill/operate.py | mode_database_functions | def mode_database_functions():
"Select a function to perform from chill.database"
print globals()['mode_database_functions'].__doc__
selection = True
database_functions = [
'init_db',
'insert_node',
'insert_node_node',
'delete_node',
'select_n... | python | def mode_database_functions():
"Select a function to perform from chill.database"
print globals()['mode_database_functions'].__doc__
selection = True
database_functions = [
'init_db',
'insert_node',
'insert_node_node',
'delete_node',
'select_n... | [
"def",
"mode_database_functions",
"(",
")",
":",
"print",
"globals",
"(",
")",
"[",
"'mode_database_functions'",
"]",
".",
"__doc__",
"selection",
"=",
"True",
"database_functions",
"=",
"[",
"'init_db'",
",",
"'insert_node'",
",",
"'insert_node_node'",
",",
"'del... | Select a function to perform from chill.database | [
"Select",
"a",
"function",
"to",
"perform",
"from",
"chill",
".",
"database"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L295-L389 |
jkenlooper/chill | src/chill/operate.py | operate_menu | def operate_menu():
"Select between these operations on the database"
selection = True
while selection:
print globals()['operate_menu'].__doc__
selection = select([
'chill.database functions',
'execute sql file',
'render_node',
'New collectio... | python | def operate_menu():
"Select between these operations on the database"
selection = True
while selection:
print globals()['operate_menu'].__doc__
selection = select([
'chill.database functions',
'execute sql file',
'render_node',
'New collectio... | [
"def",
"operate_menu",
"(",
")",
":",
"selection",
"=",
"True",
"while",
"selection",
":",
"print",
"globals",
"(",
")",
"[",
"'operate_menu'",
"]",
".",
"__doc__",
"selection",
"=",
"select",
"(",
"[",
"'chill.database functions'",
",",
"'execute sql file'",
... | Select between these operations on the database | [
"Select",
"between",
"these",
"operations",
"on",
"the",
"database"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L391-L481 |
dossier/dossier.web | dossier/web/config.py | safe_service | def safe_service(attr, default_value=None):
'''A **method** decorator for creating safe services.
Given an attribute name, this returns a decorator for creating
safe services. Namely, if a service that is not yet available is
requested (like a database connection), then ``safe_service`` will
log an... | python | def safe_service(attr, default_value=None):
'''A **method** decorator for creating safe services.
Given an attribute name, this returns a decorator for creating
safe services. Namely, if a service that is not yet available is
requested (like a database connection), then ``safe_service`` will
log an... | [
"def",
"safe_service",
"(",
"attr",
",",
"default_value",
"=",
"None",
")",
":",
"def",
"_",
"(",
"fun",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fun",
")",
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"return",
"fun",
"(",
"self",
")"... | A **method** decorator for creating safe services.
Given an attribute name, this returns a decorator for creating
safe services. Namely, if a service that is not yet available is
requested (like a database connection), then ``safe_service`` will
log any errors and set the given attribute to ``default_v... | [
"A",
"**",
"method",
"**",
"decorator",
"for",
"creating",
"safe",
"services",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L22-L43 |
dossier/dossier.web | dossier/web/config.py | thread_local_property | def thread_local_property(name):
'''Creates a thread local ``property``.'''
name = '_thread_local_' + name
def fget(self):
try:
return getattr(self, name).value
except AttributeError:
return None
def fset(self, value):
getattr(self, name).value = value
... | python | def thread_local_property(name):
'''Creates a thread local ``property``.'''
name = '_thread_local_' + name
def fget(self):
try:
return getattr(self, name).value
except AttributeError:
return None
def fset(self, value):
getattr(self, name).value = value
... | [
"def",
"thread_local_property",
"(",
"name",
")",
":",
"name",
"=",
"'_thread_local_'",
"+",
"name",
"def",
"fget",
"(",
"self",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"self",
",",
"name",
")",
".",
"value",
"except",
"AttributeError",
":",
"ret... | Creates a thread local ``property``. | [
"Creates",
"a",
"thread",
"local",
"property",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L46-L59 |
dossier/dossier.web | dossier/web/config.py | Config.tags | def tags(self):
'Return a thread local :class:`dossier.web.Tags` client.'
if self._tags is None:
config = global_config('dossier.tags')
self._tags = self.create(Tags, config=config)
return self._tags | python | def tags(self):
'Return a thread local :class:`dossier.web.Tags` client.'
if self._tags is None:
config = global_config('dossier.tags')
self._tags = self.create(Tags, config=config)
return self._tags | [
"def",
"tags",
"(",
"self",
")",
":",
"if",
"self",
".",
"_tags",
"is",
"None",
":",
"config",
"=",
"global_config",
"(",
"'dossier.tags'",
")",
"self",
".",
"_tags",
"=",
"self",
".",
"create",
"(",
"Tags",
",",
"config",
"=",
"config",
")",
"return... | Return a thread local :class:`dossier.web.Tags` client. | [
"Return",
"a",
"thread",
"local",
":",
"class",
":",
"dossier",
".",
"web",
".",
"Tags",
"client",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L101-L106 |
dossier/dossier.web | dossier/web/config.py | Config.store | def store(self):
'''Return a thread local :class:`dossier.store.Store` client.'''
if self._store is None:
config = global_config('dossier.store')
self._store = self.create(ElasticStore, config=config)
return self._store | python | def store(self):
'''Return a thread local :class:`dossier.store.Store` client.'''
if self._store is None:
config = global_config('dossier.store')
self._store = self.create(ElasticStore, config=config)
return self._store | [
"def",
"store",
"(",
"self",
")",
":",
"if",
"self",
".",
"_store",
"is",
"None",
":",
"config",
"=",
"global_config",
"(",
"'dossier.store'",
")",
"self",
".",
"_store",
"=",
"self",
".",
"create",
"(",
"ElasticStore",
",",
"config",
"=",
"config",
")... | Return a thread local :class:`dossier.store.Store` client. | [
"Return",
"a",
"thread",
"local",
":",
"class",
":",
"dossier",
".",
"store",
".",
"Store",
"client",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L110-L115 |
dossier/dossier.web | dossier/web/config.py | Config.label_store | def label_store(self):
'''Return a thread local :class:`dossier.label.LabelStore` client.'''
if self._label_store is None:
config = global_config('dossier.label')
if 'kvlayer' in config:
kvl = kvlayer.client(config=config['kvlayer'])
self._label_st... | python | def label_store(self):
'''Return a thread local :class:`dossier.label.LabelStore` client.'''
if self._label_store is None:
config = global_config('dossier.label')
if 'kvlayer' in config:
kvl = kvlayer.client(config=config['kvlayer'])
self._label_st... | [
"def",
"label_store",
"(",
"self",
")",
":",
"if",
"self",
".",
"_label_store",
"is",
"None",
":",
"config",
"=",
"global_config",
"(",
"'dossier.label'",
")",
"if",
"'kvlayer'",
"in",
"config",
":",
"kvl",
"=",
"kvlayer",
".",
"client",
"(",
"config",
"... | Return a thread local :class:`dossier.label.LabelStore` client. | [
"Return",
"a",
"thread",
"local",
":",
"class",
":",
"dossier",
".",
"label",
".",
"LabelStore",
"client",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L119-L128 |
dossier/dossier.web | dossier/web/config.py | Config.kvlclient | def kvlclient(self):
'''Return a thread local ``kvlayer`` client.'''
if self._kvlclient is None:
self._kvlclient = kvlayer.client()
return self._kvlclient | python | def kvlclient(self):
'''Return a thread local ``kvlayer`` client.'''
if self._kvlclient is None:
self._kvlclient = kvlayer.client()
return self._kvlclient | [
"def",
"kvlclient",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kvlclient",
"is",
"None",
":",
"self",
".",
"_kvlclient",
"=",
"kvlayer",
".",
"client",
"(",
")",
"return",
"self",
".",
"_kvlclient"
] | Return a thread local ``kvlayer`` client. | [
"Return",
"a",
"thread",
"local",
"kvlayer",
"client",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L132-L136 |
alexgorin/pymar | pymar/producer.py | Producer.divide | def divide(self, data_source_factory):
"""Divides the task according to the number of workers."""
data_length = data_source_factory.length()
data_interval_length = data_length / self.workers_number() + 1
current_index = 0
self.responses = []
while current_index < data_le... | python | def divide(self, data_source_factory):
"""Divides the task according to the number of workers."""
data_length = data_source_factory.length()
data_interval_length = data_length / self.workers_number() + 1
current_index = 0
self.responses = []
while current_index < data_le... | [
"def",
"divide",
"(",
"self",
",",
"data_source_factory",
")",
":",
"data_length",
"=",
"data_source_factory",
".",
"length",
"(",
")",
"data_interval_length",
"=",
"data_length",
"/",
"self",
".",
"workers_number",
"(",
")",
"+",
"1",
"current_index",
"=",
"0... | Divides the task according to the number of workers. | [
"Divides",
"the",
"task",
"according",
"to",
"the",
"number",
"of",
"workers",
"."
] | train | https://github.com/alexgorin/pymar/blob/39cd029ea6ff135a6400af2114658166dd6f4ae6/pymar/producer.py#L89-L101 |
alexgorin/pymar | pymar/producer.py | Producer.map | def map(self, data_source_factory, timeout=0, on_timeout="local_mode"):
"""Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
... | python | def map(self, data_source_factory, timeout=0, on_timeout="local_mode"):
"""Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
... | [
"def",
"map",
"(",
"self",
",",
"data_source_factory",
",",
"timeout",
"=",
"0",
",",
"on_timeout",
"=",
"\"local_mode\"",
")",
":",
"def",
"local_launch",
"(",
")",
":",
"print",
"\"Local launch\"",
"return",
"self",
".",
"reduce_fn",
"(",
"self",
".",
"m... | Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
If on_timeout is set to "local_mode", after the time limit producer will run ... | [
"Sends",
"tasks",
"to",
"workers",
"and",
"awaits",
"the",
"responses",
".",
"When",
"all",
"the",
"responses",
"are",
"received",
"reduces",
"them",
"and",
"returns",
"the",
"result",
"."
] | train | https://github.com/alexgorin/pymar/blob/39cd029ea6ff135a6400af2114658166dd6f4ae6/pymar/producer.py#L103-L156 |
thespacedoctor/transientNamer | transientNamer/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opti... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"WARNING\"",
",",
"options_first",
"=",
"False",
... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | train | https://github.com/thespacedoctor/transientNamer/blob/39be410c84275ed4669632f5df67e728d66a318f/transientNamer/cl_utils.py#L49-L162 |
alexhayes/django-toolkit | django_toolkit/db/models.py | LockingManager.lock | def lock(self, *args):
"""
Lock table(s).
Locks the object model table so that atomic update is possible.
Simulatenous database access request pend until the lock is unlock()'ed.
See http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
@param *args: Models to be loc... | python | def lock(self, *args):
"""
Lock table(s).
Locks the object model table so that atomic update is possible.
Simulatenous database access request pend until the lock is unlock()'ed.
See http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
@param *args: Models to be loc... | [
"def",
"lock",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"self",
".",
"model",
"]",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"tables",
"=",
"\", \"",
".",
"join",
"(",
"[",
"'%s WRITE'",
"%"... | Lock table(s).
Locks the object model table so that atomic update is possible.
Simulatenous database access request pend until the lock is unlock()'ed.
See http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
@param *args: Models to be locked - if None then self.model is used. | [
"Lock",
"table",
"(",
"s",
")",
"."
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/db/models.py#L57-L75 |
alexhayes/django-toolkit | django_toolkit/db/models.py | LockingManager.unlock | def unlock(self):
"""
Unlock the table(s)
"""
cursor = connection.cursor()
cursor.execute("UNLOCK TABLES")
logger.debug('Unlocked tables')
row = cursor.fetchone()
return row | python | def unlock(self):
"""
Unlock the table(s)
"""
cursor = connection.cursor()
cursor.execute("UNLOCK TABLES")
logger.debug('Unlocked tables')
row = cursor.fetchone()
return row | [
"def",
"unlock",
"(",
"self",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"UNLOCK TABLES\"",
")",
"logger",
".",
"debug",
"(",
"'Unlocked tables'",
")",
"row",
"=",
"cursor",
".",
"fetchone",
"(",
")",... | Unlock the table(s) | [
"Unlock",
"the",
"table",
"(",
"s",
")"
] | train | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/db/models.py#L77-L85 |
corydodt/Crosscap | crosscap/openapi.py | _orderedCleanDict | def _orderedCleanDict(attrsObj):
"""
-> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties
"""
def _filt(k, v):
if attr.has(v):
return not not any(attr.astuple(v))
return not not v
return attr.asd... | python | def _orderedCleanDict(attrsObj):
"""
-> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties
"""
def _filt(k, v):
if attr.has(v):
return not not any(attr.astuple(v))
return not not v
return attr.asd... | [
"def",
"_orderedCleanDict",
"(",
"attrsObj",
")",
":",
"def",
"_filt",
"(",
"k",
",",
"v",
")",
":",
"if",
"attr",
".",
"has",
"(",
"v",
")",
":",
"return",
"not",
"not",
"any",
"(",
"attr",
".",
"astuple",
"(",
"v",
")",
")",
"return",
"not",
... | -> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties | [
"-",
">",
"dict",
"with",
"false",
"-",
"values",
"removed"
] | train | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L124-L138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.