repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
zsimic/runez
src/runez/program.py
get_dev_folder
def get_dev_folder(path=sys.prefix): """ :param str path: Path to examine :return str|None: Path to development build folder, such as .venv, .tox etc, if any """ if not path or len(path) <= 4: return None dirpath, basename = os.path.split(path) if basename in DEV_FOLDERS: ret...
python
def get_dev_folder(path=sys.prefix): """ :param str path: Path to examine :return str|None: Path to development build folder, such as .venv, .tox etc, if any """ if not path or len(path) <= 4: return None dirpath, basename = os.path.split(path) if basename in DEV_FOLDERS: ret...
[ "def", "get_dev_folder", "(", "path", "=", "sys", ".", "prefix", ")", ":", "if", "not", "path", "or", "len", "(", "path", ")", "<=", "4", ":", "return", "None", "dirpath", ",", "basename", "=", "os", ".", "path", ".", "split", "(", "path", ")", "...
:param str path: Path to examine :return str|None: Path to development build folder, such as .venv, .tox etc, if any
[ ":", "param", "str", "path", ":", "Path", "to", "examine", ":", "return", "str|None", ":", "Path", "to", "development", "build", "folder", "such", "as", ".", "venv", ".", "tox", "etc", "if", "any" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L33-L43
train
Get the path to the development build folder.
zsimic/runez
src/runez/program.py
is_younger
def is_younger(path, age): """ :param str|None path: Path to file :param int|float age: How many seconds to consider the file too old :return bool: True if file exists and is younger than 'age' seconds """ try: return time.time() - os.path.getmtime(path) < age except (OSError, TypeE...
python
def is_younger(path, age): """ :param str|None path: Path to file :param int|float age: How many seconds to consider the file too old :return bool: True if file exists and is younger than 'age' seconds """ try: return time.time() - os.path.getmtime(path) < age except (OSError, TypeE...
[ "def", "is_younger", "(", "path", ",", "age", ")", ":", "try", ":", "return", "time", ".", "time", "(", ")", "-", "os", ".", "path", ".", "getmtime", "(", "path", ")", "<", "age", "except", "(", "OSError", ",", "TypeError", ")", ":", "return", "F...
:param str|None path: Path to file :param int|float age: How many seconds to consider the file too old :return bool: True if file exists and is younger than 'age' seconds
[ ":", "param", "str|None", "path", ":", "Path", "to", "file", ":", "param", "int|float", "age", ":", "How", "many", "seconds", "to", "consider", "the", "file", "too", "old", ":", "return", "bool", ":", "True", "if", "file", "exists", "and", "is", "young...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L63-L73
train
Check if a file is younger than age seconds
zsimic/runez
src/runez/program.py
make_executable
def make_executable(path, fatal=True): """ :param str|None path: chmod file with 'path' as executable :param bool|None fatal: Abort execution on failure if True :return int: 1 if effectively done, 0 if no-op, -1 on failure """ if is_executable(path): return 0 if is_dryrun(): ...
python
def make_executable(path, fatal=True): """ :param str|None path: chmod file with 'path' as executable :param bool|None fatal: Abort execution on failure if True :return int: 1 if effectively done, 0 if no-op, -1 on failure """ if is_executable(path): return 0 if is_dryrun(): ...
[ "def", "make_executable", "(", "path", ",", "fatal", "=", "True", ")", ":", "if", "is_executable", "(", "path", ")", ":", "return", "0", "if", "is_dryrun", "(", ")", ":", "LOG", ".", "debug", "(", "\"Would make %s executable\"", ",", "short", "(", "path"...
:param str|None path: chmod file with 'path' as executable :param bool|None fatal: Abort execution on failure if True :return int: 1 if effectively done, 0 if no-op, -1 on failure
[ ":", "param", "str|None", "path", ":", "chmod", "file", "with", "path", "as", "executable", ":", "param", "bool|None", "fatal", ":", "Abort", "execution", "on", "failure", "if", "True", ":", "return", "int", ":", "1", "if", "effectively", "done", "0", "i...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L76-L97
train
Make a new executable file with the given path.
zsimic/runez
src/runez/program.py
run
def run(program, *args, **kwargs): """Run 'program' with 'args'""" args = flattened(args, split=SHELL) full_path = which(program) logger = kwargs.pop("logger", LOG.debug) fatal = kwargs.pop("fatal", True) dryrun = kwargs.pop("dryrun", is_dryrun()) include_error = kwargs.pop("include_error",...
python
def run(program, *args, **kwargs): """Run 'program' with 'args'""" args = flattened(args, split=SHELL) full_path = which(program) logger = kwargs.pop("logger", LOG.debug) fatal = kwargs.pop("fatal", True) dryrun = kwargs.pop("dryrun", is_dryrun()) include_error = kwargs.pop("include_error",...
[ "def", "run", "(", "program", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "flattened", "(", "args", ",", "split", "=", "SHELL", ")", "full_path", "=", "which", "(", "program", ")", "logger", "=", "kwargs", ".", "pop", "(", "...
Run 'program' with 'args
[ "Run", "program", "with", "args" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L100-L143
train
Run a program with the given arguments and return the output of the process.
zsimic/runez
src/runez/program.py
which
def which(program, ignore_own_venv=False): """ :param str|None program: Program name to find via env var PATH :param bool ignore_own_venv: If True, do not resolve to executables in current venv :return str|None: Full path to program, if one exists and is executable """ if not program: re...
python
def which(program, ignore_own_venv=False): """ :param str|None program: Program name to find via env var PATH :param bool ignore_own_venv: If True, do not resolve to executables in current venv :return str|None: Full path to program, if one exists and is executable """ if not program: re...
[ "def", "which", "(", "program", ",", "ignore_own_venv", "=", "False", ")", ":", "if", "not", "program", ":", "return", "None", "if", "os", ".", "path", ".", "isabs", "(", "program", ")", ":", "return", "program", "if", "is_executable", "(", "program", ...
:param str|None program: Program name to find via env var PATH :param bool ignore_own_venv: If True, do not resolve to executables in current venv :return str|None: Full path to program, if one exists and is executable
[ ":", "param", "str|None", "program", ":", "Program", "name", "to", "find", "via", "env", "var", "PATH", ":", "param", "bool", "ignore_own_venv", ":", "If", "True", "do", "not", "resolve", "to", "executables", "in", "current", "venv", ":", "return", "str|No...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L146-L160
train
Find the full path to a program in the current virtualenv.
zsimic/runez
src/runez/program.py
added_env_paths
def added_env_paths(env_vars, env=None): """ :param dict|None env_vars: Env vars to customize :param dict env: Original env vars """ if not env_vars: return None if not env: env = dict(os.environ) result = dict(env) for env_var, paths in env_vars.items(): separa...
python
def added_env_paths(env_vars, env=None): """ :param dict|None env_vars: Env vars to customize :param dict env: Original env vars """ if not env_vars: return None if not env: env = dict(os.environ) result = dict(env) for env_var, paths in env_vars.items(): separa...
[ "def", "added_env_paths", "(", "env_vars", ",", "env", "=", "None", ")", ":", "if", "not", "env_vars", ":", "return", "None", "if", "not", "env", ":", "env", "=", "dict", "(", "os", ".", "environ", ")", "result", "=", "dict", "(", "env", ")", "for"...
:param dict|None env_vars: Env vars to customize :param dict env: Original env vars
[ ":", "param", "dict|None", "env_vars", ":", "Env", "vars", "to", "customize", ":", "param", "dict", "env", ":", "Original", "env", "vars" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/program.py#L163-L190
train
Return a dict with the added environment paths.
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/department_request.py
DeptRequest.get_dept_name
def get_dept_name(self): """Method to get the department name""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("name", None)
python
def get_dept_name(self): """Method to get the department name""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("name", None)
[ "def", "get_dept_name", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "self", ".", "request_url", ")", ")", "return", "self", ".", "json_response", ".", "get", "(", "\"name\""...
Method to get the department name
[ "Method", "to", "get", "the", "department", "name" ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/department_request.py#L22-L25
train
Method to get the department name
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/department_request.py
DeptRequest.get_dept_manager_ids
def get_dept_manager_ids(self): """Method to get the id list of department manager.""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("deptManagerUseridList", None)
python
def get_dept_manager_ids(self): """Method to get the id list of department manager.""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("deptManagerUseridList", None)
[ "def", "get_dept_manager_ids", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "self", ".", "request_url", ")", ")", "return", "self", ".", "json_response", ".", "get", "(", "\"...
Method to get the id list of department manager.
[ "Method", "to", "get", "the", "id", "list", "of", "department", "manager", "." ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/department_request.py#L27-L30
train
Method to get the id list of department manager
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/department_request.py
DeptsRequest.get_depts
def get_depts(self, dept_name=None): """Method to get department by name.""" depts = self.json_response.get("department", None) params = self.kwargs.get("params", None) fetch_child = params.get("fetch_child", True) if params else True if dept_name is not None: d...
python
def get_depts(self, dept_name=None): """Method to get department by name.""" depts = self.json_response.get("department", None) params = self.kwargs.get("params", None) fetch_child = params.get("fetch_child", True) if params else True if dept_name is not None: d...
[ "def", "get_depts", "(", "self", ",", "dept_name", "=", "None", ")", ":", "depts", "=", "self", ".", "json_response", ".", "get", "(", "\"department\"", ",", "None", ")", "params", "=", "self", ".", "kwargs", ".", "get", "(", "\"params\"", ",", "None",...
Method to get department by name.
[ "Method", "to", "get", "department", "by", "name", "." ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/department_request.py#L52-L61
train
Method to get department by name.
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/department_request.py
SubDeptIdsRequest.get_sub_dept_ids
def get_sub_dept_ids(self): """Method to get the department list""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("sub_dept_id_list", None)
python
def get_sub_dept_ids(self): """Method to get the department list""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("sub_dept_id_list", None)
[ "def", "get_sub_dept_ids", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "self", ".", "request_url", ")", ")", "return", "self", ".", "json_response", ".", "get", "(", "\"sub_...
Method to get the department list
[ "Method", "to", "get", "the", "department", "list" ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/department_request.py#L81-L84
train
Method to get the department list
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/department_request.py
ParentDeptPathRequest.get_parent_dept_path
def get_parent_dept_path(self): """Method to get the department list""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("parentIds", None)
python
def get_parent_dept_path(self): """Method to get the department list""" self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return self.json_response.get("parentIds", None)
[ "def", "get_parent_dept_path", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "self", ".", "request_url", ")", ")", "return", "self", ".", "json_response", ".", "get", "(", "\"...
Method to get the department list
[ "Method", "to", "get", "the", "department", "list" ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/department_request.py#L105-L108
train
Method to get the parent department list
lsst-sqre/documenteer
documenteer/sphinxext/__init__.py
setup
def setup(app): """Wrapper for the `setup` functions of each individual extension module. """ jira.setup(app) lsstdocushare.setup(app) mockcoderefs.setup(app) packagetoctree.setup(app) remotecodeblock.setup(app) try: __version__ = get_distribution('documenteer').version exce...
python
def setup(app): """Wrapper for the `setup` functions of each individual extension module. """ jira.setup(app) lsstdocushare.setup(app) mockcoderefs.setup(app) packagetoctree.setup(app) remotecodeblock.setup(app) try: __version__ = get_distribution('documenteer').version exce...
[ "def", "setup", "(", "app", ")", ":", "jira", ".", "setup", "(", "app", ")", "lsstdocushare", ".", "setup", "(", "app", ")", "mockcoderefs", ".", "setup", "(", "app", ")", "packagetoctree", ".", "setup", "(", "app", ")", "remotecodeblock", ".", "setup"...
Wrapper for the `setup` functions of each individual extension module.
[ "Wrapper", "for", "the", "setup", "functions", "of", "each", "individual", "extension", "module", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/__init__.py#L25-L41
train
Wrapper for the setup functions of each individual extension module.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
task_ref_role
def task_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the target nodes created by the ``lsst-task`` directive. Parameters ---------- name The role name used in the document. rawtext The entire mar...
python
def task_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the target nodes created by the ``lsst-task`` directive. Parameters ---------- name The role name used in the document. rawtext The entire mar...
[ "def", "task_ref_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "# app = inliner.document.settings.env.app", "node", "=", "pending_task_xref", "(", "rawsource", ...
Process a role that references the target nodes created by the ``lsst-task`` directive. Parameters ---------- name The role name used in the document. rawtext The entire markup snippet, with role. text The text marked with the role. lineno The line number whe...
[ "Process", "a", "role", "that", "references", "the", "target", "nodes", "created", "by", "the", "lsst", "-", "task", "directive", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L89-L120
train
Process a role that references the target nodes created by the lsst - task directive.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
process_pending_task_xref_nodes
def process_pending_task_xref_nodes(app, doctree, fromdocname): """Process the ``pending_task_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-task-topic`` directives. """ logger = getLogger(__name__) env = app.builder.env for node in doctree.travers...
python
def process_pending_task_xref_nodes(app, doctree, fromdocname): """Process the ``pending_task_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-task-topic`` directives. """ logger = getLogger(__name__) env = app.builder.env for node in doctree.travers...
[ "def", "process_pending_task_xref_nodes", "(", "app", ",", "doctree", ",", "fromdocname", ")", ":", "logger", "=", "getLogger", "(", "__name__", ")", "env", "=", "app", ".", "builder", ".", "env", "for", "node", "in", "doctree", ".", "traverse", "(", "pend...
Process the ``pending_task_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-task-topic`` directives.
[ "Process", "the", "pending_task_xref", "nodes", "during", "the", "doctree", "-", "resolved", "event", "to", "insert", "links", "to", "the", "locations", "of", "lsst", "-", "task", "-", "topic", "directives", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L123-L173
train
Process the pending_task_xref nodes during the doctree - resolved event.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
config_ref_role
def config_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the target nodes created by the ``lsst-config-topic`` directive. Parameters ---------- name The role name used in the document. rawtext Th...
python
def config_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the target nodes created by the ``lsst-config-topic`` directive. Parameters ---------- name The role name used in the document. rawtext Th...
[ "def", "config_ref_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "node", "=", "pending_config_xref", "(", "rawsource", "=", "text", ")", "return", "[", ...
Process a role that references the target nodes created by the ``lsst-config-topic`` directive. Parameters ---------- name The role name used in the document. rawtext The entire markup snippet, with role. text The text marked with the role. lineno The line nu...
[ "Process", "a", "role", "that", "references", "the", "target", "nodes", "created", "by", "the", "lsst", "-", "config", "-", "topic", "directive", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L176-L212
train
Process a role that references the target nodes created by the lsst - config - topic directive.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
process_pending_config_xref_nodes
def process_pending_config_xref_nodes(app, doctree, fromdocname): """Process the ``pending_config_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-config-topic`` directives. See also -------- `config_ref_role` `ConfigTopicTargetDirective` `pendin...
python
def process_pending_config_xref_nodes(app, doctree, fromdocname): """Process the ``pending_config_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-config-topic`` directives. See also -------- `config_ref_role` `ConfigTopicTargetDirective` `pendin...
[ "def", "process_pending_config_xref_nodes", "(", "app", ",", "doctree", ",", "fromdocname", ")", ":", "logger", "=", "getLogger", "(", "__name__", ")", "env", "=", "app", ".", "builder", ".", "env", "for", "node", "in", "doctree", ".", "traverse", "(", "pe...
Process the ``pending_config_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of ``lsst-config-topic`` directives. See also -------- `config_ref_role` `ConfigTopicTargetDirective` `pending_config_xref`
[ "Process", "the", "pending_config_xref", "nodes", "during", "the", "doctree", "-", "resolved", "event", "to", "insert", "links", "to", "the", "locations", "of", "lsst", "-", "config", "-", "topic", "directives", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L215-L271
train
Process the pending_config_xref nodes during the doctree - resolved event.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
configfield_ref_role
def configfield_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the Task configuration field nodes created by the ``lsst-config-fields``, ``lsst-task-config-subtasks``, and ``lsst-task-config-subtasks`` directives. P...
python
def configfield_ref_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Process a role that references the Task configuration field nodes created by the ``lsst-config-fields``, ``lsst-task-config-subtasks``, and ``lsst-task-config-subtasks`` directives. P...
[ "def", "configfield_ref_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "node", "=", "pending_configfield_xref", "(", "rawsource", "=", "text", ")", "return...
Process a role that references the Task configuration field nodes created by the ``lsst-config-fields``, ``lsst-task-config-subtasks``, and ``lsst-task-config-subtasks`` directives. Parameters ---------- name The role name used in the document. rawtext The entire markup snippet,...
[ "Process", "a", "role", "that", "references", "the", "Task", "configuration", "field", "nodes", "created", "by", "the", "lsst", "-", "config", "-", "fields", "lsst", "-", "task", "-", "config", "-", "subtasks", "and", "lsst", "-", "task", "-", "config", ...
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L274-L311
train
Process a role that references the Task configuration field nodes.
lsst-sqre/documenteer
documenteer/sphinxext/lssttasks/crossrefs.py
process_pending_configfield_xref_nodes
def process_pending_configfield_xref_nodes(app, doctree, fromdocname): """Process the ``pending_configfield_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of configuration field nodes. See also -------- `format_configfield_id` `configfield_ref_role` ...
python
def process_pending_configfield_xref_nodes(app, doctree, fromdocname): """Process the ``pending_configfield_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of configuration field nodes. See also -------- `format_configfield_id` `configfield_ref_role` ...
[ "def", "process_pending_configfield_xref_nodes", "(", "app", ",", "doctree", ",", "fromdocname", ")", ":", "logger", "=", "getLogger", "(", "__name__", ")", "env", "=", "app", ".", "builder", ".", "env", "for", "node", "in", "doctree", ".", "traverse", "(", ...
Process the ``pending_configfield_xref`` nodes during the ``doctree-resolved`` event to insert links to the locations of configuration field nodes. See also -------- `format_configfield_id` `configfield_ref_role` `pending_configfield_xref`
[ "Process", "the", "pending_configfield_xref", "nodes", "during", "the", "doctree", "-", "resolved", "event", "to", "insert", "links", "to", "the", "locations", "of", "configuration", "field", "nodes", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lssttasks/crossrefs.py#L314-L377
train
Process the pending_configfield_xref nodes during the doctree - resolved event.
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.run
def run(self): """ Runs the scanner :return: self """ # Normalize path self.path = os.path.expanduser(self.path) # Start scanning if os.path.isdir(self.path): self.search_script_directory(self.path) return self else: ...
python
def run(self): """ Runs the scanner :return: self """ # Normalize path self.path = os.path.expanduser(self.path) # Start scanning if os.path.isdir(self.path): self.search_script_directory(self.path) return self else: ...
[ "def", "run", "(", "self", ")", ":", "# Normalize path", "self", ".", "path", "=", "os", ".", "path", ".", "expanduser", "(", "self", ".", "path", ")", "# Start scanning", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "path", ")", ":", "...
Runs the scanner :return: self
[ "Runs", "the", "scanner", ":", "return", ":", "self" ]
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L34-L48
train
Runs the scanner.
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.output
def output(self): """ Output the results to either STDOUT or :return: """ if not self.path_output: self.output_to_fd(sys.stdout) else: with open(self.path_output, "w") as out: self.output_to_fd(out)
python
def output(self): """ Output the results to either STDOUT or :return: """ if not self.path_output: self.output_to_fd(sys.stdout) else: with open(self.path_output, "w") as out: self.output_to_fd(out)
[ "def", "output", "(", "self", ")", ":", "if", "not", "self", ".", "path_output", ":", "self", ".", "output_to_fd", "(", "sys", ".", "stdout", ")", "else", ":", "with", "open", "(", "self", ".", "path_output", ",", "\"w\"", ")", "as", "out", ":", "s...
Output the results to either STDOUT or :return:
[ "Output", "the", "results", "to", "either", "STDOUT", "or", ":", "return", ":" ]
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L50-L59
train
Output the results to either STDOUT or the file descriptor.
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.output_to_fd
def output_to_fd(self, fd): """ Outputs the results of the scanner to a file descriptor (stdout counts :) :param fd: file :return: void """ for library in self.libraries_found: fd.write("%s==%s\n" % (library.key, library.version))
python
def output_to_fd(self, fd): """ Outputs the results of the scanner to a file descriptor (stdout counts :) :param fd: file :return: void """ for library in self.libraries_found: fd.write("%s==%s\n" % (library.key, library.version))
[ "def", "output_to_fd", "(", "self", ",", "fd", ")", ":", "for", "library", "in", "self", ".", "libraries_found", ":", "fd", ".", "write", "(", "\"%s==%s\\n\"", "%", "(", "library", ".", "key", ",", "library", ".", "version", ")", ")" ]
Outputs the results of the scanner to a file descriptor (stdout counts :) :param fd: file :return: void
[ "Outputs", "the", "results", "of", "the", "scanner", "to", "a", "file", "descriptor", "(", "stdout", "counts", ":", ")", ":", "param", "fd", ":", "file", ":", "return", ":", "void" ]
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L61-L68
train
Outputs the results of the scanner to a file descriptor
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.search_script_directory
def search_script_directory(self, path): """ Recursively loop through a directory to find all python script files. When one is found, it is analyzed for import statements :param path: string :return: generator """ for subdir, dirs, files in os.walk(path): ...
python
def search_script_directory(self, path): """ Recursively loop through a directory to find all python script files. When one is found, it is analyzed for import statements :param path: string :return: generator """ for subdir, dirs, files in os.walk(path): ...
[ "def", "search_script_directory", "(", "self", ",", "path", ")", ":", "for", "subdir", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "file_name", "in", "files", ":", "if", "file_name", ".", "endswith", "(", "\".py\""...
Recursively loop through a directory to find all python script files. When one is found, it is analyzed for import statements :param path: string :return: generator
[ "Recursively", "loop", "through", "a", "directory", "to", "find", "all", "python", "script", "files", ".", "When", "one", "is", "found", "it", "is", "analyzed", "for", "import", "statements", ":", "param", "path", ":", "string", ":", "return", ":", "genera...
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L70-L80
train
Recursively search a directory for all python script files.
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.search_script_file
def search_script_file(self, path, file_name): """ Open a script file and search it for library references :param path: :param file_name: :return: void """ with open(os.path.join(path, file_name), "r") as script: self.search_script(script.read())
python
def search_script_file(self, path, file_name): """ Open a script file and search it for library references :param path: :param file_name: :return: void """ with open(os.path.join(path, file_name), "r") as script: self.search_script(script.read())
[ "def", "search_script_file", "(", "self", ",", "path", ",", "file_name", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "path", ",", "file_name", ")", ",", "\"r\"", ")", "as", "script", ":", "self", ".", "search_script", "(", "sc...
Open a script file and search it for library references :param path: :param file_name: :return: void
[ "Open", "a", "script", "file", "and", "search", "it", "for", "library", "references", ":", "param", "path", ":", ":", "param", "file_name", ":", ":", "return", ":", "void" ]
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L82-L90
train
Search a script file and search it for library references
Paradoxis/PIP-Module-Scanner
pip_module_scanner/scanner.py
Scanner.search_script
def search_script(self, script): """ Search a script's contents for import statements and check if they're currently prevent in the list of all installed pip modules. :param script: string :return: void """ if self.import_statement.search(script): ...
python
def search_script(self, script): """ Search a script's contents for import statements and check if they're currently prevent in the list of all installed pip modules. :param script: string :return: void """ if self.import_statement.search(script): ...
[ "def", "search_script", "(", "self", ",", "script", ")", ":", "if", "self", ".", "import_statement", ".", "search", "(", "script", ")", ":", "for", "installed", "in", "self", ".", "libraries_installed", ":", "for", "found", "in", "set", "(", "self", ".",...
Search a script's contents for import statements and check if they're currently prevent in the list of all installed pip modules. :param script: string :return: void
[ "Search", "a", "script", "s", "contents", "for", "import", "statements", "and", "check", "if", "they", "re", "currently", "prevent", "in", "the", "list", "of", "all", "installed", "pip", "modules", ".", ":", "param", "script", ":", "string", ":", "return",...
168c62050b8217df0167b7d59405dcb1421cf50d
https://github.com/Paradoxis/PIP-Module-Scanner/blob/168c62050b8217df0167b7d59405dcb1421cf50d/pip_module_scanner/scanner.py#L92-L105
train
Search a script s contents for import statements and check pip modules.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/team.py
create
def create(context, name, country, active, parent_id): """create(context, name, country, active, parent_id) Create a team. >>> dcictl team-create [OPTIONS] :param string name: Name of the team [required] :param string country: Country code where the team is based :param boolean active: Set th...
python
def create(context, name, country, active, parent_id): """create(context, name, country, active, parent_id) Create a team. >>> dcictl team-create [OPTIONS] :param string name: Name of the team [required] :param string country: Country code where the team is based :param boolean active: Set th...
[ "def", "create", "(", "context", ",", "name", ",", "country", ",", "active", ",", "parent_id", ")", ":", "state", "=", "utils", ".", "active_string", "(", "active", ")", "result", "=", "team", ".", "create", "(", "context", ",", "name", "=", "name", ...
create(context, name, country, active, parent_id) Create a team. >>> dcictl team-create [OPTIONS] :param string name: Name of the team [required] :param string country: Country code where the team is based :param boolean active: Set the team in the (in)active state :param string parent_id: Th...
[ "create", "(", "context", "name", "country", "active", "parent_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/team.py#L55-L71
train
Create a new NCBI team.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/team.py
update
def update(context, id, etag, name, country, parent_id, active, external): """update(context, id, etag, name, country, parent_id, active, external) Update a team. >>> dcictl team-update [OPTIONS] :param string id: ID of the team to update [required] :param string etag: Entity tag of the resource ...
python
def update(context, id, etag, name, country, parent_id, active, external): """update(context, id, etag, name, country, parent_id, active, external) Update a team. >>> dcictl team-update [OPTIONS] :param string id: ID of the team to update [required] :param string etag: Entity tag of the resource ...
[ "def", "update", "(", "context", ",", "id", ",", "etag", ",", "name", ",", "country", ",", "parent_id", ",", "active", ",", "external", ")", ":", "result", "=", "team", ".", "update", "(", "context", ",", "id", "=", "id", ",", "etag", "=", "etag", ...
update(context, id, etag, name, country, parent_id, active, external) Update a team. >>> dcictl team-update [OPTIONS] :param string id: ID of the team to update [required] :param string etag: Entity tag of the resource [required] :param string name: Name of the team [required] :param string c...
[ "update", "(", "context", "id", "etag", "name", "country", "parent_id", "active", "external", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/team.py#L83-L104
train
Team update.
zsimic/runez
src/runez/config.py
capped
def capped(value, minimum=None, maximum=None): """ Args: value: Value to cap minimum: If specified, value should not be lower than this minimum maximum: If specified, value should not be higher than this maximum Returns: `value` capped to `minimum` and `maximum` (if it is ou...
python
def capped(value, minimum=None, maximum=None): """ Args: value: Value to cap minimum: If specified, value should not be lower than this minimum maximum: If specified, value should not be higher than this maximum Returns: `value` capped to `minimum` and `maximum` (if it is ou...
[ "def", "capped", "(", "value", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "if", "minimum", "is", "not", "None", "and", "value", "<", "minimum", ":", "return", "minimum", "if", "maximum", "is", "not", "None", "and", "value", "...
Args: value: Value to cap minimum: If specified, value should not be lower than this minimum maximum: If specified, value should not be higher than this maximum Returns: `value` capped to `minimum` and `maximum` (if it is outside of those bounds)
[ "Args", ":", "value", ":", "Value", "to", "cap", "minimum", ":", "If", "specified", "value", "should", "not", "be", "lower", "than", "this", "minimum", "maximum", ":", "If", "specified", "value", "should", "not", "be", "higher", "than", "this", "maximum" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L319-L335
train
Returns the value capped to the specified minimum and maximum.
zsimic/runez
src/runez/config.py
to_boolean
def to_boolean(value): """ Args: value (str | unicode | None): Value to convert to bool Returns: (bool): Deduced boolean value """ if value is not None: if str(value).lower() in TRUE_TOKENS: return True vfloat = to_number(float, value) if vfloat ...
python
def to_boolean(value): """ Args: value (str | unicode | None): Value to convert to bool Returns: (bool): Deduced boolean value """ if value is not None: if str(value).lower() in TRUE_TOKENS: return True vfloat = to_number(float, value) if vfloat ...
[ "def", "to_boolean", "(", "value", ")", ":", "if", "value", "is", "not", "None", ":", "if", "str", "(", "value", ")", ".", "lower", "(", ")", "in", "TRUE_TOKENS", ":", "return", "True", "vfloat", "=", "to_number", "(", "float", ",", "value", ")", "...
Args: value (str | unicode | None): Value to convert to bool Returns: (bool): Deduced boolean value
[ "Args", ":", "value", "(", "str", "|", "unicode", "|", "None", ")", ":", "Value", "to", "convert", "to", "bool" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L353-L369
train
Converts value to boolean
zsimic/runez
src/runez/config.py
to_bytesize
def to_bytesize(value, default_unit=None, base=DEFAULT_BASE): """Convert `value` to bytes, accepts notations such as "4k" to mean 4096 bytes Args: value (str | unicode | int | None): Number of bytes optionally suffixed by a char from UNITS default_unit (str | unicode | None): Default unit to us...
python
def to_bytesize(value, default_unit=None, base=DEFAULT_BASE): """Convert `value` to bytes, accepts notations such as "4k" to mean 4096 bytes Args: value (str | unicode | int | None): Number of bytes optionally suffixed by a char from UNITS default_unit (str | unicode | None): Default unit to us...
[ "def", "to_bytesize", "(", "value", ",", "default_unit", "=", "None", ",", "base", "=", "DEFAULT_BASE", ")", ":", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ")", ")", ":", "return", "unitized", "(", "value", ",", "default_unit", "...
Convert `value` to bytes, accepts notations such as "4k" to mean 4096 bytes Args: value (str | unicode | int | None): Number of bytes optionally suffixed by a char from UNITS default_unit (str | unicode | None): Default unit to use for unqualified values base (int): Base to use (usually 102...
[ "Convert", "value", "to", "bytes", "accepts", "notations", "such", "as", "4k", "to", "mean", "4096", "bytes" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L372-L404
train
Convert value to bytes
zsimic/runez
src/runez/config.py
to_dict
def to_dict(value, prefix=None, separators="=,"): """ Args: value: Value to turn into a dict prefix (str | unicode | None): Optional prefix for keys (if provided, `prefix.` is added to all keys) separators (str | unicode): 2 chars: 1st is assignment separator, 2nd is key-value pair separ...
python
def to_dict(value, prefix=None, separators="=,"): """ Args: value: Value to turn into a dict prefix (str | unicode | None): Optional prefix for keys (if provided, `prefix.` is added to all keys) separators (str | unicode): 2 chars: 1st is assignment separator, 2nd is key-value pair separ...
[ "def", "to_dict", "(", "value", ",", "prefix", "=", "None", ",", "separators", "=", "\"=,\"", ")", ":", "if", "not", "value", "or", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "value", "or", "{", "}", "result", "=", "{", "}", "for"...
Args: value: Value to turn into a dict prefix (str | unicode | None): Optional prefix for keys (if provided, `prefix.` is added to all keys) separators (str | unicode): 2 chars: 1st is assignment separator, 2nd is key-value pair separator Returns: (dict): Parse key/values
[ "Args", ":", "value", ":", "Value", "to", "turn", "into", "a", "dict", "prefix", "(", "str", "|", "unicode", "|", "None", ")", ":", "Optional", "prefix", "for", "keys", "(", "if", "provided", "prefix", ".", "is", "added", "to", "all", "keys", ")", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L407-L434
train
Converts a value to a dict.
zsimic/runez
src/runez/config.py
to_int
def to_int(value, default=None, minimum=None, maximum=None): """ Args: value: Value to convert default (int | None): Default to use `value` can't be turned into an int minimum (int | None): If specified, result can't be below this minimum maximum (int | None): If specified, resul...
python
def to_int(value, default=None, minimum=None, maximum=None): """ Args: value: Value to convert default (int | None): Default to use `value` can't be turned into an int minimum (int | None): If specified, result can't be below this minimum maximum (int | None): If specified, resul...
[ "def", "to_int", "(", "value", ",", "default", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "return", "to_number", "(", "int", ",", "value", ",", "default", "=", "default", ",", "minimum", "=", "minimum", ",", "max...
Args: value: Value to convert default (int | None): Default to use `value` can't be turned into an int minimum (int | None): If specified, result can't be below this minimum maximum (int | None): If specified, result can't be above this maximum Returns: (int | None): Corresp...
[ "Args", ":", "value", ":", "Value", "to", "convert", "default", "(", "int", "|", "None", ")", ":", "Default", "to", "use", "value", "can", "t", "be", "turned", "into", "an", "int", "minimum", "(", "int", "|", "None", ")", ":", "If", "specified", "r...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L437-L448
train
Converts a value to an integer value in the format.
zsimic/runez
src/runez/config.py
to_number
def to_number(result_type, value, default=None, minimum=None, maximum=None): """Cast `value` to numeric `result_type` if possible Args: result_type (type): Numerical type to convert to (one of: int, float, ...) value (str | unicode): Value to convert default (result_type.__class__ | Non...
python
def to_number(result_type, value, default=None, minimum=None, maximum=None): """Cast `value` to numeric `result_type` if possible Args: result_type (type): Numerical type to convert to (one of: int, float, ...) value (str | unicode): Value to convert default (result_type.__class__ | Non...
[ "def", "to_number", "(", "result_type", ",", "value", ",", "default", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "try", ":", "return", "capped", "(", "result_type", "(", "value", ")", ",", "minimum", ",", "maximum"...
Cast `value` to numeric `result_type` if possible Args: result_type (type): Numerical type to convert to (one of: int, float, ...) value (str | unicode): Value to convert default (result_type.__class__ | None): Default to use `value` can't be turned into an int minimum (result_type....
[ "Cast", "value", "to", "numeric", "result_type", "if", "possible" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L451-L468
train
Cast value to numeric result_type if possible
zsimic/runez
src/runez/config.py
unitized
def unitized(value, unit, base=DEFAULT_BASE): """ Args: value (int | float): Value to expand unit (str | unicode): Given unit (see UNITS) base (int): Base to use (usually 1024) Returns: Deduced value (example: "1k" becomes 1000) """ exponent = 0 if not unit else UNIT...
python
def unitized(value, unit, base=DEFAULT_BASE): """ Args: value (int | float): Value to expand unit (str | unicode): Given unit (see UNITS) base (int): Base to use (usually 1024) Returns: Deduced value (example: "1k" becomes 1000) """ exponent = 0 if not unit else UNIT...
[ "def", "unitized", "(", "value", ",", "unit", ",", "base", "=", "DEFAULT_BASE", ")", ":", "exponent", "=", "0", "if", "not", "unit", "else", "UNITS", ".", "index", "(", "unit", ")", "+", "1", "return", "int", "(", "value", "*", "(", "base", "**", ...
Args: value (int | float): Value to expand unit (str | unicode): Given unit (see UNITS) base (int): Base to use (usually 1024) Returns: Deduced value (example: "1k" becomes 1000)
[ "Args", ":", "value", "(", "int", "|", "float", ")", ":", "Value", "to", "expand", "unit", "(", "str", "|", "unicode", ")", ":", "Given", "unit", "(", "see", "UNITS", ")", "base", "(", "int", ")", ":", "Base", "to", "use", "(", "usually", "1024",...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L471-L482
train
Expand a value to a given unit
zsimic/runez
src/runez/config.py
Configuration.set_providers
def set_providers(self, *providers): """Replace current providers with given ones""" if self.providers: self.clear() for provider in providers: self.add(provider)
python
def set_providers(self, *providers): """Replace current providers with given ones""" if self.providers: self.clear() for provider in providers: self.add(provider)
[ "def", "set_providers", "(", "self", ",", "*", "providers", ")", ":", "if", "self", ".", "providers", ":", "self", ".", "clear", "(", ")", "for", "provider", "in", "providers", ":", "self", ".", "add", "(", "provider", ")" ]
Replace current providers with given ones
[ "Replace", "current", "providers", "with", "given", "ones" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L62-L67
train
Replace current providers with given ones
zsimic/runez
src/runez/config.py
Configuration.provider_id_slot
def provider_id_slot(self, other): """ Args: other (ConfigProvider): Provider to examine Returns: (int | None): Index of existing provider with same id, if any """ if other: pid = other.provider_id() for i, provider in enumerate(se...
python
def provider_id_slot(self, other): """ Args: other (ConfigProvider): Provider to examine Returns: (int | None): Index of existing provider with same id, if any """ if other: pid = other.provider_id() for i, provider in enumerate(se...
[ "def", "provider_id_slot", "(", "self", ",", "other", ")", ":", "if", "other", ":", "pid", "=", "other", ".", "provider_id", "(", ")", "for", "i", ",", "provider", "in", "enumerate", "(", "self", ".", "providers", ")", ":", "if", "provider", ".", "pr...
Args: other (ConfigProvider): Provider to examine Returns: (int | None): Index of existing provider with same id, if any
[ "Args", ":", "other", "(", "ConfigProvider", ")", ":", "Provider", "to", "examine" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L69-L83
train
Returns the index of existing provider with same id or None if no such provider exists.
zsimic/runez
src/runez/config.py
Configuration.use_propsfs
def use_propsfs(self, folder=None, front=False): """ Args: folder (str | unicode | None): Optional custom mount folder (defaults to /mnt/props on Linux, and /Volumes/props on OSX) front (bool): If True, add provider to front of list """ if folder is None: ...
python
def use_propsfs(self, folder=None, front=False): """ Args: folder (str | unicode | None): Optional custom mount folder (defaults to /mnt/props on Linux, and /Volumes/props on OSX) front (bool): If True, add provider to front of list """ if folder is None: ...
[ "def", "use_propsfs", "(", "self", ",", "folder", "=", "None", ",", "front", "=", "False", ")", ":", "if", "folder", "is", "None", ":", "folder", "=", "\"/%s/props\"", "%", "(", "\"Volumes\"", "if", "platform", ".", "system", "(", ")", ".", "lower", ...
Args: folder (str | unicode | None): Optional custom mount folder (defaults to /mnt/props on Linux, and /Volumes/props on OSX) front (bool): If True, add provider to front of list
[ "Args", ":", "folder", "(", "str", "|", "unicode", "|", "None", ")", ":", "Optional", "custom", "mount", "folder", "(", "defaults", "to", "/", "mnt", "/", "props", "on", "Linux", "and", "/", "Volumes", "/", "props", "on", "OSX", ")", "front", "(", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L85-L93
train
Add a new provider to list of propertiesfs providers.
zsimic/runez
src/runez/config.py
Configuration.use_cli
def use_cli(self, config, prefix=None, name="--config", front=True): """ Args: config: Multi-value option, typically tuple from click CLI flag such as --config prefix (str | unicode | None): Prefix to add to all parsed keys name (str | unicode): Name of cli flag ...
python
def use_cli(self, config, prefix=None, name="--config", front=True): """ Args: config: Multi-value option, typically tuple from click CLI flag such as --config prefix (str | unicode | None): Prefix to add to all parsed keys name (str | unicode): Name of cli flag ...
[ "def", "use_cli", "(", "self", ",", "config", ",", "prefix", "=", "None", ",", "name", "=", "\"--config\"", ",", "front", "=", "True", ")", ":", "if", "config", ":", "provider", "=", "DictProvider", "(", "to_dict", "(", "config", ",", "prefix", "=", ...
Args: config: Multi-value option, typically tuple from click CLI flag such as --config prefix (str | unicode | None): Prefix to add to all parsed keys name (str | unicode): Name of cli flag front (bool): If True, add provider to front of list
[ "Args", ":", "config", ":", "Multi", "-", "value", "option", "typically", "tuple", "from", "click", "CLI", "flag", "such", "as", "--", "config", "prefix", "(", "str", "|", "unicode", "|", "None", ")", ":", "Prefix", "to", "add", "to", "all", "parsed", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L95-L105
train
Add provider to list of keys available in CLI
zsimic/runez
src/runez/config.py
Configuration.use_json
def use_json(self, *paths): """ Args: *paths (str | unicode): Paths to files to add as static DictProvider-s, only existing files are added """ for path in paths: if path: fpath = os.path.expanduser(path) if os.path.exists(fpath): ...
python
def use_json(self, *paths): """ Args: *paths (str | unicode): Paths to files to add as static DictProvider-s, only existing files are added """ for path in paths: if path: fpath = os.path.expanduser(path) if os.path.exists(fpath): ...
[ "def", "use_json", "(", "self", ",", "*", "paths", ")", ":", "for", "path", "in", "paths", ":", "if", "path", ":", "fpath", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "if", "os", ".", "path", ".", "exists", "(", "fpath", ")", ...
Args: *paths (str | unicode): Paths to files to add as static DictProvider-s, only existing files are added
[ "Args", ":", "*", "paths", "(", "str", "|", "unicode", ")", ":", "Paths", "to", "files", "to", "add", "as", "static", "DictProvider", "-", "s", "only", "existing", "files", "are", "added" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L107-L118
train
Adds a DictProvider - s to the cache
zsimic/runez
src/runez/config.py
Configuration.add
def add(self, provider, front=False): """ Args: provider (ConfigProvider): Provider to add front (bool): If True, add provider to front of list """ if provider: i = self.provider_id_slot(provider) if i is not None: self.prov...
python
def add(self, provider, front=False): """ Args: provider (ConfigProvider): Provider to add front (bool): If True, add provider to front of list """ if provider: i = self.provider_id_slot(provider) if i is not None: self.prov...
[ "def", "add", "(", "self", ",", "provider", ",", "front", "=", "False", ")", ":", "if", "provider", ":", "i", "=", "self", ".", "provider_id_slot", "(", "provider", ")", "if", "i", "is", "not", "None", ":", "self", ".", "providers", "[", "i", "]", ...
Args: provider (ConfigProvider): Provider to add front (bool): If True, add provider to front of list
[ "Args", ":", "provider", "(", "ConfigProvider", ")", ":", "Provider", "to", "add", "front", "(", "bool", ")", ":", "If", "True", "add", "provider", "to", "front", "of", "list" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L120-L135
train
Adds a provider to the list of available providers.
zsimic/runez
src/runez/config.py
Configuration.get_str
def get_str(self, key, default=None): """ Args: key (str | unicode | None): Key to lookup default (str | unicode | None): Default to use if key is not configured Returns: (str | None): Value of key, if defined """ if key: for provi...
python
def get_str(self, key, default=None): """ Args: key (str | unicode | None): Key to lookup default (str | unicode | None): Default to use if key is not configured Returns: (str | None): Value of key, if defined """ if key: for provi...
[ "def", "get_str", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", ":", "for", "provider", "in", "self", ".", "providers", ":", "value", "=", "provider", ".", "get_str", "(", "key", ")", "if", "value", "is", "not", "None...
Args: key (str | unicode | None): Key to lookup default (str | unicode | None): Default to use if key is not configured Returns: (str | None): Value of key, if defined
[ "Args", ":", "key", "(", "str", "|", "unicode", "|", "None", ")", ":", "Key", "to", "lookup", "default", "(", "str", "|", "unicode", "|", "None", ")", ":", "Default", "to", "use", "if", "key", "is", "not", "configured" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L137-L152
train
Returns the string value of a key if it exists otherwise returns default
zsimic/runez
src/runez/config.py
Configuration.get_int
def get_int(self, key, default=None, minimum=None, maximum=None): """ Args: key (str | unicode): Key to lookup default (int | None): Default to use if key is not configured minimum (int | None): If specified, result can't be below this minimum maximum (int...
python
def get_int(self, key, default=None, minimum=None, maximum=None): """ Args: key (str | unicode): Key to lookup default (int | None): Default to use if key is not configured minimum (int | None): If specified, result can't be below this minimum maximum (int...
[ "def", "get_int", "(", "self", ",", "key", ",", "default", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "return", "to_number", "(", "int", ",", "self", ".", "get_str", "(", "key", ")", ",", "default", "=", "defau...
Args: key (str | unicode): Key to lookup default (int | None): Default to use if key is not configured minimum (int | None): If specified, result can't be below this minimum maximum (int | None): If specified, result can't be above this maximum Returns: ...
[ "Args", ":", "key", "(", "str", "|", "unicode", ")", ":", "Key", "to", "lookup", "default", "(", "int", "|", "None", ")", ":", "Default", "to", "use", "if", "key", "is", "not", "configured", "minimum", "(", "int", "|", "None", ")", ":", "If", "sp...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L154-L165
train
Returns the value of a key in the cache as an integer.
zsimic/runez
src/runez/config.py
Configuration.get_float
def get_float(self, key, default=None, minimum=None, maximum=None): """ Args: key (str | unicode): Key to lookup default (float | None): Default to use if key is not configured minimum (float | None): If specified, result can't be below this minimum maximu...
python
def get_float(self, key, default=None, minimum=None, maximum=None): """ Args: key (str | unicode): Key to lookup default (float | None): Default to use if key is not configured minimum (float | None): If specified, result can't be below this minimum maximu...
[ "def", "get_float", "(", "self", ",", "key", ",", "default", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ")", ":", "return", "to_number", "(", "float", ",", "self", ".", "get_str", "(", "key", ")", ",", "default", "=", "d...
Args: key (str | unicode): Key to lookup default (float | None): Default to use if key is not configured minimum (float | None): If specified, result can't be below this minimum maximum (float | None): If specified, result can't be above this maximum Returns: ...
[ "Args", ":", "key", "(", "str", "|", "unicode", ")", ":", "Key", "to", "lookup", "default", "(", "float", "|", "None", ")", ":", "Default", "to", "use", "if", "key", "is", "not", "configured", "minimum", "(", "float", "|", "None", ")", ":", "If", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L167-L178
train
Returns the value of a key in the national system if it exists otherwise returns default.
zsimic/runez
src/runez/config.py
Configuration.get_bool
def get_bool(self, key, default=None): """ Args: key (str | unicode): Key to lookup default (bool | None): Default to use if key is not configured Returns: (bool | None): Value of key, if defined """ value = self.get_str(key) if value...
python
def get_bool(self, key, default=None): """ Args: key (str | unicode): Key to lookup default (bool | None): Default to use if key is not configured Returns: (bool | None): Value of key, if defined """ value = self.get_str(key) if value...
[ "def", "get_bool", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "value", "=", "self", ".", "get_str", "(", "key", ")", "if", "value", "is", "not", "None", ":", "return", "to_boolean", "(", "value", ")", "return", "default" ]
Args: key (str | unicode): Key to lookup default (bool | None): Default to use if key is not configured Returns: (bool | None): Value of key, if defined
[ "Args", ":", "key", "(", "str", "|", "unicode", ")", ":", "Key", "to", "lookup", "default", "(", "bool", "|", "None", ")", ":", "Default", "to", "use", "if", "key", "is", "not", "configured" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L180-L194
train
Returns the boolean value of the specified key if it exists otherwise returns default
zsimic/runez
src/runez/config.py
Configuration.get_bytesize
def get_bytesize(self, key, default=None, minimum=None, maximum=None, default_unit=None, base=DEFAULT_BASE): """Size in bytes expressed by value configured under 'key' Args: key (str | unicode): Key to lookup default (int | str | unicode | None): Default to use if key is not con...
python
def get_bytesize(self, key, default=None, minimum=None, maximum=None, default_unit=None, base=DEFAULT_BASE): """Size in bytes expressed by value configured under 'key' Args: key (str | unicode): Key to lookup default (int | str | unicode | None): Default to use if key is not con...
[ "def", "get_bytesize", "(", "self", ",", "key", ",", "default", "=", "None", ",", "minimum", "=", "None", ",", "maximum", "=", "None", ",", "default_unit", "=", "None", ",", "base", "=", "DEFAULT_BASE", ")", ":", "value", "=", "to_bytesize", "(", "self...
Size in bytes expressed by value configured under 'key' Args: key (str | unicode): Key to lookup default (int | str | unicode | None): Default to use if key is not configured minimum (int | str | unicode | None): If specified, result can't be below this minimum m...
[ "Size", "in", "bytes", "expressed", "by", "value", "configured", "under", "key" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L196-L213
train
Returns the size in bytes expressed by value configured under key.
zsimic/runez
src/runez/config.py
Configuration.get_json
def get_json(self, key, default=None): """ Args: key (str | unicode): Key to lookup default (str | unicode | dict | list | None): Default to use if key is not configured Returns: (dict | list | str | int | None): Deserialized json, if any """ ...
python
def get_json(self, key, default=None): """ Args: key (str | unicode): Key to lookup default (str | unicode | dict | list | None): Default to use if key is not configured Returns: (dict | list | str | int | None): Deserialized json, if any """ ...
[ "def", "get_json", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "value", "=", "self", ".", "get_str", "(", "key", ")", "if", "value", "is", "not", "None", ":", "value", "=", "from_json", "(", "value", ")", "if", "value", "is", ...
Args: key (str | unicode): Key to lookup default (str | unicode | dict | list | None): Default to use if key is not configured Returns: (dict | list | str | int | None): Deserialized json, if any
[ "Args", ":", "key", "(", "str", "|", "unicode", ")", ":", "Key", "to", "lookup", "default", "(", "str", "|", "unicode", "|", "dict", "|", "list", "|", "None", ")", ":", "Default", "to", "use", "if", "key", "is", "not", "configured" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L215-L233
train
Returns the json value for the specified key
sfstpala/pcr
pcr/pbkdf2.py
pbkdf2
def pbkdf2(digestmod, password, salt, count, dk_length): """ PBKDF2, from PKCS #5 v2.0[1]. [1]: http://tools.ietf.org/html/rfc2898 For proper usage, see NIST Special Publication 800-132: http://csrc.nist.gov/publications/PubsSPs.html The arguments for this function are: digestmod...
python
def pbkdf2(digestmod, password, salt, count, dk_length): """ PBKDF2, from PKCS #5 v2.0[1]. [1]: http://tools.ietf.org/html/rfc2898 For proper usage, see NIST Special Publication 800-132: http://csrc.nist.gov/publications/PubsSPs.html The arguments for this function are: digestmod...
[ "def", "pbkdf2", "(", "digestmod", ",", "password", ",", "salt", ",", "count", ",", "dk_length", ")", ":", "def", "pbkdf2_function", "(", "pw", ",", "salt", ",", "count", ",", "i", ")", ":", "# in the first iteration, the hmac message is the salt", "# concatinat...
PBKDF2, from PKCS #5 v2.0[1]. [1]: http://tools.ietf.org/html/rfc2898 For proper usage, see NIST Special Publication 800-132: http://csrc.nist.gov/publications/PubsSPs.html The arguments for this function are: digestmod a crypographic hash constructor, such as hashlib.sha256 ...
[ "PBKDF2", "from", "PKCS", "#5", "v2", ".", "0", "[", "1", "]", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/pbkdf2.py#L22-L84
train
Return a sequence of key - value pairs for the specified key.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
install
def install(application, **kwargs): """Call this to install StatsD for the Tornado application. :param tornado.web.Application application: the application to install the collector into. :param kwargs: keyword parameters to pass to the :class:`StatsDCollector` initializer. :returns: :da...
python
def install(application, **kwargs): """Call this to install StatsD for the Tornado application. :param tornado.web.Application application: the application to install the collector into. :param kwargs: keyword parameters to pass to the :class:`StatsDCollector` initializer. :returns: :da...
[ "def", "install", "(", "application", ",", "*", "*", "kwargs", ")", ":", "if", "getattr", "(", "application", ",", "'statsd'", ",", "None", ")", "is", "not", "None", ":", "LOGGER", ".", "warning", "(", "'Statsd collector is already installed'", ")", "return"...
Call this to install StatsD for the Tornado application. :param tornado.web.Application application: the application to install the collector into. :param kwargs: keyword parameters to pass to the :class:`StatsDCollector` initializer. :returns: :data:`True` if the client was installed succe...
[ "Call", "this", "to", "install", "StatsD", "for", "the", "Tornado", "application", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L202-L234
train
Installs StatsD for the Tornado application.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsdMixin.record_timing
def record_timing(self, duration, *path): """Record a timing. This method records a timing to the application's namespace followed by a calculated path. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization pro...
python
def record_timing(self, duration, *path): """Record a timing. This method records a timing to the application's namespace followed by a calculated path. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization pro...
[ "def", "record_timing", "(", "self", ",", "duration", ",", "*", "path", ")", ":", "self", ".", "application", ".", "statsd", ".", "send", "(", "path", ",", "duration", "*", "1000.0", ",", "'ms'", ")" ]
Record a timing. This method records a timing to the application's namespace followed by a calculated path. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization process is little more than replacing periods wi...
[ "Record", "a", "timing", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L19-L32
train
Record a timing to the application s namespace followed by a calculated path.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsdMixin.increase_counter
def increase_counter(self, *path, **kwargs): """Increase a counter. This method increases a counter within the application's namespace. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization process is little mo...
python
def increase_counter(self, *path, **kwargs): """Increase a counter. This method increases a counter within the application's namespace. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization process is little mo...
[ "def", "increase_counter", "(", "self", ",", "*", "path", ",", "*", "*", "kwargs", ")", ":", "self", ".", "application", ".", "statsd", ".", "send", "(", "path", ",", "kwargs", ".", "get", "(", "'amount'", ",", "'1'", ")", ",", "'c'", ")" ]
Increase a counter. This method increases a counter within the application's namespace. Each element of `path` is converted to a string and normalized before joining the elements by periods. The normalization process is little more than replacing periods with dashes. ...
[ "Increase", "a", "counter", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L34-L48
train
Increase a counter within the application s namespace.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsdMixin.execution_timer
def execution_timer(self, *path): """ Record the time it takes to perform an arbitrary code block. :param path: elements of the metric path to record This method returns a context manager that records the amount of time spent inside of the context and submits a timing metric ...
python
def execution_timer(self, *path): """ Record the time it takes to perform an arbitrary code block. :param path: elements of the metric path to record This method returns a context manager that records the amount of time spent inside of the context and submits a timing metric ...
[ "def", "execution_timer", "(", "self", ",", "*", "path", ")", ":", "start", "=", "time", ".", "time", "(", ")", "try", ":", "yield", "finally", ":", "self", ".", "record_timing", "(", "max", "(", "start", ",", "time", ".", "time", "(", ")", ")", ...
Record the time it takes to perform an arbitrary code block. :param path: elements of the metric path to record This method returns a context manager that records the amount of time spent inside of the context and submits a timing metric to the specified `path` using (:meth:`record_tim...
[ "Record", "the", "time", "it", "takes", "to", "perform", "an", "arbitrary", "code", "block", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L51-L66
train
A context manager that records the time spent inside of the context and submits a timing metric to the specified path.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsdMixin.on_finish
def on_finish(self): """ Records the time taken to process the request. This method records the amount of time taken to process the request (as reported by :meth:`~tornado.httputil.HTTPServerRequest.request_time`) under the path defined by the class's module, it's name, ...
python
def on_finish(self): """ Records the time taken to process the request. This method records the amount of time taken to process the request (as reported by :meth:`~tornado.httputil.HTTPServerRequest.request_time`) under the path defined by the class's module, it's name, ...
[ "def", "on_finish", "(", "self", ")", ":", "super", "(", ")", ".", "on_finish", "(", ")", "self", ".", "record_timing", "(", "self", ".", "request", ".", "request_time", "(", ")", ",", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "req...
Records the time taken to process the request. This method records the amount of time taken to process the request (as reported by :meth:`~tornado.httputil.HTTPServerRequest.request_time`) under the path defined by the class's module, it's name, the request method, and the statu...
[ "Records", "the", "time", "taken", "to", "process", "the", "request", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L68-L83
train
Called by the server when the request has finished processing.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsDCollector._tcp_socket
def _tcp_socket(self): """Connect to statsd via TCP and return the IOStream handle. :rtype: iostream.IOStream """ sock = iostream.IOStream(socket.socket( socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)) sock.connect(self._address, self._tcp_on_connecte...
python
def _tcp_socket(self): """Connect to statsd via TCP and return the IOStream handle. :rtype: iostream.IOStream """ sock = iostream.IOStream(socket.socket( socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)) sock.connect(self._address, self._tcp_on_connecte...
[ "def", "_tcp_socket", "(", "self", ")", ":", "sock", "=", "iostream", ".", "IOStream", "(", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ",", "socket", ".", "IPPROTO_TCP", ")", ")", "sock", ".", "connect", ...
Connect to statsd via TCP and return the IOStream handle. :rtype: iostream.IOStream
[ "Connect", "to", "statsd", "via", "TCP", "and", "return", "the", "IOStream", "handle", ".", ":", "rtype", ":", "iostream", ".", "IOStream" ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L125-L133
train
Connect to statsd via TCP and return the IOStream handle.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsDCollector._tcp_on_closed
async def _tcp_on_closed(self): """Invoked when the socket is closed.""" LOGGER.warning('Not connected to statsd, connecting in %s seconds', self._tcp_reconnect_sleep) await asyncio.sleep(self._tcp_reconnect_sleep) self._sock = self._tcp_socket()
python
async def _tcp_on_closed(self): """Invoked when the socket is closed.""" LOGGER.warning('Not connected to statsd, connecting in %s seconds', self._tcp_reconnect_sleep) await asyncio.sleep(self._tcp_reconnect_sleep) self._sock = self._tcp_socket()
[ "async", "def", "_tcp_on_closed", "(", "self", ")", ":", "LOGGER", ".", "warning", "(", "'Not connected to statsd, connecting in %s seconds'", ",", "self", ".", "_tcp_reconnect_sleep", ")", "await", "asyncio", ".", "sleep", "(", "self", ".", "_tcp_reconnect_sleep", ...
Invoked when the socket is closed.
[ "Invoked", "when", "the", "socket", "is", "closed", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L135-L140
train
Invoked when the socket is closed.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsDCollector.send
def send(self, path, value, metric_type): """Send a metric to Statsd. :param list path: The metric path to record :param mixed value: The value to record :param str metric_type: The metric type """ msg = self._msg_format.format( path=self._build_path(path, m...
python
def send(self, path, value, metric_type): """Send a metric to Statsd. :param list path: The metric path to record :param mixed value: The value to record :param str metric_type: The metric type """ msg = self._msg_format.format( path=self._build_path(path, m...
[ "def", "send", "(", "self", ",", "path", ",", "value", ",", "metric_type", ")", ":", "msg", "=", "self", ".", "_msg_format", ".", "format", "(", "path", "=", "self", ".", "_build_path", "(", "path", ",", "metric_type", ")", ",", "value", "=", "value"...
Send a metric to Statsd. :param list path: The metric path to record :param mixed value: The value to record :param str metric_type: The metric type
[ "Send", "a", "metric", "to", "Statsd", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L146-L172
train
Send a metric to Statsd.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsDCollector._build_path
def _build_path(self, path, metric_type): """Return a normalized path. :param list path: elements of the metric path to record :param str metric_type: The metric type :rtype: str """ path = self._get_prefixes(metric_type) + list(path) return '{}.{}'.format(self....
python
def _build_path(self, path, metric_type): """Return a normalized path. :param list path: elements of the metric path to record :param str metric_type: The metric type :rtype: str """ path = self._get_prefixes(metric_type) + list(path) return '{}.{}'.format(self....
[ "def", "_build_path", "(", "self", ",", "path", ",", "metric_type", ")", ":", "path", "=", "self", ".", "_get_prefixes", "(", "metric_type", ")", "+", "list", "(", "path", ")", "return", "'{}.{}'", ".", "format", "(", "self", ".", "_namespace", ",", "'...
Return a normalized path. :param list path: elements of the metric path to record :param str metric_type: The metric type :rtype: str
[ "Return", "a", "normalized", "path", "." ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L174-L184
train
Build a normalized path.
sprockets/sprockets.mixins.metrics
sprockets/mixins/metrics/statsd.py
StatsDCollector._get_prefixes
def _get_prefixes(self, metric_type): """Get prefixes where applicable Add metric prefix counters, timers respectively if :attr:`prepend_metric_type` flag is True. :param str metric_type: The metric type :rtype: list """ prefixes = [] if self._prepend_m...
python
def _get_prefixes(self, metric_type): """Get prefixes where applicable Add metric prefix counters, timers respectively if :attr:`prepend_metric_type` flag is True. :param str metric_type: The metric type :rtype: list """ prefixes = [] if self._prepend_m...
[ "def", "_get_prefixes", "(", "self", ",", "metric_type", ")", ":", "prefixes", "=", "[", "]", "if", "self", ".", "_prepend_metric_type", ":", "prefixes", ".", "append", "(", "self", ".", "METRIC_TYPES", "[", "metric_type", "]", ")", "return", "prefixes" ]
Get prefixes where applicable Add metric prefix counters, timers respectively if :attr:`prepend_metric_type` flag is True. :param str metric_type: The metric type :rtype: list
[ "Get", "prefixes", "where", "applicable" ]
0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0
https://github.com/sprockets/sprockets.mixins.metrics/blob/0b17d5f0c09a2be9db779e17e6789d3d5ff9a0d0/sprockets/mixins/metrics/statsd.py#L186-L199
train
Get the list of prefixes where applicable is a list of metric prefixes.
mesbahamin/chronophore
chronophore/qtview.py
QtChronophoreUI._set_signed_in
def _set_signed_in(self): """Populate the signed_in list with the names of currently signed in users. """ names = [ controller.get_user_name(user, full_name=CONFIG['FULL_USER_NAMES']) for user in controller.signed_in_users() ] self.lbl_signedin_lis...
python
def _set_signed_in(self): """Populate the signed_in list with the names of currently signed in users. """ names = [ controller.get_user_name(user, full_name=CONFIG['FULL_USER_NAMES']) for user in controller.signed_in_users() ] self.lbl_signedin_lis...
[ "def", "_set_signed_in", "(", "self", ")", ":", "names", "=", "[", "controller", ".", "get_user_name", "(", "user", ",", "full_name", "=", "CONFIG", "[", "'FULL_USER_NAMES'", "]", ")", "for", "user", "in", "controller", ".", "signed_in_users", "(", ")", "]...
Populate the signed_in list with the names of currently signed in users.
[ "Populate", "the", "signed_in", "list", "with", "the", "names", "of", "currently", "signed", "in", "users", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/qtview.py#L127-L135
train
Populate the signed_in list with the names of currently signed in users.
mesbahamin/chronophore
chronophore/qtview.py
QtChronophoreUI._show_feedback_label
def _show_feedback_label(self, message, seconds=None): """Display a message in lbl_feedback, which times out after some number of seconds. """ if seconds is None: seconds = CONFIG['MESSAGE_DURATION'] logger.debug('Label feedback: "{}"'.format(message)) self....
python
def _show_feedback_label(self, message, seconds=None): """Display a message in lbl_feedback, which times out after some number of seconds. """ if seconds is None: seconds = CONFIG['MESSAGE_DURATION'] logger.debug('Label feedback: "{}"'.format(message)) self....
[ "def", "_show_feedback_label", "(", "self", ",", "message", ",", "seconds", "=", "None", ")", ":", "if", "seconds", "is", "None", ":", "seconds", "=", "CONFIG", "[", "'MESSAGE_DURATION'", "]", "logger", ".", "debug", "(", "'Label feedback: \"{}\"'", ".", "fo...
Display a message in lbl_feedback, which times out after some number of seconds.
[ "Display", "a", "message", "in", "lbl_feedback", "which", "times", "out", "after", "some", "number", "of", "seconds", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/qtview.py#L137-L149
train
Display a message in lbl_feedback which times out after some number of seconds.
mesbahamin/chronophore
chronophore/qtview.py
QtChronophoreUI._sign_button_press
def _sign_button_press(self): """Validate input from ent_id, then sign in to the Timesheet.""" user_id = self.ent_id.text().strip() try: status = controller.sign(user_id) # ERROR: User type is unknown (!student and !tutor) except ValueError as e: logger....
python
def _sign_button_press(self): """Validate input from ent_id, then sign in to the Timesheet.""" user_id = self.ent_id.text().strip() try: status = controller.sign(user_id) # ERROR: User type is unknown (!student and !tutor) except ValueError as e: logger....
[ "def", "_sign_button_press", "(", "self", ")", ":", "user_id", "=", "self", ".", "ent_id", ".", "text", "(", ")", ".", "strip", "(", ")", "try", ":", "status", "=", "controller", ".", "sign", "(", "user_id", ")", "# ERROR: User type is unknown (!student and ...
Validate input from ent_id, then sign in to the Timesheet.
[ "Validate", "input", "from", "ent_id", "then", "sign", "in", "to", "the", "Timesheet", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/qtview.py#L159-L228
train
Validate input from ent_id then sign in to the Timesheet.
mesbahamin/chronophore
chronophore/qtview.py
QtUserTypeSelectionDialog.update_user_type
def update_user_type(self): """Return either 'tutor' or 'student' based on which radio button is selected. """ if self.rb_tutor.isChecked(): self.user_type = 'tutor' elif self.rb_student.isChecked(): self.user_type = 'student' self.accept()
python
def update_user_type(self): """Return either 'tutor' or 'student' based on which radio button is selected. """ if self.rb_tutor.isChecked(): self.user_type = 'tutor' elif self.rb_student.isChecked(): self.user_type = 'student' self.accept()
[ "def", "update_user_type", "(", "self", ")", ":", "if", "self", ".", "rb_tutor", ".", "isChecked", "(", ")", ":", "self", ".", "user_type", "=", "'tutor'", "elif", "self", ".", "rb_student", ".", "isChecked", "(", ")", ":", "self", ".", "user_type", "=...
Return either 'tutor' or 'student' based on which radio button is selected.
[ "Return", "either", "tutor", "or", "student", "based", "on", "which", "radio", "button", "is", "selected", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/qtview.py#L278-L286
train
Update user type based on which radio is selected.
mojaie/chorus
chorus/draw/calc2dcoords.py
calc2dcoords
def calc2dcoords(mol): """ Calculate optimal 2D coordinates of chemical structure """ topology.recognize(mol) g = set(i for i, _ in mol.atoms_iter()) # 1: get nodes in scaffolds scaffolds = [] belongs = {} for i, rkeys in enumerate(sorted(mol.scaffolds, key=len)): scf = [] ...
python
def calc2dcoords(mol): """ Calculate optimal 2D coordinates of chemical structure """ topology.recognize(mol) g = set(i for i, _ in mol.atoms_iter()) # 1: get nodes in scaffolds scaffolds = [] belongs = {} for i, rkeys in enumerate(sorted(mol.scaffolds, key=len)): scf = [] ...
[ "def", "calc2dcoords", "(", "mol", ")", ":", "topology", ".", "recognize", "(", "mol", ")", "g", "=", "set", "(", "i", "for", "i", ",", "_", "in", "mol", ".", "atoms_iter", "(", ")", ")", "# 1: get nodes in scaffolds", "scaffolds", "=", "[", "]", "be...
Calculate optimal 2D coordinates of chemical structure
[ "Calculate", "optimal", "2D", "coordinates", "of", "chemical", "structure" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/calc2dcoords.py#L16-L95
train
Calculate optimal 2D coordinates of chemical structure
mojaie/chorus
chorus/draw/calc2dcoords.py
scaffold_coords
def scaffold_coords(rings): """ assign scaffold coordinate and angle {node: (coords, angle)} """ rs = deque(sorted(rings, key=len, reverse=True)) base = rs.popleft() first = base[0] coords = {first: [0, 0, 0, 1]} attach_spiro(coords, base, first) # display(coords) while rs: ...
python
def scaffold_coords(rings): """ assign scaffold coordinate and angle {node: (coords, angle)} """ rs = deque(sorted(rings, key=len, reverse=True)) base = rs.popleft() first = base[0] coords = {first: [0, 0, 0, 1]} attach_spiro(coords, base, first) # display(coords) while rs: ...
[ "def", "scaffold_coords", "(", "rings", ")", ":", "rs", "=", "deque", "(", "sorted", "(", "rings", ",", "key", "=", "len", ",", "reverse", "=", "True", ")", ")", "base", "=", "rs", ".", "popleft", "(", ")", "first", "=", "base", "[", "0", "]", ...
assign scaffold coordinate and angle {node: (coords, angle)}
[ "assign", "scaffold", "coordinate", "and", "angle", "{", "node", ":", "(", "coords", "angle", ")", "}" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/calc2dcoords.py#L111-L133
train
assign scaffold coordinate and angle to the tree
pereorga/csvshuf
csvshuf/csvshuf.py
shuffle_sattolo
def shuffle_sattolo(items): """Shuffle items in place using Sattolo's algorithm.""" _randrange = random.randrange for i in reversed(range(1, len(items))): j = _randrange(i) # 0 <= j < i items[j], items[i] = items[i], items[j]
python
def shuffle_sattolo(items): """Shuffle items in place using Sattolo's algorithm.""" _randrange = random.randrange for i in reversed(range(1, len(items))): j = _randrange(i) # 0 <= j < i items[j], items[i] = items[i], items[j]
[ "def", "shuffle_sattolo", "(", "items", ")", ":", "_randrange", "=", "random", ".", "randrange", "for", "i", "in", "reversed", "(", "range", "(", "1", ",", "len", "(", "items", ")", ")", ")", ":", "j", "=", "_randrange", "(", "i", ")", "# 0 <= j < i"...
Shuffle items in place using Sattolo's algorithm.
[ "Shuffle", "items", "in", "place", "using", "Sattolo", "s", "algorithm", "." ]
70fdd4f512ef980bffe9cc51bfe59fea116d7c2f
https://github.com/pereorga/csvshuf/blob/70fdd4f512ef980bffe9cc51bfe59fea116d7c2f/csvshuf/csvshuf.py#L19-L24
train
Shuffle items in place using Sattolo s algorithm.
pereorga/csvshuf
csvshuf/csvshuf.py
column_list
def column_list(string): """Validate and convert comma-separated list of column numbers.""" try: columns = list(map(int, string.split(','))) except ValueError as e: raise argparse.ArgumentTypeError(*e.args) for column in columns: if column < 1: raise argparse.Argument...
python
def column_list(string): """Validate and convert comma-separated list of column numbers.""" try: columns = list(map(int, string.split(','))) except ValueError as e: raise argparse.ArgumentTypeError(*e.args) for column in columns: if column < 1: raise argparse.Argument...
[ "def", "column_list", "(", "string", ")", ":", "try", ":", "columns", "=", "list", "(", "map", "(", "int", ",", "string", ".", "split", "(", "','", ")", ")", ")", "except", "ValueError", "as", "e", ":", "raise", "argparse", ".", "ArgumentTypeError", ...
Validate and convert comma-separated list of column numbers.
[ "Validate", "and", "convert", "comma", "-", "separated", "list", "of", "column", "numbers", "." ]
70fdd4f512ef980bffe9cc51bfe59fea116d7c2f
https://github.com/pereorga/csvshuf/blob/70fdd4f512ef980bffe9cc51bfe59fea116d7c2f/csvshuf/csvshuf.py#L27-L38
train
Validate and convert comma - separated list of column numbers.
pereorga/csvshuf
csvshuf/csvshuf.py
main
def main(): parser = argparse.ArgumentParser(description='Shuffle columns in a CSV file') parser.add_argument(metavar="FILE", dest='input_file', type=argparse.FileType('r'), nargs='?', default=sys.stdin, help='Input CSV file. If omitted, read standard input.') parser.add_argument('-s...
python
def main(): parser = argparse.ArgumentParser(description='Shuffle columns in a CSV file') parser.add_argument(metavar="FILE", dest='input_file', type=argparse.FileType('r'), nargs='?', default=sys.stdin, help='Input CSV file. If omitted, read standard input.') parser.add_argument('-s...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Shuffle columns in a CSV file'", ")", "parser", ".", "add_argument", "(", "metavar", "=", "\"FILE\"", ",", "dest", "=", "'input_file'", ",", "type", "=",...
Get the first row and use it as column headers
[ "Get", "the", "first", "row", "and", "use", "it", "as", "column", "headers" ]
70fdd4f512ef980bffe9cc51bfe59fea116d7c2f
https://github.com/pereorga/csvshuf/blob/70fdd4f512ef980bffe9cc51bfe59fea116d7c2f/csvshuf/csvshuf.py#L41-L101
train
Main function for the sample.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/file.py
list
def list(context, job_id, sort, limit, where, verbose): """list(context, sort, limit, where, verbose) List all files. >>> dcictl file-list job-id [OPTIONS] :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criter...
python
def list(context, job_id, sort, limit, where, verbose): """list(context, sort, limit, where, verbose) List all files. >>> dcictl file-list job-id [OPTIONS] :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criter...
[ "def", "list", "(", "context", ",", "job_id", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "result", "=", "job", ".", "list_files", "(", "context", ",", "id", "=", "job_id", ",", "sort", "=", "sort", ",", "limit", "=", "limit"...
list(context, sort, limit, where, verbose) List all files. >>> dcictl file-list job-id [OPTIONS] :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criteria :param boolean verbose: Display verbose output
[ "list", "(", "context", "sort", "limit", "where", "verbose", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/file.py#L35-L49
train
list - List all files in a node
redhat-cip/python-dciclient
dciclient/v1/shell_commands/file.py
show
def show(context, id): """show(context, id) Show a file. >>> dcictl file-show [OPTIONS] :param string id: ID of the file to show [required] """ content = file.content(context, id=id) click.echo(content.text)
python
def show(context, id): """show(context, id) Show a file. >>> dcictl file-show [OPTIONS] :param string id: ID of the file to show [required] """ content = file.content(context, id=id) click.echo(content.text)
[ "def", "show", "(", "context", ",", "id", ")", ":", "content", "=", "file", ".", "content", "(", "context", ",", "id", "=", "id", ")", "click", ".", "echo", "(", "content", ".", "text", ")" ]
show(context, id) Show a file. >>> dcictl file-show [OPTIONS] :param string id: ID of the file to show [required]
[ "show", "(", "context", "id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/file.py#L55-L65
train
Show a file.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.get
def get(self, keyword): """Return the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automat...
python
def get(self, keyword): """Return the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automat...
[ "def", "get", "(", "self", ",", "keyword", ")", ":", "if", "not", "keyword", ".", "startswith", "(", "':'", ")", ":", "keyword", "=", "':'", "+", "keyword", "for", "i", ",", "s", "in", "enumerate", "(", "self", ".", "data", ")", ":", "if", "s", ...
Return the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automatically (e.g. "keyword" will be foun...
[ "Return", "the", "element", "of", "the", "list", "after", "the", "given", "keyword", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L44-L72
train
Return the element of the list after the given keyword.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.gets
def gets(self, keyword): """Return the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is ad...
python
def gets(self, keyword): """Return the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is ad...
[ "def", "gets", "(", "self", ",", "keyword", ")", ":", "param", "=", "self", ".", "get", "(", "keyword", ")", "if", "param", "is", "not", "None", ":", "return", "safe_decode", "(", "param", ".", "string_value", "(", ")", ")", "return", "None" ]
Return the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automatically (e.g. "keyword" wi...
[ "Return", "the", "element", "of", "the", "list", "after", "the", "given", "keyword", "as", "string", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L74-L97
train
Returns the element of the list after the given keyword as string.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.append
def append(self, obj): """Append an element to the end of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list. """ if isinstance(obj, str): obj...
python
def append(self, obj): """Append an element to the end of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list. """ if isinstance(obj, str): obj...
[ "def", "append", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "obj", "=", "KQMLToken", "(", "obj", ")", "self", ".", "data", ".", "append", "(", "obj", ")" ]
Append an element to the end of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list.
[ "Append", "an", "element", "to", "the", "end", "of", "the", "list", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L100-L111
train
Append an element to the end of the list.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.push
def push(self, obj): """Prepend an element to the beginnging of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list. """ if isinstance(obj, str): ...
python
def push(self, obj): """Prepend an element to the beginnging of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list. """ if isinstance(obj, str): ...
[ "def", "push", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "obj", "=", "KQMLToken", "(", "obj", ")", "self", ".", "data", ".", "insert", "(", "0", ",", "obj", ")" ]
Prepend an element to the beginnging of the list. Parameters ---------- obj : KQMLObject or str If a string is passed, it is instantiated as a KQMLToken before being added to the list.
[ "Prepend", "an", "element", "to", "the", "beginnging", "of", "the", "list", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L113-L124
train
Push an element to the beginning of the list.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.set
def set(self, keyword, value): """Set the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added aut...
python
def set(self, keyword, value): """Set the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added aut...
[ "def", "set", "(", "self", ",", "keyword", ",", "value", ")", ":", "if", "not", "keyword", ".", "startswith", "(", "':'", ")", ":", "keyword", "=", "':'", "+", "keyword", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "KQMLTo...
Set the element of the list after the given keyword. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automatically (e.g. "keyword" will be found a...
[ "Set", "the", "element", "of", "the", "list", "after", "the", "given", "keyword", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L149-L182
train
Set the element of the list after the given keyword.
bgyori/pykqml
kqml/kqml_list.py
KQMLList.sets
def sets(self, keyword, value): """Set the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it i...
python
def sets(self, keyword, value): """Set the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it i...
[ "def", "sets", "(", "self", ",", "keyword", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "KQMLString", "(", "value", ")", "self", ".", "set", "(", "keyword", ",", "value", ")" ]
Set the element of the list after the given keyword as string. Parameters ---------- keyword : str The keyword parameter to find in the list. Putting a colon before the keyword is optional, if no colon is given, it is added automatically (e.g. "keyword" will ...
[ "Set", "the", "element", "of", "the", "list", "after", "the", "given", "keyword", "as", "string", "." ]
c18b39868626215deb634567c6bd7c0838e443c0
https://github.com/bgyori/pykqml/blob/c18b39868626215deb634567c6bd7c0838e443c0/kqml/kqml_list.py#L184-L204
train
Sets the element of the list after the given keyword as string.
mastro35/flows
flows/ConfigManager.py
ConfigManager.default_instance
def default_instance(): """ For use like a singleton, return the existing instance of the object or a new instance """ if ConfigManager._instance is None: with threading.Lock(): if ConfigManager._instance is None: ConfigManager._ins...
python
def default_instance(): """ For use like a singleton, return the existing instance of the object or a new instance """ if ConfigManager._instance is None: with threading.Lock(): if ConfigManager._instance is None: ConfigManager._ins...
[ "def", "default_instance", "(", ")", ":", "if", "ConfigManager", ".", "_instance", "is", "None", ":", "with", "threading", ".", "Lock", "(", ")", ":", "if", "ConfigManager", ".", "_instance", "is", "None", ":", "ConfigManager", ".", "_instance", "=", "Conf...
For use like a singleton, return the existing instance of the object or a new instance
[ "For", "use", "like", "a", "singleton", "return", "the", "existing", "instance", "of", "the", "object", "or", "a", "new", "instance" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/ConfigManager.py#L44-L54
train
Return the default instance of ConfigManager.
mastro35/flows
flows/ConfigManager.py
ConfigManager.read_recipe
def read_recipe(self, filename): """ Read a recipe file from disk """ Global.LOGGER.debug(f"reading recipe {filename}") if not os.path.isfile(filename): Global.LOGGER.error(filename + " recipe not found, skipping") return config = configparser.Con...
python
def read_recipe(self, filename): """ Read a recipe file from disk """ Global.LOGGER.debug(f"reading recipe {filename}") if not os.path.isfile(filename): Global.LOGGER.error(filename + " recipe not found, skipping") return config = configparser.Con...
[ "def", "read_recipe", "(", "self", ",", "filename", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "f\"reading recipe {filename}\"", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "Global", ".", "LOGGER", ".", "erro...
Read a recipe file from disk
[ "Read", "a", "recipe", "file", "from", "disk" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/ConfigManager.py#L56-L73
train
Read a recipe file from disk and store it in self. sections.
mastro35/flows
flows/ConfigManager.py
ConfigManager.set_socket_address
def set_socket_address(self): """ Set a random port to be used by zmq """ Global.LOGGER.debug('defining socket addresses for zmq') random.seed() default_port = random.randrange(5001, 5999) internal_0mq_address = "tcp://127.0.0.1" internal_0mq_port...
python
def set_socket_address(self): """ Set a random port to be used by zmq """ Global.LOGGER.debug('defining socket addresses for zmq') random.seed() default_port = random.randrange(5001, 5999) internal_0mq_address = "tcp://127.0.0.1" internal_0mq_port...
[ "def", "set_socket_address", "(", "self", ")", ":", "Global", ".", "LOGGER", ".", "debug", "(", "'defining socket addresses for zmq'", ")", "random", ".", "seed", "(", ")", "default_port", "=", "random", ".", "randrange", "(", "5001", ",", "5999", ")", "inte...
Set a random port to be used by zmq
[ "Set", "a", "random", "port", "to", "be", "used", "by", "zmq" ]
05e488385673a69597b5b39c7728795aa4d5eb18
https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/ConfigManager.py#L75-L93
train
Set a random port to be used by zmq
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_quantities
def get_quantities(self, quantities, filters=None, native_filters=None, return_iterator=False): """ Fetch quantities from this catalog. Parameters ---------- quantities : str or list of str or tuple of str quantities to fetch filters : list of tuple, or GCRQ...
python
def get_quantities(self, quantities, filters=None, native_filters=None, return_iterator=False): """ Fetch quantities from this catalog. Parameters ---------- quantities : str or list of str or tuple of str quantities to fetch filters : list of tuple, or GCRQ...
[ "def", "get_quantities", "(", "self", ",", "quantities", ",", "filters", "=", "None", ",", "native_filters", "=", "None", ",", "return_iterator", "=", "False", ")", ":", "quantities", "=", "self", ".", "_preprocess_requested_quantities", "(", "quantities", ")", ...
Fetch quantities from this catalog. Parameters ---------- quantities : str or list of str or tuple of str quantities to fetch filters : list of tuple, or GCRQuery instance, optional filters to apply. Each filter should be in the format of (callable, str, str, .....
[ "Fetch", "quantities", "from", "this", "catalog", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L41-L77
train
Fetch the requested quantities from this catalog.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.has_quantity
def has_quantity(self, quantity, include_native=True): """ Check if *quantity* is available in this catalog Parameters ---------- quantity : str a quantity name to check include_native : bool, optional whether or not to include native quantity na...
python
def has_quantity(self, quantity, include_native=True): """ Check if *quantity* is available in this catalog Parameters ---------- quantity : str a quantity name to check include_native : bool, optional whether or not to include native quantity na...
[ "def", "has_quantity", "(", "self", ",", "quantity", ",", "include_native", "=", "True", ")", ":", "if", "include_native", ":", "return", "all", "(", "q", "in", "self", ".", "_native_quantities", "for", "q", "in", "self", ".", "_translate_quantities", "(", ...
Check if *quantity* is available in this catalog Parameters ---------- quantity : str a quantity name to check include_native : bool, optional whether or not to include native quantity names when checking Returns ------- has_quantity : b...
[ "Check", "if", "*", "quantity", "*", "is", "available", "in", "this", "catalog" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L79-L100
train
Check if quantity is available in this catalog.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.has_quantities
def has_quantities(self, quantities, include_native=True): """ Check if ALL *quantities* specified are available in this catalog Parameters ---------- quantities : iterable a list of quantity names to check include_native : bool, optional whether...
python
def has_quantities(self, quantities, include_native=True): """ Check if ALL *quantities* specified are available in this catalog Parameters ---------- quantities : iterable a list of quantity names to check include_native : bool, optional whether...
[ "def", "has_quantities", "(", "self", ",", "quantities", ",", "include_native", "=", "True", ")", ":", "quantities", "=", "set", "(", "quantities", ")", "if", "include_native", ":", "return", "all", "(", "q", "in", "self", ".", "_native_quantities", "for", ...
Check if ALL *quantities* specified are available in this catalog Parameters ---------- quantities : iterable a list of quantity names to check include_native : bool, optional whether or not to include native quantity names when checking Returns ...
[ "Check", "if", "ALL", "*", "quantities", "*", "specified", "are", "available", "in", "this", "catalog" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L102-L124
train
Checks if ALL quantities specified are available in this catalog.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.list_all_quantities
def list_all_quantities(self, include_native=False, with_info=False): """ Return a list of all available quantities in this catalog. If *include_native* is `True`, includes native quantities. If *with_info* is `True`, return a dict with quantity info. See also: list_all_native_...
python
def list_all_quantities(self, include_native=False, with_info=False): """ Return a list of all available quantities in this catalog. If *include_native* is `True`, includes native quantities. If *with_info* is `True`, return a dict with quantity info. See also: list_all_native_...
[ "def", "list_all_quantities", "(", "self", ",", "include_native", "=", "False", ",", "with_info", "=", "False", ")", ":", "q", "=", "set", "(", "self", ".", "_quantity_modifiers", ")", "if", "include_native", ":", "q", ".", "update", "(", "self", ".", "_...
Return a list of all available quantities in this catalog. If *include_native* is `True`, includes native quantities. If *with_info* is `True`, return a dict with quantity info. See also: list_all_native_quantities
[ "Return", "a", "list", "of", "all", "available", "quantities", "in", "this", "catalog", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L126-L138
train
Return a list of all available quantities in this catalog.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.list_all_native_quantities
def list_all_native_quantities(self, with_info=False): """ Return a list of all available native quantities in this catalog. If *with_info* is `True`, return a dict with quantity info. See also: list_all_quantities """ q = self._native_quantities return {k: self...
python
def list_all_native_quantities(self, with_info=False): """ Return a list of all available native quantities in this catalog. If *with_info* is `True`, return a dict with quantity info. See also: list_all_quantities """ q = self._native_quantities return {k: self...
[ "def", "list_all_native_quantities", "(", "self", ",", "with_info", "=", "False", ")", ":", "q", "=", "self", ".", "_native_quantities", "return", "{", "k", ":", "self", ".", "get_quantity_info", "(", "k", ")", "for", "k", "in", "q", "}", "if", "with_inf...
Return a list of all available native quantities in this catalog. If *with_info* is `True`, return a dict with quantity info. See also: list_all_quantities
[ "Return", "a", "list", "of", "all", "available", "native", "quantities", "in", "this", "catalog", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L140-L149
train
Return a list of all available native quantities in this catalog.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.first_available
def first_available(self, *quantities): """ Return the first available quantity in the input arguments. Return `None` if none of them is available. """ for i, q in enumerate(quantities): if self.has_quantity(q): if i: warnings.warn(...
python
def first_available(self, *quantities): """ Return the first available quantity in the input arguments. Return `None` if none of them is available. """ for i, q in enumerate(quantities): if self.has_quantity(q): if i: warnings.warn(...
[ "def", "first_available", "(", "self", ",", "*", "quantities", ")", ":", "for", "i", ",", "q", "in", "enumerate", "(", "quantities", ")", ":", "if", "self", ".", "has_quantity", "(", "q", ")", ":", "if", "i", ":", "warnings", ".", "warn", "(", "'{}...
Return the first available quantity in the input arguments. Return `None` if none of them is available.
[ "Return", "the", "first", "available", "quantity", "in", "the", "input", "arguments", ".", "Return", "None", "if", "none", "of", "them", "is", "available", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L151-L160
train
Return the first available quantity in the input arguments.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_input_kwargs
def get_input_kwargs(self, key=None, default=None): """ Deprecated. Use `get_catalog_info` instead. Get information from the catalog config file. If *key* is `None`, return the full dict. """ warnings.warn("`get_input_kwargs` is deprecated; use `get_catalog_info` instead...
python
def get_input_kwargs(self, key=None, default=None): """ Deprecated. Use `get_catalog_info` instead. Get information from the catalog config file. If *key* is `None`, return the full dict. """ warnings.warn("`get_input_kwargs` is deprecated; use `get_catalog_info` instead...
[ "def", "get_input_kwargs", "(", "self", ",", "key", "=", "None", ",", "default", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"`get_input_kwargs` is deprecated; use `get_catalog_info` instead.\"", ",", "DeprecationWarning", ")", "return", "self", ".", "get...
Deprecated. Use `get_catalog_info` instead. Get information from the catalog config file. If *key* is `None`, return the full dict.
[ "Deprecated", ".", "Use", "get_catalog_info", "instead", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L162-L170
train
Deprecated. Use get_catalog_info instead.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_catalog_info
def get_catalog_info(self, key=None, default=None): """ Get information from the catalog config file. If *key* is `None`, return the full dict. """ if key is None: return self._init_kwargs return self._init_kwargs.get(key, default)
python
def get_catalog_info(self, key=None, default=None): """ Get information from the catalog config file. If *key* is `None`, return the full dict. """ if key is None: return self._init_kwargs return self._init_kwargs.get(key, default)
[ "def", "get_catalog_info", "(", "self", ",", "key", "=", "None", ",", "default", "=", "None", ")", ":", "if", "key", "is", "None", ":", "return", "self", ".", "_init_kwargs", "return", "self", ".", "_init_kwargs", ".", "get", "(", "key", ",", "default"...
Get information from the catalog config file. If *key* is `None`, return the full dict.
[ "Get", "information", "from", "the", "catalog", "config", "file", ".", "If", "*", "key", "*", "is", "None", "return", "the", "full", "dict", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L172-L180
train
Get information from the catalog config file.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_quantity_info
def get_quantity_info(self, quantity, key=None, default=None): """ Get information of a certain quantity. If *key* is `None`, return the full dict for that quantity. """ d = self._get_quantity_info_dict(quantity, default if key is None else dict()) if key is None: ...
python
def get_quantity_info(self, quantity, key=None, default=None): """ Get information of a certain quantity. If *key* is `None`, return the full dict for that quantity. """ d = self._get_quantity_info_dict(quantity, default if key is None else dict()) if key is None: ...
[ "def", "get_quantity_info", "(", "self", ",", "quantity", ",", "key", "=", "None", ",", "default", "=", "None", ")", ":", "d", "=", "self", ".", "_get_quantity_info_dict", "(", "quantity", ",", "default", "if", "key", "is", "None", "else", "dict", "(", ...
Get information of a certain quantity. If *key* is `None`, return the full dict for that quantity.
[ "Get", "information", "of", "a", "certain", "quantity", ".", "If", "*", "key", "*", "is", "None", "return", "the", "full", "dict", "for", "that", "quantity", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L182-L192
train
Get information of a certain quantity.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_quantity_modifier
def add_quantity_modifier(self, quantity, modifier, overwrite=False): """ Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifi...
python
def add_quantity_modifier(self, quantity, modifier, overwrite=False): """ Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifi...
[ "def", "add_quantity_modifier", "(", "self", ",", "quantity", ",", "modifier", ",", "overwrite", "=", "False", ")", ":", "if", "quantity", "in", "self", ".", "_quantity_modifiers", "and", "not", "overwrite", ":", "raise", "ValueError", "(", "'quantity `{}` alrea...
Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifier : None or str or tuple If the quantity modifier is a tuple of length >=2 an...
[ "Add", "a", "quantify", "modifier", ".", "Consider", "useing", "the", "high", "-", "level", "function", "add_derived_quantity", "instead!" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L194-L217
train
Add a quantity modifier to the internal quantity list.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_normalized_quantity_modifier
def get_normalized_quantity_modifier(self, quantity): """ Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of...
python
def get_normalized_quantity_modifier(self, quantity): """ Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of...
[ "def", "get_normalized_quantity_modifier", "(", "self", ",", "quantity", ")", ":", "modifier", "=", "self", ".", "_quantity_modifiers", ".", "get", "(", "quantity", ",", "self", ".", "_default_quantity_modifier", ")", "if", "modifier", "is", "None", ":", "return...
Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of the derived quantity to get Returns ------- tupl...
[ "Retrive", "a", "quantify", "modifier", "normalized", ".", "This", "function", "would", "also", "return", "a", "tuple", "with", "the", "first", "item", "a", "callable", "and", "the", "rest", "native", "quantity", "names" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L234-L259
train
Retrive a quantify modifier
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_derived_quantity
def add_derived_quantity(self, derived_quantity, func, *quantities): """ Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quan...
python
def add_derived_quantity(self, derived_quantity, func, *quantities): """ Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quan...
[ "def", "add_derived_quantity", "(", "self", ",", "derived_quantity", ",", "func", ",", "*", "quantities", ")", ":", "if", "derived_quantity", "in", "self", ".", "_quantity_modifiers", ":", "raise", "ValueError", "(", "'quantity name `{}` already exists'", ".", "form...
Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quantity the number of arguments should equal number of following `quantities` ...
[ "Add", "a", "derived", "quantify", "modifier", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L261-L304
train
Adds a derived quantity modifier to the internal list of related items.
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_modifier_on_derived_quantities
def add_modifier_on_derived_quantities(self, new_quantity, func, *quantities): """ Deprecated. Use `add_derived_quantity` instead. """ warnings.warn("Use `add_derived_quantity` instead.", DeprecationWarning) self.add_derived_quantity(new_quantity, func, *quantities)
python
def add_modifier_on_derived_quantities(self, new_quantity, func, *quantities): """ Deprecated. Use `add_derived_quantity` instead. """ warnings.warn("Use `add_derived_quantity` instead.", DeprecationWarning) self.add_derived_quantity(new_quantity, func, *quantities)
[ "def", "add_modifier_on_derived_quantities", "(", "self", ",", "new_quantity", ",", "func", ",", "*", "quantities", ")", ":", "warnings", ".", "warn", "(", "\"Use `add_derived_quantity` instead.\"", ",", "DeprecationWarning", ")", "self", ".", "add_derived_quantity", ...
Deprecated. Use `add_derived_quantity` instead.
[ "Deprecated", ".", "Use", "add_derived_quantity", "instead", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L306-L311
train
Add a modifier to the derived quantity list.
brutus/wdiffhtml
wdiffhtml/utils.py
check_for_wdiff
def check_for_wdiff(): """ Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found. """ cmd = ['which', CMD_WDIFF] DEVNULL = open(os.devnull, 'wb') proc = sub.Popen(cmd, stdout=DEVNULL) proc.wait() DEVNULL.close() if proc.returncode != 0: msg = "t...
python
def check_for_wdiff(): """ Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found. """ cmd = ['which', CMD_WDIFF] DEVNULL = open(os.devnull, 'wb') proc = sub.Popen(cmd, stdout=DEVNULL) proc.wait() DEVNULL.close() if proc.returncode != 0: msg = "t...
[ "def", "check_for_wdiff", "(", ")", ":", "cmd", "=", "[", "'which'", ",", "CMD_WDIFF", "]", "DEVNULL", "=", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "proc", "=", "sub", ".", "Popen", "(", "cmd", ",", "stdout", "=", "DEVNULL", ")", "proc...
Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found.
[ "Checks", "if", "the", "wdiff", "command", "can", "be", "found", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L36-L52
train
Checks if the wdiff command can be found.
brutus/wdiffhtml
wdiffhtml/utils.py
generate_wdiff
def generate_wdiff(org_file, new_file, fold_tags=False, html=True): """ Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span l...
python
def generate_wdiff(org_file, new_file, fold_tags=False, html=True): """ Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span l...
[ "def", "generate_wdiff", "(", "org_file", ",", "new_file", ",", "fold_tags", "=", "False", ",", "html", "=", "True", ")", ":", "check_for_wdiff", "(", ")", "cmd", "=", "[", "CMD_WDIFF", "]", "if", "html", ":", "cmd", ".", "extend", "(", "OPTIONS_OUTPUT",...
Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span line breaks (option `-n` is not used). Raises: subrocess.CalledProc...
[ "Returns", "the", "results", "from", "the", "wdiff", "command", "as", "a", "string", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L55-L79
train
Generates a WDIFF file from the given org_file and new_file.
brutus/wdiffhtml
wdiffhtml/utils.py
build_paragraph
def build_paragraph(content, hard_breaks=False): """ Returns *content* wrapped in `<p>` tags. If *hard_breaks* is `True`, all line breaks are converted to `<br />` tags. """ lines = list(filter(None, [line.strip() for line in content.split('\n')])) if hard_breaks: for line_number in range(len(lines) -...
python
def build_paragraph(content, hard_breaks=False): """ Returns *content* wrapped in `<p>` tags. If *hard_breaks* is `True`, all line breaks are converted to `<br />` tags. """ lines = list(filter(None, [line.strip() for line in content.split('\n')])) if hard_breaks: for line_number in range(len(lines) -...
[ "def", "build_paragraph", "(", "content", ",", "hard_breaks", "=", "False", ")", ":", "lines", "=", "list", "(", "filter", "(", "None", ",", "[", "line", ".", "strip", "(", ")", "for", "line", "in", "content", ".", "split", "(", "'\\n'", ")", "]", ...
Returns *content* wrapped in `<p>` tags. If *hard_breaks* is `True`, all line breaks are converted to `<br />` tags.
[ "Returns", "*", "content", "*", "wrapped", "in", "<p", ">", "tags", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L82-L93
train
Build a paragraph from a string.
brutus/wdiffhtml
wdiffhtml/utils.py
wrap_paragraphs
def wrap_paragraphs(content, hard_breaks=False): """ Returns *content* with all paragraphs wrapped in `<p>` tags. If *hard_breaks* is set, line breaks are converted to `<br />` tags. """ paras = filter(None, [para.strip() for para in content.split('\n\n')]) paras = [build_paragraph(para, hard_breaks) for ...
python
def wrap_paragraphs(content, hard_breaks=False): """ Returns *content* with all paragraphs wrapped in `<p>` tags. If *hard_breaks* is set, line breaks are converted to `<br />` tags. """ paras = filter(None, [para.strip() for para in content.split('\n\n')]) paras = [build_paragraph(para, hard_breaks) for ...
[ "def", "wrap_paragraphs", "(", "content", ",", "hard_breaks", "=", "False", ")", ":", "paras", "=", "filter", "(", "None", ",", "[", "para", ".", "strip", "(", ")", "for", "para", "in", "content", ".", "split", "(", "'\\n\\n'", ")", "]", ")", "paras"...
Returns *content* with all paragraphs wrapped in `<p>` tags. If *hard_breaks* is set, line breaks are converted to `<br />` tags.
[ "Returns", "*", "content", "*", "with", "all", "paragraphs", "wrapped", "in", "<p", ">", "tags", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L96-L105
train
Wraps paragraphs in a string.
brutus/wdiffhtml
wdiffhtml/utils.py
wrap_content
def wrap_content(content, settings, hard_breaks=False): """ Returns *content* wrapped in a HTML structure. If *hard_breaks* is set, line breaks are converted to `<br />` tags. """ settings.context['content'] = wrap_paragraphs(content, hard_breaks) template = Template(settings.template) try: return t...
python
def wrap_content(content, settings, hard_breaks=False): """ Returns *content* wrapped in a HTML structure. If *hard_breaks* is set, line breaks are converted to `<br />` tags. """ settings.context['content'] = wrap_paragraphs(content, hard_breaks) template = Template(settings.template) try: return t...
[ "def", "wrap_content", "(", "content", ",", "settings", ",", "hard_breaks", "=", "False", ")", ":", "settings", ".", "context", "[", "'content'", "]", "=", "wrap_paragraphs", "(", "content", ",", "hard_breaks", ")", "template", "=", "Template", "(", "setting...
Returns *content* wrapped in a HTML structure. If *hard_breaks* is set, line breaks are converted to `<br />` tags.
[ "Returns", "*", "content", "*", "wrapped", "in", "a", "HTML", "structure", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L108-L121
train
Wrap content in a HTML structure.
mesbahamin/chronophore
chronophore/tkview.py
TkChronophoreUI._set_signed_in
def _set_signed_in(self): """Populate the signed_in list with the names of currently signed in users. """ names = [ controller.get_user_name(user, full_name=CONFIG['FULL_USER_NAMES']) for user in controller.signed_in_users() ] self.signed_in.set('\...
python
def _set_signed_in(self): """Populate the signed_in list with the names of currently signed in users. """ names = [ controller.get_user_name(user, full_name=CONFIG['FULL_USER_NAMES']) for user in controller.signed_in_users() ] self.signed_in.set('\...
[ "def", "_set_signed_in", "(", "self", ")", ":", "names", "=", "[", "controller", ".", "get_user_name", "(", "user", ",", "full_name", "=", "CONFIG", "[", "'FULL_USER_NAMES'", "]", ")", "for", "user", "in", "controller", ".", "signed_in_users", "(", ")", "]...
Populate the signed_in list with the names of currently signed in users.
[ "Populate", "the", "signed_in", "list", "with", "the", "names", "of", "currently", "signed", "in", "users", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L126-L134
train
Populate the signed_in list with the names of currently signed in users.
mesbahamin/chronophore
chronophore/tkview.py
TkChronophoreUI._show_feedback_label
def _show_feedback_label(self, message, seconds=None): """Display a message in lbl_feedback, which then times out after some number of seconds. Use after() to schedule a callback to hide the feedback message. This works better than using threads, which can cause problems in Tk. "...
python
def _show_feedback_label(self, message, seconds=None): """Display a message in lbl_feedback, which then times out after some number of seconds. Use after() to schedule a callback to hide the feedback message. This works better than using threads, which can cause problems in Tk. "...
[ "def", "_show_feedback_label", "(", "self", ",", "message", ",", "seconds", "=", "None", ")", ":", "if", "seconds", "is", "None", ":", "seconds", "=", "CONFIG", "[", "'MESSAGE_DURATION'", "]", "# cancel any existing callback to clear the feedback", "# label. this prev...
Display a message in lbl_feedback, which then times out after some number of seconds. Use after() to schedule a callback to hide the feedback message. This works better than using threads, which can cause problems in Tk.
[ "Display", "a", "message", "in", "lbl_feedback", "which", "then", "times", "out", "after", "some", "number", "of", "seconds", ".", "Use", "after", "()", "to", "schedule", "a", "callback", "to", "hide", "the", "feedback", "message", ".", "This", "works", "b...
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L136-L155
train
Display a message in lbl_feedback which then times out after some number of seconds.
mesbahamin/chronophore
chronophore/tkview.py
TkChronophoreUI._sign_button_press
def _sign_button_press(self, *args): """Validate input from ent_id, then sign in to the Timesheet.""" user_id = self.ent_id.get().strip() try: status = controller.sign(user_id) # ERROR: User type is unknown (!student and !tutor) except ValueError as e: l...
python
def _sign_button_press(self, *args): """Validate input from ent_id, then sign in to the Timesheet.""" user_id = self.ent_id.get().strip() try: status = controller.sign(user_id) # ERROR: User type is unknown (!student and !tutor) except ValueError as e: l...
[ "def", "_sign_button_press", "(", "self", ",", "*", "args", ")", ":", "user_id", "=", "self", ".", "ent_id", ".", "get", "(", ")", ".", "strip", "(", ")", "try", ":", "status", "=", "controller", ".", "sign", "(", "user_id", ")", "# ERROR: User type is...
Validate input from ent_id, then sign in to the Timesheet.
[ "Validate", "input", "from", "ent_id", "then", "sign", "in", "to", "the", "Timesheet", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L169-L227
train
Sign in to the Timesheet.
mesbahamin/chronophore
chronophore/tkview.py
TkUserTypeSelectionDialog.body
def body(self, master): """Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog """ self.frame = ttk.Frame(master, padding=(5, 5, 10, 10)) self.lbl_message = ttk.Label( self.frame, text='Sel...
python
def body(self, master): """Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog """ self.frame = ttk.Frame(master, padding=(5, 5, 10, 10)) self.lbl_message = ttk.Label( self.frame, text='Sel...
[ "def", "body", "(", "self", ",", "master", ")", ":", "self", ".", "frame", "=", "ttk", ".", "Frame", "(", "master", ",", "padding", "=", "(", "5", ",", "5", ",", "10", ",", "10", ")", ")", "self", ".", "lbl_message", "=", "ttk", ".", "Label", ...
Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog
[ "Create", "dialog", "body", ".", "Return", "widget", "that", "should", "have", "initial", "focus", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L240-L289
train
Create dialog body. Return widget that should have initial focus.
mesbahamin/chronophore
chronophore/tkview.py
TkUserTypeSelectionDialog.ok
def ok(self, event=None): """This method is identical to tkinter.simpledialog.Dialog.ok(), but with 'self.withdraw()' commented out. """ if not self.validate(): self.initial_focus.focus_set() # put focus back return # NOTE(amin): Using self.withdraw() he...
python
def ok(self, event=None): """This method is identical to tkinter.simpledialog.Dialog.ok(), but with 'self.withdraw()' commented out. """ if not self.validate(): self.initial_focus.focus_set() # put focus back return # NOTE(amin): Using self.withdraw() he...
[ "def", "ok", "(", "self", ",", "event", "=", "None", ")", ":", "if", "not", "self", ".", "validate", "(", ")", ":", "self", ".", "initial_focus", ".", "focus_set", "(", ")", "# put focus back", "return", "# NOTE(amin): Using self.withdraw() here causes the", "...
This method is identical to tkinter.simpledialog.Dialog.ok(), but with 'self.withdraw()' commented out.
[ "This", "method", "is", "identical", "to", "tkinter", ".", "simpledialog", ".", "Dialog", ".", "ok", "()", "but", "with", "self", ".", "withdraw", "()", "commented", "out", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L295-L319
train
This method is identical to tkinter. simpledialog. Dialog. ok but with the focus back to the entry.
mesbahamin/chronophore
chronophore/tkview.py
TkUserTypeSelectionDialog.apply
def apply(self): """Inherited from tkinter.simpledialog.Dialog""" user_type = self.rb_choice.get() if user_type == 'student' or user_type == 'tutor': self.result = user_type
python
def apply(self): """Inherited from tkinter.simpledialog.Dialog""" user_type = self.rb_choice.get() if user_type == 'student' or user_type == 'tutor': self.result = user_type
[ "def", "apply", "(", "self", ")", ":", "user_type", "=", "self", ".", "rb_choice", ".", "get", "(", ")", "if", "user_type", "==", "'student'", "or", "user_type", "==", "'tutor'", ":", "self", ".", "result", "=", "user_type" ]
Inherited from tkinter.simpledialog.Dialog
[ "Inherited", "from", "tkinter", ".", "simpledialog", ".", "Dialog" ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L321-L325
train
Inherited from tkinter. simpledialog. Dialog