repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
emilssolmanis/tapes | tapes/distributed/registry.py | RegistryAggregator.stop | def stop(self):
"""Terminates the forked process.
Only valid if started as a fork, because... well you wouldn't get here otherwise.
:return:
"""
distributed_logger.info('Stopping metrics aggregator')
self.process.terminate()
self.process.join()
distribute... | python | def stop(self):
"""Terminates the forked process.
Only valid if started as a fork, because... well you wouldn't get here otherwise.
:return:
"""
distributed_logger.info('Stopping metrics aggregator')
self.process.terminate()
self.process.join()
distribute... | [
"def",
"stop",
"(",
"self",
")",
":",
"distributed_logger",
".",
"info",
"(",
"'Stopping metrics aggregator'",
")",
"self",
".",
"process",
".",
"terminate",
"(",
")",
"self",
".",
"process",
".",
"join",
"(",
")",
"distributed_logger",
".",
"info",
"(",
"... | Terminates the forked process.
Only valid if started as a fork, because... well you wouldn't get here otherwise.
:return: | [
"Terminates",
"the",
"forked",
"process",
"."
] | train | https://github.com/emilssolmanis/tapes/blob/7797fc9ebcb359cb1ba5085570e3cab5ebcd1d3c/tapes/distributed/registry.py#L83-L92 |
emilssolmanis/tapes | tapes/distributed/registry.py | DistributedRegistry.connect | def connect(self):
"""Connects to the 0MQ socket and starts publishing."""
distributed_logger.info('Connecting registry proxy to ZMQ socket %s', self.socket_addr)
self.zmq_context = zmq.Context()
sock = self.zmq_context.socket(zmq.PUB)
sock.set_hwm(0)
sock.setsockopt(zmq.... | python | def connect(self):
"""Connects to the 0MQ socket and starts publishing."""
distributed_logger.info('Connecting registry proxy to ZMQ socket %s', self.socket_addr)
self.zmq_context = zmq.Context()
sock = self.zmq_context.socket(zmq.PUB)
sock.set_hwm(0)
sock.setsockopt(zmq.... | [
"def",
"connect",
"(",
"self",
")",
":",
"distributed_logger",
".",
"info",
"(",
"'Connecting registry proxy to ZMQ socket %s'",
",",
"self",
".",
"socket_addr",
")",
"self",
".",
"zmq_context",
"=",
"zmq",
".",
"Context",
"(",
")",
"sock",
"=",
"self",
".",
... | Connects to the 0MQ socket and starts publishing. | [
"Connects",
"to",
"the",
"0MQ",
"socket",
"and",
"starts",
"publishing",
"."
] | train | https://github.com/emilssolmanis/tapes/blob/7797fc9ebcb359cb1ba5085570e3cab5ebcd1d3c/tapes/distributed/registry.py#L122-L142 |
wooyek/django-powerbank | setup.py | get_version | def get_version(*file_paths):
"""Retrieves the version from path"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
print("Looking for version in: {}".format(filename))
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file,... | python | def get_version(*file_paths):
"""Retrieves the version from path"""
filename = os.path.join(os.path.dirname(__file__), *file_paths)
print("Looking for version in: {}".format(filename))
version_file = open(filename).read()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file,... | [
"def",
"get_version",
"(",
"*",
"file_paths",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"*",
"file_paths",
")",
"print",
"(",
"\"Looking for version in: {}\"",
".",
"form... | Retrieves the version from path | [
"Retrieves",
"the",
"version",
"from",
"path"
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/setup.py#L42-L50 |
zzzsochi/includer | includer.py | resolve_str | def resolve_str(name_or_func, module, default):
""" Resolve and return object from dotted name
"""
assert isinstance(name_or_func, str)
resolved = resolve(name_or_func, module=module)
if isinstance(resolved, ModuleType):
if not hasattr(resolved, default):
raise ImportError("{}.{... | python | def resolve_str(name_or_func, module, default):
""" Resolve and return object from dotted name
"""
assert isinstance(name_or_func, str)
resolved = resolve(name_or_func, module=module)
if isinstance(resolved, ModuleType):
if not hasattr(resolved, default):
raise ImportError("{}.{... | [
"def",
"resolve_str",
"(",
"name_or_func",
",",
"module",
",",
"default",
")",
":",
"assert",
"isinstance",
"(",
"name_or_func",
",",
"str",
")",
"resolved",
"=",
"resolve",
"(",
"name_or_func",
",",
"module",
"=",
"module",
")",
"if",
"isinstance",
"(",
"... | Resolve and return object from dotted name | [
"Resolve",
"and",
"return",
"object",
"from",
"dotted",
"name"
] | train | https://github.com/zzzsochi/includer/blob/c0cbb7776fa416f5dac974b5bc19524683fbd99a/includer.py#L6-L22 |
zzzsochi/includer | includer.py | include | def include(_name_or_func, *args,
_module=None, _default='includeme', **kwargs):
""" Resolve and call functions
"""
if callable(_name_or_func):
resolved = _name_or_func
else:
resolved = resolve_str(_name_or_func, _module, _default)
resolved(*args, **kwargs) | python | def include(_name_or_func, *args,
_module=None, _default='includeme', **kwargs):
""" Resolve and call functions
"""
if callable(_name_or_func):
resolved = _name_or_func
else:
resolved = resolve_str(_name_or_func, _module, _default)
resolved(*args, **kwargs) | [
"def",
"include",
"(",
"_name_or_func",
",",
"*",
"args",
",",
"_module",
"=",
"None",
",",
"_default",
"=",
"'includeme'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"callable",
"(",
"_name_or_func",
")",
":",
"resolved",
"=",
"_name_or_func",
"else",
":"... | Resolve and call functions | [
"Resolve",
"and",
"call",
"functions"
] | train | https://github.com/zzzsochi/includer/blob/c0cbb7776fa416f5dac974b5bc19524683fbd99a/includer.py#L25-L34 |
lvjiyong/configreset | configreset/__init__.py | reset | def reset(target, settings):
"""
重置设置
:param target:
:param settings:
:return:
"""
target_settings = _import_module(target)
for k, v in settings.items():
if hasattr(target_settings, k):
setattr(target_settings, k, _get_value(getattr(target_settings, k), v))
el... | python | def reset(target, settings):
"""
重置设置
:param target:
:param settings:
:return:
"""
target_settings = _import_module(target)
for k, v in settings.items():
if hasattr(target_settings, k):
setattr(target_settings, k, _get_value(getattr(target_settings, k), v))
el... | [
"def",
"reset",
"(",
"target",
",",
"settings",
")",
":",
"target_settings",
"=",
"_import_module",
"(",
"target",
")",
"for",
"k",
",",
"v",
"in",
"settings",
".",
"items",
"(",
")",
":",
"if",
"hasattr",
"(",
"target_settings",
",",
"k",
")",
":",
... | 重置设置
:param target:
:param settings:
:return: | [
"重置设置",
":",
"param",
"target",
":",
":",
"param",
"settings",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L37-L50 |
lvjiyong/configreset | configreset/__init__.py | load_package | def load_package(package_dir, package=None, exclude=None, default_section=_DEFAULT_SECTION):
"""
从目录中载入配置文件
:param package_dir:
:param package:
:param exclude:
:param default_section:
:return:
"""
init_py = '__init__.py'
py_ext = '.py'
files = os.listdir(package_dir)
if i... | python | def load_package(package_dir, package=None, exclude=None, default_section=_DEFAULT_SECTION):
"""
从目录中载入配置文件
:param package_dir:
:param package:
:param exclude:
:param default_section:
:return:
"""
init_py = '__init__.py'
py_ext = '.py'
files = os.listdir(package_dir)
if i... | [
"def",
"load_package",
"(",
"package_dir",
",",
"package",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"default_section",
"=",
"_DEFAULT_SECTION",
")",
":",
"init_py",
"=",
"'__init__.py'",
"py_ext",
"=",
"'.py'",
"files",
"=",
"os",
".",
"listdir",
"(",
... | 从目录中载入配置文件
:param package_dir:
:param package:
:param exclude:
:param default_section:
:return: | [
"从目录中载入配置文件",
":",
"param",
"package_dir",
":",
":",
"param",
"package",
":",
":",
"param",
"exclude",
":",
":",
"param",
"default_section",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L53-L87 |
lvjiyong/configreset | configreset/__init__.py | load | def load(items, default_section=_DEFAULT_SECTION):
"""
从混合类型组中读取配置
:param default_section:
:param items:
:return:
"""
settings = []
assert isinstance(items, list), 'items必须为list'
logger.debug(items)
for item in items:
if _is_conf(item):
settings.append(load_... | python | def load(items, default_section=_DEFAULT_SECTION):
"""
从混合类型组中读取配置
:param default_section:
:param items:
:return:
"""
settings = []
assert isinstance(items, list), 'items必须为list'
logger.debug(items)
for item in items:
if _is_conf(item):
settings.append(load_... | [
"def",
"load",
"(",
"items",
",",
"default_section",
"=",
"_DEFAULT_SECTION",
")",
":",
"settings",
"=",
"[",
"]",
"assert",
"isinstance",
"(",
"items",
",",
"list",
")",
",",
"'items必须为list'",
"logger",
".",
"debug",
"(",
"items",
")",
"for",
"item",
"i... | 从混合类型组中读取配置
:param default_section:
:param items:
:return: | [
"从混合类型组中读取配置",
":",
"param",
"default_section",
":",
":",
"param",
"items",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L90-L108 |
lvjiyong/configreset | configreset/__init__.py | merge | def merge(settings_list):
"""
合并配置
:param settings_list:
:return:
"""
if not isinstance(settings_list, list):
return settings_list
settings = OrderedDict()
for item in settings_list:
for k, v in item.items():
if settings.get(k) and isinstance(v, OrderedDict):
... | python | def merge(settings_list):
"""
合并配置
:param settings_list:
:return:
"""
if not isinstance(settings_list, list):
return settings_list
settings = OrderedDict()
for item in settings_list:
for k, v in item.items():
if settings.get(k) and isinstance(v, OrderedDict):
... | [
"def",
"merge",
"(",
"settings_list",
")",
":",
"if",
"not",
"isinstance",
"(",
"settings_list",
",",
"list",
")",
":",
"return",
"settings_list",
"settings",
"=",
"OrderedDict",
"(",
")",
"for",
"item",
"in",
"settings_list",
":",
"for",
"k",
",",
"v",
... | 合并配置
:param settings_list:
:return: | [
"合并配置",
":",
"param",
"settings_list",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L112-L127 |
lvjiyong/configreset | configreset/__init__.py | config | def config(settings):
"""
将配置文件转为Parameter
:param settings:
:return:
"""
parameter_settings = Parameter()
for k, v in settings.items():
if isinstance(v, OrderedDict):
k_settings = Parameter()
for ki, vi in v.items():
k_settings[ki] = vi
... | python | def config(settings):
"""
将配置文件转为Parameter
:param settings:
:return:
"""
parameter_settings = Parameter()
for k, v in settings.items():
if isinstance(v, OrderedDict):
k_settings = Parameter()
for ki, vi in v.items():
k_settings[ki] = vi
... | [
"def",
"config",
"(",
"settings",
")",
":",
"parameter_settings",
"=",
"Parameter",
"(",
")",
"for",
"k",
",",
"v",
"in",
"settings",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"OrderedDict",
")",
":",
"k_settings",
"=",
"Parameter... | 将配置文件转为Parameter
:param settings:
:return: | [
"将配置文件转为Parameter",
":",
"param",
"settings",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L130-L146 |
lvjiyong/configreset | configreset/__init__.py | load_from_name | def load_from_name(module_name):
"""
从python module文件中获取配置
:param module_name:
:return:
"""
global _CONFIG_CACHE
if module_name not in _CONFIG_CACHE:
settings = OrderedDict()
if isinstance(module_name, six.string_types):
settings = _load_from_module(_import_module... | python | def load_from_name(module_name):
"""
从python module文件中获取配置
:param module_name:
:return:
"""
global _CONFIG_CACHE
if module_name not in _CONFIG_CACHE:
settings = OrderedDict()
if isinstance(module_name, six.string_types):
settings = _load_from_module(_import_module... | [
"def",
"load_from_name",
"(",
"module_name",
")",
":",
"global",
"_CONFIG_CACHE",
"if",
"module_name",
"not",
"in",
"_CONFIG_CACHE",
":",
"settings",
"=",
"OrderedDict",
"(",
")",
"if",
"isinstance",
"(",
"module_name",
",",
"six",
".",
"string_types",
")",
":... | 从python module文件中获取配置
:param module_name:
:return: | [
"从python",
"module文件中获取配置",
":",
"param",
"module_name",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L149-L161 |
lvjiyong/configreset | configreset/__init__.py | load_from_ini | def load_from_ini(ini, default_section=_DEFAULT_SECTION):
"""
从单个配置文件读取配置
:param ini:
:param default_section:
:return:
"""
global _CONFIG_CACHE
if ini not in _CONFIG_CACHE:
if six.PY3:
logger.debug("PY3........")
_CONFIG_CACHE[ini] = _load_from_ini_py3(ini... | python | def load_from_ini(ini, default_section=_DEFAULT_SECTION):
"""
从单个配置文件读取配置
:param ini:
:param default_section:
:return:
"""
global _CONFIG_CACHE
if ini not in _CONFIG_CACHE:
if six.PY3:
logger.debug("PY3........")
_CONFIG_CACHE[ini] = _load_from_ini_py3(ini... | [
"def",
"load_from_ini",
"(",
"ini",
",",
"default_section",
"=",
"_DEFAULT_SECTION",
")",
":",
"global",
"_CONFIG_CACHE",
"if",
"ini",
"not",
"in",
"_CONFIG_CACHE",
":",
"if",
"six",
".",
"PY3",
":",
"logger",
".",
"debug",
"(",
"\"PY3........\"",
")",
"_CON... | 从单个配置文件读取配置
:param ini:
:param default_section:
:return: | [
"从单个配置文件读取配置",
":",
"param",
"ini",
":",
":",
"param",
"default_section",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L164-L180 |
lvjiyong/configreset | configreset/__init__.py | _load_from_ini_py2 | def _load_from_ini_py2(ini):
"""
py2从单个配置文件中,获取设置
:param :
:param ini:
:return:
"""
logger.debug('使用PY2不支持自定义default_section,其默认值是:%s' % _DEFAULT_SECTION)
cf = configparser.ConfigParser()
cf.read(ini)
settings = OrderedDict()
for k, v in cf.defaults().items():
setting... | python | def _load_from_ini_py2(ini):
"""
py2从单个配置文件中,获取设置
:param :
:param ini:
:return:
"""
logger.debug('使用PY2不支持自定义default_section,其默认值是:%s' % _DEFAULT_SECTION)
cf = configparser.ConfigParser()
cf.read(ini)
settings = OrderedDict()
for k, v in cf.defaults().items():
setting... | [
"def",
"_load_from_ini_py2",
"(",
"ini",
")",
":",
"logger",
".",
"debug",
"(",
"'使用PY2不支持自定义default_section,其默认值是:%s' % _DEFAULT_SECTION)",
"",
"",
"",
"cf",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"cf",
".",
"read",
"(",
"ini",
")",
"settings",
"... | py2从单个配置文件中,获取设置
:param :
:param ini:
:return: | [
"py2从单个配置文件中",
"获取设置",
":",
"param",
":",
":",
"param",
"ini",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L183-L202 |
lvjiyong/configreset | configreset/__init__.py | convert_value | def convert_value(v):
"""
默认使用Json转化数据,凡以[或{开始的,均载入json
:param v:
:return:
"""
if v and isinstance(v, six.string_types):
v = v.strip()
if (v.startswith('{') and v.endswith('}')) or (v.startswith('[') and v.endswith(']')):
try:
return json.loads(v)
... | python | def convert_value(v):
"""
默认使用Json转化数据,凡以[或{开始的,均载入json
:param v:
:return:
"""
if v and isinstance(v, six.string_types):
v = v.strip()
if (v.startswith('{') and v.endswith('}')) or (v.startswith('[') and v.endswith(']')):
try:
return json.loads(v)
... | [
"def",
"convert_value",
"(",
"v",
")",
":",
"if",
"v",
"and",
"isinstance",
"(",
"v",
",",
"six",
".",
"string_types",
")",
":",
"v",
"=",
"v",
".",
"strip",
"(",
")",
"if",
"(",
"v",
".",
"startswith",
"(",
"'{'",
")",
"and",
"v",
".",
"endswi... | 默认使用Json转化数据,凡以[或{开始的,均载入json
:param v:
:return: | [
"默认使用Json转化数据",
"凡以",
"[",
"或",
"{",
"开始的",
"均载入json",
":",
"param",
"v",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L205-L219 |
lvjiyong/configreset | configreset/__init__.py | _load_from_ini_py3 | def _load_from_ini_py3(ini, default_section=_DEFAULT_SECTION):
"""
py3从单个配置文件中,获取设置
:param default_section:
:param ini:
:return:
"""
cf = configparser.ConfigParser(default_section=default_section)
cf.read(ini, encoding="UTF8")
settings = OrderedDict()
for item in cf.items():
... | python | def _load_from_ini_py3(ini, default_section=_DEFAULT_SECTION):
"""
py3从单个配置文件中,获取设置
:param default_section:
:param ini:
:return:
"""
cf = configparser.ConfigParser(default_section=default_section)
cf.read(ini, encoding="UTF8")
settings = OrderedDict()
for item in cf.items():
... | [
"def",
"_load_from_ini_py3",
"(",
"ini",
",",
"default_section",
"=",
"_DEFAULT_SECTION",
")",
":",
"cf",
"=",
"configparser",
".",
"ConfigParser",
"(",
"default_section",
"=",
"default_section",
")",
"cf",
".",
"read",
"(",
"ini",
",",
"encoding",
"=",
"\"UTF... | py3从单个配置文件中,获取设置
:param default_section:
:param ini:
:return: | [
"py3从单个配置文件中",
"获取设置",
":",
"param",
"default_section",
":",
":",
"param",
"ini",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L222-L252 |
lvjiyong/configreset | configreset/__init__.py | _load_from_module | def _load_from_module(module):
"""
从python模块中获取配置
:param py:
:return:
"""
settings = OrderedDict()
for key in dir(module):
if key.isupper():
settings[key] = getattr(module, key)
return settings | python | def _load_from_module(module):
"""
从python模块中获取配置
:param py:
:return:
"""
settings = OrderedDict()
for key in dir(module):
if key.isupper():
settings[key] = getattr(module, key)
return settings | [
"def",
"_load_from_module",
"(",
"module",
")",
":",
"settings",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
"in",
"dir",
"(",
"module",
")",
":",
"if",
"key",
".",
"isupper",
"(",
")",
":",
"settings",
"[",
"key",
"]",
"=",
"getattr",
"(",
"module",... | 从python模块中获取配置
:param py:
:return: | [
"从python模块中获取配置",
":",
"param",
"py",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L255-L266 |
lvjiyong/configreset | configreset/__init__.py | _import_module | def _import_module(name, package=None):
"""
根据模块名载入模块
:param name:
:param package:
:return:
"""
if name.startswith('.'):
name = '{package}.{module}'.format(package=package, module=str(name).strip('.'))
__import__(name)
return sys.modules[name] | python | def _import_module(name, package=None):
"""
根据模块名载入模块
:param name:
:param package:
:return:
"""
if name.startswith('.'):
name = '{package}.{module}'.format(package=package, module=str(name).strip('.'))
__import__(name)
return sys.modules[name] | [
"def",
"_import_module",
"(",
"name",
",",
"package",
"=",
"None",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"'.'",
")",
":",
"name",
"=",
"'{package}.{module}'",
".",
"format",
"(",
"package",
"=",
"package",
",",
"module",
"=",
"str",
"(",
"nam... | 根据模块名载入模块
:param name:
:param package:
:return: | [
"根据模块名载入模块",
":",
"param",
"name",
":",
":",
"param",
"package",
":",
":",
"return",
":"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L269-L279 |
lvjiyong/configreset | configreset/__init__.py | _get_value | def _get_value(first, second):
"""
数据转化
:param first:
:param second:
:return:
>>> _get_value(1,'2')
2
>>> _get_value([1,2],[2,3])
[1, 2, 3]
"""
if isinstance(first, list) and isinstance(second, list):
return list(set(first).union(set(second)))
elif isinstance(fir... | python | def _get_value(first, second):
"""
数据转化
:param first:
:param second:
:return:
>>> _get_value(1,'2')
2
>>> _get_value([1,2],[2,3])
[1, 2, 3]
"""
if isinstance(first, list) and isinstance(second, list):
return list(set(first).union(set(second)))
elif isinstance(fir... | [
"def",
"_get_value",
"(",
"first",
",",
"second",
")",
":",
"if",
"isinstance",
"(",
"first",
",",
"list",
")",
"and",
"isinstance",
"(",
"second",
",",
"list",
")",
":",
"return",
"list",
"(",
"set",
"(",
"first",
")",
".",
"union",
"(",
"set",
"(... | 数据转化
:param first:
:param second:
:return:
>>> _get_value(1,'2')
2
>>> _get_value([1,2],[2,3])
[1, 2, 3] | [
"数据转化",
":",
"param",
"first",
":",
":",
"param",
"second",
":",
":",
"return",
":",
">>>",
"_get_value",
"(",
"1",
"2",
")",
"2",
">>>",
"_get_value",
"(",
"[",
"1",
"2",
"]",
"[",
"2",
"3",
"]",
")",
"[",
"1",
"2",
"3",
"]"
] | train | https://github.com/lvjiyong/configreset/blob/cde0a426e993a6aa483d6934358e61750c944de9/configreset/__init__.py#L286-L306 |
honsiorovskyi/codeharvester | src/codeharvester/harvester.py | Harvester.parse_requirements | def parse_requirements(self, filename):
"""
Recursively find all the requirements needed
storing them in req_parents, req_paths, req_linenos
"""
cwd = os.path.dirname(filename)
try:
fd = open(filename, 'r')
for i, line in enumerate(fd.readlines()... | python | def parse_requirements(self, filename):
"""
Recursively find all the requirements needed
storing them in req_parents, req_paths, req_linenos
"""
cwd = os.path.dirname(filename)
try:
fd = open(filename, 'r')
for i, line in enumerate(fd.readlines()... | [
"def",
"parse_requirements",
"(",
"self",
",",
"filename",
")",
":",
"cwd",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
"try",
":",
"fd",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"for",
"i",
",",
"line",
"in",
"enumerate",
"... | Recursively find all the requirements needed
storing them in req_parents, req_paths, req_linenos | [
"Recursively",
"find",
"all",
"the",
"requirements",
"needed",
"storing",
"them",
"in",
"req_parents",
"req_paths",
"req_linenos"
] | train | https://github.com/honsiorovskyi/codeharvester/blob/301b907b32ef9bbdb7099657100fbd3829c3ecc8/src/codeharvester/harvester.py#L56-L105 |
honsiorovskyi/codeharvester | src/codeharvester/harvester.py | Harvester.replace_requirements | def replace_requirements(self, infilename, outfile_initial=None):
"""
Recursively replaces the requirements in the files with the content of the requirements.
Returns final temporary file opened for reading.
"""
infile = open(infilename, 'r')
# extract the requirements ... | python | def replace_requirements(self, infilename, outfile_initial=None):
"""
Recursively replaces the requirements in the files with the content of the requirements.
Returns final temporary file opened for reading.
"""
infile = open(infilename, 'r')
# extract the requirements ... | [
"def",
"replace_requirements",
"(",
"self",
",",
"infilename",
",",
"outfile_initial",
"=",
"None",
")",
":",
"infile",
"=",
"open",
"(",
"infilename",
",",
"'r'",
")",
"# extract the requirements for this file that were not skipped from the global database",
"_indexes",
... | Recursively replaces the requirements in the files with the content of the requirements.
Returns final temporary file opened for reading. | [
"Recursively",
"replaces",
"the",
"requirements",
"in",
"the",
"files",
"with",
"the",
"content",
"of",
"the",
"requirements",
".",
"Returns",
"final",
"temporary",
"file",
"opened",
"for",
"reading",
"."
] | train | https://github.com/honsiorovskyi/codeharvester/blob/301b907b32ef9bbdb7099657100fbd3829c3ecc8/src/codeharvester/harvester.py#L107-L150 |
synw/goerr | goerr/messages.py | Msg.fatal | def fatal(self, i: int=None) -> str:
"""
Returns a fatal error message
"""
head = "[" + colors.red("\033[1mfatal error") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def fatal(self, i: int=None) -> str:
"""
Returns a fatal error message
"""
head = "[" + colors.red("\033[1mfatal error") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"fatal",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"red",
"(",
"\"\\033[1mfatal error\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"(... | Returns a fatal error message | [
"Returns",
"a",
"fatal",
"error",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L9-L16 |
synw/goerr | goerr/messages.py | Msg.error | def error(self, i: int=None) -> str:
"""
Returns an error message
"""
head = "[" + colors.red("error") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def error(self, i: int=None) -> str:
"""
Returns an error message
"""
head = "[" + colors.red("error") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"error",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"red",
"(",
"\"error\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"(",
"i",
")... | Returns an error message | [
"Returns",
"an",
"error",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L18-L25 |
synw/goerr | goerr/messages.py | Msg.warning | def warning(self, i: int=None) -> str:
"""
Returns a warning message
"""
head = "[" + colors.purple("\033[1mwarning") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def warning(self, i: int=None) -> str:
"""
Returns a warning message
"""
head = "[" + colors.purple("\033[1mwarning") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"warning",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"purple",
"(",
"\"\\033[1mwarning\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"... | Returns a warning message | [
"Returns",
"a",
"warning",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L27-L34 |
synw/goerr | goerr/messages.py | Msg.info | def info(self, i: int=None) -> str:
"""
Returns an info message
"""
head = "[" + colors.blue("info") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def info(self, i: int=None) -> str:
"""
Returns an info message
"""
head = "[" + colors.blue("info") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"info",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"blue",
"(",
"\"info\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"(",
"i",
")"... | Returns an info message | [
"Returns",
"an",
"info",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L36-L43 |
synw/goerr | goerr/messages.py | Msg.via | def via(self, i: int=None) -> str:
"""
Returns an via message
"""
head = "[" + colors.green("via") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def via(self, i: int=None) -> str:
"""
Returns an via message
"""
head = "[" + colors.green("via") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"via",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"green",
"(",
"\"via\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"(",
"i",
")",... | Returns an via message | [
"Returns",
"an",
"via",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L45-L52 |
synw/goerr | goerr/messages.py | Msg.debug | def debug(self, i: int=None) -> str:
"""
Returns a debug message
"""
head = "[" + colors.yellow("debug") + "]"
if i is not None:
head = str(i) + " " + head
return head | python | def debug(self, i: int=None) -> str:
"""
Returns a debug message
"""
head = "[" + colors.yellow("debug") + "]"
if i is not None:
head = str(i) + " " + head
return head | [
"def",
"debug",
"(",
"self",
",",
"i",
":",
"int",
"=",
"None",
")",
"->",
"str",
":",
"head",
"=",
"\"[\"",
"+",
"colors",
".",
"yellow",
"(",
"\"debug\"",
")",
"+",
"\"]\"",
"if",
"i",
"is",
"not",
"None",
":",
"head",
"=",
"str",
"(",
"i",
... | Returns a debug message | [
"Returns",
"a",
"debug",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/messages.py#L54-L61 |
malthe/pop | src/pop/machine.py | MachineAgent.scan | def scan(self):
"""Analyze state and queue tasks."""
log.debug("scanning machine: %s..." % self.name)
deployed = set()
services = yield self.client.get_children(self.path + "/services")
for name in services:
log.debug("checking service: '%s'..." % name)
... | python | def scan(self):
"""Analyze state and queue tasks."""
log.debug("scanning machine: %s..." % self.name)
deployed = set()
services = yield self.client.get_children(self.path + "/services")
for name in services:
log.debug("checking service: '%s'..." % name)
... | [
"def",
"scan",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"scanning machine: %s...\"",
"%",
"self",
".",
"name",
")",
"deployed",
"=",
"set",
"(",
")",
"services",
"=",
"yield",
"self",
".",
"client",
".",
"get_children",
"(",
"self",
".",
"pat... | Analyze state and queue tasks. | [
"Analyze",
"state",
"and",
"queue",
"tasks",
"."
] | train | https://github.com/malthe/pop/blob/3b58b91b41d8b9bee546eb40dc280a57500b8bed/src/pop/machine.py#L34-L79 |
tmacwill/stellata | stellata/database.py | initialize | def initialize(name='', pool_size=10, host='localhost', password='', port=5432, user=''):
"""Initialize a new database connection and return the pool object.
Saves a reference to that instance in a module-level variable, so applications with only one database
can just call this function and not worry about... | python | def initialize(name='', pool_size=10, host='localhost', password='', port=5432, user=''):
"""Initialize a new database connection and return the pool object.
Saves a reference to that instance in a module-level variable, so applications with only one database
can just call this function and not worry about... | [
"def",
"initialize",
"(",
"name",
"=",
"''",
",",
"pool_size",
"=",
"10",
",",
"host",
"=",
"'localhost'",
",",
"password",
"=",
"''",
",",
"port",
"=",
"5432",
",",
"user",
"=",
"''",
")",
":",
"global",
"pool",
"instance",
"=",
"Pool",
"(",
"name... | Initialize a new database connection and return the pool object.
Saves a reference to that instance in a module-level variable, so applications with only one database
can just call this function and not worry about pool objects. | [
"Initialize",
"a",
"new",
"database",
"connection",
"and",
"return",
"the",
"pool",
"object",
"."
] | train | https://github.com/tmacwill/stellata/blob/9519c170397740eb6faf5d8a96b9a77f0d909b92/stellata/database.py#L57-L67 |
tmacwill/stellata | stellata/database.py | Pool.query | def query(self, sql: str, args: tuple = None):
"""Execute a SQL query with a return value."""
with self._cursor() as cursor:
log.debug('Running SQL: ' + str((sql, args)))
cursor.execute(sql, args)
return cursor.fetchall() | python | def query(self, sql: str, args: tuple = None):
"""Execute a SQL query with a return value."""
with self._cursor() as cursor:
log.debug('Running SQL: ' + str((sql, args)))
cursor.execute(sql, args)
return cursor.fetchall() | [
"def",
"query",
"(",
"self",
",",
"sql",
":",
"str",
",",
"args",
":",
"tuple",
"=",
"None",
")",
":",
"with",
"self",
".",
"_cursor",
"(",
")",
"as",
"cursor",
":",
"log",
".",
"debug",
"(",
"'Running SQL: '",
"+",
"str",
"(",
"(",
"sql",
",",
... | Execute a SQL query with a return value. | [
"Execute",
"a",
"SQL",
"query",
"with",
"a",
"return",
"value",
"."
] | train | https://github.com/tmacwill/stellata/blob/9519c170397740eb6faf5d8a96b9a77f0d909b92/stellata/database.py#L49-L55 |
davisd50/sparc.cache | sparc/cache/sources/csvdata.py | CSVSource.items | def items(self):
"""Returns a generator of available ICachableItem in the ICachableSource
"""
for dictreader in self._csv_dictreader_list:
for entry in dictreader:
item = self.factory()
item.key = self.key()
item.attributes = entry
... | python | def items(self):
"""Returns a generator of available ICachableItem in the ICachableSource
"""
for dictreader in self._csv_dictreader_list:
for entry in dictreader:
item = self.factory()
item.key = self.key()
item.attributes = entry
... | [
"def",
"items",
"(",
"self",
")",
":",
"for",
"dictreader",
"in",
"self",
".",
"_csv_dictreader_list",
":",
"for",
"entry",
"in",
"dictreader",
":",
"item",
"=",
"self",
".",
"factory",
"(",
")",
"item",
".",
"key",
"=",
"self",
".",
"key",
"(",
")",... | Returns a generator of available ICachableItem in the ICachableSource | [
"Returns",
"a",
"generator",
"of",
"available",
"ICachableItem",
"in",
"the",
"ICachableSource"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sources/csvdata.py#L75-L89 |
davisd50/sparc.cache | sparc/cache/sources/csvdata.py | CSVSource.getById | def getById(self, Id):
"""Returns ICachableItem that matches id
Args:
id: String that identifies the item to return whose key matches
"""
# we need to create a new object to insure we don't corrupt the generator count
csvsource = CSVSource(self.source, self.f... | python | def getById(self, Id):
"""Returns ICachableItem that matches id
Args:
id: String that identifies the item to return whose key matches
"""
# we need to create a new object to insure we don't corrupt the generator count
csvsource = CSVSource(self.source, self.f... | [
"def",
"getById",
"(",
"self",
",",
"Id",
")",
":",
"# we need to create a new object to insure we don't corrupt the generator count",
"csvsource",
"=",
"CSVSource",
"(",
"self",
".",
"source",
",",
"self",
".",
"factory",
",",
"self",
".",
"key",
"(",
")",
")",
... | Returns ICachableItem that matches id
Args:
id: String that identifies the item to return whose key matches | [
"Returns",
"ICachableItem",
"that",
"matches",
"id",
"Args",
":",
"id",
":",
"String",
"that",
"identifies",
"the",
"item",
"to",
"return",
"whose",
"key",
"matches"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sources/csvdata.py#L91-L104 |
davisd50/sparc.cache | sparc/cache/sources/csvdata.py | CSVSource.first | def first(self):
"""Returns the first ICachableItem in the ICachableSource"""
# we need to create a new object to insure we don't corrupt the generator count
csvsource = CSVSource(self.source, self.factory, self.key())
try:
item = csvsource.items().next()
return i... | python | def first(self):
"""Returns the first ICachableItem in the ICachableSource"""
# we need to create a new object to insure we don't corrupt the generator count
csvsource = CSVSource(self.source, self.factory, self.key())
try:
item = csvsource.items().next()
return i... | [
"def",
"first",
"(",
"self",
")",
":",
"# we need to create a new object to insure we don't corrupt the generator count",
"csvsource",
"=",
"CSVSource",
"(",
"self",
".",
"source",
",",
"self",
".",
"factory",
",",
"self",
".",
"key",
"(",
")",
")",
"try",
":",
... | Returns the first ICachableItem in the ICachableSource | [
"Returns",
"the",
"first",
"ICachableItem",
"in",
"the",
"ICachableSource"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/sources/csvdata.py#L106-L114 |
Humch/django-auxiliare | auxiliare/views.py | MyProfileView.get | def get(self, request,pk):
"""
If the user requests his profile return it, else return a 403 (Forbidden)
"""
requested_profile = Profile.objects.get(user=pk)
if requested_profile.user == self.request.user:
return render(request, self.template... | python | def get(self, request,pk):
"""
If the user requests his profile return it, else return a 403 (Forbidden)
"""
requested_profile = Profile.objects.get(user=pk)
if requested_profile.user == self.request.user:
return render(request, self.template... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"pk",
")",
":",
"requested_profile",
"=",
"Profile",
".",
"objects",
".",
"get",
"(",
"user",
"=",
"pk",
")",
"if",
"requested_profile",
".",
"user",
"==",
"self",
".",
"request",
".",
"user",
":",
"ret... | If the user requests his profile return it, else return a 403 (Forbidden) | [
"If",
"the",
"user",
"requests",
"his",
"profile",
"return",
"it",
"else",
"return",
"a",
"403",
"(",
"Forbidden",
")"
] | train | https://github.com/Humch/django-auxiliare/blob/326cf51f116a3242b19c0737bce29d1196854a5d/auxiliare/views.py#L60-L72 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | register | def register(name=None, exprresolver=None, params=None, reg=None):
"""Register an expression resolver.
Can be used such as a decorator.
For example all remainding expressions are the same.
.. code-block:: python
@register('myresolver')
def myresolver(**kwargs): pass
.. code-bloc... | python | def register(name=None, exprresolver=None, params=None, reg=None):
"""Register an expression resolver.
Can be used such as a decorator.
For example all remainding expressions are the same.
.. code-block:: python
@register('myresolver')
def myresolver(**kwargs): pass
.. code-bloc... | [
"def",
"register",
"(",
"name",
"=",
"None",
",",
"exprresolver",
"=",
"None",
",",
"params",
"=",
"None",
",",
"reg",
"=",
"None",
")",
":",
"def",
"_register",
"(",
"exprresolver",
",",
"_name",
"=",
"name",
",",
"_params",
"=",
"params",
")",
":",... | Register an expression resolver.
Can be used such as a decorator.
For example all remainding expressions are the same.
.. code-block:: python
@register('myresolver')
def myresolver(**kwargs): pass
.. code-block:: python
def myresolver(**kwargs): pass
register('myre... | [
"Register",
"an",
"expression",
"resolver",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L170-L257 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | defaultname | def defaultname(name=None):
"""Get default resolver name.
:param str name: if given, change the default name.
:raises: NameError if name given and not in registered resolvers.
:rtype: str"""
if name is None:
name = _RESOLVER_REGISTRY.default
else:
_RESOLVER_REGISTRY.default = ... | python | def defaultname(name=None):
"""Get default resolver name.
:param str name: if given, change the default name.
:raises: NameError if name given and not in registered resolvers.
:rtype: str"""
if name is None:
name = _RESOLVER_REGISTRY.default
else:
_RESOLVER_REGISTRY.default = ... | [
"def",
"defaultname",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"_RESOLVER_REGISTRY",
".",
"default",
"else",
":",
"_RESOLVER_REGISTRY",
".",
"default",
"=",
"name",
"return",
"name"
] | Get default resolver name.
:param str name: if given, change the default name.
:raises: NameError if name given and not in registered resolvers.
:rtype: str | [
"Get",
"default",
"resolver",
"name",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L270-L283 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | resolve | def resolve(
expr, name=None,
safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is the
first registe... | python | def resolve(
expr, name=None,
safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is the
first registe... | [
"def",
"resolve",
"(",
"expr",
",",
"name",
"=",
"None",
",",
"safe",
"=",
"DEFAULT_SAFE",
",",
"tostr",
"=",
"DEFAULT_TOSTR",
",",
"scope",
"=",
"DEFAULT_SCOPE",
",",
"besteffort",
"=",
"DEFAULT_BESTEFFORT",
")",
":",
"return",
"_RESOLVER_REGISTRY",
".",
"r... | Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is the
first registered expression resolver.
:param bool safe: if True (Default), resolve in a safe context
(without I/O).
:param bool tostr: if True (False by... | [
"Resolve",
"an",
"expression",
"with",
"possibly",
"a",
"dedicated",
"expression",
"resolvers",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L292-L315 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | getname | def getname(exprresolver):
"""Get expression resolver name.
Expression resolver name is given by the attribute __resolver__.
If not exist, then the it is given by the attribute __name__.
Otherwise, given by the __class__.__name__ attribute.
:raises: TypeError if exprresolver is not callable."""
... | python | def getname(exprresolver):
"""Get expression resolver name.
Expression resolver name is given by the attribute __resolver__.
If not exist, then the it is given by the attribute __name__.
Otherwise, given by the __class__.__name__ attribute.
:raises: TypeError if exprresolver is not callable."""
... | [
"def",
"getname",
"(",
"exprresolver",
")",
":",
"result",
"=",
"None",
"if",
"not",
"callable",
"(",
"exprresolver",
")",
":",
"raise",
"TypeError",
"(",
"'Expression resolver must be a callable object.'",
")",
"result",
"=",
"getattr",
"(",
"exprresolver",
",",
... | Get expression resolver name.
Expression resolver name is given by the attribute __resolver__.
If not exist, then the it is given by the attribute __name__.
Otherwise, given by the __class__.__name__ attribute.
:raises: TypeError if exprresolver is not callable. | [
"Get",
"expression",
"resolver",
"name",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L317-L339 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | ResolverRegistry.default | def default(self):
"""Get default resolver name."""
if self._default is None or self._default not in self:
self._default = list(self.keys())[0] if self else None
return self._default | python | def default(self):
"""Get default resolver name."""
if self._default is None or self._default not in self:
self._default = list(self.keys())[0] if self else None
return self._default | [
"def",
"default",
"(",
"self",
")",
":",
"if",
"self",
".",
"_default",
"is",
"None",
"or",
"self",
".",
"_default",
"not",
"in",
"self",
":",
"self",
".",
"_default",
"=",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"if",
"... | Get default resolver name. | [
"Get",
"default",
"resolver",
"name",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L103-L109 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | ResolverRegistry.default | def default(self, value):
"""Change of resolver name.
:param value: new default value to use.
:type value: str or callable
:raises: KeyError if value is a string not already registered."""
if value is None:
if self:
value = list(self.keys())[0]
... | python | def default(self, value):
"""Change of resolver name.
:param value: new default value to use.
:type value: str or callable
:raises: KeyError if value is a string not already registered."""
if value is None:
if self:
value = list(self.keys())[0]
... | [
"def",
"default",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"if",
"self",
":",
"value",
"=",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"string_type... | Change of resolver name.
:param value: new default value to use.
:type value: str or callable
:raises: KeyError if value is a string not already registered. | [
"Change",
"of",
"resolver",
"name",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L112-L131 |
b3j0f/conf | b3j0f/conf/parser/resolver/registry.py | ResolverRegistry.resolve | def resolve(
self, expr, name,
safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is ... | python | def resolve(
self, expr, name,
safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is ... | [
"def",
"resolve",
"(",
"self",
",",
"expr",
",",
"name",
",",
"safe",
"=",
"DEFAULT_SAFE",
",",
"tostr",
"=",
"DEFAULT_TOSTR",
",",
"scope",
"=",
"DEFAULT_SCOPE",
",",
"besteffort",
"=",
"DEFAULT_BESTEFFORT",
")",
":",
"resolver",
"=",
"None",
"if",
"name"... | Resolve an expression with possibly a dedicated expression resolvers.
:param str name: expression resolver registered name. Default is the
first registered expression resolver.
:param bool safe: if True (Default), resolve in a safe context
(without I/O).
:param bool tost... | [
"Resolve",
"an",
"expression",
"with",
"possibly",
"a",
"dedicated",
"expression",
"resolvers",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/registry.py#L133-L165 |
django-stars/plankton | plankton/wkhtmltopdf/utils.py | wkhtmltopdf_args_mapping | def wkhtmltopdf_args_mapping(data):
"""
fix our names to wkhtmltopdf's args
"""
mapping = {
'cookies': 'cookie',
'custom-headers': 'custom-header',
'run-scripts': 'run-script'
}
return {mapping.get(k, k): v for k, v in data.items()} | python | def wkhtmltopdf_args_mapping(data):
"""
fix our names to wkhtmltopdf's args
"""
mapping = {
'cookies': 'cookie',
'custom-headers': 'custom-header',
'run-scripts': 'run-script'
}
return {mapping.get(k, k): v for k, v in data.items()} | [
"def",
"wkhtmltopdf_args_mapping",
"(",
"data",
")",
":",
"mapping",
"=",
"{",
"'cookies'",
":",
"'cookie'",
",",
"'custom-headers'",
":",
"'custom-header'",
",",
"'run-scripts'",
":",
"'run-script'",
"}",
"return",
"{",
"mapping",
".",
"get",
"(",
"k",
",",
... | fix our names to wkhtmltopdf's args | [
"fix",
"our",
"names",
"to",
"wkhtmltopdf",
"s",
"args"
] | train | https://github.com/django-stars/plankton/blob/83a672d8d40f8bea51dc772aa084139c409d47e4/plankton/wkhtmltopdf/utils.py#L18-L28 |
usc-isi-i2/dig-dictionary-extractor | digDictionaryExtractor/name_dictionary_extractor.py | get_name_dictionary_extractor | def get_name_dictionary_extractor(name_trie):
"""Method for creating default name dictionary extractor"""
return DictionaryExtractor()\
.set_trie(name_trie)\
.set_pre_filter(VALID_TOKEN_RE.match)\
.set_pre_process(lambda x: x.lower())\
.set_metadata({'extractor': 'dig_name_dicti... | python | def get_name_dictionary_extractor(name_trie):
"""Method for creating default name dictionary extractor"""
return DictionaryExtractor()\
.set_trie(name_trie)\
.set_pre_filter(VALID_TOKEN_RE.match)\
.set_pre_process(lambda x: x.lower())\
.set_metadata({'extractor': 'dig_name_dicti... | [
"def",
"get_name_dictionary_extractor",
"(",
"name_trie",
")",
":",
"return",
"DictionaryExtractor",
"(",
")",
".",
"set_trie",
"(",
"name_trie",
")",
".",
"set_pre_filter",
"(",
"VALID_TOKEN_RE",
".",
"match",
")",
".",
"set_pre_process",
"(",
"lambda",
"x",
":... | Method for creating default name dictionary extractor | [
"Method",
"for",
"creating",
"default",
"name",
"dictionary",
"extractor"
] | train | https://github.com/usc-isi-i2/dig-dictionary-extractor/blob/1fe4f6c121fd09a8f194ccd419284d3c3760195d/digDictionaryExtractor/name_dictionary_extractor.py#L11-L18 |
artisanofcode/python-broadway | broadway/whitenoise.py | init_app | def init_app(application):
"""
Initialise an application
Set up whitenoise to handle static files.
"""
config = {k: v for k, v in application.config.items() if k in SCHEMA}
kwargs = {'autorefresh': application.debug}
kwargs.update((k[11:].lower(), v) for k, v in config.items())
insta... | python | def init_app(application):
"""
Initialise an application
Set up whitenoise to handle static files.
"""
config = {k: v for k, v in application.config.items() if k in SCHEMA}
kwargs = {'autorefresh': application.debug}
kwargs.update((k[11:].lower(), v) for k, v in config.items())
insta... | [
"def",
"init_app",
"(",
"application",
")",
":",
"config",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"application",
".",
"config",
".",
"items",
"(",
")",
"if",
"k",
"in",
"SCHEMA",
"}",
"kwargs",
"=",
"{",
"'autorefresh'",
":",
"applica... | Initialise an application
Set up whitenoise to handle static files. | [
"Initialise",
"an",
"application"
] | train | https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/broadway/whitenoise.py#L38-L59 |
neuroticnerd/armory | armory/utils/__init__.py | env | def env(key, default=_NOT_PROVIDED, cast=str, force=False, **kwargs):
"""
Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in... | python | def env(key, default=_NOT_PROVIDED, cast=str, force=False, **kwargs):
"""
Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in... | [
"def",
"env",
"(",
"key",
",",
"default",
"=",
"_NOT_PROVIDED",
",",
"cast",
"=",
"str",
",",
"force",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"boolmap",
"=",
"kwargs",
".",
"get",
"(",
"'boolmap'",
",",
"None",
")",
"sticky",
"=",
"kwargs... | Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in as strings, cast to this type if needed
:param force: force casting of value ... | [
"Retrieve",
"environment",
"variables",
"and",
"specify",
"default",
"and",
"options",
"."
] | train | https://github.com/neuroticnerd/armory/blob/d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1/armory/utils/__init__.py#L14-L48 |
n8henrie/urlmon | urlmon/urlmon.py | main | def main(arguments):
"""Parse arguments, request the urls, notify if different."""
formatter_class = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=formatter_class)
parser.add_argument('infile', help="Inpu... | python | def main(arguments):
"""Parse arguments, request the urls, notify if different."""
formatter_class = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=formatter_class)
parser.add_argument('infile', help="Inpu... | [
"def",
"main",
"(",
"arguments",
")",
":",
"formatter_class",
"=",
"argparse",
".",
"ArgumentDefaultsHelpFormatter",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"formatter_class",
")",
"parser",
... | Parse arguments, request the urls, notify if different. | [
"Parse",
"arguments",
"request",
"the",
"urls",
"notify",
"if",
"different",
"."
] | train | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L101-L148 |
n8henrie/urlmon | urlmon/urlmon.py | Pushover.validate | def validate(self):
"""Validate the user and token, returns the Requests response."""
validate_url = "https://api.pushover.net/1/users/validate.json"
payload = {
'token': self.api_token,
'user': self.user,
}
return requests.post(validate_url, data=paylo... | python | def validate(self):
"""Validate the user and token, returns the Requests response."""
validate_url = "https://api.pushover.net/1/users/validate.json"
payload = {
'token': self.api_token,
'user': self.user,
}
return requests.post(validate_url, data=paylo... | [
"def",
"validate",
"(",
"self",
")",
":",
"validate_url",
"=",
"\"https://api.pushover.net/1/users/validate.json\"",
"payload",
"=",
"{",
"'token'",
":",
"self",
".",
"api_token",
",",
"'user'",
":",
"self",
".",
"user",
",",
"}",
"return",
"requests",
".",
"p... | Validate the user and token, returns the Requests response. | [
"Validate",
"the",
"user",
"and",
"token",
"returns",
"the",
"Requests",
"response",
"."
] | train | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L42-L52 |
n8henrie/urlmon | urlmon/urlmon.py | Pushover.push | def push(self, message, device=None, title=None, url=None, url_title=None,
priority=None, timestamp=None, sound=None):
"""Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's dev... | python | def push(self, message, device=None, title=None, url=None, url_title=None,
priority=None, timestamp=None, sound=None):
"""Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's dev... | [
"def",
"push",
"(",
"self",
",",
"message",
",",
"device",
"=",
"None",
",",
"title",
"=",
"None",
",",
"url",
"=",
"None",
",",
"url_title",
"=",
"None",
",",
"priority",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"sound",
"=",
"None",
")",
... | Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's device name to send the message directly to
that device, rather than all of the user's devices
title -- your message's... | [
"Pushes",
"the",
"notification",
"returns",
"the",
"Requests",
"response",
"."
] | train | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L54-L93 |
mythmon/chief-james | james.py | extract_bugs | def extract_bugs(changelog):
"""Takes output from git log --oneline and extracts bug numbers"""
bug_regexp = re.compile(r'\bbug (\d+)\b', re.IGNORECASE)
bugs = set()
for line in changelog:
for bug in bug_regexp.findall(line):
bugs.add(bug)
return sorted(list(bugs)) | python | def extract_bugs(changelog):
"""Takes output from git log --oneline and extracts bug numbers"""
bug_regexp = re.compile(r'\bbug (\d+)\b', re.IGNORECASE)
bugs = set()
for line in changelog:
for bug in bug_regexp.findall(line):
bugs.add(bug)
return sorted(list(bugs)) | [
"def",
"extract_bugs",
"(",
"changelog",
")",
":",
"bug_regexp",
"=",
"re",
".",
"compile",
"(",
"r'\\bbug (\\d+)\\b'",
",",
"re",
".",
"IGNORECASE",
")",
"bugs",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"changelog",
":",
"for",
"bug",
"in",
"bug_regex... | Takes output from git log --oneline and extracts bug numbers | [
"Takes",
"output",
"from",
"git",
"log",
"--",
"oneline",
"and",
"extracts",
"bug",
"numbers"
] | train | https://github.com/mythmon/chief-james/blob/a671af30ba76f1bd3d04a31fd2df566fc0425bbd/james.py#L148-L156 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/edsl.py | kwargsql.__resolve_path | def __resolve_path(cls, obj, path):
"""Follow a kwargsql expression starting from a given object
and return the deduced object.
:param obj: the object to start from
:param list path: list of operations to perform. It does not contain
the optional operation of a... | python | def __resolve_path(cls, obj, path):
"""Follow a kwargsql expression starting from a given object
and return the deduced object.
:param obj: the object to start from
:param list path: list of operations to perform. It does not contain
the optional operation of a... | [
"def",
"__resolve_path",
"(",
"cls",
",",
"obj",
",",
"path",
")",
":",
"path",
"=",
"filter",
"(",
"lambda",
"s",
":",
"s",
",",
"path",
")",
"if",
"any",
"(",
"path",
")",
":",
"pathes",
"=",
"len",
"(",
"path",
")",
"i",
"=",
"0",
"while",
... | Follow a kwargsql expression starting from a given object
and return the deduced object.
:param obj: the object to start from
:param list path: list of operations to perform. It does not contain
the optional operation of a traditional kwargsql
... | [
"Follow",
"a",
"kwargsql",
"expression",
"starting",
"from",
"a",
"given",
"object",
"and",
"return",
"the",
"deduced",
"object",
"."
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/edsl.py#L208-L234 |
cogniteev/docido-python-sdk | docido_sdk/toolbox/edsl.py | kwargsql._get_obj_attr | def _get_obj_attr(cls, obj, path, pos):
"""Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: p... | python | def _get_obj_attr(cls, obj, path, pos):
"""Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: p... | [
"def",
"_get_obj_attr",
"(",
"cls",
",",
"obj",
",",
"path",
",",
"pos",
")",
":",
"field",
"=",
"path",
"[",
"pos",
"]",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"dict",
",",
"Mapping",
")",
")",
":",
"return",
"obj",
"[",
"field",
"]",
",",
... | Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: provides index of the expression to evaluate in the
... | [
"Resolve",
"one",
"kwargsql",
"expression",
"for",
"a",
"given",
"object",
"and",
"returns",
"its",
"result",
"."
] | train | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/edsl.py#L245-L271 |
todddeluca/dones | dones.py | get | def get(ns, dburl=None):
'''
Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned.
'''
if dburl is None:
dburl = DONES_DB_URL
cache_key = (ns, dburl)
if ns not in DONES_CACHE:
dones_ns = 'dones_{}'.f... | python | def get(ns, dburl=None):
'''
Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned.
'''
if dburl is None:
dburl = DONES_DB_URL
cache_key = (ns, dburl)
if ns not in DONES_CACHE:
dones_ns = 'dones_{}'.f... | [
"def",
"get",
"(",
"ns",
",",
"dburl",
"=",
"None",
")",
":",
"if",
"dburl",
"is",
"None",
":",
"dburl",
"=",
"DONES_DB_URL",
"cache_key",
"=",
"(",
"ns",
",",
"dburl",
")",
"if",
"ns",
"not",
"in",
"DONES_CACHE",
":",
"dones_ns",
"=",
"'dones_{}'",
... | Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned. | [
"Get",
"a",
"default",
"dones",
"object",
"for",
"ns",
".",
"If",
"no",
"dones",
"object",
"exists",
"for",
"ns",
"yet",
"a",
"DbDones",
"object",
"will",
"be",
"created",
"cached",
"and",
"returned",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L26-L39 |
todddeluca/dones | dones.py | open_conn | def open_conn(host, db, user, password, retries=0, sleep=0.5):
'''
Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this ma... | python | def open_conn(host, db, user, password, retries=0, sleep=0.5):
'''
Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this ma... | [
"def",
"open_conn",
"(",
"host",
",",
"db",
",",
"user",
",",
"password",
",",
"retries",
"=",
"0",
",",
"sleep",
"=",
"0.5",
")",
":",
"assert",
"retries",
">=",
"0",
"try",
":",
"return",
"MySQLdb",
".",
"connect",
"(",
"host",
"=",
"host",
",",
... | Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this many times.
sleep: pause between retries for this many seconds. a float ... | [
"Return",
"an",
"open",
"mysql",
"db",
"connection",
"using",
"the",
"given",
"credentials",
".",
"Use",
"retries",
"and",
"sleep",
"to",
"be",
"robust",
"to",
"the",
"occassional",
"transient",
"connection",
"failure",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L265-L283 |
todddeluca/dones | dones.py | open_url | def open_url(url, retries=0, sleep=0.5):
'''
Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database"
'''
return open_conn(retries=retries, sleep=sleep,... | python | def open_url(url, retries=0, sleep=0.5):
'''
Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database"
'''
return open_conn(retries=retries, sleep=sleep,... | [
"def",
"open_url",
"(",
"url",
",",
"retries",
"=",
"0",
",",
"sleep",
"=",
"0.5",
")",
":",
"return",
"open_conn",
"(",
"retries",
"=",
"retries",
",",
"sleep",
"=",
"sleep",
",",
"*",
"*",
"parse_url",
"(",
"url",
")",
")"
] | Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database" | [
"Open",
"a",
"mysql",
"connection",
"to",
"a",
"url",
".",
"Note",
"that",
"if",
"your",
"password",
"has",
"punctuation",
"characters",
"it",
"might",
"break",
"the",
"parsing",
"of",
"url",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L286-L293 |
todddeluca/dones | dones.py | doTransaction | def doTransaction(conn, start=True, startSQL='START TRANSACTION'):
'''
wrap a connection in a transaction. starts a transaction, yields the conn, and then if an exception occurs, calls rollback(). otherwise calls commit().
start: if True, executes 'START TRANSACTION' sql before yielding conn. Useful for ... | python | def doTransaction(conn, start=True, startSQL='START TRANSACTION'):
'''
wrap a connection in a transaction. starts a transaction, yields the conn, and then if an exception occurs, calls rollback(). otherwise calls commit().
start: if True, executes 'START TRANSACTION' sql before yielding conn. Useful for ... | [
"def",
"doTransaction",
"(",
"conn",
",",
"start",
"=",
"True",
",",
"startSQL",
"=",
"'START TRANSACTION'",
")",
":",
"try",
":",
"if",
"start",
":",
"executeSQL",
"(",
"conn",
",",
"startSQL",
")",
"yield",
"conn",
"except",
":",
"if",
"conn",
"is",
... | wrap a connection in a transaction. starts a transaction, yields the conn, and then if an exception occurs, calls rollback(). otherwise calls commit().
start: if True, executes 'START TRANSACTION' sql before yielding conn. Useful for connections that are autocommit by default.
startSQL: override if 'START TR... | [
"wrap",
"a",
"connection",
"in",
"a",
"transaction",
".",
"starts",
"a",
"transaction",
"yields",
"the",
"conn",
"and",
"then",
"if",
"an",
"exception",
"occurs",
"calls",
"rollback",
"()",
".",
"otherwise",
"calls",
"commit",
"()",
".",
"start",
":",
"if"... | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L324-L339 |
todddeluca/dones | dones.py | selectSQL | def selectSQL(conn, sql, args=None):
'''
sql: a select statement
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns a tuple of rows, each of which is a tuple.
'''
with doCursor(conn) as cursor:
... | python | def selectSQL(conn, sql, args=None):
'''
sql: a select statement
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns a tuple of rows, each of which is a tuple.
'''
with doCursor(conn) as cursor:
... | [
"def",
"selectSQL",
"(",
"conn",
",",
"sql",
",",
"args",
"=",
"None",
")",
":",
"with",
"doCursor",
"(",
"conn",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
"sql",
",",
"args",
")",
"results",
"=",
"cursor",
".",
"fetchall",
"(",
")",... | sql: a select statement
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns a tuple of rows, each of which is a tuple. | [
"sql",
":",
"a",
"select",
"statement",
"args",
":",
"if",
"sql",
"has",
"parameters",
"defined",
"with",
"either",
"%s",
"or",
"%",
"(",
"key",
")",
"s",
"then",
"args",
"should",
"be",
"a",
"either",
"list",
"or",
"dict",
"of",
"parameter",
"values",... | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L354-L364 |
todddeluca/dones | dones.py | insertSQL | def insertSQL(conn, sql, args=None):
'''
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns the insert id
'''
with doCursor(conn) as cursor:
cursor.execute(sql, args)
id = conn.insert_i... | python | def insertSQL(conn, sql, args=None):
'''
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns the insert id
'''
with doCursor(conn) as cursor:
cursor.execute(sql, args)
id = conn.insert_i... | [
"def",
"insertSQL",
"(",
"conn",
",",
"sql",
",",
"args",
"=",
"None",
")",
":",
"with",
"doCursor",
"(",
"conn",
")",
"as",
"cursor",
":",
"cursor",
".",
"execute",
"(",
"sql",
",",
"args",
")",
"id",
"=",
"conn",
".",
"insert_id",
"(",
")",
"re... | args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
returns the insert id | [
"args",
":",
"if",
"sql",
"has",
"parameters",
"defined",
"with",
"either",
"%s",
"or",
"%",
"(",
"key",
")",
"s",
"then",
"args",
"should",
"be",
"a",
"either",
"list",
"or",
"dict",
"of",
"parameter",
"values",
"respectively",
".",
"returns",
"the",
... | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L367-L376 |
todddeluca/dones | dones.py | executeSQL | def executeSQL(conn, sql, args=None):
'''
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
executes sql statement. useful for executing statements like CREATE TABLE or RENAME TABLE,
which do not have an result ... | python | def executeSQL(conn, sql, args=None):
'''
args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
executes sql statement. useful for executing statements like CREATE TABLE or RENAME TABLE,
which do not have an result ... | [
"def",
"executeSQL",
"(",
"conn",
",",
"sql",
",",
"args",
"=",
"None",
")",
":",
"with",
"doCursor",
"(",
"conn",
")",
"as",
"cursor",
":",
"numRowsAffected",
"=",
"cursor",
".",
"execute",
"(",
"sql",
",",
"args",
")",
"return",
"numRowsAffected"
] | args: if sql has parameters defined with either %s or %(key)s then args should be a either list or dict of parameter
values respectively.
executes sql statement. useful for executing statements like CREATE TABLE or RENAME TABLE,
which do not have an result like insert id or a rowset.
returns: the numbe... | [
"args",
":",
"if",
"sql",
"has",
"parameters",
"defined",
"with",
"either",
"%s",
"or",
"%",
"(",
"key",
")",
"s",
"then",
"args",
"should",
"be",
"a",
"either",
"list",
"or",
"dict",
"of",
"parameter",
"values",
"respectively",
".",
"executes",
"sql",
... | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L379-L389 |
todddeluca/dones | dones.py | DbDones._get_k | def _get_k(self):
'''
Accessing self.k indirectly allows for creating the kvstore table
if necessary.
'''
if not self.ready:
self.k.create() # create table if it does not exist.
self.ready = True
return self.k | python | def _get_k(self):
'''
Accessing self.k indirectly allows for creating the kvstore table
if necessary.
'''
if not self.ready:
self.k.create() # create table if it does not exist.
self.ready = True
return self.k | [
"def",
"_get_k",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"ready",
":",
"self",
".",
"k",
".",
"create",
"(",
")",
"# create table if it does not exist.",
"self",
".",
"ready",
"=",
"True",
"return",
"self",
".",
"k"
] | Accessing self.k indirectly allows for creating the kvstore table
if necessary. | [
"Accessing",
"self",
".",
"k",
"indirectly",
"allows",
"for",
"creating",
"the",
"kvstore",
"table",
"if",
"necessary",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L64-L73 |
todddeluca/dones | dones.py | FileJSONAppendDones.clear | def clear(self):
'''
Remove all existing done markers and the file used to store the dones.
'''
if os.path.exists(self.path):
os.remove(self.path) | python | def clear(self):
'''
Remove all existing done markers and the file used to store the dones.
'''
if os.path.exists(self.path):
os.remove(self.path) | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")"
] | Remove all existing done markers and the file used to store the dones. | [
"Remove",
"all",
"existing",
"done",
"markers",
"and",
"the",
"file",
"used",
"to",
"store",
"the",
"dones",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L170-L175 |
todddeluca/dones | dones.py | FileJSONAppendDones.done | def done(self, key):
'''
return True iff key is marked done.
:param key: a json-serializable object.
'''
# key is not done b/c the file does not even exist yet
if not os.path.exists(self.path):
return False
is_done = False
done_line = self._d... | python | def done(self, key):
'''
return True iff key is marked done.
:param key: a json-serializable object.
'''
# key is not done b/c the file does not even exist yet
if not os.path.exists(self.path):
return False
is_done = False
done_line = self._d... | [
"def",
"done",
"(",
"self",
",",
"key",
")",
":",
"# key is not done b/c the file does not even exist yet",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"False",
"is_done",
"=",
"False",
"done_line",
"=",
"self... | return True iff key is marked done.
:param key: a json-serializable object. | [
"return",
"True",
"iff",
"key",
"is",
"marked",
"done",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L195-L215 |
todddeluca/dones | dones.py | FileJSONAppendDones.are_done | def are_done(self, keys):
'''
Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serial... | python | def are_done(self, keys):
'''
Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serial... | [
"def",
"are_done",
"(",
"self",
",",
"keys",
")",
":",
"# No keys are done b/c the file does not even exist yet.",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"[",
"False",
"]",
"*",
"len",
"(",
"keys",
")",... | Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serializable keys | [
"Return",
"a",
"list",
"of",
"boolean",
"values",
"corresponding",
"to",
"whether",
"or",
"not",
"each",
"key",
"in",
"keys",
"is",
"marked",
"done",
".",
"This",
"method",
"can",
"be",
"faster",
"than",
"individually",
"checking",
"each",
"key",
"depending"... | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L217-L241 |
todddeluca/dones | dones.py | KStore.add | def add(self, key):
'''
add key to the namespace. it is fine to add a key multiple times.
'''
encodedKey = json.dumps(key)
with self.connect() as conn:
with doTransaction(conn):
sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
... | python | def add(self, key):
'''
add key to the namespace. it is fine to add a key multiple times.
'''
encodedKey = json.dumps(key)
with self.connect() as conn:
with doTransaction(conn):
sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"encodedKey",
"=",
"json",
".",
"dumps",
"(",
"key",
")",
"with",
"self",
".",
"connect",
"(",
")",
"as",
"conn",
":",
"with",
"doTransaction",
"(",
"conn",
")",
":",
"sql",
"=",
"'INSERT IGNORE INTO '... | add key to the namespace. it is fine to add a key multiple times. | [
"add",
"key",
"to",
"the",
"namespace",
".",
"it",
"is",
"fine",
"to",
"add",
"a",
"key",
"multiple",
"times",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L458-L466 |
todddeluca/dones | dones.py | KStore.remove | def remove(self, key):
'''
remove key from the namespace. it is fine to remove a key multiple times.
'''
encodedKey = json.dumps(key)
sql = 'DELETE FROM ' + self.table + ' WHERE name = %s'
with self.connect() as conn:
with doTransaction(conn):
... | python | def remove(self, key):
'''
remove key from the namespace. it is fine to remove a key multiple times.
'''
encodedKey = json.dumps(key)
sql = 'DELETE FROM ' + self.table + ' WHERE name = %s'
with self.connect() as conn:
with doTransaction(conn):
... | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"encodedKey",
"=",
"json",
".",
"dumps",
"(",
"key",
")",
"sql",
"=",
"'DELETE FROM '",
"+",
"self",
".",
"table",
"+",
"' WHERE name = %s'",
"with",
"self",
".",
"connect",
"(",
")",
"as",
"conn",
... | remove key from the namespace. it is fine to remove a key multiple times. | [
"remove",
"key",
"from",
"the",
"namespace",
".",
"it",
"is",
"fine",
"to",
"remove",
"a",
"key",
"multiple",
"times",
"."
] | train | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L468-L476 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.load_machine | def load_machine(self, descriptor):
"""
Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values.
"""
def get_cfg(name):
if(name in descriptor):
return descriptor[name]
else:
return defaults[name]
self.processor = Processor(width = get_... | python | def load_machine(self, descriptor):
"""
Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values.
"""
def get_cfg(name):
if(name in descriptor):
return descriptor[name]
else:
return defaults[name]
self.processor = Processor(width = get_... | [
"def",
"load_machine",
"(",
"self",
",",
"descriptor",
")",
":",
"def",
"get_cfg",
"(",
"name",
")",
":",
"if",
"(",
"name",
"in",
"descriptor",
")",
":",
"return",
"descriptor",
"[",
"name",
"]",
"else",
":",
"return",
"defaults",
"[",
"name",
"]",
... | Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values. | [
"Load",
"a",
"complete",
"register",
"machine",
".",
"The",
"descriptor",
"is",
"a",
"map",
"unspecified",
"values",
"are",
"loaded",
"from",
"the",
"default",
"values",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L67-L99 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.assemble_rom_code | def assemble_rom_code(self, asm):
"""
assemble the given code and program the ROM
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.rom.program(result)
return None, result | python | def assemble_rom_code(self, asm):
"""
assemble the given code and program the ROM
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.rom.program(result)
return None, result | [
"def",
"assemble_rom_code",
"(",
"self",
",",
"asm",
")",
":",
"stream",
"=",
"StringIO",
"(",
"asm",
")",
"worker",
"=",
"assembler",
".",
"Assembler",
"(",
"self",
".",
"processor",
",",
"stream",
")",
"try",
":",
"result",
"=",
"worker",
".",
"assem... | assemble the given code and program the ROM | [
"assemble",
"the",
"given",
"code",
"and",
"program",
"the",
"ROM"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L105-L116 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.assemble_flash_code | def assemble_flash_code(self, asm):
"""
assemble the given code and program the Flash
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.flash.program(result)
return None, result | python | def assemble_flash_code(self, asm):
"""
assemble the given code and program the Flash
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.flash.program(result)
return None, result | [
"def",
"assemble_flash_code",
"(",
"self",
",",
"asm",
")",
":",
"stream",
"=",
"StringIO",
"(",
"asm",
")",
"worker",
"=",
"assembler",
".",
"Assembler",
"(",
"self",
".",
"processor",
",",
"stream",
")",
"try",
":",
"result",
"=",
"worker",
".",
"ass... | assemble the given code and program the Flash | [
"assemble",
"the",
"given",
"code",
"and",
"program",
"the",
"Flash"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L117-L128 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.flush_devices | def flush_devices(self):
"""
overwrite the complete memory with zeros
"""
self.rom.program([0 for i in range(self.rom.size)])
self.flash.program([0 for i in range(self.flash.size)])
for i in range(self.ram.size):
self.ram.write(i, 0) | python | def flush_devices(self):
"""
overwrite the complete memory with zeros
"""
self.rom.program([0 for i in range(self.rom.size)])
self.flash.program([0 for i in range(self.flash.size)])
for i in range(self.ram.size):
self.ram.write(i, 0) | [
"def",
"flush_devices",
"(",
"self",
")",
":",
"self",
".",
"rom",
".",
"program",
"(",
"[",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"rom",
".",
"size",
")",
"]",
")",
"self",
".",
"flash",
".",
"program",
"(",
"[",
"0",
"for",
"i",
... | overwrite the complete memory with zeros | [
"overwrite",
"the",
"complete",
"memory",
"with",
"zeros"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L153-L160 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.get_rom | def get_rom(self, format_ = "nl"):
"""
return a string representations of the rom
"""
rom = [self.rom.read(i) for i in range(self.rom.size)]
return self._format_mem(rom, format_) | python | def get_rom(self, format_ = "nl"):
"""
return a string representations of the rom
"""
rom = [self.rom.read(i) for i in range(self.rom.size)]
return self._format_mem(rom, format_) | [
"def",
"get_rom",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"rom",
"=",
"[",
"self",
".",
"rom",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"rom",
".",
"size",
")",
"]",
"return",
"self",
".",
"_format_... | return a string representations of the rom | [
"return",
"a",
"string",
"representations",
"of",
"the",
"rom"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L168-L173 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.get_ram | def get_ram(self, format_ = "nl"):
"""
return a string representations of the ram
"""
ram = [self.ram.read(i) for i in range(self.ram.size)]
return self._format_mem(ram, format_) | python | def get_ram(self, format_ = "nl"):
"""
return a string representations of the ram
"""
ram = [self.ram.read(i) for i in range(self.ram.size)]
return self._format_mem(ram, format_) | [
"def",
"get_ram",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"ram",
"=",
"[",
"self",
".",
"ram",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"ram",
".",
"size",
")",
"]",
"return",
"self",
".",
"_format_... | return a string representations of the ram | [
"return",
"a",
"string",
"representations",
"of",
"the",
"ram"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L174-L179 |
daknuett/py_register_machine2 | app/web/model.py | RMServer.get_flash | def get_flash(self, format_ = "nl"):
"""
return a string representations of the flash
"""
flash = [self.flash.read(i) for i in range(self.flash.size)]
return self._format_mem(flash, format_) | python | def get_flash(self, format_ = "nl"):
"""
return a string representations of the flash
"""
flash = [self.flash.read(i) for i in range(self.flash.size)]
return self._format_mem(flash, format_) | [
"def",
"get_flash",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"flash",
"=",
"[",
"self",
".",
"flash",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"flash",
".",
"size",
")",
"]",
"return",
"self",
".",
"... | return a string representations of the flash | [
"return",
"a",
"string",
"representations",
"of",
"the",
"flash"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L180-L185 |
soasme/rio-client | rio_client/base.py | Client.emit | def emit(self, action, payload=None, retry=0):
"""Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict.
"""
payload = payload or {}
if retry:
... | python | def emit(self, action, payload=None, retry=0):
"""Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict.
"""
payload = payload or {}
if retry:
... | [
"def",
"emit",
"(",
"self",
",",
"action",
",",
"payload",
"=",
"None",
",",
"retry",
"=",
"0",
")",
":",
"payload",
"=",
"payload",
"or",
"{",
"}",
"if",
"retry",
":",
"_retry",
"=",
"self",
".",
"transport",
".",
"retry",
"(",
"retry",
")",
"em... | Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict. | [
"Emit",
"action",
"with",
"payload",
"."
] | train | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/base.py#L31-L47 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_upcoming_events | def get_upcoming_events(self):
"""
Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadR... | python | def get_upcoming_events(self):
"""
Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadR... | [
"def",
"get_upcoming_events",
"(",
"self",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'group_urlname'",
":",
"GROUP_URLNAME",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
"EVENTS_URL... | Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse
* PythonKCMeetupsMeetupDown
... | [
"Get",
"upcoming",
"PythonKC",
"meetup",
"events",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L60-L84 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_past_events | def get_past_events(self):
"""
Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse... | python | def get_past_events(self):
"""
Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse... | [
"def",
"get_past_events",
"(",
"self",
")",
":",
"def",
"get_attendees",
"(",
"event",
")",
":",
"return",
"[",
"attendee",
"for",
"event_id",
",",
"attendee",
"in",
"events_attendees",
"if",
"event_id",
"==",
"event",
"[",
"'id'",
"]",
"]",
"def",
"get_ph... | Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse
* PythonKCMeetupsMeetupDown
* ... | [
"Get",
"past",
"PythonKC",
"meetup",
"events",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L86-L130 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_events_attendees | def get_events_attendees(self, event_ids):
"""
Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.Meetu... | python | def get_events_attendees(self, event_ids):
"""
Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.Meetu... | [
"def",
"get_events_attendees",
"(",
"self",
",",
"event_ids",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"','",
".",
"join",
"(",
"event_ids",
")",
"}",
")",
"url",
"=",
... | Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupMember``).
Exceptions
----------
* Py... | [
"Get",
"the",
"attendees",
"of",
"the",
"identified",
"events",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L132-L161 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_event_attendees | def get_event_attendees(self, event_id):
"""
Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
... | python | def get_event_attendees(self, event_id):
"""
Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
... | [
"def",
"get_event_attendees",
"(",
"self",
",",
"event_id",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"event_id",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
... | Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
----------
* PythonKCMeetupsBadJson
*... | [
"Get",
"the",
"attendees",
"of",
"the",
"identified",
"event",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L163-L191 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_events_photos | def get_events_photos(self, event_ids):
"""
Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
... | python | def get_events_photos(self, event_ids):
"""
Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
... | [
"def",
"get_events_photos",
"(",
"self",
",",
"event_ids",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"','",
".",
"join",
"(",
"event_ids",
")",
"}",
")",
"url",
"=",
"... | Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
Exceptions
----------
* PythonKCMeet... | [
"Get",
"photos",
"for",
"the",
"identified",
"events",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L193-L221 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_event_photos | def get_event_photos(self, event_id):
"""
Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
-----... | python | def get_event_photos(self, event_id):
"""
Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
-----... | [
"def",
"get_event_photos",
"(",
"self",
",",
"event_id",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"event_id",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
"PH... | Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCM... | [
"Get",
"photos",
"for",
"the",
"identified",
"event",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L223-L250 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups._http_get_json | def _http_get_json(self, url):
"""
Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dicti... | python | def _http_get_json(self, url):
"""
Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dicti... | [
"def",
"_http_get_json",
"(",
"self",
",",
"url",
")",
":",
"response",
"=",
"self",
".",
"_http_get",
"(",
"url",
")",
"content_type",
"=",
"response",
".",
"headers",
"[",
"'content-type'",
"]",
"parsed_mimetype",
"=",
"mimeparse",
".",
"parse_mime_type",
... | Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dictionary of data parsed from a JSON HTTP response.
... | [
"Make",
"an",
"HTTP",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"check",
"that",
"it",
"returned",
"a",
"JSON",
"response",
"and",
"returned",
"the",
"data",
"parsed",
"from",
"that",
"response",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L252-L285 |
pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups._http_get | def _http_get(self, url):
"""
Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 50... | python | def _http_get(self, url):
"""
Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 50... | [
"def",
"_http_get",
"(",
"self",
",",
"url",
")",
":",
"for",
"try_number",
"in",
"range",
"(",
"self",
".",
"_http_retries",
"+",
"1",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"timeout",
"=",
"self",
".",
"_http_timeout",
... | Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 502, 503, and 504.
Returns
----... | [
"Make",
"an",
"HTTP",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"and",
"return",
"the",
"response",
"."
] | train | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L287-L325 |
exekias/droplet | droplet/common.py | save | def save():
"""
Apply configuration changes on all the modules
"""
from .models import ModuleInfo
logger = logging.getLogger(__name__)
logger.info("Saving changes")
# Save + restart
for module in modules():
if module.enabled:
if module.changed:
modul... | python | def save():
"""
Apply configuration changes on all the modules
"""
from .models import ModuleInfo
logger = logging.getLogger(__name__)
logger.info("Saving changes")
# Save + restart
for module in modules():
if module.enabled:
if module.changed:
modul... | [
"def",
"save",
"(",
")",
":",
"from",
".",
"models",
"import",
"ModuleInfo",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"\"Saving changes\"",
")",
"# Save + restart",
"for",
"module",
"in",
"modules",
"(",
... | Apply configuration changes on all the modules | [
"Apply",
"configuration",
"changes",
"on",
"all",
"the",
"modules"
] | train | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/common.py#L40-L66 |
minhhoit/yacms | yacms/pages/fields.py | MenusField.get_default | def get_default(self):
"""
If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable.
"""
if self._overridden_default:
... | python | def get_default(self):
"""
If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable.
"""
if self._overridden_default:
... | [
"def",
"get_default",
"(",
"self",
")",
":",
"if",
"self",
".",
"_overridden_default",
":",
"# Even with user-provided default we'd rather not have it",
"# forced to text. Compare with Field.get_default().",
"if",
"callable",
"(",
"self",
".",
"default",
")",
":",
"default"... | If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable. | [
"If",
"the",
"user",
"provided",
"a",
"default",
"in",
"the",
"field",
"definition",
"returns",
"it",
"otherwise",
"determines",
"the",
"default",
"menus",
"based",
"on",
"available",
"choices",
"and",
"PAGE_MENU_TEMPLATES_DEFAULT",
".",
"Ensures",
"the",
"default... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/fields.py#L26-L50 |
minhhoit/yacms | yacms/pages/fields.py | MenusField._get_choices | def _get_choices(self):
"""
Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition.
"""
if self._overridden_choices:
# Note: choices is a property on Field bound to _get_choices().
return self._cho... | python | def _get_choices(self):
"""
Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition.
"""
if self._overridden_choices:
# Note: choices is a property on Field bound to _get_choices().
return self._cho... | [
"def",
"_get_choices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_overridden_choices",
":",
"# Note: choices is a property on Field bound to _get_choices().",
"return",
"self",
".",
"_choices",
"else",
":",
"menus",
"=",
"getattr",
"(",
"settings",
",",
"\"PAGE_MENU_... | Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition. | [
"Returns",
"menus",
"specified",
"in",
"PAGE_MENU_TEMPLATES",
"unless",
"you",
"provide",
"some",
"custom",
"choices",
"in",
"the",
"field",
"definition",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/fields.py#L52-L62 |
brutasse/rache | rache/__init__.py | job_details | def job_details(job_id, connection=None):
"""Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve."""
if connection is None:
connection = r
data = connection.hgetall(job_key(job_id))
job_data = {'id': job_id, 'schedule_at': int(connection.zscore(R... | python | def job_details(job_id, connection=None):
"""Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve."""
if connection is None:
connection = r
data = connection.hgetall(job_key(job_id))
job_data = {'id': job_id, 'schedule_at': int(connection.zscore(R... | [
"def",
"job_details",
"(",
"job_id",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"data",
"=",
"connection",
".",
"hgetall",
"(",
"job_key",
"(",
"job_id",
")",
")",
"job_data",
"=",
"{",
"'id... | Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve. | [
"Returns",
"the",
"job",
"data",
"with",
"its",
"scheduled",
"timestamp",
"."
] | train | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L27-L45 |
brutasse/rache | rache/__init__.py | schedule_job | def schedule_job(job_id, schedule_in, connection=None, **kwargs):
"""Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure... | python | def schedule_job(job_id, schedule_in, connection=None, **kwargs):
"""Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure... | [
"def",
"schedule_job",
"(",
"job_id",
",",
"schedule_in",
",",
"connection",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"schedule_in",
",",
"int",
")",
":",
"# assumed to be a timedelta",
"schedule_in",
"=",
"schedule_in",
... | Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure.
>>> schedule_job('http://example.com/test', schedule_in=10, num_re... | [
"Schedules",
"a",
"job",
"."
] | train | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L48-L87 |
brutasse/rache | rache/__init__.py | delete_job | def delete_job(job_id, connection=None):
"""Deletes a job.
:param job_id: unique identifier for this job
>>> delete_job('http://example.com/test')
"""
if connection is None:
connection = r
with connection.pipeline() as pipe:
pipe.delete(job_key(job_id))
pipe.zrem(REDIS_... | python | def delete_job(job_id, connection=None):
"""Deletes a job.
:param job_id: unique identifier for this job
>>> delete_job('http://example.com/test')
"""
if connection is None:
connection = r
with connection.pipeline() as pipe:
pipe.delete(job_key(job_id))
pipe.zrem(REDIS_... | [
"def",
"delete_job",
"(",
"job_id",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"with",
"connection",
".",
"pipeline",
"(",
")",
"as",
"pipe",
":",
"pipe",
".",
"delete",
"(",
"job_key",
"(",... | Deletes a job.
:param job_id: unique identifier for this job
>>> delete_job('http://example.com/test') | [
"Deletes",
"a",
"job",
"."
] | train | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L90-L102 |
brutasse/rache | rache/__init__.py | pending_jobs | def pending_jobs(reschedule_in=None, limit=None, connection=None):
"""Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set ... | python | def pending_jobs(reschedule_in=None, limit=None, connection=None):
"""Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set ... | [
"def",
"pending_jobs",
"(",
"reschedule_in",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"start",
"=",
"None",
"if",
"limit",
"is",
"None",
"else",
"0"... | Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set to None (default),
retrieves all pending jobs with no limit. | [
"Gets",
"the",
"job",
"needing",
"execution",
"."
] | train | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L105-L147 |
brutasse/rache | rache/__init__.py | scheduled_jobs | def scheduled_jobs(with_times=False, connection=None):
"""Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings.
"""
if connection is None:
connection = r
jobs = connection.zrangebyscore(REDIS_KEY, 0, sys... | python | def scheduled_jobs(with_times=False, connection=None):
"""Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings.
"""
if connection is None:
connection = r
jobs = connection.zrangebyscore(REDIS_KEY, 0, sys... | [
"def",
"scheduled_jobs",
"(",
"with_times",
"=",
"False",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"jobs",
"=",
"connection",
".",
"zrangebyscore",
"(",
"REDIS_KEY",
",",
"0",
",",
"sys",
".... | Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings. | [
"Gets",
"all",
"jobs",
"in",
"the",
"scheduler",
"."
] | train | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L150-L164 |
SmartDeveloperHub/agora-service-provider | agora/provider/server/base.py | AgoraApp.batch_work | def batch_work(self):
"""
Method to be executed in batch mode for collecting the required fragment (composite)
and then other custom tasks.
:return:
"""
while True:
gen = collect_fragment(self._stop_event, self.config['AGORA'])
for collector, (t, ... | python | def batch_work(self):
"""
Method to be executed in batch mode for collecting the required fragment (composite)
and then other custom tasks.
:return:
"""
while True:
gen = collect_fragment(self._stop_event, self.config['AGORA'])
for collector, (t, ... | [
"def",
"batch_work",
"(",
"self",
")",
":",
"while",
"True",
":",
"gen",
"=",
"collect_fragment",
"(",
"self",
".",
"_stop_event",
",",
"self",
".",
"config",
"[",
"'AGORA'",
"]",
")",
"for",
"collector",
",",
"(",
"t",
",",
"s",
",",
"p",
",",
"o"... | Method to be executed in batch mode for collecting the required fragment (composite)
and then other custom tasks.
:return: | [
"Method",
"to",
"be",
"executed",
"in",
"batch",
"mode",
"for",
"collecting",
"the",
"required",
"fragment",
"(",
"composite",
")",
"and",
"then",
"other",
"custom",
"tasks",
".",
":",
"return",
":"
] | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/server/base.py#L105-L121 |
SmartDeveloperHub/agora-service-provider | agora/provider/server/base.py | AgoraApp.run | def run(self, host=None, port=None, debug=None, **options):
"""
Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields.
"""
tasks = options.get('tasks', [])
for task in tasks:
if task is not None and hasattr(task, '__call__'):
... | python | def run(self, host=None, port=None, debug=None, **options):
"""
Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields.
"""
tasks = options.get('tasks', [])
for task in tasks:
if task is not None and hasattr(task, '__call__'):
... | [
"def",
"run",
"(",
"self",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"debug",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"tasks",
"=",
"options",
".",
"get",
"(",
"'tasks'",
",",
"[",
"]",
")",
"for",
"task",
"in",
"tasks",... | Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields. | [
"Start",
"the",
"AgoraApp",
"expecting",
"the",
"provided",
"config",
"to",
"have",
"at",
"least",
"REDIS",
"and",
"PORT",
"fields",
"."
] | train | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/server/base.py#L123-L142 |
thomasvandoren/bugzscout-py | doc/example/src/celery_wsgi.py | _handle_exc | def _handle_exc(exception):
"""Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app
"""
# Set the des... | python | def _handle_exc(exception):
"""Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app
"""
# Set the des... | [
"def",
"_handle_exc",
"(",
"exception",
")",
":",
"# Set the description to a familiar string with the exception",
"# message. Add the stack trace to extra.",
"bugzscout",
".",
"ext",
".",
"celery_app",
".",
"submit_error",
".",
"delay",
"(",
"'http://fogbugz/scoutSubmit.asp'",
... | Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app | [
"Record",
"exception",
"with",
"stack",
"trace",
"to",
"FogBugz",
"via",
"BugzScout",
"asynchronously",
".",
"Returns",
"an",
"empty",
"string",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/doc/example/src/celery_wsgi.py#L19-L39 |
thomasvandoren/bugzscout-py | doc/example/src/celery_wsgi.py | app | def app(environ, start_response):
"""Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or... | python | def app(environ, start_response):
"""Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or... | [
"def",
"app",
"(",
"environ",
",",
"start_response",
")",
":",
"try",
":",
"if",
"environ",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'GET'",
":",
"start_response",
"(",
"'200 OK'",
",",
"[",
"(",
"'content-type'",
",",
"'text/html'",
")",
"]",
")",
"return",
... | Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or any information about it. The error and
... | [
"Simple",
"WSGI",
"application",
".",
"Returns",
"200",
"OK",
"response",
"with",
"Hellow",
"world!",
"in",
"the",
"body",
"for",
"GET",
"requests",
".",
"Returns",
"405",
"Method",
"Not",
"Allowed",
"for",
"all",
"other",
"methods",
"."
] | train | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/doc/example/src/celery_wsgi.py#L42-L71 |
gmr/remy | remy/cli.py | add_cookbook_mgmt_options | def add_cookbook_mgmt_options(parser):
"""Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('cookbook', help='Invoke in a Jenkins job to '
'update a cookbook in '
... | python | def add_cookbook_mgmt_options(parser):
"""Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('cookbook', help='Invoke in a Jenkins job to '
'update a cookbook in '
... | [
"def",
"add_cookbook_mgmt_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'cookbook'",
",",
"help",
"=",
"'Invoke in a Jenkins job to '",
"'update a cookbook in '",
"'chef-repo'",
")",
"cookbook",
".",
"add_argument",
"(",
"'repo... | Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser | [
"Add",
"the",
"cookbook",
"management",
"command",
"and",
"arguments",
"."
] | train | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L19-L30 |
gmr/remy | remy/cli.py | add_github_hook_options | def add_github_hook_options(parser):
"""Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('github', help='Install the Jenkins callback '
'hook in a GitHub repository')
cookbook.add_arg... | python | def add_github_hook_options(parser):
"""Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('github', help='Install the Jenkins callback '
'hook in a GitHub repository')
cookbook.add_arg... | [
"def",
"add_github_hook_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'github'",
",",
"help",
"=",
"'Install the Jenkins callback '",
"'hook in a GitHub repository'",
")",
"cookbook",
".",
"add_argument",
"(",
"'owner'",
",",
... | Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser | [
"Add",
"the",
"github",
"jenkins",
"hook",
"command",
"and",
"arguments",
"."
] | train | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L32-L61 |
gmr/remy | remy/cli.py | add_jenkins_job_options | def add_jenkins_job_options(parser):
"""Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('jenkins', help='Add a new cookbook job to '
'Jenkins')
cookbook.add_argument('jenkins', action=... | python | def add_jenkins_job_options(parser):
"""Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('jenkins', help='Add a new cookbook job to '
'Jenkins')
cookbook.add_argument('jenkins', action=... | [
"def",
"add_jenkins_job_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'jenkins'",
",",
"help",
"=",
"'Add a new cookbook job to '",
"'Jenkins'",
")",
"cookbook",
".",
"add_argument",
"(",
"'jenkins'",
",",
"action",
"=",
... | Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser | [
"Add",
"a",
"new",
"job",
"to",
"Jenkins",
"for",
"updating",
"chef",
"-",
"repo"
] | train | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L64-L90 |
gmr/remy | remy/cli.py | argparser | def argparser():
"""Build the argument parser
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description=__description__)
sparser = parser.add_subparsers()
add_cookbook_mgmt_options(sparser)
add_role_options(sparser)
add_github_hook_options(sparser)
add_jenkin... | python | def argparser():
"""Build the argument parser
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description=__description__)
sparser = parser.add_subparsers()
add_cookbook_mgmt_options(sparser)
add_role_options(sparser)
add_github_hook_options(sparser)
add_jenkin... | [
"def",
"argparser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__description__",
")",
"sparser",
"=",
"parser",
".",
"add_subparsers",
"(",
")",
"add_cookbook_mgmt_options",
"(",
"sparser",
")",
"add_role_options",
... | Build the argument parser
:rtype: argparse.ArgumentParser | [
"Build",
"the",
"argument",
"parser"
] | train | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L105-L117 |
jmgilman/Neolib | neolib/pyamf/adapters/__init__.py | register_adapter | def register_adapter(mod, func):
"""
Registers a callable to be executed when a module is imported. If the
module already exists then the callable will be executed immediately.
You can register the same module multiple times, the callables will be
executed in the order they were registered. The root... | python | def register_adapter(mod, func):
"""
Registers a callable to be executed when a module is imported. If the
module already exists then the callable will be executed immediately.
You can register the same module multiple times, the callables will be
executed in the order they were registered. The root... | [
"def",
"register_adapter",
"(",
"mod",
",",
"func",
")",
":",
"if",
"not",
"hasattr",
"(",
"func",
",",
"'__call__'",
")",
":",
"raise",
"TypeError",
"(",
"'func must be callable'",
")",
"imports",
".",
"when_imported",
"(",
"mod",
",",
"func",
")"
] | Registers a callable to be executed when a module is imported. If the
module already exists then the callable will be executed immediately.
You can register the same module multiple times, the callables will be
executed in the order they were registered. The root module must exist
(i.e. be importable) o... | [
"Registers",
"a",
"callable",
"to",
"be",
"executed",
"when",
"a",
"module",
"is",
"imported",
".",
"If",
"the",
"module",
"already",
"exists",
"then",
"the",
"callable",
"will",
"be",
"executed",
"immediately",
".",
"You",
"can",
"register",
"the",
"same",
... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/adapters/__init__.py#L57-L76 |
nickw444/wtforms-webwidgets | wtforms_webwidgets/bootstrap/util.py | render_field_errors | def render_field_errors(field):
"""
Render field errors as html.
"""
if field.errors:
html = """<p class="help-block">Error: {errors}</p>""".format(
errors='. '.join(field.errors)
)
return HTMLString(html)
return None | python | def render_field_errors(field):
"""
Render field errors as html.
"""
if field.errors:
html = """<p class="help-block">Error: {errors}</p>""".format(
errors='. '.join(field.errors)
)
return HTMLString(html)
return None | [
"def",
"render_field_errors",
"(",
"field",
")",
":",
"if",
"field",
".",
"errors",
":",
"html",
"=",
"\"\"\"<p class=\"help-block\">Error: {errors}</p>\"\"\"",
".",
"format",
"(",
"errors",
"=",
"'. '",
".",
"join",
"(",
"field",
".",
"errors",
")",
")",
"ret... | Render field errors as html. | [
"Render",
"field",
"errors",
"as",
"html",
"."
] | train | https://github.com/nickw444/wtforms-webwidgets/blob/88f224b68c0b0f4f5c97de39fe1428b96e12f8db/wtforms_webwidgets/bootstrap/util.py#L7-L17 |
nickw444/wtforms-webwidgets | wtforms_webwidgets/bootstrap/util.py | render_field_description | def render_field_description(field):
"""
Render a field description as HTML.
"""
if hasattr(field, 'description') and field.description != '':
html = """<p class="help-block">{field.description}</p>"""
html = html.format(
field=field
)
return HTMLString(html)... | python | def render_field_description(field):
"""
Render a field description as HTML.
"""
if hasattr(field, 'description') and field.description != '':
html = """<p class="help-block">{field.description}</p>"""
html = html.format(
field=field
)
return HTMLString(html)... | [
"def",
"render_field_description",
"(",
"field",
")",
":",
"if",
"hasattr",
"(",
"field",
",",
"'description'",
")",
"and",
"field",
".",
"description",
"!=",
"''",
":",
"html",
"=",
"\"\"\"<p class=\"help-block\">{field.description}</p>\"\"\"",
"html",
"=",
"html",... | Render a field description as HTML. | [
"Render",
"a",
"field",
"description",
"as",
"HTML",
"."
] | train | https://github.com/nickw444/wtforms-webwidgets/blob/88f224b68c0b0f4f5c97de39fe1428b96e12f8db/wtforms_webwidgets/bootstrap/util.py#L19-L30 |
nickw444/wtforms-webwidgets | wtforms_webwidgets/bootstrap/util.py | form_group_wrapped | def form_group_wrapped(f):
"""
Wrap a field within a bootstrap form-group. Additionally sets has-error
This decorator sets has-error if the field has any errors.
"""
@wraps(f)
def wrapped(self, field, *args, **kwargs):
classes = ['form-group']
if field.errors:
classe... | python | def form_group_wrapped(f):
"""
Wrap a field within a bootstrap form-group. Additionally sets has-error
This decorator sets has-error if the field has any errors.
"""
@wraps(f)
def wrapped(self, field, *args, **kwargs):
classes = ['form-group']
if field.errors:
classe... | [
"def",
"form_group_wrapped",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"self",
",",
"field",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"classes",
"=",
"[",
"'form-group'",
"]",
"if",
"field",
".",
"errors",
... | Wrap a field within a bootstrap form-group. Additionally sets has-error
This decorator sets has-error if the field has any errors. | [
"Wrap",
"a",
"field",
"within",
"a",
"bootstrap",
"form",
"-",
"group",
".",
"Additionally",
"sets",
"has",
"-",
"error"
] | train | https://github.com/nickw444/wtforms-webwidgets/blob/88f224b68c0b0f4f5c97de39fe1428b96e12f8db/wtforms_webwidgets/bootstrap/util.py#L33-L51 |
nickw444/wtforms-webwidgets | wtforms_webwidgets/bootstrap/util.py | meta_wrapped | def meta_wrapped(f):
"""
Add a field label, errors, and a description (if it exists) to
a field.
"""
@wraps(f)
def wrapped(self, field, *args, **kwargs):
html = "{label}{errors}{original}<small>{description}</small>".format(
label=field.label(class_='control-label'),
... | python | def meta_wrapped(f):
"""
Add a field label, errors, and a description (if it exists) to
a field.
"""
@wraps(f)
def wrapped(self, field, *args, **kwargs):
html = "{label}{errors}{original}<small>{description}</small>".format(
label=field.label(class_='control-label'),
... | [
"def",
"meta_wrapped",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"self",
",",
"field",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"\"{label}{errors}{original}<small>{description}</small>\"",
".",
"format... | Add a field label, errors, and a description (if it exists) to
a field. | [
"Add",
"a",
"field",
"label",
"errors",
"and",
"a",
"description",
"(",
"if",
"it",
"exists",
")",
"to",
"a",
"field",
"."
] | train | https://github.com/nickw444/wtforms-webwidgets/blob/88f224b68c0b0f4f5c97de39fe1428b96e12f8db/wtforms_webwidgets/bootstrap/util.py#L53-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.