repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Erotemic/utool | utool/util_progress.py | ProgressIter.ensure_newline | def ensure_newline(self):
"""
use before any custom printing when using the progress iter to ensure
your print statement starts on a new line instead of at the end of a
progress line
"""
DECTCEM_SHOW = '\033[?25h' # show cursor
AT_END = DECTCEM_SHOW + '\n'
... | python | def ensure_newline(self):
"""
use before any custom printing when using the progress iter to ensure
your print statement starts on a new line instead of at the end of a
progress line
"""
DECTCEM_SHOW = '\033[?25h' # show cursor
AT_END = DECTCEM_SHOW + '\n'
... | [
"def",
"ensure_newline",
"(",
"self",
")",
":",
"DECTCEM_SHOW",
"=",
"'\\033[?25h'",
"AT_END",
"=",
"DECTCEM_SHOW",
"+",
"'\\n'",
"if",
"not",
"self",
".",
"_cursor_at_newline",
":",
"self",
".",
"write",
"(",
"AT_END",
")",
"self",
".",
"_cursor_at_newline",
... | use before any custom printing when using the progress iter to ensure
your print statement starts on a new line instead of at the end of a
progress line | [
"use",
"before",
"any",
"custom",
"printing",
"when",
"using",
"the",
"progress",
"iter",
"to",
"ensure",
"your",
"print",
"statement",
"starts",
"on",
"a",
"new",
"line",
"instead",
"of",
"at",
"the",
"end",
"of",
"a",
"progress",
"line"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L796-L806 | train |
Erotemic/utool | utool/util_progress.py | ProgressIter._get_timethresh_heuristics | def _get_timethresh_heuristics(self):
"""
resonably decent hueristics for how much time to wait before
updating progress.
"""
if self.length > 1E5:
time_thresh = 2.5
elif self.length > 1E4:
time_thresh = 2.0
elif self.length > 1E3:
... | python | def _get_timethresh_heuristics(self):
"""
resonably decent hueristics for how much time to wait before
updating progress.
"""
if self.length > 1E5:
time_thresh = 2.5
elif self.length > 1E4:
time_thresh = 2.0
elif self.length > 1E3:
... | [
"def",
"_get_timethresh_heuristics",
"(",
"self",
")",
":",
"if",
"self",
".",
"length",
">",
"1E5",
":",
"time_thresh",
"=",
"2.5",
"elif",
"self",
".",
"length",
">",
"1E4",
":",
"time_thresh",
"=",
"2.0",
"elif",
"self",
".",
"length",
">",
"1E3",
"... | resonably decent hueristics for how much time to wait before
updating progress. | [
"resonably",
"decent",
"hueristics",
"for",
"how",
"much",
"time",
"to",
"wait",
"before",
"updating",
"progress",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_progress.py#L808-L821 | train |
timedata-org/loady | loady/code.py | load_code | def load_code(name, base_path=None, recurse=False):
"""Load executable code from a URL or a path"""
if '/' in name:
return load_location(name, base_path, module=False)
return importer.import_code(name, base_path, recurse=recurse) | python | def load_code(name, base_path=None, recurse=False):
"""Load executable code from a URL or a path"""
if '/' in name:
return load_location(name, base_path, module=False)
return importer.import_code(name, base_path, recurse=recurse) | [
"def",
"load_code",
"(",
"name",
",",
"base_path",
"=",
"None",
",",
"recurse",
"=",
"False",
")",
":",
"if",
"'/'",
"in",
"name",
":",
"return",
"load_location",
"(",
"name",
",",
"base_path",
",",
"module",
"=",
"False",
")",
"return",
"importer",
".... | Load executable code from a URL or a path | [
"Load",
"executable",
"code",
"from",
"a",
"URL",
"or",
"a",
"path"
] | 94ffcdb92f15a28f3c85f77bd293a9cb59de4cad | https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/code.py#L64-L69 | train |
timedata-org/loady | loady/code.py | load | def load(name, base_path=None):
"""Load a module from a URL or a path"""
if '/' in name:
return load_location(name, base_path, module=True)
return importer.import_symbol(name, base_path) | python | def load(name, base_path=None):
"""Load a module from a URL or a path"""
if '/' in name:
return load_location(name, base_path, module=True)
return importer.import_symbol(name, base_path) | [
"def",
"load",
"(",
"name",
",",
"base_path",
"=",
"None",
")",
":",
"if",
"'/'",
"in",
"name",
":",
"return",
"load_location",
"(",
"name",
",",
"base_path",
",",
"module",
"=",
"True",
")",
"return",
"importer",
".",
"import_symbol",
"(",
"name",
","... | Load a module from a URL or a path | [
"Load",
"a",
"module",
"from",
"a",
"URL",
"or",
"a",
"path"
] | 94ffcdb92f15a28f3c85f77bd293a9cb59de4cad | https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/code.py#L73-L78 | train |
timedata-org/loady | loady/sys_path.py | extend | def extend(path=None, cache=None):
"""Extend sys.path by a list of git paths."""
if path is None:
path = config.PATH
try:
path = path.split(':')
except:
pass
sys.path.extend([library.to_path(p, cache) for p in path]) | python | def extend(path=None, cache=None):
"""Extend sys.path by a list of git paths."""
if path is None:
path = config.PATH
try:
path = path.split(':')
except:
pass
sys.path.extend([library.to_path(p, cache) for p in path]) | [
"def",
"extend",
"(",
"path",
"=",
"None",
",",
"cache",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"config",
".",
"PATH",
"try",
":",
"path",
"=",
"path",
".",
"split",
"(",
"':'",
")",
"except",
":",
"pass",
"sys",
"... | Extend sys.path by a list of git paths. | [
"Extend",
"sys",
".",
"path",
"by",
"a",
"list",
"of",
"git",
"paths",
"."
] | 94ffcdb92f15a28f3c85f77bd293a9cb59de4cad | https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/sys_path.py#L5-L14 | train |
timedata-org/loady | loady/sys_path.py | extender | def extender(path=None, cache=None):
"""A context that temporarily extends sys.path and reverts it after the
context is complete."""
old_path = sys.path[:]
extend(path, cache=None)
try:
yield
finally:
sys.path = old_path | python | def extender(path=None, cache=None):
"""A context that temporarily extends sys.path and reverts it after the
context is complete."""
old_path = sys.path[:]
extend(path, cache=None)
try:
yield
finally:
sys.path = old_path | [
"def",
"extender",
"(",
"path",
"=",
"None",
",",
"cache",
"=",
"None",
")",
":",
"old_path",
"=",
"sys",
".",
"path",
"[",
":",
"]",
"extend",
"(",
"path",
",",
"cache",
"=",
"None",
")",
"try",
":",
"yield",
"finally",
":",
"sys",
".",
"path",
... | A context that temporarily extends sys.path and reverts it after the
context is complete. | [
"A",
"context",
"that",
"temporarily",
"extends",
"sys",
".",
"path",
"and",
"reverts",
"it",
"after",
"the",
"context",
"is",
"complete",
"."
] | 94ffcdb92f15a28f3c85f77bd293a9cb59de4cad | https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/sys_path.py#L18-L27 | train |
LEMS/pylems | lems/model/dynamics.py | ConditionalDerivedVariable.add | def add(self, child):
"""
Adds a typed child object to the conditional derived variable.
@param child: Child object to be added.
"""
if isinstance(child, Case):
self.add_case(child)
else:
raise ModelError('Unsupported child element') | python | def add(self, child):
"""
Adds a typed child object to the conditional derived variable.
@param child: Child object to be added.
"""
if isinstance(child, Case):
self.add_case(child)
else:
raise ModelError('Unsupported child element') | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Case",
")",
":",
"self",
".",
"add_case",
"(",
"child",
")",
"else",
":",
"raise",
"ModelError",
"(",
"'Unsupported child element'",
")"
] | Adds a typed child object to the conditional derived variable.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"conditional",
"derived",
"variable",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L203-L213 | train |
LEMS/pylems | lems/model/dynamics.py | EventHandler.add | def add(self, child):
"""
Adds a typed child object to the event handler.
@param child: Child object to be added.
"""
if isinstance(child, Action):
self.add_action(child)
else:
raise ModelError('Unsupported child element') | python | def add(self, child):
"""
Adds a typed child object to the event handler.
@param child: Child object to be added.
"""
if isinstance(child, Action):
self.add_action(child)
else:
raise ModelError('Unsupported child element') | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Action",
")",
":",
"self",
".",
"add_action",
"(",
"child",
")",
"else",
":",
"raise",
"ModelError",
"(",
"'Unsupported child element'",
")"
] | Adds a typed child object to the event handler.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"event",
"handler",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L402-L412 | train |
LEMS/pylems | lems/model/dynamics.py | Behavioral.add | def add(self, child):
"""
Adds a typed child object to the behavioral object.
@param child: Child object to be added.
"""
if isinstance(child, StateVariable):
self.add_state_variable(child)
elif isinstance(child, DerivedVariable):
self.add_derive... | python | def add(self, child):
"""
Adds a typed child object to the behavioral object.
@param child: Child object to be added.
"""
if isinstance(child, StateVariable):
self.add_state_variable(child)
elif isinstance(child, DerivedVariable):
self.add_derive... | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"StateVariable",
")",
":",
"self",
".",
"add_state_variable",
"(",
"child",
")",
"elif",
"isinstance",
"(",
"child",
",",
"DerivedVariable",
")",
":",
"self",
".",
... | Adds a typed child object to the behavioral object.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"behavioral",
"object",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L757-L777 | train |
LEMS/pylems | lems/model/dynamics.py | Dynamics.add | def add(self, child):
"""
Adds a typed child object to the dynamics object.
@param child: Child object to be added.
"""
if isinstance(child, Regime):
self.add_regime(child)
else:
Behavioral.add(self, child) | python | def add(self, child):
"""
Adds a typed child object to the dynamics object.
@param child: Child object to be added.
"""
if isinstance(child, Regime):
self.add_regime(child)
else:
Behavioral.add(self, child) | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Regime",
")",
":",
"self",
".",
"add_regime",
"(",
"child",
")",
"else",
":",
"Behavioral",
".",
"add",
"(",
"self",
",",
"child",
")"
] | Adds a typed child object to the dynamics object.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"dynamics",
"object",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/dynamics.py#L876-L886 | train |
glormph/msstitch | src/app/actions/mslookup/biosets.py | create_bioset_lookup | def create_bioset_lookup(lookupdb, spectrafns, set_names):
"""Fills lookup database with biological set names"""
unique_setnames = set(set_names)
lookupdb.store_biosets(((x,) for x in unique_setnames))
set_id_map = lookupdb.get_setnames()
mzmlfiles = ((os.path.basename(fn), set_id_map[setname])
... | python | def create_bioset_lookup(lookupdb, spectrafns, set_names):
"""Fills lookup database with biological set names"""
unique_setnames = set(set_names)
lookupdb.store_biosets(((x,) for x in unique_setnames))
set_id_map = lookupdb.get_setnames()
mzmlfiles = ((os.path.basename(fn), set_id_map[setname])
... | [
"def",
"create_bioset_lookup",
"(",
"lookupdb",
",",
"spectrafns",
",",
"set_names",
")",
":",
"unique_setnames",
"=",
"set",
"(",
"set_names",
")",
"lookupdb",
".",
"store_biosets",
"(",
"(",
"(",
"x",
",",
")",
"for",
"x",
"in",
"unique_setnames",
")",
"... | Fills lookup database with biological set names | [
"Fills",
"lookup",
"database",
"with",
"biological",
"set",
"names"
] | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mslookup/biosets.py#L4-L12 | train |
Erotemic/utool | utool/util_import.py | get_modpath_from_modname | def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False):
"""
Same as get_modpath but doesnt import directly
SeeAlso:
get_modpath
"""
from os.path import dirname, basename, join, exists
initname = '__init__.py'
mainname = '__main__.py'
if modname in sys.modules... | python | def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False):
"""
Same as get_modpath but doesnt import directly
SeeAlso:
get_modpath
"""
from os.path import dirname, basename, join, exists
initname = '__init__.py'
mainname = '__main__.py'
if modname in sys.modules... | [
"def",
"get_modpath_from_modname",
"(",
"modname",
",",
"prefer_pkg",
"=",
"False",
",",
"prefer_main",
"=",
"False",
")",
":",
"from",
"os",
".",
"path",
"import",
"dirname",
",",
"basename",
",",
"join",
",",
"exists",
"initname",
"=",
"'__init__.py'",
"ma... | Same as get_modpath but doesnt import directly
SeeAlso:
get_modpath | [
"Same",
"as",
"get_modpath",
"but",
"doesnt",
"import",
"directly"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L243-L269 | train |
Erotemic/utool | utool/util_import.py | check_module_installed | def check_module_installed(modname):
"""
Check if a python module is installed without attempting to import it.
Note, that if ``modname`` indicates a child module, the parent module is
always loaded.
Args:
modname (str): module name
Returns:
bool: found
References:
... | python | def check_module_installed(modname):
"""
Check if a python module is installed without attempting to import it.
Note, that if ``modname`` indicates a child module, the parent module is
always loaded.
Args:
modname (str): module name
Returns:
bool: found
References:
... | [
"def",
"check_module_installed",
"(",
"modname",
")",
":",
"import",
"pkgutil",
"if",
"'.'",
"in",
"modname",
":",
"parts",
"=",
"modname",
".",
"split",
"(",
"'.'",
")",
"base",
"=",
"parts",
"[",
"0",
"]",
"submods",
"=",
"parts",
"[",
"1",
":",
"]... | Check if a python module is installed without attempting to import it.
Note, that if ``modname`` indicates a child module, the parent module is
always loaded.
Args:
modname (str): module name
Returns:
bool: found
References:
http://stackoverflow.com/questions/14050281/mod... | [
"Check",
"if",
"a",
"python",
"module",
"is",
"installed",
"without",
"attempting",
"to",
"import",
"it",
".",
"Note",
"that",
"if",
"modname",
"indicates",
"a",
"child",
"module",
"the",
"parent",
"module",
"is",
"always",
"loaded",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L272-L317 | train |
Erotemic/utool | utool/util_import.py | import_module_from_fpath | def import_module_from_fpath(module_fpath):
r""" imports module from a file path
Args:
module_fpath (str):
Returns:
module: module
CommandLine:
python -m utool.util_import --test-import_module_from_fpath
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_i... | python | def import_module_from_fpath(module_fpath):
r""" imports module from a file path
Args:
module_fpath (str):
Returns:
module: module
CommandLine:
python -m utool.util_import --test-import_module_from_fpath
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_i... | [
"def",
"import_module_from_fpath",
"(",
"module_fpath",
")",
":",
"r",
"from",
"os",
".",
"path",
"import",
"basename",
",",
"splitext",
",",
"isdir",
",",
"join",
",",
"exists",
",",
"dirname",
",",
"split",
"import",
"platform",
"if",
"isdir",
"(",
"modu... | r""" imports module from a file path
Args:
module_fpath (str):
Returns:
module: module
CommandLine:
python -m utool.util_import --test-import_module_from_fpath
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_import import * # NOQA
>>> import utool
... | [
"r",
"imports",
"module",
"from",
"a",
"file",
"path"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_import.py#L469-L609 | train |
Erotemic/utool | utool/util_print.py | print_locals | def print_locals(*args, **kwargs):
"""
Prints local variables in function.
If no arguments all locals are printed.
Variables can be specified directly (variable values passed in) as varargs
or indirectly (variable names passed in) in kwargs by using keys and a list
of strings.
"""
from... | python | def print_locals(*args, **kwargs):
"""
Prints local variables in function.
If no arguments all locals are printed.
Variables can be specified directly (variable values passed in) as varargs
or indirectly (variable names passed in) in kwargs by using keys and a list
of strings.
"""
from... | [
"def",
"print_locals",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"from",
"utool",
"import",
"util_str",
"from",
"utool",
"import",
"util_dbg",
"from",
"utool",
"import",
"util_dict",
"locals_",
"=",
"util_dbg",
".",
"get_parent_frame",
"(",
")",
".",
... | Prints local variables in function.
If no arguments all locals are printed.
Variables can be specified directly (variable values passed in) as varargs
or indirectly (variable names passed in) in kwargs by using keys and a list
of strings. | [
"Prints",
"local",
"variables",
"in",
"function",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_print.py#L329-L353 | train |
Erotemic/utool | utool/util_grabdata.py | _extract_archive | def _extract_archive(archive_fpath, archive_file, archive_namelist, output_dir,
force_commonprefix=True, prefix=None,
dryrun=False, verbose=not QUIET, overwrite=None):
"""
archive_fpath = zip_fpath
archive_file = zip_file
"""
# force extracted components int... | python | def _extract_archive(archive_fpath, archive_file, archive_namelist, output_dir,
force_commonprefix=True, prefix=None,
dryrun=False, verbose=not QUIET, overwrite=None):
"""
archive_fpath = zip_fpath
archive_file = zip_file
"""
# force extracted components int... | [
"def",
"_extract_archive",
"(",
"archive_fpath",
",",
"archive_file",
",",
"archive_namelist",
",",
"output_dir",
",",
"force_commonprefix",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"dryrun",
"=",
"False",
",",
"verbose",
"=",
"not",
"QUIET",
",",
"overwr... | archive_fpath = zip_fpath
archive_file = zip_file | [
"archive_fpath",
"=",
"zip_fpath",
"archive_file",
"=",
"zip_file"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L164-L196 | train |
Erotemic/utool | utool/util_grabdata.py | open_url_in_browser | def open_url_in_browser(url, browsername=None, fallback=False):
r"""
Opens a url in the specified or default browser
Args:
url (str): web url
CommandLine:
python -m utool.util_grabdata --test-open_url_in_browser
Example:
>>> # DISABLE_DOCTEST
>>> # SCRIPT
>... | python | def open_url_in_browser(url, browsername=None, fallback=False):
r"""
Opens a url in the specified or default browser
Args:
url (str): web url
CommandLine:
python -m utool.util_grabdata --test-open_url_in_browser
Example:
>>> # DISABLE_DOCTEST
>>> # SCRIPT
>... | [
"def",
"open_url_in_browser",
"(",
"url",
",",
"browsername",
"=",
"None",
",",
"fallback",
"=",
"False",
")",
":",
"r",
"import",
"webbrowser",
"print",
"(",
"'[utool] Opening url=%r in browser'",
"%",
"(",
"url",
",",
")",
")",
"if",
"browsername",
"is",
"... | r"""
Opens a url in the specified or default browser
Args:
url (str): web url
CommandLine:
python -m utool.util_grabdata --test-open_url_in_browser
Example:
>>> # DISABLE_DOCTEST
>>> # SCRIPT
>>> from utool.util_grabdata import * # NOQA
>>> url = 'http... | [
"r",
"Opens",
"a",
"url",
"in",
"the",
"specified",
"or",
"default",
"browser"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L199-L222 | train |
Erotemic/utool | utool/util_grabdata.py | url_read | def url_read(url, verbose=True):
r"""
Directly reads data from url
"""
if url.find('://') == -1:
url = 'http://' + url
if verbose:
print('Reading data from url=%r' % (url,))
try:
file_ = _urllib.request.urlopen(url)
#file_ = _urllib.urlopen(url)
except IOError... | python | def url_read(url, verbose=True):
r"""
Directly reads data from url
"""
if url.find('://') == -1:
url = 'http://' + url
if verbose:
print('Reading data from url=%r' % (url,))
try:
file_ = _urllib.request.urlopen(url)
#file_ = _urllib.urlopen(url)
except IOError... | [
"def",
"url_read",
"(",
"url",
",",
"verbose",
"=",
"True",
")",
":",
"r",
"if",
"url",
".",
"find",
"(",
"'://'",
")",
"==",
"-",
"1",
":",
"url",
"=",
"'http://'",
"+",
"url",
"if",
"verbose",
":",
"print",
"(",
"'Reading data from url=%r'",
"%",
... | r"""
Directly reads data from url | [
"r",
"Directly",
"reads",
"data",
"from",
"url"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L402-L417 | train |
Erotemic/utool | utool/util_grabdata.py | url_read_text | def url_read_text(url, verbose=True):
r"""
Directly reads text data from url
"""
data = url_read(url, verbose)
text = data.decode('utf8')
return text | python | def url_read_text(url, verbose=True):
r"""
Directly reads text data from url
"""
data = url_read(url, verbose)
text = data.decode('utf8')
return text | [
"def",
"url_read_text",
"(",
"url",
",",
"verbose",
"=",
"True",
")",
":",
"r",
"data",
"=",
"url_read",
"(",
"url",
",",
"verbose",
")",
"text",
"=",
"data",
".",
"decode",
"(",
"'utf8'",
")",
"return",
"text"
] | r"""
Directly reads text data from url | [
"r",
"Directly",
"reads",
"text",
"data",
"from",
"url"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L420-L426 | train |
Erotemic/utool | utool/util_grabdata.py | clean_dropbox_link | def clean_dropbox_link(dropbox_url):
"""
Dropbox links should be en-mass downloaed from dl.dropbox
DEPRICATE?
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_grabdata import * # NOQA
>>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0'
>>> cleaned_ur... | python | def clean_dropbox_link(dropbox_url):
"""
Dropbox links should be en-mass downloaed from dl.dropbox
DEPRICATE?
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_grabdata import * # NOQA
>>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0'
>>> cleaned_ur... | [
"def",
"clean_dropbox_link",
"(",
"dropbox_url",
")",
":",
"cleaned_url",
"=",
"dropbox_url",
".",
"replace",
"(",
"'www.dropbox'",
",",
"'dl.dropbox'",
")",
"postfix_list",
"=",
"[",
"'?dl=0'",
"]",
"for",
"postfix",
"in",
"postfix_list",
":",
"if",
"cleaned_ur... | Dropbox links should be en-mass downloaed from dl.dropbox
DEPRICATE?
Example:
>>> # ENABLE_DOCTEST
>>> from utool.util_grabdata import * # NOQA
>>> dropbox_url = 'www.dropbox.com/s/123456789abcdef/foobar.zip?dl=0'
>>> cleaned_url = clean_dropbox_link(dropbox_url)
>>> r... | [
"Dropbox",
"links",
"should",
"be",
"en",
"-",
"mass",
"downloaed",
"from",
"dl",
".",
"dropbox"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L503-L526 | train |
Erotemic/utool | utool/util_grabdata.py | grab_selenium_chromedriver | def grab_selenium_chromedriver(redownload=False):
r"""
Automatically download selenium chrome driver if needed
CommandLine:
python -m utool.util_grabdata --test-grab_selenium_chromedriver:1
Example:
>>> # DISABLE_DOCTEST
>>> ut.grab_selenium_chromedriver()
>>> import se... | python | def grab_selenium_chromedriver(redownload=False):
r"""
Automatically download selenium chrome driver if needed
CommandLine:
python -m utool.util_grabdata --test-grab_selenium_chromedriver:1
Example:
>>> # DISABLE_DOCTEST
>>> ut.grab_selenium_chromedriver()
>>> import se... | [
"def",
"grab_selenium_chromedriver",
"(",
"redownload",
"=",
"False",
")",
":",
"r",
"import",
"utool",
"as",
"ut",
"import",
"os",
"import",
"stat",
"chromedriver_dpath",
"=",
"ut",
".",
"ensuredir",
"(",
"ut",
".",
"truepath",
"(",
"'~/bin'",
")",
")",
"... | r"""
Automatically download selenium chrome driver if needed
CommandLine:
python -m utool.util_grabdata --test-grab_selenium_chromedriver:1
Example:
>>> # DISABLE_DOCTEST
>>> ut.grab_selenium_chromedriver()
>>> import selenium.webdriver
>>> driver = selenium.webdriv... | [
"r",
"Automatically",
"download",
"selenium",
"chrome",
"driver",
"if",
"needed"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L627-L675 | train |
Erotemic/utool | utool/util_grabdata.py | grab_selenium_driver | def grab_selenium_driver(driver_name=None):
"""
pip install selenium -U
"""
from selenium import webdriver
if driver_name is None:
driver_name = 'firefox'
if driver_name.lower() == 'chrome':
grab_selenium_chromedriver()
return webdriver.Chrome()
elif driver_name.lower... | python | def grab_selenium_driver(driver_name=None):
"""
pip install selenium -U
"""
from selenium import webdriver
if driver_name is None:
driver_name = 'firefox'
if driver_name.lower() == 'chrome':
grab_selenium_chromedriver()
return webdriver.Chrome()
elif driver_name.lower... | [
"def",
"grab_selenium_driver",
"(",
"driver_name",
"=",
"None",
")",
":",
"from",
"selenium",
"import",
"webdriver",
"if",
"driver_name",
"is",
"None",
":",
"driver_name",
"=",
"'firefox'",
"if",
"driver_name",
".",
"lower",
"(",
")",
"==",
"'chrome'",
":",
... | pip install selenium -U | [
"pip",
"install",
"selenium",
"-",
"U"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L678-L692 | train |
Erotemic/utool | utool/util_grabdata.py | grab_file_url | def grab_file_url(file_url, appname='utool', download_dir=None, delay=None,
spoof=False, fname=None, verbose=True, redownload=False,
check_hash=False):
r"""
Downloads a file and returns the local path of the file.
The resulting file is cached, so multiple calls to this f... | python | def grab_file_url(file_url, appname='utool', download_dir=None, delay=None,
spoof=False, fname=None, verbose=True, redownload=False,
check_hash=False):
r"""
Downloads a file and returns the local path of the file.
The resulting file is cached, so multiple calls to this f... | [
"def",
"grab_file_url",
"(",
"file_url",
",",
"appname",
"=",
"'utool'",
",",
"download_dir",
"=",
"None",
",",
"delay",
"=",
"None",
",",
"spoof",
"=",
"False",
",",
"fname",
"=",
"None",
",",
"verbose",
"=",
"True",
",",
"redownload",
"=",
"False",
"... | r"""
Downloads a file and returns the local path of the file.
The resulting file is cached, so multiple calls to this function do not
result in multiple dowloads.
Args:
file_url (str): url to the file
appname (str): (default = 'utool')
download_dir custom directory (None): (def... | [
"r",
"Downloads",
"a",
"file",
"and",
"returns",
"the",
"local",
"path",
"of",
"the",
"file",
"."
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L782-L905 | train |
Erotemic/utool | utool/util_grabdata.py | grab_zipped_url | def grab_zipped_url(zipped_url, ensure=True, appname='utool',
download_dir=None, force_commonprefix=True, cleanup=False,
redownload=False, spoof=False):
r"""
downloads and unzips the url
Args:
zipped_url (str): url which must be either a .zip of a .tar.gz fil... | python | def grab_zipped_url(zipped_url, ensure=True, appname='utool',
download_dir=None, force_commonprefix=True, cleanup=False,
redownload=False, spoof=False):
r"""
downloads and unzips the url
Args:
zipped_url (str): url which must be either a .zip of a .tar.gz fil... | [
"def",
"grab_zipped_url",
"(",
"zipped_url",
",",
"ensure",
"=",
"True",
",",
"appname",
"=",
"'utool'",
",",
"download_dir",
"=",
"None",
",",
"force_commonprefix",
"=",
"True",
",",
"cleanup",
"=",
"False",
",",
"redownload",
"=",
"False",
",",
"spoof",
... | r"""
downloads and unzips the url
Args:
zipped_url (str): url which must be either a .zip of a .tar.gz file
ensure (bool): eager evaluation if True(default = True)
appname (str): (default = 'utool')
download_dir (str): containing downloading directory
force_commonprefix... | [
"r",
"downloads",
"and",
"unzips",
"the",
"url"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L908-L974 | train |
Erotemic/utool | utool/util_grabdata.py | scp_pull | def scp_pull(remote_path, local_path='.', remote='localhost', user=None):
r""" wrapper for scp """
import utool as ut
if user is not None:
remote_uri = user + '@' + remote + ':' + remote_path
else:
remote_uri = remote + ':' + remote_path
scp_exe = 'scp'
scp_args = (scp_exe, '-r',... | python | def scp_pull(remote_path, local_path='.', remote='localhost', user=None):
r""" wrapper for scp """
import utool as ut
if user is not None:
remote_uri = user + '@' + remote + ':' + remote_path
else:
remote_uri = remote + ':' + remote_path
scp_exe = 'scp'
scp_args = (scp_exe, '-r',... | [
"def",
"scp_pull",
"(",
"remote_path",
",",
"local_path",
"=",
"'.'",
",",
"remote",
"=",
"'localhost'",
",",
"user",
"=",
"None",
")",
":",
"r",
"import",
"utool",
"as",
"ut",
"if",
"user",
"is",
"not",
"None",
":",
"remote_uri",
"=",
"user",
"+",
"... | r""" wrapper for scp | [
"r",
"wrapper",
"for",
"scp"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1123-L1132 | train |
Erotemic/utool | utool/util_grabdata.py | list_remote | def list_remote(remote_uri, verbose=False):
"""
remote_uri = 'user@xx.xx.xx.xx'
"""
remote_uri1, remote_dpath = remote_uri.split(':')
if not remote_dpath:
remote_dpath = '.'
import utool as ut
out = ut.cmd('ssh', remote_uri1, 'ls -l %s' % (remote_dpath,), verbose=verbose)
import ... | python | def list_remote(remote_uri, verbose=False):
"""
remote_uri = 'user@xx.xx.xx.xx'
"""
remote_uri1, remote_dpath = remote_uri.split(':')
if not remote_dpath:
remote_dpath = '.'
import utool as ut
out = ut.cmd('ssh', remote_uri1, 'ls -l %s' % (remote_dpath,), verbose=verbose)
import ... | [
"def",
"list_remote",
"(",
"remote_uri",
",",
"verbose",
"=",
"False",
")",
":",
"remote_uri1",
",",
"remote_dpath",
"=",
"remote_uri",
".",
"split",
"(",
"':'",
")",
"if",
"not",
"remote_dpath",
":",
"remote_dpath",
"=",
"'.'",
"import",
"utool",
"as",
"u... | remote_uri = 'user@xx.xx.xx.xx' | [
"remote_uri",
"=",
"user"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1135-L1148 | train |
Erotemic/utool | utool/util_grabdata.py | rsync | def rsync(src_uri, dst_uri, exclude_dirs=[], port=22, dryrun=False):
r"""
Wrapper for rsync
General function to push or pull a directory from a remote server to a
local path
Args:
src_uri (str):
dst_uri (str):
exclude_dirs (list): (default = [])
port (int): (default... | python | def rsync(src_uri, dst_uri, exclude_dirs=[], port=22, dryrun=False):
r"""
Wrapper for rsync
General function to push or pull a directory from a remote server to a
local path
Args:
src_uri (str):
dst_uri (str):
exclude_dirs (list): (default = [])
port (int): (default... | [
"def",
"rsync",
"(",
"src_uri",
",",
"dst_uri",
",",
"exclude_dirs",
"=",
"[",
"]",
",",
"port",
"=",
"22",
",",
"dryrun",
"=",
"False",
")",
":",
"r",
"from",
"utool",
"import",
"util_cplat",
"rsync_exe",
"=",
"'rsync'",
"rsync_options",
"=",
"'-avhzP'"... | r"""
Wrapper for rsync
General function to push or pull a directory from a remote server to a
local path
Args:
src_uri (str):
dst_uri (str):
exclude_dirs (list): (default = [])
port (int): (default = 22)
dryrun (bool): (default = False)
References:
... | [
"r",
"Wrapper",
"for",
"rsync"
] | 3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_grabdata.py#L1151-L1214 | train |
chriso/gauged | gauged/drivers/sqlite.py | SQLiteDriver.get_cache | def get_cache(self, namespace, query_hash, length, start, end):
"""Get a cached value for the specified date range and query"""
query = 'SELECT start, value FROM gauged_cache WHERE namespace = ? ' \
'AND hash = ? AND length = ? AND start BETWEEN ? AND ?'
cursor = self.cursor
... | python | def get_cache(self, namespace, query_hash, length, start, end):
"""Get a cached value for the specified date range and query"""
query = 'SELECT start, value FROM gauged_cache WHERE namespace = ? ' \
'AND hash = ? AND length = ? AND start BETWEEN ? AND ?'
cursor = self.cursor
... | [
"def",
"get_cache",
"(",
"self",
",",
"namespace",
",",
"query_hash",
",",
"length",
",",
"start",
",",
"end",
")",
":",
"query",
"=",
"'SELECT start, value FROM gauged_cache WHERE namespace = ? '",
"'AND hash = ? AND length = ? AND start BETWEEN ? AND ?'",
"cursor",
"=",
... | Get a cached value for the specified date range and query | [
"Get",
"a",
"cached",
"value",
"for",
"the",
"specified",
"date",
"range",
"and",
"query"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/drivers/sqlite.py#L237-L243 | train |
ColinDuquesnoy/QCrash | qcrash/_dialogs/review.py | DlgReview.review | def review(cls, content, log, parent, window_icon): # pragma: no cover
"""
Reviews the final bug report.
:param content: content of the final report, before review
:param parent: parent widget
:returns: the reviewed report content or None if the review was
ca... | python | def review(cls, content, log, parent, window_icon): # pragma: no cover
"""
Reviews the final bug report.
:param content: content of the final report, before review
:param parent: parent widget
:returns: the reviewed report content or None if the review was
ca... | [
"def",
"review",
"(",
"cls",
",",
"content",
",",
"log",
",",
"parent",
",",
"window_icon",
")",
":",
"dlg",
"=",
"DlgReview",
"(",
"content",
",",
"log",
",",
"parent",
",",
"window_icon",
")",
"if",
"dlg",
".",
"exec_",
"(",
")",
":",
"return",
"... | Reviews the final bug report.
:param content: content of the final report, before review
:param parent: parent widget
:returns: the reviewed report content or None if the review was
canceled. | [
"Reviews",
"the",
"final",
"bug",
"report",
"."
] | 775e1b15764e2041a8f9a08bea938e4d6ce817c7 | https://github.com/ColinDuquesnoy/QCrash/blob/775e1b15764e2041a8f9a08bea938e4d6ce817c7/qcrash/_dialogs/review.py#L44-L58 | train |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/version/version.py | Version.get_version | def get_version():
"""
Return version from setup.py
"""
version_desc = open(os.path.join(os.path.abspath(APISettings.VERSION_FILE)))
version_file = version_desc.read()
try:
version = re.search(r"version=['\"]([^'\"]+)['\"]", version_file).group(1)
... | python | def get_version():
"""
Return version from setup.py
"""
version_desc = open(os.path.join(os.path.abspath(APISettings.VERSION_FILE)))
version_file = version_desc.read()
try:
version = re.search(r"version=['\"]([^'\"]+)['\"]", version_file).group(1)
... | [
"def",
"get_version",
"(",
")",
":",
"version_desc",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"APISettings",
".",
"VERSION_FILE",
")",
")",
")",
"version_file",
"=",
"version_desc",
".",
"read",
"("... | Return version from setup.py | [
"Return",
"version",
"from",
"setup",
".",
"py"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/version/version.py#L13-L30 | train |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/version/version.py | Version.set_version | def set_version(old_version, new_version):
"""
Write new version into VERSION_FILE
"""
try:
if APISettings.DEBUG:
Shell.debug('* ' + old_version + ' --> ' + new_version)
return True
for line in fileinput.input(os.path.abspath(APISe... | python | def set_version(old_version, new_version):
"""
Write new version into VERSION_FILE
"""
try:
if APISettings.DEBUG:
Shell.debug('* ' + old_version + ' --> ' + new_version)
return True
for line in fileinput.input(os.path.abspath(APISe... | [
"def",
"set_version",
"(",
"old_version",
",",
"new_version",
")",
":",
"try",
":",
"if",
"APISettings",
".",
"DEBUG",
":",
"Shell",
".",
"debug",
"(",
"'* '",
"+",
"old_version",
"+",
"' ",
"+",
"new_version",
")",
"return",
"True",
"for",
"line",
"in",... | Write new version into VERSION_FILE | [
"Write",
"new",
"version",
"into",
"VERSION_FILE"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/version/version.py#L33-L46 | train |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/version/version.py | Version.set_major | def set_major(self):
"""
Increment the major number of project
"""
old_version = self.get_version()
new_version = str(int(old_version.split('.', 5)[0])+1) + '.0.0'
self.set_version(old_version, new_version) | python | def set_major(self):
"""
Increment the major number of project
"""
old_version = self.get_version()
new_version = str(int(old_version.split('.', 5)[0])+1) + '.0.0'
self.set_version(old_version, new_version) | [
"def",
"set_major",
"(",
"self",
")",
":",
"old_version",
"=",
"self",
".",
"get_version",
"(",
")",
"new_version",
"=",
"str",
"(",
"int",
"(",
"old_version",
".",
"split",
"(",
"'.'",
",",
"5",
")",
"[",
"0",
"]",
")",
"+",
"1",
")",
"+",
"'.0.... | Increment the major number of project | [
"Increment",
"the",
"major",
"number",
"of",
"project"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/version/version.py#L71-L77 | train |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/version/version.py | Version.set_minor | def set_minor(self):
"""
Increment the minor number of project
"""
old_version = self.get_version()
new_version = str(int(old_version.split('.', 5)[0])) + '.' + \
str(int(old_version.split('.', 5)[1])+1) + '.0'
self.set_version(old_version, new_version) | python | def set_minor(self):
"""
Increment the minor number of project
"""
old_version = self.get_version()
new_version = str(int(old_version.split('.', 5)[0])) + '.' + \
str(int(old_version.split('.', 5)[1])+1) + '.0'
self.set_version(old_version, new_version) | [
"def",
"set_minor",
"(",
"self",
")",
":",
"old_version",
"=",
"self",
".",
"get_version",
"(",
")",
"new_version",
"=",
"str",
"(",
"int",
"(",
"old_version",
".",
"split",
"(",
"'.'",
",",
"5",
")",
"[",
"0",
"]",
")",
")",
"+",
"'.'",
"+",
"st... | Increment the minor number of project | [
"Increment",
"the",
"minor",
"number",
"of",
"project"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/version/version.py#L79-L86 | train |
rhazdon/django-sonic-screwdriver | django_sonic_screwdriver/version/version.py | Version.set_patch | def set_patch(self, pre_release_tag=''):
"""
Increment the patch number of project
:var release_tag describes the tag ('a', 'b', 'rc', ...)
:var release_tag_version describes the number behind the 'a', 'b' or 'rc'
For e.g.:
"""
current_version = self.get_version... | python | def set_patch(self, pre_release_tag=''):
"""
Increment the patch number of project
:var release_tag describes the tag ('a', 'b', 'rc', ...)
:var release_tag_version describes the number behind the 'a', 'b' or 'rc'
For e.g.:
"""
current_version = self.get_version... | [
"def",
"set_patch",
"(",
"self",
",",
"pre_release_tag",
"=",
"''",
")",
":",
"current_version",
"=",
"self",
".",
"get_version",
"(",
")",
"current_patch",
"=",
"self",
".",
"get_patch_version",
"(",
"current_version",
")",
"current_pre_release_tag",
"=",
"self... | Increment the patch number of project
:var release_tag describes the tag ('a', 'b', 'rc', ...)
:var release_tag_version describes the number behind the 'a', 'b' or 'rc'
For e.g.: | [
"Increment",
"the",
"patch",
"number",
"of",
"project"
] | 89e885e8c1322fc5c3e0f79b03a55acdc6e63972 | https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/version/version.py#L88-L134 | train |
dsoprea/NsqSpinner | nsq/connection.py | _Buffer.flush | def flush(self):
"""Return all buffered data, and clear the stack."""
(slice_, self.__buffer) = (self.__buffer, '')
self.__size = 0
return slice_ | python | def flush(self):
"""Return all buffered data, and clear the stack."""
(slice_, self.__buffer) = (self.__buffer, '')
self.__size = 0
return slice_ | [
"def",
"flush",
"(",
"self",
")",
":",
"(",
"slice_",
",",
"self",
".",
"__buffer",
")",
"=",
"(",
"self",
".",
"__buffer",
",",
"''",
")",
"self",
".",
"__size",
"=",
"0",
"return",
"slice_"
] | Return all buffered data, and clear the stack. | [
"Return",
"all",
"buffered",
"data",
"and",
"clear",
"the",
"stack",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/connection.py#L78-L84 | train |
dsoprea/NsqSpinner | nsq/connection.py | _ManagedConnection.__send_hello | def __send_hello(self):
"""Initiate the handshake."""
_logger.debug("Saying hello: [%s]", self)
self.__c.send(nsq.config.protocol.MAGIC_IDENTIFIER) | python | def __send_hello(self):
"""Initiate the handshake."""
_logger.debug("Saying hello: [%s]", self)
self.__c.send(nsq.config.protocol.MAGIC_IDENTIFIER) | [
"def",
"__send_hello",
"(",
"self",
")",
":",
"_logger",
".",
"debug",
"(",
"\"Saying hello: [%s]\"",
",",
"self",
")",
"self",
".",
"__c",
".",
"send",
"(",
"nsq",
".",
"config",
".",
"protocol",
".",
"MAGIC_IDENTIFIER",
")"
] | Initiate the handshake. | [
"Initiate",
"the",
"handshake",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/connection.py#L137-L142 | train |
dsoprea/NsqSpinner | nsq/connection.py | _ManagedConnection.__sender | def __sender(self):
"""Send-loop."""
# If we're ignoring the quit, the connections will have to be closed
# by the server.
while (self.__ignore_quit is True or \
self.__nice_quit_ev.is_set() is False) and \
self.__force_quit_ev.is_set() is False:
# TODO(du... | python | def __sender(self):
"""Send-loop."""
# If we're ignoring the quit, the connections will have to be closed
# by the server.
while (self.__ignore_quit is True or \
self.__nice_quit_ev.is_set() is False) and \
self.__force_quit_ev.is_set() is False:
# TODO(du... | [
"def",
"__sender",
"(",
"self",
")",
":",
"while",
"(",
"self",
".",
"__ignore_quit",
"is",
"True",
"or",
"self",
".",
"__nice_quit_ev",
".",
"is_set",
"(",
")",
"is",
"False",
")",
"and",
"self",
".",
"__force_quit_ev",
".",
"is_set",
"(",
")",
"is",
... | Send-loop. | [
"Send",
"-",
"loop",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/connection.py#L479-L506 | train |
dsoprea/NsqSpinner | nsq/connection.py | _ManagedConnection.__receiver | def __receiver(self):
"""Receive-loop."""
# If we're ignoring the quit, the connections will have to be closed
# by the server.
while (self.__ignore_quit is True or \
self.__nice_quit_ev.is_set() is False) and \
self.__force_quit_ev.is_set() is False:
# TO... | python | def __receiver(self):
"""Receive-loop."""
# If we're ignoring the quit, the connections will have to be closed
# by the server.
while (self.__ignore_quit is True or \
self.__nice_quit_ev.is_set() is False) and \
self.__force_quit_ev.is_set() is False:
# TO... | [
"def",
"__receiver",
"(",
"self",
")",
":",
"while",
"(",
"self",
".",
"__ignore_quit",
"is",
"True",
"or",
"self",
".",
"__nice_quit_ev",
".",
"is_set",
"(",
")",
"is",
"False",
")",
"and",
"self",
".",
"__force_quit_ev",
".",
"is_set",
"(",
")",
"is"... | Receive-loop. | [
"Receive",
"-",
"loop",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/connection.py#L508-L529 | train |
dsoprea/NsqSpinner | nsq/connection.py | Connection.run | def run(self):
"""Connect the server, and maintain the connection. This shall not
return until a connection has been determined to absolutely not be
available.
"""
while self.__nice_quit_ev.is_set() is False:
self.__connect()
_logger.info("Connection re-co... | python | def run(self):
"""Connect the server, and maintain the connection. This shall not
return until a connection has been determined to absolutely not be
available.
"""
while self.__nice_quit_ev.is_set() is False:
self.__connect()
_logger.info("Connection re-co... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"self",
".",
"__nice_quit_ev",
".",
"is_set",
"(",
")",
"is",
"False",
":",
"self",
".",
"__connect",
"(",
")",
"_logger",
".",
"info",
"(",
"\"Connection re-connect loop has terminated: %s\"",
",",
"self",
".",
... | Connect the server, and maintain the connection. This shall not
return until a connection has been determined to absolutely not be
available. | [
"Connect",
"the",
"server",
"and",
"maintain",
"the",
"connection",
".",
"This",
"shall",
"not",
"return",
"until",
"a",
"connection",
"has",
"been",
"determined",
"to",
"absolutely",
"not",
"be",
"available",
"."
] | 972237b8ddce737983bfed001fde52e5236be695 | https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/connection.py#L598-L607 | train |
YuriyGuts/pygoose | pygoose/kg/io.py | save | def save(obj, filename, protocol=4):
"""
Serialize an object to disk using pickle protocol.
Args:
obj: The object to serialize.
filename: Path to the output file.
protocol: Version of the pickle protocol.
"""
with open(filename, 'wb') as f:
pickle.dump(obj, f, proto... | python | def save(obj, filename, protocol=4):
"""
Serialize an object to disk using pickle protocol.
Args:
obj: The object to serialize.
filename: Path to the output file.
protocol: Version of the pickle protocol.
"""
with open(filename, 'wb') as f:
pickle.dump(obj, f, proto... | [
"def",
"save",
"(",
"obj",
",",
"filename",
",",
"protocol",
"=",
"4",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'wb'",
")",
"as",
"f",
":",
"pickle",
".",
"dump",
"(",
"obj",
",",
"f",
",",
"protocol",
"=",
"protocol",
")"
] | Serialize an object to disk using pickle protocol.
Args:
obj: The object to serialize.
filename: Path to the output file.
protocol: Version of the pickle protocol. | [
"Serialize",
"an",
"object",
"to",
"disk",
"using",
"pickle",
"protocol",
"."
] | 4d9b8827c6d6c4b79949d1cd653393498c0bb3c2 | https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/io.py#L20-L31 | train |
YuriyGuts/pygoose | pygoose/kg/io.py | load_json | def load_json(filename, **kwargs):
"""
Load a JSON object from the specified file.
Args:
filename: Path to the input JSON file.
**kwargs: Additional arguments to `json.load`.
Returns:
The object deserialized from JSON.
"""
with open(filename, 'r', encoding='utf-8') as ... | python | def load_json(filename, **kwargs):
"""
Load a JSON object from the specified file.
Args:
filename: Path to the input JSON file.
**kwargs: Additional arguments to `json.load`.
Returns:
The object deserialized from JSON.
"""
with open(filename, 'r', encoding='utf-8') as ... | [
"def",
"load_json",
"(",
"filename",
",",
"**",
"kwargs",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
",",
"**",
"kwargs",
")"
] | Load a JSON object from the specified file.
Args:
filename: Path to the input JSON file.
**kwargs: Additional arguments to `json.load`.
Returns:
The object deserialized from JSON. | [
"Load",
"a",
"JSON",
"object",
"from",
"the",
"specified",
"file",
"."
] | 4d9b8827c6d6c4b79949d1cd653393498c0bb3c2 | https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/io.py#L34-L47 | train |
YuriyGuts/pygoose | pygoose/kg/io.py | save_json | def save_json(obj, filename, **kwargs):
"""
Save an object as a JSON file.
Args:
obj: The object to save. Must be JSON-serializable.
filename: Path to the output file.
**kwargs: Additional arguments to `json.dump`.
"""
with open(filename, 'w', encoding='utf-8') as f:
... | python | def save_json(obj, filename, **kwargs):
"""
Save an object as a JSON file.
Args:
obj: The object to save. Must be JSON-serializable.
filename: Path to the output file.
**kwargs: Additional arguments to `json.dump`.
"""
with open(filename, 'w', encoding='utf-8') as f:
... | [
"def",
"save_json",
"(",
"obj",
",",
"filename",
",",
"**",
"kwargs",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"obj",
",",
"f",
",",
"**",
"kwargs",
")"... | Save an object as a JSON file.
Args:
obj: The object to save. Must be JSON-serializable.
filename: Path to the output file.
**kwargs: Additional arguments to `json.dump`. | [
"Save",
"an",
"object",
"as",
"a",
"JSON",
"file",
"."
] | 4d9b8827c6d6c4b79949d1cd653393498c0bb3c2 | https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/io.py#L50-L61 | train |
YuriyGuts/pygoose | pygoose/kg/io.py | load_lines | def load_lines(filename):
"""
Load a text file as an array of lines.
Args:
filename: Path to the input file.
Returns:
An array of strings, each representing an individual line.
"""
with open(filename, 'r', encoding='utf-8') as f:
return [line.rstrip('\n') for line in f... | python | def load_lines(filename):
"""
Load a text file as an array of lines.
Args:
filename: Path to the input file.
Returns:
An array of strings, each representing an individual line.
"""
with open(filename, 'r', encoding='utf-8') as f:
return [line.rstrip('\n') for line in f... | [
"def",
"load_lines",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"[",
"line",
".",
"rstrip",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"f",
".",
"readlines",
... | Load a text file as an array of lines.
Args:
filename: Path to the input file.
Returns:
An array of strings, each representing an individual line. | [
"Load",
"a",
"text",
"file",
"as",
"an",
"array",
"of",
"lines",
"."
] | 4d9b8827c6d6c4b79949d1cd653393498c0bb3c2 | https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/io.py#L64-L76 | train |
YuriyGuts/pygoose | pygoose/kg/io.py | save_lines | def save_lines(lines, filename):
"""
Save an array of lines to a file.
Args:
lines: An array of strings that will be saved as individual lines.
filename: Path to the output file.
"""
with open(filename, 'w', encoding='utf-8') as f:
f.write('\n'.join(lines)) | python | def save_lines(lines, filename):
"""
Save an array of lines to a file.
Args:
lines: An array of strings that will be saved as individual lines.
filename: Path to the output file.
"""
with open(filename, 'w', encoding='utf-8') as f:
f.write('\n'.join(lines)) | [
"def",
"save_lines",
"(",
"lines",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"'\\n'",
".",
"join",
"(",
"lines",
")",
")"
] | Save an array of lines to a file.
Args:
lines: An array of strings that will be saved as individual lines.
filename: Path to the output file. | [
"Save",
"an",
"array",
"of",
"lines",
"to",
"a",
"file",
"."
] | 4d9b8827c6d6c4b79949d1cd653393498c0bb3c2 | https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/io.py#L79-L89 | train |
LEMS/pylems | lems/model/component.py | Component.add | def add(self, child):
"""
Adds a typed child object to the component.
@param child: Child object to be added.
"""
if isinstance(child, Component):
self.add_child(child)
else:
raise ModelError('Unsupported child element') | python | def add(self, child):
"""
Adds a typed child object to the component.
@param child: Child object to be added.
"""
if isinstance(child, Component):
self.add_child(child)
else:
raise ModelError('Unsupported child element') | [
"def",
"add",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Component",
")",
":",
"self",
".",
"add_child",
"(",
"child",
")",
"else",
":",
"raise",
"ModelError",
"(",
"'Unsupported child element'",
")"
] | Adds a typed child object to the component.
@param child: Child object to be added. | [
"Adds",
"a",
"typed",
"child",
"object",
"to",
"the",
"component",
"."
] | 4eeb719d2f23650fe16c38626663b69b5c83818b | https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/component.py#L1122-L1132 | train |
glormph/msstitch | src/app/lookups/sqlite/searchspace.py | SearchSpaceDB.write_peps | def write_peps(self, peps, reverse_seqs):
"""Writes peps to db. We can reverse to be able to look up
peptides that have some amino acids missing at the N-terminal.
This way we can still use the index.
"""
if reverse_seqs:
peps = [(x[0][::-1],) for x in peps]
c... | python | def write_peps(self, peps, reverse_seqs):
"""Writes peps to db. We can reverse to be able to look up
peptides that have some amino acids missing at the N-terminal.
This way we can still use the index.
"""
if reverse_seqs:
peps = [(x[0][::-1],) for x in peps]
c... | [
"def",
"write_peps",
"(",
"self",
",",
"peps",
",",
"reverse_seqs",
")",
":",
"if",
"reverse_seqs",
":",
"peps",
"=",
"[",
"(",
"x",
"[",
"0",
"]",
"[",
":",
":",
"-",
"1",
"]",
",",
")",
"for",
"x",
"in",
"peps",
"]",
"cursor",
"=",
"self",
... | Writes peps to db. We can reverse to be able to look up
peptides that have some amino acids missing at the N-terminal.
This way we can still use the index. | [
"Writes",
"peps",
"to",
"db",
".",
"We",
"can",
"reverse",
"to",
"be",
"able",
"to",
"look",
"up",
"peptides",
"that",
"have",
"some",
"amino",
"acids",
"missing",
"at",
"the",
"N",
"-",
"terminal",
".",
"This",
"way",
"we",
"can",
"still",
"use",
"t... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/searchspace.py#L9-L19 | train |
quikmile/trellio | trellio/bus.py | HTTPBus.send_http_request | def send_http_request(self, app: str, service: str, version: str, method: str, entity: str, params: dict):
"""
A convenience method that allows you to send a well formatted http request to another service
"""
host, port, node_id, service_type = self._registry_client.resolve(service, vers... | python | def send_http_request(self, app: str, service: str, version: str, method: str, entity: str, params: dict):
"""
A convenience method that allows you to send a well formatted http request to another service
"""
host, port, node_id, service_type = self._registry_client.resolve(service, vers... | [
"def",
"send_http_request",
"(",
"self",
",",
"app",
":",
"str",
",",
"service",
":",
"str",
",",
"version",
":",
"str",
",",
"method",
":",
"str",
",",
"entity",
":",
"str",
",",
"params",
":",
"dict",
")",
":",
"host",
",",
"port",
",",
"node_id"... | A convenience method that allows you to send a well formatted http request to another service | [
"A",
"convenience",
"method",
"that",
"allows",
"you",
"to",
"send",
"a",
"well",
"formatted",
"http",
"request",
"to",
"another",
"service"
] | e8b050077562acf32805fcbb9c0c162248a23c62 | https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/bus.py#L31-L51 | train |
ColinDuquesnoy/QCrash | qcrash/api.py | install_except_hook | def install_except_hook(except_hook=_hooks.except_hook):
"""
Install an except hook that will show the crash report dialog when an
unhandled exception has occured.
:param except_hook: except_hook function that will be called on the main
thread whenever an unhandled exception occured. The functi... | python | def install_except_hook(except_hook=_hooks.except_hook):
"""
Install an except hook that will show the crash report dialog when an
unhandled exception has occured.
:param except_hook: except_hook function that will be called on the main
thread whenever an unhandled exception occured. The functi... | [
"def",
"install_except_hook",
"(",
"except_hook",
"=",
"_hooks",
".",
"except_hook",
")",
":",
"if",
"not",
"_backends",
":",
"raise",
"ValueError",
"(",
"'no backends found, you must at least install one '",
"'backend before calling this function'",
")",
"global",
"_except... | Install an except hook that will show the crash report dialog when an
unhandled exception has occured.
:param except_hook: except_hook function that will be called on the main
thread whenever an unhandled exception occured. The function takes
two parameters: the exception object and the traceba... | [
"Install",
"an",
"except",
"hook",
"that",
"will",
"show",
"the",
"crash",
"report",
"dialog",
"when",
"an",
"unhandled",
"exception",
"has",
"occured",
"."
] | 775e1b15764e2041a8f9a08bea938e4d6ce817c7 | https://github.com/ColinDuquesnoy/QCrash/blob/775e1b15764e2041a8f9a08bea938e4d6ce817c7/qcrash/api.py#L36-L49 | train |
ColinDuquesnoy/QCrash | qcrash/api.py | show_report_dialog | def show_report_dialog(window_title='Report an issue...',
window_icon=None, traceback=None, issue_title='',
issue_description='', parent=None,
modal=None, include_log=True, include_sys_info=True):
"""
Show the issue report dialog manually.
... | python | def show_report_dialog(window_title='Report an issue...',
window_icon=None, traceback=None, issue_title='',
issue_description='', parent=None,
modal=None, include_log=True, include_sys_info=True):
"""
Show the issue report dialog manually.
... | [
"def",
"show_report_dialog",
"(",
"window_title",
"=",
"'Report an issue...'",
",",
"window_icon",
"=",
"None",
",",
"traceback",
"=",
"None",
",",
"issue_title",
"=",
"''",
",",
"issue_description",
"=",
"''",
",",
"parent",
"=",
"None",
",",
"modal",
"=",
... | Show the issue report dialog manually.
:param window_title: Title of dialog window
:param window_icon: the icon to use for the dialog window
:param traceback: optional traceback string to include in the report.
:param issue_title: optional issue title
:param issue_description: optional issue descri... | [
"Show",
"the",
"issue",
"report",
"dialog",
"manually",
"."
] | 775e1b15764e2041a8f9a08bea938e4d6ce817c7 | https://github.com/ColinDuquesnoy/QCrash/blob/775e1b15764e2041a8f9a08bea938e4d6ce817c7/qcrash/api.py#L64-L93 | train |
moluwole/Bast | bast/route.py | Route.middleware | def middleware(self, args):
"""
Appends a Middleware to the route which is to be executed before the route runs
"""
if self.url[(len(self.url) - 1)] == (self.url_, self.controller, dict(method=self.method, request_type=self.request_type, middleware=None)):
self.url.pop()
... | python | def middleware(self, args):
"""
Appends a Middleware to the route which is to be executed before the route runs
"""
if self.url[(len(self.url) - 1)] == (self.url_, self.controller, dict(method=self.method, request_type=self.request_type, middleware=None)):
self.url.pop()
... | [
"def",
"middleware",
"(",
"self",
",",
"args",
")",
":",
"if",
"self",
".",
"url",
"[",
"(",
"len",
"(",
"self",
".",
"url",
")",
"-",
"1",
")",
"]",
"==",
"(",
"self",
".",
"url_",
",",
"self",
".",
"controller",
",",
"dict",
"(",
"method",
... | Appends a Middleware to the route which is to be executed before the route runs | [
"Appends",
"a",
"Middleware",
"to",
"the",
"route",
"which",
"is",
"to",
"be",
"executed",
"before",
"the",
"route",
"runs"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/route.py#L27-L34 | train |
moluwole/Bast | bast/route.py | Route.get | def get(self, url, controller):
"""
Gets the Controller and adds the route, controller and method to the url list for GET request
"""
self.request_type = 'GET'
controller_class, controller_method = self.__return_controller__(controller)
self.controller = controller_clas... | python | def get(self, url, controller):
"""
Gets the Controller and adds the route, controller and method to the url list for GET request
"""
self.request_type = 'GET'
controller_class, controller_method = self.__return_controller__(controller)
self.controller = controller_clas... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"controller",
")",
":",
"self",
".",
"request_type",
"=",
"'GET'",
"controller_class",
",",
"controller_method",
"=",
"self",
".",
"__return_controller__",
"(",
"controller",
")",
"self",
".",
"controller",
"=",
"c... | Gets the Controller and adds the route, controller and method to the url list for GET request | [
"Gets",
"the",
"Controller",
"and",
"adds",
"the",
"route",
"controller",
"and",
"method",
"to",
"the",
"url",
"list",
"for",
"GET",
"request"
] | eecf55ae72e6f24af7c101549be0422cd2c1c95a | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/route.py#L62-L75 | train |
chriso/gauged | gauged/utilities.py | to_bytes | def to_bytes(value):
"""Get a byte array representing the value"""
if isinstance(value, unicode):
return value.encode('utf8')
elif not isinstance(value, str):
return str(value)
return value | python | def to_bytes(value):
"""Get a byte array representing the value"""
if isinstance(value, unicode):
return value.encode('utf8')
elif not isinstance(value, str):
return str(value)
return value | [
"def",
"to_bytes",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"unicode",
")",
":",
"return",
"value",
".",
"encode",
"(",
"'utf8'",
")",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"str",
"(",
"value... | Get a byte array representing the value | [
"Get",
"a",
"byte",
"array",
"representing",
"the",
"value"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/utilities.py#L14-L20 | train |
chriso/gauged | gauged/utilities.py | table_repr | def table_repr(columns, rows, data, padding=2):
"""Generate a table for cli output"""
padding = ' ' * padding
column_lengths = [len(column) for column in columns]
for row in rows:
for i, column in enumerate(columns):
item = str(data[row][column])
column_lengths[i] = max(l... | python | def table_repr(columns, rows, data, padding=2):
"""Generate a table for cli output"""
padding = ' ' * padding
column_lengths = [len(column) for column in columns]
for row in rows:
for i, column in enumerate(columns):
item = str(data[row][column])
column_lengths[i] = max(l... | [
"def",
"table_repr",
"(",
"columns",
",",
"rows",
",",
"data",
",",
"padding",
"=",
"2",
")",
":",
"padding",
"=",
"' '",
"*",
"padding",
"column_lengths",
"=",
"[",
"len",
"(",
"column",
")",
"for",
"column",
"in",
"columns",
"]",
"for",
"row",
"in"... | Generate a table for cli output | [
"Generate",
"a",
"table",
"for",
"cli",
"output"
] | cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976 | https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/utilities.py#L36-L55 | train |
glormph/msstitch | src/app/readers/fasta.py | get_proteins_for_db | def get_proteins_for_db(fastafn):
"""Runs through fasta file and returns proteins accession nrs, sequences
and evidence levels for storage in lookup DB. Duplicate accessions in
fasta are accepted and removed by keeping only the last one.
"""
objects = {}
for record in parse_fasta(fastafn):
... | python | def get_proteins_for_db(fastafn):
"""Runs through fasta file and returns proteins accession nrs, sequences
and evidence levels for storage in lookup DB. Duplicate accessions in
fasta are accepted and removed by keeping only the last one.
"""
objects = {}
for record in parse_fasta(fastafn):
... | [
"def",
"get_proteins_for_db",
"(",
"fastafn",
")",
":",
"objects",
"=",
"{",
"}",
"for",
"record",
"in",
"parse_fasta",
"(",
"fastafn",
")",
":",
"objects",
"[",
"parse_protein_identifier",
"(",
"record",
")",
"]",
"=",
"record",
"return",
"(",
"(",
"(",
... | Runs through fasta file and returns proteins accession nrs, sequences
and evidence levels for storage in lookup DB. Duplicate accessions in
fasta are accepted and removed by keeping only the last one. | [
"Runs",
"through",
"fasta",
"file",
"and",
"returns",
"proteins",
"accession",
"nrs",
"sequences",
"and",
"evidence",
"levels",
"for",
"storage",
"in",
"lookup",
"DB",
".",
"Duplicate",
"accessions",
"in",
"fasta",
"are",
"accepted",
"and",
"removed",
"by",
"k... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/fasta.py#L4-L15 | train |
glormph/msstitch | src/app/readers/fasta.py | get_uniprot_evidence_level | def get_uniprot_evidence_level(header):
"""Returns uniprot protein existence evidence level for a fasta header.
Evidence levels are 1-5, but we return 5 - x since sorting still demands
that higher is better."""
header = header.split()
for item in header:
item = item.split('=')
try:
... | python | def get_uniprot_evidence_level(header):
"""Returns uniprot protein existence evidence level for a fasta header.
Evidence levels are 1-5, but we return 5 - x since sorting still demands
that higher is better."""
header = header.split()
for item in header:
item = item.split('=')
try:
... | [
"def",
"get_uniprot_evidence_level",
"(",
"header",
")",
":",
"header",
"=",
"header",
".",
"split",
"(",
")",
"for",
"item",
"in",
"header",
":",
"item",
"=",
"item",
".",
"split",
"(",
"'='",
")",
"try",
":",
"if",
"item",
"[",
"0",
"]",
"==",
"'... | Returns uniprot protein existence evidence level for a fasta header.
Evidence levels are 1-5, but we return 5 - x since sorting still demands
that higher is better. | [
"Returns",
"uniprot",
"protein",
"existence",
"evidence",
"level",
"for",
"a",
"fasta",
"header",
".",
"Evidence",
"levels",
"are",
"1",
"-",
"5",
"but",
"we",
"return",
"5",
"-",
"x",
"since",
"sorting",
"still",
"demands",
"that",
"higher",
"is",
"better... | ded7e5cbd813d7797dc9d42805778266e59ff042 | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/readers/fasta.py#L119-L131 | train |
jdodds/feather | feather/plugin.py | Plugin.run | def run(self):
"""Run our loop, and any defined hooks...
"""
self.pre_run()
first = True
while self.runnable:
self.pre_call_message()
if first:
self.pre_first_call_message()
message, payload = self.listener.get()
... | python | def run(self):
"""Run our loop, and any defined hooks...
"""
self.pre_run()
first = True
while self.runnable:
self.pre_call_message()
if first:
self.pre_first_call_message()
message, payload = self.listener.get()
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"pre_run",
"(",
")",
"first",
"=",
"True",
"while",
"self",
".",
"runnable",
":",
"self",
".",
"pre_call_message",
"(",
")",
"if",
"first",
":",
"self",
".",
"pre_first_call_message",
"(",
")",
"message... | Run our loop, and any defined hooks... | [
"Run",
"our",
"loop",
"and",
"any",
"defined",
"hooks",
"..."
] | 92a9426e692b33c7fddf758df8dbc99a9a1ba8ef | https://github.com/jdodds/feather/blob/92a9426e692b33c7fddf758df8dbc99a9a1ba8ef/feather/plugin.py#L70-L90 | train |
tamasgal/km3pipe | km3modules/hits.py | count_multiplicities | def count_multiplicities(times, tmax=20):
"""Calculate an array of multiplicities and corresponding coincidence IDs
Note that this algorithm does not take care about DOM IDs, so it has to
be fed with DOM hits.
Parameters
----------
times: array[float], shape=(n,)
Hit times for n hits
... | python | def count_multiplicities(times, tmax=20):
"""Calculate an array of multiplicities and corresponding coincidence IDs
Note that this algorithm does not take care about DOM IDs, so it has to
be fed with DOM hits.
Parameters
----------
times: array[float], shape=(n,)
Hit times for n hits
... | [
"def",
"count_multiplicities",
"(",
"times",
",",
"tmax",
"=",
"20",
")",
":",
"n",
"=",
"times",
".",
"shape",
"[",
"0",
"]",
"mtp",
"=",
"np",
".",
"ones",
"(",
"n",
",",
"dtype",
"=",
"'<i4'",
")",
"cid",
"=",
"np",
".",
"zeros",
"(",
"n",
... | Calculate an array of multiplicities and corresponding coincidence IDs
Note that this algorithm does not take care about DOM IDs, so it has to
be fed with DOM hits.
Parameters
----------
times: array[float], shape=(n,)
Hit times for n hits
dt: int [default: 20]
Time window of a... | [
"Calculate",
"an",
"array",
"of",
"multiplicities",
"and",
"corresponding",
"coincidence",
"IDs"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/hits.py#L28-L68 | train |
vslutov/turingmarkov | turingmarkov/turing.py | build_machine | def build_machine(lines):
"""Build machine from list of lines."""
if lines == []:
raise SyntaxError('Empty file')
else:
machine = Machine(lines[0].split())
for line in lines[1:]:
if line.strip() != '':
machine.add_state(line)
machine.check()
return... | python | def build_machine(lines):
"""Build machine from list of lines."""
if lines == []:
raise SyntaxError('Empty file')
else:
machine = Machine(lines[0].split())
for line in lines[1:]:
if line.strip() != '':
machine.add_state(line)
machine.check()
return... | [
"def",
"build_machine",
"(",
"lines",
")",
":",
"if",
"lines",
"==",
"[",
"]",
":",
"raise",
"SyntaxError",
"(",
"'Empty file'",
")",
"else",
":",
"machine",
"=",
"Machine",
"(",
"lines",
"[",
"0",
"]",
".",
"split",
"(",
")",
")",
"for",
"line",
"... | Build machine from list of lines. | [
"Build",
"machine",
"from",
"list",
"of",
"lines",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L175-L185 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.add_state | def add_state(self, string):
"""Add state and rules to machine."""
parsed_string = string.split()
if len(parsed_string) > 0:
state, rules = parsed_string[0], parsed_string[1:]
if len(rules) != len(self.alphabet):
raise SyntaxError('Wrong count of rules ({... | python | def add_state(self, string):
"""Add state and rules to machine."""
parsed_string = string.split()
if len(parsed_string) > 0:
state, rules = parsed_string[0], parsed_string[1:]
if len(rules) != len(self.alphabet):
raise SyntaxError('Wrong count of rules ({... | [
"def",
"add_state",
"(",
"self",
",",
"string",
")",
":",
"parsed_string",
"=",
"string",
".",
"split",
"(",
")",
"if",
"len",
"(",
"parsed_string",
")",
">",
"0",
":",
"state",
",",
"rules",
"=",
"parsed_string",
"[",
"0",
"]",
",",
"parsed_string",
... | Add state and rules to machine. | [
"Add",
"state",
"and",
"rules",
"to",
"machine",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L60-L81 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.check | def check(self):
"""Check semantic rules."""
has_term = False
if self.START_STATE not in self.states:
raise SyntaxError('Undefined start rule')
for state in self.states:
for rule in self.states[state]:
if rule is not None:
if ... | python | def check(self):
"""Check semantic rules."""
has_term = False
if self.START_STATE not in self.states:
raise SyntaxError('Undefined start rule')
for state in self.states:
for rule in self.states[state]:
if rule is not None:
if ... | [
"def",
"check",
"(",
"self",
")",
":",
"has_term",
"=",
"False",
"if",
"self",
".",
"START_STATE",
"not",
"in",
"self",
".",
"states",
":",
"raise",
"SyntaxError",
"(",
"'Undefined start rule'",
")",
"for",
"state",
"in",
"self",
".",
"states",
":",
"for... | Check semantic rules. | [
"Check",
"semantic",
"rules",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L83-L99 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.init_tape | def init_tape(self, string):
"""Init system values."""
for char in string:
if char not in self.alphabet and not char.isspace() and char != self.EMPTY_SYMBOL:
raise RuntimeError('Invalid symbol: "' + char + '"')
self.check()
self.state = self.START_STATE
... | python | def init_tape(self, string):
"""Init system values."""
for char in string:
if char not in self.alphabet and not char.isspace() and char != self.EMPTY_SYMBOL:
raise RuntimeError('Invalid symbol: "' + char + '"')
self.check()
self.state = self.START_STATE
... | [
"def",
"init_tape",
"(",
"self",
",",
"string",
")",
":",
"for",
"char",
"in",
"string",
":",
"if",
"char",
"not",
"in",
"self",
".",
"alphabet",
"and",
"not",
"char",
".",
"isspace",
"(",
")",
"and",
"char",
"!=",
"self",
".",
"EMPTY_SYMBOL",
":",
... | Init system values. | [
"Init",
"system",
"values",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L101-L114 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.get_tape | def get_tape(self):
"""Get content of tape."""
result = ''
for i in range(min(self.tape), max(self.tape) + 1):
symbol = self.tape[i] if self.tape[i] != self.EMPTY_SYMBOL else ' '
result += symbol
# Remove unnecessary empty symbols on tape
return result.str... | python | def get_tape(self):
"""Get content of tape."""
result = ''
for i in range(min(self.tape), max(self.tape) + 1):
symbol = self.tape[i] if self.tape[i] != self.EMPTY_SYMBOL else ' '
result += symbol
# Remove unnecessary empty symbols on tape
return result.str... | [
"def",
"get_tape",
"(",
"self",
")",
":",
"result",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"min",
"(",
"self",
".",
"tape",
")",
",",
"max",
"(",
"self",
".",
"tape",
")",
"+",
"1",
")",
":",
"symbol",
"=",
"self",
".",
"tape",
"[",
"i",
... | Get content of tape. | [
"Get",
"content",
"of",
"tape",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L116-L123 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.execute_once | def execute_once(self):
"""One step of execution."""
symbol = self.tape.get(self.head, self.EMPTY_SYMBOL)
index = self.alphabet.index(symbol)
rule = self.states[self.state][index]
if rule is None:
raise RuntimeError('Unexpected symbol: ' + symbol)
self.tape... | python | def execute_once(self):
"""One step of execution."""
symbol = self.tape.get(self.head, self.EMPTY_SYMBOL)
index = self.alphabet.index(symbol)
rule = self.states[self.state][index]
if rule is None:
raise RuntimeError('Unexpected symbol: ' + symbol)
self.tape... | [
"def",
"execute_once",
"(",
"self",
")",
":",
"symbol",
"=",
"self",
".",
"tape",
".",
"get",
"(",
"self",
".",
"head",
",",
"self",
".",
"EMPTY_SYMBOL",
")",
"index",
"=",
"self",
".",
"alphabet",
".",
"index",
"(",
"symbol",
")",
"rule",
"=",
"se... | One step of execution. | [
"One",
"step",
"of",
"execution",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L125-L142 | train |
vslutov/turingmarkov | turingmarkov/turing.py | Machine.compile | def compile(self):
"""Return python code for create and execute machine."""
result = TEMPLATE
result += 'machine = Machine(' + repr(self.alphabet) + ')\n'
for state in self.states:
repr_state = state[0]
for rule in self.states[state]:
repr_state +... | python | def compile(self):
"""Return python code for create and execute machine."""
result = TEMPLATE
result += 'machine = Machine(' + repr(self.alphabet) + ')\n'
for state in self.states:
repr_state = state[0]
for rule in self.states[state]:
repr_state +... | [
"def",
"compile",
"(",
"self",
")",
":",
"result",
"=",
"TEMPLATE",
"result",
"+=",
"'machine = Machine('",
"+",
"repr",
"(",
"self",
".",
"alphabet",
")",
"+",
"')\\n'",
"for",
"state",
"in",
"self",
".",
"states",
":",
"repr_state",
"=",
"state",
"[",
... | Return python code for create and execute machine. | [
"Return",
"python",
"code",
"for",
"create",
"and",
"execute",
"machine",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/turing.py#L159-L173 | train |
tamasgal/km3pipe | km3pipe/core.py | ServiceManager.get_missing_services | def get_missing_services(self, services):
"""
Check if all required services are provided
Args:
services: List with the service names which are required
Returns:
List with missing services
"""
required_services = set(services)
provided_ser... | python | def get_missing_services(self, services):
"""
Check if all required services are provided
Args:
services: List with the service names which are required
Returns:
List with missing services
"""
required_services = set(services)
provided_ser... | [
"def",
"get_missing_services",
"(",
"self",
",",
"services",
")",
":",
"required_services",
"=",
"set",
"(",
"services",
")",
"provided_services",
"=",
"set",
"(",
"self",
".",
"_services",
".",
"keys",
"(",
")",
")",
"missing_services",
"=",
"required_service... | Check if all required services are provided
Args:
services: List with the service names which are required
Returns:
List with missing services | [
"Check",
"if",
"all",
"required",
"services",
"are",
"provided"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L72-L85 | train |
tamasgal/km3pipe | km3pipe/core.py | Pipeline._drain | def _drain(self, cycles=None):
"""Activate the pump and let the flow go.
This will call the process() method on each attached module until
a StopIteration is raised, usually by a pump when it reached the EOF.
A StopIteration is also raised when self.cycles was set and the
numbe... | python | def _drain(self, cycles=None):
"""Activate the pump and let the flow go.
This will call the process() method on each attached module until
a StopIteration is raised, usually by a pump when it reached the EOF.
A StopIteration is also raised when self.cycles was set and the
numbe... | [
"def",
"_drain",
"(",
"self",
",",
"cycles",
"=",
"None",
")",
":",
"log",
".",
"info",
"(",
"\"Now draining...\"",
")",
"if",
"not",
"cycles",
":",
"log",
".",
"info",
"(",
"\"No cycle count, the pipeline may be drained forever.\"",
")",
"if",
"self",
".",
... | Activate the pump and let the flow go.
This will call the process() method on each attached module until
a StopIteration is raised, usually by a pump when it reached the EOF.
A StopIteration is also raised when self.cycles was set and the
number of cycles has reached that limit. | [
"Activate",
"the",
"pump",
"and",
"let",
"the",
"flow",
"go",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L258-L344 | train |
tamasgal/km3pipe | km3pipe/core.py | Pipeline._check_service_requirements | def _check_service_requirements(self):
"""Final comparison of provided and required modules"""
missing = self.services.get_missing_services(
self.required_services.keys()
)
if missing:
self.log.critical(
"Following services are required and missing... | python | def _check_service_requirements(self):
"""Final comparison of provided and required modules"""
missing = self.services.get_missing_services(
self.required_services.keys()
)
if missing:
self.log.critical(
"Following services are required and missing... | [
"def",
"_check_service_requirements",
"(",
"self",
")",
":",
"missing",
"=",
"self",
".",
"services",
".",
"get_missing_services",
"(",
"self",
".",
"required_services",
".",
"keys",
"(",
")",
")",
"if",
"missing",
":",
"self",
".",
"log",
".",
"critical",
... | Final comparison of provided and required modules | [
"Final",
"comparison",
"of",
"provided",
"and",
"required",
"modules"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L346-L358 | train |
tamasgal/km3pipe | km3pipe/core.py | Pipeline.drain | def drain(self, cycles=None):
"""Execute _drain while trapping KeyboardInterrupt"""
if not self._check_service_requirements():
self.init_timer.stop()
return self.finish()
if self.anybar: self.anybar.change("orange")
self.init_timer.stop()
log.info("Trappi... | python | def drain(self, cycles=None):
"""Execute _drain while trapping KeyboardInterrupt"""
if not self._check_service_requirements():
self.init_timer.stop()
return self.finish()
if self.anybar: self.anybar.change("orange")
self.init_timer.stop()
log.info("Trappi... | [
"def",
"drain",
"(",
"self",
",",
"cycles",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_check_service_requirements",
"(",
")",
":",
"self",
".",
"init_timer",
".",
"stop",
"(",
")",
"return",
"self",
".",
"finish",
"(",
")",
"if",
"self",
".",... | Execute _drain while trapping KeyboardInterrupt | [
"Execute",
"_drain",
"while",
"trapping",
"KeyboardInterrupt"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L360-L371 | train |
tamasgal/km3pipe | km3pipe/core.py | Pipeline._handle_ctrl_c | def _handle_ctrl_c(self, *args):
"""Handle the keyboard interrupts."""
if self.anybar: self.anybar.change("exclamation")
if self._stop:
print("\nForced shutdown...")
raise SystemExit
if not self._stop:
hline = 42 * '='
print(
... | python | def _handle_ctrl_c(self, *args):
"""Handle the keyboard interrupts."""
if self.anybar: self.anybar.change("exclamation")
if self._stop:
print("\nForced shutdown...")
raise SystemExit
if not self._stop:
hline = 42 * '='
print(
... | [
"def",
"_handle_ctrl_c",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"anybar",
":",
"self",
".",
"anybar",
".",
"change",
"(",
"\"exclamation\"",
")",
"if",
"self",
".",
"_stop",
":",
"print",
"(",
"\"\\nForced shutdown...\"",
")",
"raise... | Handle the keyboard interrupts. | [
"Handle",
"the",
"keyboard",
"interrupts",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L397-L410 | train |
tamasgal/km3pipe | km3pipe/core.py | Module.get | def get(self, name, default=None):
"""Return the value of the requested parameter or `default` if None."""
value = self.parameters.get(name)
self._processed_parameters.append(name)
if value is None:
return default
return value | python | def get(self, name, default=None):
"""Return the value of the requested parameter or `default` if None."""
value = self.parameters.get(name)
self._processed_parameters.append(name)
if value is None:
return default
return value | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"parameters",
".",
"get",
"(",
"name",
")",
"self",
".",
"_processed_parameters",
".",
"append",
"(",
"name",
")",
"if",
"value",
"is",
"None",
... | Return the value of the requested parameter or `default` if None. | [
"Return",
"the",
"value",
"of",
"the",
"requested",
"parameter",
"or",
"default",
"if",
"None",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L531-L537 | train |
tamasgal/km3pipe | km3pipe/core.py | Module.require | def require(self, name):
"""Return the value of the requested parameter or raise an error."""
value = self.get(name)
if value is None:
raise TypeError(
"{0} requires the parameter '{1}'.".format(
self.__class__, name
)
)... | python | def require(self, name):
"""Return the value of the requested parameter or raise an error."""
value = self.get(name)
if value is None:
raise TypeError(
"{0} requires the parameter '{1}'.".format(
self.__class__, name
)
)... | [
"def",
"require",
"(",
"self",
",",
"name",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"name",
")",
"if",
"value",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"{0} requires the parameter '{1}'.\"",
".",
"format",
"(",
"self",
".",
"__class__",
... | Return the value of the requested parameter or raise an error. | [
"Return",
"the",
"value",
"of",
"the",
"requested",
"parameter",
"or",
"raise",
"an",
"error",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L539-L548 | train |
tamasgal/km3pipe | km3pipe/core.py | Module._check_unused_parameters | def _check_unused_parameters(self):
"""Check if any of the parameters passed in are ignored"""
all_params = set(self.parameters.keys())
processed_params = set(self._processed_parameters)
unused_params = all_params - processed_params - RESERVED_ARGS
if unused_params:
... | python | def _check_unused_parameters(self):
"""Check if any of the parameters passed in are ignored"""
all_params = set(self.parameters.keys())
processed_params = set(self._processed_parameters)
unused_params = all_params - processed_params - RESERVED_ARGS
if unused_params:
... | [
"def",
"_check_unused_parameters",
"(",
"self",
")",
":",
"all_params",
"=",
"set",
"(",
"self",
".",
"parameters",
".",
"keys",
"(",
")",
")",
"processed_params",
"=",
"set",
"(",
"self",
".",
"_processed_parameters",
")",
"unused_params",
"=",
"all_params",
... | Check if any of the parameters passed in are ignored | [
"Check",
"if",
"any",
"of",
"the",
"parameters",
"passed",
"in",
"are",
"ignored"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L565-L576 | train |
tamasgal/km3pipe | km3pipe/core.py | Pump.open_file | def open_file(self, filename):
"""Open the file with filename"""
try:
if filename.endswith('.gz'):
self.blob_file = gzip.open(filename, 'rb')
else:
self.blob_file = open(filename, 'rb')
except TypeError:
log.error("Please specif... | python | def open_file(self, filename):
"""Open the file with filename"""
try:
if filename.endswith('.gz'):
self.blob_file = gzip.open(filename, 'rb')
else:
self.blob_file = open(filename, 'rb')
except TypeError:
log.error("Please specif... | [
"def",
"open_file",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.gz'",
")",
":",
"self",
".",
"blob_file",
"=",
"gzip",
".",
"open",
"(",
"filename",
",",
"'rb'",
")",
"else",
":",
"self",
".",
"blo... | Open the file with filename | [
"Open",
"the",
"file",
"with",
"filename"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/core.py#L599-L611 | train |
ioos/pyoos | pyoos/utils/asatime.py | AsaTime.parse | def parse(cls, date_string):
"""
Parse any time string. Use a custom timezone matching if
the original matching does not pull one out.
"""
try:
date = dateparser.parse(date_string)
if date.tzinfo is None:
date = dateparser.parse(da... | python | def parse(cls, date_string):
"""
Parse any time string. Use a custom timezone matching if
the original matching does not pull one out.
"""
try:
date = dateparser.parse(date_string)
if date.tzinfo is None:
date = dateparser.parse(da... | [
"def",
"parse",
"(",
"cls",
",",
"date_string",
")",
":",
"try",
":",
"date",
"=",
"dateparser",
".",
"parse",
"(",
"date_string",
")",
"if",
"date",
".",
"tzinfo",
"is",
"None",
":",
"date",
"=",
"dateparser",
".",
"parse",
"(",
"date_string",
",",
... | Parse any time string. Use a custom timezone matching if
the original matching does not pull one out. | [
"Parse",
"any",
"time",
"string",
".",
"Use",
"a",
"custom",
"timezone",
"matching",
"if",
"the",
"original",
"matching",
"does",
"not",
"pull",
"one",
"out",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/utils/asatime.py#L54-L65 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | epsg_code | def epsg_code(geojson):
""" get the espg code from the crs system """
if isinstance(geojson, dict):
if 'crs' in geojson:
urn = geojson['crs']['properties']['name'].split(':')
if 'EPSG' in urn:
try:
return int(urn[-1])
except (T... | python | def epsg_code(geojson):
""" get the espg code from the crs system """
if isinstance(geojson, dict):
if 'crs' in geojson:
urn = geojson['crs']['properties']['name'].split(':')
if 'EPSG' in urn:
try:
return int(urn[-1])
except (T... | [
"def",
"epsg_code",
"(",
"geojson",
")",
":",
"if",
"isinstance",
"(",
"geojson",
",",
"dict",
")",
":",
"if",
"'crs'",
"in",
"geojson",
":",
"urn",
"=",
"geojson",
"[",
"'crs'",
"]",
"[",
"'properties'",
"]",
"[",
"'name'",
"]",
".",
"split",
"(",
... | get the espg code from the crs system | [
"get",
"the",
"espg",
"code",
"from",
"the",
"crs",
"system"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L24-L36 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | convert_coordinates | def convert_coordinates(coords, origin, wgs84, wrapped):
""" Convert coordinates from one crs to another """
if isinstance(coords, list) or isinstance(coords, tuple):
try:
if isinstance(coords[0], list) or isinstance(coords[0], tuple):
return [convert_coordinates(list(c), ori... | python | def convert_coordinates(coords, origin, wgs84, wrapped):
""" Convert coordinates from one crs to another """
if isinstance(coords, list) or isinstance(coords, tuple):
try:
if isinstance(coords[0], list) or isinstance(coords[0], tuple):
return [convert_coordinates(list(c), ori... | [
"def",
"convert_coordinates",
"(",
"coords",
",",
"origin",
",",
"wgs84",
",",
"wrapped",
")",
":",
"if",
"isinstance",
"(",
"coords",
",",
"list",
")",
"or",
"isinstance",
"(",
"coords",
",",
"tuple",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"co... | Convert coordinates from one crs to another | [
"Convert",
"coordinates",
"from",
"one",
"crs",
"to",
"another"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L56-L71 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | to_latlon | def to_latlon(geojson, origin_espg=None):
"""
Convert a given geojson to wgs84. The original epsg must be included insde the crs
tag of geojson
"""
if isinstance(geojson, dict):
# get epsg code:
if origin_espg:
code = origin_espg
else:
code = epsg_co... | python | def to_latlon(geojson, origin_espg=None):
"""
Convert a given geojson to wgs84. The original epsg must be included insde the crs
tag of geojson
"""
if isinstance(geojson, dict):
# get epsg code:
if origin_espg:
code = origin_espg
else:
code = epsg_co... | [
"def",
"to_latlon",
"(",
"geojson",
",",
"origin_espg",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"geojson",
",",
"dict",
")",
":",
"if",
"origin_espg",
":",
"code",
"=",
"origin_espg",
"else",
":",
"code",
"=",
"epsg_code",
"(",
"geojson",
")",
... | Convert a given geojson to wgs84. The original epsg must be included insde the crs
tag of geojson | [
"Convert",
"a",
"given",
"geojson",
"to",
"wgs84",
".",
"The",
"original",
"epsg",
"must",
"be",
"included",
"insde",
"the",
"crs",
"tag",
"of",
"geojson"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L74-L99 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | camelcase_underscore | def camelcase_underscore(name):
""" Convert camelcase names to underscore """
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | python | def camelcase_underscore(name):
""" Convert camelcase names to underscore """
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"def",
"camelcase_underscore",
"(",
"name",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"name",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(... | Convert camelcase names to underscore | [
"Convert",
"camelcase",
"names",
"to",
"underscore"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L102-L105 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | get_tiles_list | def get_tiles_list(element):
"""
Returns the list of all tile names from Product_Organisation element
in metadata.xml
"""
tiles = {}
for el in element:
g = (el.findall('.//Granules') or el.findall('.//Granule'))[0]
name = g.attrib['granuleIdentifier']
name_parts = name... | python | def get_tiles_list(element):
"""
Returns the list of all tile names from Product_Organisation element
in metadata.xml
"""
tiles = {}
for el in element:
g = (el.findall('.//Granules') or el.findall('.//Granule'))[0]
name = g.attrib['granuleIdentifier']
name_parts = name... | [
"def",
"get_tiles_list",
"(",
"element",
")",
":",
"tiles",
"=",
"{",
"}",
"for",
"el",
"in",
"element",
":",
"g",
"=",
"(",
"el",
".",
"findall",
"(",
"'.//Granules'",
")",
"or",
"el",
".",
"findall",
"(",
"'.//Granule'",
")",
")",
"[",
"0",
"]",
... | Returns the list of all tile names from Product_Organisation element
in metadata.xml | [
"Returns",
"the",
"list",
"of",
"all",
"tile",
"names",
"from",
"Product_Organisation",
"element",
"in",
"metadata",
".",
"xml"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L108-L124 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | metadata_to_dict | def metadata_to_dict(metadata):
""" Looks at metadata.xml file of sentinel product and extract useful keys
Returns a python dict """
tree = etree.parse(metadata)
root = tree.getroot()
meta = OrderedDict()
keys = [
'SPACECRAFT_NAME',
'PRODUCT_STOP_TIME',
'Cloud_Coverage... | python | def metadata_to_dict(metadata):
""" Looks at metadata.xml file of sentinel product and extract useful keys
Returns a python dict """
tree = etree.parse(metadata)
root = tree.getroot()
meta = OrderedDict()
keys = [
'SPACECRAFT_NAME',
'PRODUCT_STOP_TIME',
'Cloud_Coverage... | [
"def",
"metadata_to_dict",
"(",
"metadata",
")",
":",
"tree",
"=",
"etree",
".",
"parse",
"(",
"metadata",
")",
"root",
"=",
"tree",
".",
"getroot",
"(",
")",
"meta",
"=",
"OrderedDict",
"(",
")",
"keys",
"=",
"[",
"'SPACECRAFT_NAME'",
",",
"'PRODUCT_STO... | Looks at metadata.xml file of sentinel product and extract useful keys
Returns a python dict | [
"Looks",
"at",
"metadata",
".",
"xml",
"file",
"of",
"sentinel",
"product",
"and",
"extract",
"useful",
"keys",
"Returns",
"a",
"python",
"dict"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L127-L184 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | get_tile_geometry | def get_tile_geometry(path, origin_espg, tolerance=500):
""" Calculate the data and tile geometry for sentinel-2 tiles """
with rasterio.open(path) as src:
# Get tile geometry
b = src.bounds
tile_shape = Polygon([(b[0], b[1]), (b[2], b[1]), (b[2], b[3]), (b[0], b[3]), (b[0], b[1])])
... | python | def get_tile_geometry(path, origin_espg, tolerance=500):
""" Calculate the data and tile geometry for sentinel-2 tiles """
with rasterio.open(path) as src:
# Get tile geometry
b = src.bounds
tile_shape = Polygon([(b[0], b[1]), (b[2], b[1]), (b[2], b[3]), (b[0], b[3]), (b[0], b[1])])
... | [
"def",
"get_tile_geometry",
"(",
"path",
",",
"origin_espg",
",",
"tolerance",
"=",
"500",
")",
":",
"with",
"rasterio",
".",
"open",
"(",
"path",
")",
"as",
"src",
":",
"b",
"=",
"src",
".",
"bounds",
"tile_shape",
"=",
"Polygon",
"(",
"[",
"(",
"b"... | Calculate the data and tile geometry for sentinel-2 tiles | [
"Calculate",
"the",
"data",
"and",
"tile",
"geometry",
"for",
"sentinel",
"-",
"2",
"tiles"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L187-L235 | train |
developmentseed/sentinel-s3 | sentinel_s3/converter.py | tile_metadata | def tile_metadata(tile, product, geometry_check=None):
""" Generate metadata for a given tile
- geometry_check is a function the determines whether to calculate the geometry by downloading
B01 and override provided geometry in tilejson. The meta object is passed to this function.
The function return a ... | python | def tile_metadata(tile, product, geometry_check=None):
""" Generate metadata for a given tile
- geometry_check is a function the determines whether to calculate the geometry by downloading
B01 and override provided geometry in tilejson. The meta object is passed to this function.
The function return a ... | [
"def",
"tile_metadata",
"(",
"tile",
",",
"product",
",",
"geometry_check",
"=",
"None",
")",
":",
"grid",
"=",
"'T{0}{1}{2}'",
".",
"format",
"(",
"pad",
"(",
"tile",
"[",
"'utmZone'",
"]",
",",
"2",
")",
",",
"tile",
"[",
"'latitudeBand'",
"]",
",",
... | Generate metadata for a given tile
- geometry_check is a function the determines whether to calculate the geometry by downloading
B01 and override provided geometry in tilejson. The meta object is passed to this function.
The function return a True or False response. | [
"Generate",
"metadata",
"for",
"a",
"given",
"tile"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/converter.py#L266-L324 | train |
vslutov/turingmarkov | turingmarkov/__main__.py | load_markov | def load_markov(argv, stdin):
"""Load and return markov algorithm."""
if len(argv) > 3:
with open(argv[3]) as input_file:
return Algorithm(input_file.readlines())
else:
return Algorithm(stdin.readlines()) | python | def load_markov(argv, stdin):
"""Load and return markov algorithm."""
if len(argv) > 3:
with open(argv[3]) as input_file:
return Algorithm(input_file.readlines())
else:
return Algorithm(stdin.readlines()) | [
"def",
"load_markov",
"(",
"argv",
",",
"stdin",
")",
":",
"if",
"len",
"(",
"argv",
")",
">",
"3",
":",
"with",
"open",
"(",
"argv",
"[",
"3",
"]",
")",
"as",
"input_file",
":",
"return",
"Algorithm",
"(",
"input_file",
".",
"readlines",
"(",
")",... | Load and return markov algorithm. | [
"Load",
"and",
"return",
"markov",
"algorithm",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/__main__.py#L21-L27 | train |
vslutov/turingmarkov | turingmarkov/__main__.py | load_turing | def load_turing(argv, stdin):
"""Load and return turing machine."""
if len(argv) > 3:
with open(argv[3]) as input_file:
return build_machine(input_file.readlines())
else:
return build_machine(stdin.readlines()) | python | def load_turing(argv, stdin):
"""Load and return turing machine."""
if len(argv) > 3:
with open(argv[3]) as input_file:
return build_machine(input_file.readlines())
else:
return build_machine(stdin.readlines()) | [
"def",
"load_turing",
"(",
"argv",
",",
"stdin",
")",
":",
"if",
"len",
"(",
"argv",
")",
">",
"3",
":",
"with",
"open",
"(",
"argv",
"[",
"3",
"]",
")",
"as",
"input_file",
":",
"return",
"build_machine",
"(",
"input_file",
".",
"readlines",
"(",
... | Load and return turing machine. | [
"Load",
"and",
"return",
"turing",
"machine",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/__main__.py#L29-L35 | train |
vslutov/turingmarkov | turingmarkov/__main__.py | main | def main(argv, stdin, stdout):
"""Execute, when user call turingmarkov."""
if len(argv) > 1 and argv[1:3] == ["compile", "markov"]:
algo = load_markov(argv, stdin)
print(algo.compile(), file=stdout)
elif len(argv) == 4 and argv[1:3] == ["run", "markov"]:
algo = load_markov(argv, stdi... | python | def main(argv, stdin, stdout):
"""Execute, when user call turingmarkov."""
if len(argv) > 1 and argv[1:3] == ["compile", "markov"]:
algo = load_markov(argv, stdin)
print(algo.compile(), file=stdout)
elif len(argv) == 4 and argv[1:3] == ["run", "markov"]:
algo = load_markov(argv, stdi... | [
"def",
"main",
"(",
"argv",
",",
"stdin",
",",
"stdout",
")",
":",
"if",
"len",
"(",
"argv",
")",
">",
"1",
"and",
"argv",
"[",
"1",
":",
"3",
"]",
"==",
"[",
"\"compile\"",
",",
"\"markov\"",
"]",
":",
"algo",
"=",
"load_markov",
"(",
"argv",
... | Execute, when user call turingmarkov. | [
"Execute",
"when",
"user",
"call",
"turingmarkov",
"."
] | 63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce | https://github.com/vslutov/turingmarkov/blob/63e2ba255d7d0d868cbc4bf3e568b1c1bbcf38ce/turingmarkov/__main__.py#L37-L65 | train |
tamasgal/km3pipe | km3pipe/cmd.py | detectors | def detectors(regex=None, sep='\t', temporary=False):
"""Print the detectors table"""
db = DBManager(temporary=temporary)
dt = db.detectors
if regex is not None:
try:
re.compile(regex)
except re.error:
log.error("Invalid regex!")
return
dt = dt... | python | def detectors(regex=None, sep='\t', temporary=False):
"""Print the detectors table"""
db = DBManager(temporary=temporary)
dt = db.detectors
if regex is not None:
try:
re.compile(regex)
except re.error:
log.error("Invalid regex!")
return
dt = dt... | [
"def",
"detectors",
"(",
"regex",
"=",
"None",
",",
"sep",
"=",
"'\\t'",
",",
"temporary",
"=",
"False",
")",
":",
"db",
"=",
"DBManager",
"(",
"temporary",
"=",
"temporary",
")",
"dt",
"=",
"db",
".",
"detectors",
"if",
"regex",
"is",
"not",
"None",... | Print the detectors table | [
"Print",
"the",
"detectors",
"table"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/cmd.py#L112-L123 | train |
developmentseed/sentinel-s3 | sentinel_s3/crawler.py | get_product_metadata_path | def get_product_metadata_path(product_name):
""" gets a single products metadata """
string_date = product_name.split('_')[-1]
date = datetime.datetime.strptime(string_date, '%Y%m%dT%H%M%S')
path = 'products/{0}/{1}/{2}/{3}'.format(date.year, date.month, date.day, product_name)
return {
pr... | python | def get_product_metadata_path(product_name):
""" gets a single products metadata """
string_date = product_name.split('_')[-1]
date = datetime.datetime.strptime(string_date, '%Y%m%dT%H%M%S')
path = 'products/{0}/{1}/{2}/{3}'.format(date.year, date.month, date.day, product_name)
return {
pr... | [
"def",
"get_product_metadata_path",
"(",
"product_name",
")",
":",
"string_date",
"=",
"product_name",
".",
"split",
"(",
"'_'",
")",
"[",
"-",
"1",
"]",
"date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"string_date",
",",
"'%Y%m%dT%H%M%S'",
"... | gets a single products metadata | [
"gets",
"a",
"single",
"products",
"metadata"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/crawler.py#L24-L36 | train |
developmentseed/sentinel-s3 | sentinel_s3/crawler.py | get_products_metadata_path | def get_products_metadata_path(year, month, day):
""" Get paths to multiple products metadata """
products = {}
path = 'products/{0}/{1}/{2}/'.format(year, month, day)
for key in bucket.objects.filter(Prefix=path):
product_path = key.key.replace(path, '').split('/')
name = product_path[... | python | def get_products_metadata_path(year, month, day):
""" Get paths to multiple products metadata """
products = {}
path = 'products/{0}/{1}/{2}/'.format(year, month, day)
for key in bucket.objects.filter(Prefix=path):
product_path = key.key.replace(path, '').split('/')
name = product_path[... | [
"def",
"get_products_metadata_path",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"products",
"=",
"{",
"}",
"path",
"=",
"'products/{0}/{1}/{2}/'",
".",
"format",
"(",
"year",
",",
"month",
",",
"day",
")",
"for",
"key",
"in",
"bucket",
".",
"object... | Get paths to multiple products metadata | [
"Get",
"paths",
"to",
"multiple",
"products",
"metadata"
] | 02bf2f9cb6aff527e492b39518a54f0b4613ddda | https://github.com/developmentseed/sentinel-s3/blob/02bf2f9cb6aff527e492b39518a54f0b4613ddda/sentinel_s3/crawler.py#L39-L56 | train |
astooke/gtimer | gtimer/public/timer.py | start | def start(backdate=None):
"""
Mark the start of timing, overwriting the automatic start data written on
import, or the automatic start at the beginning of a subdivision.
Notes:
Backdating: For subdivisions only. Backdate time must be in the past
but more recent than the latest stamp in... | python | def start(backdate=None):
"""
Mark the start of timing, overwriting the automatic start data written on
import, or the automatic start at the beginning of a subdivision.
Notes:
Backdating: For subdivisions only. Backdate time must be in the past
but more recent than the latest stamp in... | [
"def",
"start",
"(",
"backdate",
"=",
"None",
")",
":",
"if",
"f",
".",
"s",
".",
"cum",
":",
"raise",
"StartError",
"(",
"\"Already have stamps, can't start again (must reset).\"",
")",
"if",
"f",
".",
"t",
".",
"subdvsn_awaiting",
"or",
"f",
".",
"t",
".... | Mark the start of timing, overwriting the automatic start data written on
import, or the automatic start at the beginning of a subdivision.
Notes:
Backdating: For subdivisions only. Backdate time must be in the past
but more recent than the latest stamp in the parent timer.
Args:
... | [
"Mark",
"the",
"start",
"of",
"timing",
"overwriting",
"the",
"automatic",
"start",
"data",
"written",
"on",
"import",
"or",
"the",
"automatic",
"start",
"at",
"the",
"beginning",
"of",
"a",
"subdivision",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L40-L85 | train |
astooke/gtimer | gtimer/public/timer.py | stamp | def stamp(name, backdate=None,
unique=None, keep_subdivisions=None, quick_print=None,
un=None, ks=None, qp=None):
"""
Mark the end of a timing interval.
Notes:
If keeping subdivisions, each subdivision currently awaiting
assignment to a stamp (i.e. ended since the last s... | python | def stamp(name, backdate=None,
unique=None, keep_subdivisions=None, quick_print=None,
un=None, ks=None, qp=None):
"""
Mark the end of a timing interval.
Notes:
If keeping subdivisions, each subdivision currently awaiting
assignment to a stamp (i.e. ended since the last s... | [
"def",
"stamp",
"(",
"name",
",",
"backdate",
"=",
"None",
",",
"unique",
"=",
"None",
",",
"keep_subdivisions",
"=",
"None",
",",
"quick_print",
"=",
"None",
",",
"un",
"=",
"None",
",",
"ks",
"=",
"None",
",",
"qp",
"=",
"None",
")",
":",
"t",
... | Mark the end of a timing interval.
Notes:
If keeping subdivisions, each subdivision currently awaiting
assignment to a stamp (i.e. ended since the last stamp in this level)
will be assigned to this one. Otherwise, all awaiting ones will be
discarded after aggregating their self tim... | [
"Mark",
"the",
"end",
"of",
"a",
"timing",
"interval",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L88-L155 | train |
astooke/gtimer | gtimer/public/timer.py | stop | def stop(name=None, backdate=None,
unique=None, keep_subdivisions=None, quick_print=None,
un=None, ks=None, qp=None):
"""
Mark the end of timing. Optionally performs a stamp, hence accepts the
same arguments.
Notes:
If keeping subdivisions and not calling a stamp, any awaitin... | python | def stop(name=None, backdate=None,
unique=None, keep_subdivisions=None, quick_print=None,
un=None, ks=None, qp=None):
"""
Mark the end of timing. Optionally performs a stamp, hence accepts the
same arguments.
Notes:
If keeping subdivisions and not calling a stamp, any awaitin... | [
"def",
"stop",
"(",
"name",
"=",
"None",
",",
"backdate",
"=",
"None",
",",
"unique",
"=",
"None",
",",
"keep_subdivisions",
"=",
"None",
",",
"quick_print",
"=",
"None",
",",
"un",
"=",
"None",
",",
"ks",
"=",
"None",
",",
"qp",
"=",
"None",
")",
... | Mark the end of timing. Optionally performs a stamp, hence accepts the
same arguments.
Notes:
If keeping subdivisions and not calling a stamp, any awaiting subdivisions
will be assigned to a special 'UNASSIGNED' position to indicate that they
are not properly accounted for in the hiera... | [
"Mark",
"the",
"end",
"of",
"timing",
".",
"Optionally",
"performs",
"a",
"stamp",
"hence",
"accepts",
"the",
"same",
"arguments",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L158-L231 | train |
astooke/gtimer | gtimer/public/timer.py | pause | def pause():
"""
Pause the timer, preventing subsequent time from accumulating in the
total. Renders the timer inactive, disabling other timing commands.
Returns:
float: The current time.
Raises:
PausedError: If timer already paused.
StoppedError: If timer already stopped.... | python | def pause():
"""
Pause the timer, preventing subsequent time from accumulating in the
total. Renders the timer inactive, disabling other timing commands.
Returns:
float: The current time.
Raises:
PausedError: If timer already paused.
StoppedError: If timer already stopped.... | [
"def",
"pause",
"(",
")",
":",
"t",
"=",
"timer",
"(",
")",
"if",
"f",
".",
"t",
".",
"stopped",
":",
"raise",
"StoppedError",
"(",
"\"Cannot pause stopped timer.\"",
")",
"if",
"f",
".",
"t",
".",
"paused",
":",
"raise",
"PausedError",
"(",
"\"Timer a... | Pause the timer, preventing subsequent time from accumulating in the
total. Renders the timer inactive, disabling other timing commands.
Returns:
float: The current time.
Raises:
PausedError: If timer already paused.
StoppedError: If timer already stopped. | [
"Pause",
"the",
"timer",
"preventing",
"subsequent",
"time",
"from",
"accumulating",
"in",
"the",
"total",
".",
"Renders",
"the",
"timer",
"inactive",
"disabling",
"other",
"timing",
"commands",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L234-L255 | train |
astooke/gtimer | gtimer/public/timer.py | resume | def resume():
"""
Resume a paused timer, re-activating it. Subsequent time accumulates in
the total.
Returns:
float: The current time.
Raises:
PausedError: If timer was not in paused state.
StoppedError: If timer was already stopped.
"""
t = timer()
if f.t.stop... | python | def resume():
"""
Resume a paused timer, re-activating it. Subsequent time accumulates in
the total.
Returns:
float: The current time.
Raises:
PausedError: If timer was not in paused state.
StoppedError: If timer was already stopped.
"""
t = timer()
if f.t.stop... | [
"def",
"resume",
"(",
")",
":",
"t",
"=",
"timer",
"(",
")",
"if",
"f",
".",
"t",
".",
"stopped",
":",
"raise",
"StoppedError",
"(",
"\"Cannot resume stopped timer.\"",
")",
"if",
"not",
"f",
".",
"t",
".",
"paused",
":",
"raise",
"PausedError",
"(",
... | Resume a paused timer, re-activating it. Subsequent time accumulates in
the total.
Returns:
float: The current time.
Raises:
PausedError: If timer was not in paused state.
StoppedError: If timer was already stopped. | [
"Resume",
"a",
"paused",
"timer",
"re",
"-",
"activating",
"it",
".",
"Subsequent",
"time",
"accumulates",
"in",
"the",
"total",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timer.py#L258-L278 | train |
astooke/gtimer | gtimer/private/collapse.py | collapse_times | def collapse_times():
"""Make copies of everything, assign to global shortcuts so functions work
on them, extract the times, then restore the running stacks.
"""
orig_ts = f.timer_stack
orig_ls = f.loop_stack
copy_ts = _copy_timer_stack()
copy_ls = copy.deepcopy(f.loop_stack)
f.timer_sta... | python | def collapse_times():
"""Make copies of everything, assign to global shortcuts so functions work
on them, extract the times, then restore the running stacks.
"""
orig_ts = f.timer_stack
orig_ls = f.loop_stack
copy_ts = _copy_timer_stack()
copy_ls = copy.deepcopy(f.loop_stack)
f.timer_sta... | [
"def",
"collapse_times",
"(",
")",
":",
"orig_ts",
"=",
"f",
".",
"timer_stack",
"orig_ls",
"=",
"f",
".",
"loop_stack",
"copy_ts",
"=",
"_copy_timer_stack",
"(",
")",
"copy_ls",
"=",
"copy",
".",
"deepcopy",
"(",
"f",
".",
"loop_stack",
")",
"f",
".",
... | Make copies of everything, assign to global shortcuts so functions work
on them, extract the times, then restore the running stacks. | [
"Make",
"copies",
"of",
"everything",
"assign",
"to",
"global",
"shortcuts",
"so",
"functions",
"work",
"on",
"them",
"extract",
"the",
"times",
"then",
"restore",
"the",
"running",
"stacks",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/private/collapse.py#L15-L33 | train |
IRC-SPHERE/HyperStream | hyperstream/plate/plate_manager.py | PlateManager.create_plate | def create_plate(self, plate_id, description, meta_data_id, values, complement, parent_plate):
"""
Create a new plate, and commit it to the database
:param plate_id: The plate id - required to be unique
:param description: A human readable description
:param meta_data_id: The me... | python | def create_plate(self, plate_id, description, meta_data_id, values, complement, parent_plate):
"""
Create a new plate, and commit it to the database
:param plate_id: The plate id - required to be unique
:param description: A human readable description
:param meta_data_id: The me... | [
"def",
"create_plate",
"(",
"self",
",",
"plate_id",
",",
"description",
",",
"meta_data_id",
",",
"values",
",",
"complement",
",",
"parent_plate",
")",
":",
"with",
"switch_db",
"(",
"PlateDefinitionModel",
",",
"db_alias",
"=",
"'hyperstream'",
")",
":",
"t... | Create a new plate, and commit it to the database
:param plate_id: The plate id - required to be unique
:param description: A human readable description
:param meta_data_id: The meta data id, which should correspond to the tag in the global meta data
:param values: Either a list of stri... | [
"Create",
"a",
"new",
"plate",
"and",
"commit",
"it",
"to",
"the",
"database"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/plate/plate_manager.py#L100-L139 | train |
astooke/gtimer | gtimer/public/timedloop.py | timed_loop | def timed_loop(name=None,
rgstr_stamps=None,
save_itrs=SET['SI'],
loop_end_stamp=None,
end_stamp_unique=SET['UN'],
keep_prev_subdivisions=SET['KS'],
keep_end_subdivisions=SET['KS'],
quick_print=SET['QP']):
"""
... | python | def timed_loop(name=None,
rgstr_stamps=None,
save_itrs=SET['SI'],
loop_end_stamp=None,
end_stamp_unique=SET['UN'],
keep_prev_subdivisions=SET['KS'],
keep_end_subdivisions=SET['KS'],
quick_print=SET['QP']):
"""
... | [
"def",
"timed_loop",
"(",
"name",
"=",
"None",
",",
"rgstr_stamps",
"=",
"None",
",",
"save_itrs",
"=",
"SET",
"[",
"'SI'",
"]",
",",
"loop_end_stamp",
"=",
"None",
",",
"end_stamp_unique",
"=",
"SET",
"[",
"'UN'",
"]",
",",
"keep_prev_subdivisions",
"=",
... | Instantiate a TimedLoop object for measuring loop iteration timing data.
Can be used with either for or while loops.
Example::
loop = timed_loop()
while x > 0: # or for x in <iterable>:
next(loop) # or loop.next()
<body of loop, with gtimer stamps>
loop.exit()... | [
"Instantiate",
"a",
"TimedLoop",
"object",
"for",
"measuring",
"loop",
"iteration",
"timing",
"data",
".",
"Can",
"be",
"used",
"with",
"either",
"for",
"or",
"while",
"loops",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timedloop.py#L13-L69 | train |
astooke/gtimer | gtimer/public/timedloop.py | timed_for | def timed_for(iterable,
name=None,
rgstr_stamps=None,
save_itrs=SET['SI'],
loop_end_stamp=None,
end_stamp_unique=SET['UN'],
keep_prev_subdivisions=SET['KS'],
keep_end_subdivisions=SET['KS'],
quick_print=SET['... | python | def timed_for(iterable,
name=None,
rgstr_stamps=None,
save_itrs=SET['SI'],
loop_end_stamp=None,
end_stamp_unique=SET['UN'],
keep_prev_subdivisions=SET['KS'],
keep_end_subdivisions=SET['KS'],
quick_print=SET['... | [
"def",
"timed_for",
"(",
"iterable",
",",
"name",
"=",
"None",
",",
"rgstr_stamps",
"=",
"None",
",",
"save_itrs",
"=",
"SET",
"[",
"'SI'",
"]",
",",
"loop_end_stamp",
"=",
"None",
",",
"end_stamp_unique",
"=",
"SET",
"[",
"'UN'",
"]",
",",
"keep_prev_su... | Instantiate a TimedLoop object for measuring for loop iteration timing data.
Can be used only on for loops.
Example::
for i in gtimer.timed_for(iterable, ..):
<body of loop with gtimer stamps>
Notes:
Can be used as a context manager around the loop. When breaking out of
... | [
"Instantiate",
"a",
"TimedLoop",
"object",
"for",
"measuring",
"for",
"loop",
"iteration",
"timing",
"data",
".",
"Can",
"be",
"used",
"only",
"on",
"for",
"loops",
"."
] | 2146dab459e5d959feb291821733d3d3ba7c523c | https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/timedloop.py#L72-L131 | train |
tamasgal/km3pipe | km3pipe/utils/calibrate.py | write_calibration | def write_calibration(calib, f, loc):
"""Write calibration set to file"""
for i, node in enumerate(
[p + '_' + s for p in ['pos', 'dir'] for s in 'xyz']):
h5loc = loc + '/' + node
ca = f.get_node(h5loc)
ca.append(calib[:, i])
du = f.get_node(loc + '/du')
du.append(calib[... | python | def write_calibration(calib, f, loc):
"""Write calibration set to file"""
for i, node in enumerate(
[p + '_' + s for p in ['pos', 'dir'] for s in 'xyz']):
h5loc = loc + '/' + node
ca = f.get_node(h5loc)
ca.append(calib[:, i])
du = f.get_node(loc + '/du')
du.append(calib[... | [
"def",
"write_calibration",
"(",
"calib",
",",
"f",
",",
"loc",
")",
":",
"for",
"i",
",",
"node",
"in",
"enumerate",
"(",
"[",
"p",
"+",
"'_'",
"+",
"s",
"for",
"p",
"in",
"[",
"'pos'",
",",
"'dir'",
"]",
"for",
"s",
"in",
"'xyz'",
"]",
")",
... | Write calibration set to file | [
"Write",
"calibration",
"set",
"to",
"file"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/calibrate.py#L87-L108 | train |
tamasgal/km3pipe | km3pipe/utils/calibrate.py | initialise_arrays | def initialise_arrays(group, f):
"""Create EArrays for calibrated hits"""
for node in ['pos_x', 'pos_y', 'pos_z', 'dir_x', 'dir_y', 'dir_z', 'du',
'floor', 't0']:
if node in ['floor', 'du']:
atom = U1_ATOM
else:
atom = F4_ATOM
f.create_earray(grou... | python | def initialise_arrays(group, f):
"""Create EArrays for calibrated hits"""
for node in ['pos_x', 'pos_y', 'pos_z', 'dir_x', 'dir_y', 'dir_z', 'du',
'floor', 't0']:
if node in ['floor', 'du']:
atom = U1_ATOM
else:
atom = F4_ATOM
f.create_earray(grou... | [
"def",
"initialise_arrays",
"(",
"group",
",",
"f",
")",
":",
"for",
"node",
"in",
"[",
"'pos_x'",
",",
"'pos_y'",
",",
"'pos_z'",
",",
"'dir_x'",
",",
"'dir_y'",
",",
"'dir_z'",
",",
"'du'",
",",
"'floor'",
",",
"'t0'",
"]",
":",
"if",
"node",
"in",... | Create EArrays for calibrated hits | [
"Create",
"EArrays",
"for",
"calibrated",
"hits"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/calibrate.py#L111-L119 | train |
tamasgal/km3pipe | km3pipe/io/aanet.py | AanetPump.blob_counter | def blob_counter(self):
"""Create a blob counter."""
import aa # pylint: disablF0401 # noqa
from ROOT import EventFile # pylint: disable F0401
try:
event_file = EventFile(self.filename)
except Exception:
raise SystemExit("Could not open file"... | python | def blob_counter(self):
"""Create a blob counter."""
import aa # pylint: disablF0401 # noqa
from ROOT import EventFile # pylint: disable F0401
try:
event_file = EventFile(self.filename)
except Exception:
raise SystemExit("Could not open file"... | [
"def",
"blob_counter",
"(",
"self",
")",
":",
"import",
"aa",
"from",
"ROOT",
"import",
"EventFile",
"try",
":",
"event_file",
"=",
"EventFile",
"(",
"self",
".",
"filename",
")",
"except",
"Exception",
":",
"raise",
"SystemExit",
"(",
"\"Could not open file\"... | Create a blob counter. | [
"Create",
"a",
"blob",
"counter",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/aanet.py#L248-L262 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.