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 |
|---|---|---|---|---|---|---|---|---|---|---|
synw/goerr | goerr/__init__.py | Err._headline | def _headline(self, error, i: int) -> str:
"""
Format the error message's headline
"""
msgs = Msg()
# get the error title
if error.errclass == "fatal":
msg = msgs.fatal(i)
elif error.errclass == "warning":
msg = msgs.warning(i)
elif... | python | def _headline(self, error, i: int) -> str:
"""
Format the error message's headline
"""
msgs = Msg()
# get the error title
if error.errclass == "fatal":
msg = msgs.fatal(i)
elif error.errclass == "warning":
msg = msgs.warning(i)
elif... | [
"def",
"_headline",
"(",
"self",
",",
"error",
",",
"i",
":",
"int",
")",
"->",
"str",
":",
"msgs",
"=",
"Msg",
"(",
")",
"# get the error title",
"if",
"error",
".",
"errclass",
"==",
"\"fatal\"",
":",
"msg",
"=",
"msgs",
".",
"fatal",
"(",
"i",
"... | Format the error message's headline | [
"Format",
"the",
"error",
"message",
"s",
"headline"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L190-L223 |
synw/goerr | goerr/__init__.py | Err._errmsg | def _errmsg(self, error: "Err", tb: bool=False, i: int=None,
msgformat: str="terminal") -> str:
"""
Get the error message
"""
if msgformat == "terminal":
msg = self._headline(error, i)
if error.ex is not None:
msg += "\n" + "line " ... | python | def _errmsg(self, error: "Err", tb: bool=False, i: int=None,
msgformat: str="terminal") -> str:
"""
Get the error message
"""
if msgformat == "terminal":
msg = self._headline(error, i)
if error.ex is not None:
msg += "\n" + "line " ... | [
"def",
"_errmsg",
"(",
"self",
",",
"error",
":",
"\"Err\"",
",",
"tb",
":",
"bool",
"=",
"False",
",",
"i",
":",
"int",
"=",
"None",
",",
"msgformat",
":",
"str",
"=",
"\"terminal\"",
")",
"->",
"str",
":",
"if",
"msgformat",
"==",
"\"terminal\"",
... | Get the error message | [
"Get",
"the",
"error",
"message"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L225-L263 |
synw/goerr | goerr/__init__.py | Err._print_errs | def _print_errs(self):
"""
Prints the errors trace with tracebacks
"""
i = 0
for error in self.errors:
print(self._errmsg(error, tb=True, i=i))
# for spacing
if self.errs_traceback is False:
print()
i += 1 | python | def _print_errs(self):
"""
Prints the errors trace with tracebacks
"""
i = 0
for error in self.errors:
print(self._errmsg(error, tb=True, i=i))
# for spacing
if self.errs_traceback is False:
print()
i += 1 | [
"def",
"_print_errs",
"(",
"self",
")",
":",
"i",
"=",
"0",
"for",
"error",
"in",
"self",
".",
"errors",
":",
"print",
"(",
"self",
".",
"_errmsg",
"(",
"error",
",",
"tb",
"=",
"True",
",",
"i",
"=",
"i",
")",
")",
"# for spacing",
"if",
"self",... | Prints the errors trace with tracebacks | [
"Prints",
"the",
"errors",
"trace",
"with",
"tracebacks"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L271-L281 |
synw/goerr | goerr/__init__.py | Err._add | def _add(self, error: "Err"):
"""
Adds an error to the trace if required
"""
if self.trace_errs is True:
self.errors.append(error) | python | def _add(self, error: "Err"):
"""
Adds an error to the trace if required
"""
if self.trace_errs is True:
self.errors.append(error) | [
"def",
"_add",
"(",
"self",
",",
"error",
":",
"\"Err\"",
")",
":",
"if",
"self",
".",
"trace_errs",
"is",
"True",
":",
"self",
".",
"errors",
".",
"append",
"(",
"error",
")"
] | Adds an error to the trace if required | [
"Adds",
"an",
"error",
"to",
"the",
"trace",
"if",
"required"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L283-L288 |
synw/goerr | goerr/__init__.py | Err._get_caller | def _get_caller(self, callers: List[str], function: str) -> str:
"""
Get the caller function from the provided function
"""
is_next = False
for c in callers:
if is_next is True:
return c
if function == c:
is_next = True | python | def _get_caller(self, callers: List[str], function: str) -> str:
"""
Get the caller function from the provided function
"""
is_next = False
for c in callers:
if is_next is True:
return c
if function == c:
is_next = True | [
"def",
"_get_caller",
"(",
"self",
",",
"callers",
":",
"List",
"[",
"str",
"]",
",",
"function",
":",
"str",
")",
"->",
"str",
":",
"is_next",
"=",
"False",
"for",
"c",
"in",
"callers",
":",
"if",
"is_next",
"is",
"True",
":",
"return",
"c",
"if",... | Get the caller function from the provided function | [
"Get",
"the",
"caller",
"function",
"from",
"the",
"provided",
"function"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L290-L299 |
synw/goerr | goerr/__init__.py | Err._get_args | def _get_args(self, *args) -> (Exception, str):
"""
Returns exception and message from the provided arguments
"""
ex = None
msg = None
for arg in args:
if isinstance(arg, str):
msg = arg
elif isinstance(arg, Exception):
... | python | def _get_args(self, *args) -> (Exception, str):
"""
Returns exception and message from the provided arguments
"""
ex = None
msg = None
for arg in args:
if isinstance(arg, str):
msg = arg
elif isinstance(arg, Exception):
... | [
"def",
"_get_args",
"(",
"self",
",",
"*",
"args",
")",
"->",
"(",
"Exception",
",",
"str",
")",
":",
"ex",
"=",
"None",
"msg",
"=",
"None",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"msg",
"=",
"arg... | Returns exception and message from the provided arguments | [
"Returns",
"exception",
"and",
"message",
"from",
"the",
"provided",
"arguments"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L301-L312 |
synw/goerr | goerr/__init__.py | Trace.trace | def trace(self):
"""
Print the errors trace if there are some errors
"""
if len(self.errors) > 0:
numerrs = len(self.errors)
print("========= Trace (" + str(numerrs) + ") =========")
self._print_errs()
self.errors = [] | python | def trace(self):
"""
Print the errors trace if there are some errors
"""
if len(self.errors) > 0:
numerrs = len(self.errors)
print("========= Trace (" + str(numerrs) + ") =========")
self._print_errs()
self.errors = [] | [
"def",
"trace",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"errors",
")",
">",
"0",
":",
"numerrs",
"=",
"len",
"(",
"self",
".",
"errors",
")",
"print",
"(",
"\"========= Trace (\"",
"+",
"str",
"(",
"numerrs",
")",
"+",
"\") =========\""... | Print the errors trace if there are some errors | [
"Print",
"the",
"errors",
"trace",
"if",
"there",
"are",
"some",
"errors"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L331-L339 |
synw/goerr | goerr/__init__.py | Trace.via | def via(self, *args):
"""
Creates an empty error to record in the stack
trace
"""
error = None
if len(self.errors) > 0:
error = self._err("via", *args)
return error | python | def via(self, *args):
"""
Creates an empty error to record in the stack
trace
"""
error = None
if len(self.errors) > 0:
error = self._err("via", *args)
return error | [
"def",
"via",
"(",
"self",
",",
"*",
"args",
")",
":",
"error",
"=",
"None",
"if",
"len",
"(",
"self",
".",
"errors",
")",
">",
"0",
":",
"error",
"=",
"self",
".",
"_err",
"(",
"\"via\"",
",",
"*",
"args",
")",
"return",
"error"
] | Creates an empty error to record in the stack
trace | [
"Creates",
"an",
"empty",
"error",
"to",
"record",
"in",
"the",
"stack",
"trace"
] | train | https://github.com/synw/goerr/blob/08b3809d6715bffe26899a769d96fa5de8573faf/goerr/__init__.py#L341-L349 |
gdelnegro/django-translation-server | translation_server/management/commands/make_translation_migrations.py | Command.__create_translation_migration | def __create_translation_migration(self):
""" Create an empty migration """
migrations_dir = os.path.join(self.BASE_DIR, self.app_name + "/migrations/")
dependency_migration = os.path.basename(max(glob.iglob(migrations_dir + '*.py'), key=os.path.getctime)).replace(
".py", "")
... | python | def __create_translation_migration(self):
""" Create an empty migration """
migrations_dir = os.path.join(self.BASE_DIR, self.app_name + "/migrations/")
dependency_migration = os.path.basename(max(glob.iglob(migrations_dir + '*.py'), key=os.path.getctime)).replace(
".py", "")
... | [
"def",
"__create_translation_migration",
"(",
"self",
")",
":",
"migrations_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"BASE_DIR",
",",
"self",
".",
"app_name",
"+",
"\"/migrations/\"",
")",
"dependency_migration",
"=",
"os",
".",
"path",
"... | Create an empty migration | [
"Create",
"an",
"empty",
"migration"
] | train | https://github.com/gdelnegro/django-translation-server/blob/0f9de98d1cb07a42e1d323e20a384074ad28da57/translation_server/management/commands/make_translation_migrations.py#L148-L193 |
rinocloud/rinocloud-python | rinocloud/config.py | set_local_path | def set_local_path(directory, create_dir=False):
"""
sets path for local saving of information
if create is true we will create the folder even if it doesnt exist
"""
if not os.path.exists(directory) and create_dir is True:
os.makedirs(directory)
if not os.path.exists(directory)... | python | def set_local_path(directory, create_dir=False):
"""
sets path for local saving of information
if create is true we will create the folder even if it doesnt exist
"""
if not os.path.exists(directory) and create_dir is True:
os.makedirs(directory)
if not os.path.exists(directory)... | [
"def",
"set_local_path",
"(",
"directory",
",",
"create_dir",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
"and",
"create_dir",
"is",
"True",
":",
"os",
".",
"makedirs",
"(",
"directory",
")",
"if",
"not... | sets path for local saving of information
if create is true we will create the folder even if it doesnt exist | [
"sets",
"path",
"for",
"local",
"saving",
"of",
"information",
"if",
"create",
"is",
"true",
"we",
"will",
"create",
"the",
"folder",
"even",
"if",
"it",
"doesnt",
"exist"
] | train | https://github.com/rinocloud/rinocloud-python/blob/7c4bf994a518f961cffedb7260fc1e4fa1838b38/rinocloud/config.py#L6-L20 |
kaniblu/klogger | klogger.py | task | def task(name=None, t=INFO, *args, **kwargs):
"""
This decorator modifies current function such that its start, end, and
duration is logged in console. If the task name is not given, it will
attempt to infer it from the function name. Optionally, the decorator
can log information into files.
"""... | python | def task(name=None, t=INFO, *args, **kwargs):
"""
This decorator modifies current function such that its start, end, and
duration is logged in console. If the task name is not given, it will
attempt to infer it from the function name. Optionally, the decorator
can log information into files.
"""... | [
"def",
"task",
"(",
"name",
"=",
"None",
",",
"t",
"=",
"INFO",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"c_run",
"(",
"name",
",",
"f",
",",
"t",
",",
"args",
",",
"kwargs",
")",
":",
"def",
"run",
"(",
"*",
"largs",
","... | This decorator modifies current function such that its start, end, and
duration is logged in console. If the task name is not given, it will
attempt to infer it from the function name. Optionally, the decorator
can log information into files. | [
"This",
"decorator",
"modifies",
"current",
"function",
"such",
"that",
"its",
"start",
"end",
"and",
"duration",
"is",
"logged",
"in",
"console",
".",
"If",
"the",
"task",
"name",
"is",
"not",
"given",
"it",
"will",
"attempt",
"to",
"infer",
"it",
"from",... | train | https://github.com/kaniblu/klogger/blob/e23075134f2a3aa3e2a044f68eeacedf686969d7/klogger.py#L261-L295 |
kaniblu/klogger | klogger.py | progress_task | def progress_task(name=None, t=INFO, max_value=100, *args, **kwargs):
"""
This decorator extends the basic @task decorator by allowing users to
display some form of progress on the console. The module can receive
an increment in the progress through "tick_progress".
"""
return task(name=name, t=... | python | def progress_task(name=None, t=INFO, max_value=100, *args, **kwargs):
"""
This decorator extends the basic @task decorator by allowing users to
display some form of progress on the console. The module can receive
an increment in the progress through "tick_progress".
"""
return task(name=name, t=... | [
"def",
"progress_task",
"(",
"name",
"=",
"None",
",",
"t",
"=",
"INFO",
",",
"max_value",
"=",
"100",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"task",
"(",
"name",
"=",
"name",
",",
"t",
"=",
"t",
",",
"init_progress",
"=",... | This decorator extends the basic @task decorator by allowing users to
display some form of progress on the console. The module can receive
an increment in the progress through "tick_progress". | [
"This",
"decorator",
"extends",
"the",
"basic"
] | train | https://github.com/kaniblu/klogger/blob/e23075134f2a3aa3e2a044f68eeacedf686969d7/klogger.py#L298-L305 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.current_kv_names | def current_kv_names(self):
"""Return set of string names of current available Splunk KV collections"""
return current_kv_names(self.sci, self.username, self.appname, request=self._request) | python | def current_kv_names(self):
"""Return set of string names of current available Splunk KV collections"""
return current_kv_names(self.sci, self.username, self.appname, request=self._request) | [
"def",
"current_kv_names",
"(",
"self",
")",
":",
"return",
"current_kv_names",
"(",
"self",
".",
"sci",
",",
"self",
".",
"username",
",",
"self",
".",
"appname",
",",
"request",
"=",
"self",
".",
"_request",
")"
] | Return set of string names of current available Splunk KV collections | [
"Return",
"set",
"of",
"string",
"names",
"of",
"current",
"available",
"Splunk",
"KV",
"collections"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L51-L53 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.get | def get(self, CachableItem):
"""Returns current ICachedItem for ICachableItem or None if not cached"""
cached_item = self.mapper.get(CachableItem)
r = self.request('get',
self.url+"storage/collections/data/"+self.collname+'/'+cached_item.getId(),
data={'output_mode': 'jso... | python | def get(self, CachableItem):
"""Returns current ICachedItem for ICachableItem or None if not cached"""
cached_item = self.mapper.get(CachableItem)
r = self.request('get',
self.url+"storage/collections/data/"+self.collname+'/'+cached_item.getId(),
data={'output_mode': 'jso... | [
"def",
"get",
"(",
"self",
",",
"CachableItem",
")",
":",
"cached_item",
"=",
"self",
".",
"mapper",
".",
"get",
"(",
"CachableItem",
")",
"r",
"=",
"self",
".",
"request",
"(",
"'get'",
",",
"self",
".",
"url",
"+",
"\"storage/collections/data/\"",
"+",... | Returns current ICachedItem for ICachableItem or None if not cached | [
"Returns",
"current",
"ICachedItem",
"for",
"ICachableItem",
"or",
"None",
"if",
"not",
"cached"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L94-L106 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.isDirty | def isDirty(self, CachableItem):
"""True if cached information requires update for ICachableItem"""
_cachedItem = self.get(CachableItem)
if not _cachedItem:
return True
_newCacheItem = self.mapper.get(CachableItem)
return False if _cachedItem == _newCacheItem else Tru... | python | def isDirty(self, CachableItem):
"""True if cached information requires update for ICachableItem"""
_cachedItem = self.get(CachableItem)
if not _cachedItem:
return True
_newCacheItem = self.mapper.get(CachableItem)
return False if _cachedItem == _newCacheItem else Tru... | [
"def",
"isDirty",
"(",
"self",
",",
"CachableItem",
")",
":",
"_cachedItem",
"=",
"self",
".",
"get",
"(",
"CachableItem",
")",
"if",
"not",
"_cachedItem",
":",
"return",
"True",
"_newCacheItem",
"=",
"self",
".",
"mapper",
".",
"get",
"(",
"CachableItem",... | True if cached information requires update for ICachableItem | [
"True",
"if",
"cached",
"information",
"requires",
"update",
"for",
"ICachableItem"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L109-L115 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.cache | def cache(self, CachableItem):
"""Updates caches area with latest item information returning
ICachedItem if cache updates were required.
Issues ICacheObjectCreatedEvent, and ICacheObjectModifiedEvent for
ICacheArea/ICachableItem combo.
"""
_cachedItem = self.get... | python | def cache(self, CachableItem):
"""Updates caches area with latest item information returning
ICachedItem if cache updates were required.
Issues ICacheObjectCreatedEvent, and ICacheObjectModifiedEvent for
ICacheArea/ICachableItem combo.
"""
_cachedItem = self.get... | [
"def",
"cache",
"(",
"self",
",",
"CachableItem",
")",
":",
"_cachedItem",
"=",
"self",
".",
"get",
"(",
"CachableItem",
")",
"if",
"not",
"_cachedItem",
":",
"_cachedItem",
"=",
"self",
".",
"mapper",
".",
"get",
"(",
"CachableItem",
")",
"self",
".",
... | Updates caches area with latest item information returning
ICachedItem if cache updates were required.
Issues ICacheObjectCreatedEvent, and ICacheObjectModifiedEvent for
ICacheArea/ICachableItem combo. | [
"Updates",
"caches",
"area",
"with",
"latest",
"item",
"information",
"returning",
"ICachedItem",
"if",
"cache",
"updates",
"were",
"required",
"."
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L117-L138 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.import_source | def import_source(self, CachableSource):
"""Updates cache area and returns number of items updated with all
available entries in ICachableSource
"""
_count = 0
self._import_source_items_id_list = set() # used to help speed up trim()
for item in CachableSource.items():
... | python | def import_source(self, CachableSource):
"""Updates cache area and returns number of items updated with all
available entries in ICachableSource
"""
_count = 0
self._import_source_items_id_list = set() # used to help speed up trim()
for item in CachableSource.items():
... | [
"def",
"import_source",
"(",
"self",
",",
"CachableSource",
")",
":",
"_count",
"=",
"0",
"self",
".",
"_import_source_items_id_list",
"=",
"set",
"(",
")",
"# used to help speed up trim()",
"for",
"item",
"in",
"CachableSource",
".",
"items",
"(",
")",
":",
"... | Updates cache area and returns number of items updated with all
available entries in ICachableSource | [
"Updates",
"cache",
"area",
"and",
"returns",
"number",
"of",
"items",
"updated",
"with",
"all",
"available",
"entries",
"in",
"ICachableSource"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L140-L150 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.reset | def reset(self):
"""Deletes all entries in the cache area"""
if self.collname not in self.current_kv_names():
return # nothing to do
# we'll simply delete the entire collection and then re-create it.
r = self.request('delete',
self.url+"storage/collec... | python | def reset(self):
"""Deletes all entries in the cache area"""
if self.collname not in self.current_kv_names():
return # nothing to do
# we'll simply delete the entire collection and then re-create it.
r = self.request('delete',
self.url+"storage/collec... | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"collname",
"not",
"in",
"self",
".",
"current_kv_names",
"(",
")",
":",
"return",
"# nothing to do",
"# we'll simply delete the entire collection and then re-create it.",
"r",
"=",
"self",
".",
"request",
... | Deletes all entries in the cache area | [
"Deletes",
"all",
"entries",
"in",
"the",
"cache",
"area"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L152-L160 |
davisd50/sparc.cache | sparc/cache/splunk/area.py | CacheAreaForSplunkKV.initialize | def initialize(self):
"""Instantiates the cache area to be ready for updates"""
if self.collname not in self.current_kv_names():
r = self.request('post',
self.url+"storage/collections/config",
headers={'content-type': 'application/jso... | python | def initialize(self):
"""Instantiates the cache area to be ready for updates"""
if self.collname not in self.current_kv_names():
r = self.request('post',
self.url+"storage/collections/config",
headers={'content-type': 'application/jso... | [
"def",
"initialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"collname",
"not",
"in",
"self",
".",
"current_kv_names",
"(",
")",
":",
"r",
"=",
"self",
".",
"request",
"(",
"'post'",
",",
"self",
".",
"url",
"+",
"\"storage/collections/config\"",
",",
... | Instantiates the cache area to be ready for updates | [
"Instantiates",
"the",
"cache",
"area",
"to",
"be",
"ready",
"for",
"updates"
] | train | https://github.com/davisd50/sparc.cache/blob/f2378aad48c368a53820e97b093ace790d4d4121/sparc/cache/splunk/area.py#L162-L179 |
eddiejessup/agaro | agaro/run_utils.py | run_model | def run_model(t_output_every, output_dir=None, m=None, force_resume=True,
**iterate_args):
"""Convenience function to combine making a Runner object, and
running it for some time.
Parameters
----------
m: Model
Model to run.
iterate_args:
Arguments to pass to :meth... | python | def run_model(t_output_every, output_dir=None, m=None, force_resume=True,
**iterate_args):
"""Convenience function to combine making a Runner object, and
running it for some time.
Parameters
----------
m: Model
Model to run.
iterate_args:
Arguments to pass to :meth... | [
"def",
"run_model",
"(",
"t_output_every",
",",
"output_dir",
"=",
"None",
",",
"m",
"=",
"None",
",",
"force_resume",
"=",
"True",
",",
"*",
"*",
"iterate_args",
")",
":",
"r",
"=",
"runner",
".",
"Runner",
"(",
"output_dir",
",",
"m",
",",
"force_res... | Convenience function to combine making a Runner object, and
running it for some time.
Parameters
----------
m: Model
Model to run.
iterate_args:
Arguments to pass to :meth:`Runner.iterate`.
Others:
see :class:`Runner`.
Returns
-------
r: Runner
runne... | [
"Convenience",
"function",
"to",
"combine",
"making",
"a",
"Runner",
"object",
"and",
"running",
"it",
"for",
"some",
"time",
"."
] | train | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/run_utils.py#L7-L29 |
eddiejessup/agaro | agaro/run_utils.py | resume_runs | def resume_runs(dirnames, t_output_every, t_upto, parallel=False):
"""Resume many models, and run.
Parameters
----------
dirnames: list[str]
List of output directory paths from which to resume.
output_every: int
see :class:`Runner`.
t_upto: float
Run each model until the... | python | def resume_runs(dirnames, t_output_every, t_upto, parallel=False):
"""Resume many models, and run.
Parameters
----------
dirnames: list[str]
List of output directory paths from which to resume.
output_every: int
see :class:`Runner`.
t_upto: float
Run each model until the... | [
"def",
"resume_runs",
"(",
"dirnames",
",",
"t_output_every",
",",
"t_upto",
",",
"parallel",
"=",
"False",
")",
":",
"run_model_partial",
"=",
"partial",
"(",
"run_model",
",",
"t_output_every",
",",
"force_resume",
"=",
"True",
",",
"t_upto",
"=",
"t_upto",
... | Resume many models, and run.
Parameters
----------
dirnames: list[str]
List of output directory paths from which to resume.
output_every: int
see :class:`Runner`.
t_upto: float
Run each model until the time is equal to this
parallel: bool
Whether or not to run th... | [
"Resume",
"many",
"models",
"and",
"run",
"."
] | train | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/run_utils.py#L32-L50 |
eddiejessup/agaro | agaro/run_utils.py | run_kwarg_scan | def run_kwarg_scan(ModelClass, model_kwarg_sets,
t_output_every, t_upto,
force_resume=True, parallel=False):
"""Run many models with the same parameters but variable `field`.
For each `val` in `vals`, a new model will be made, and run up to a time.
The output directory... | python | def run_kwarg_scan(ModelClass, model_kwarg_sets,
t_output_every, t_upto,
force_resume=True, parallel=False):
"""Run many models with the same parameters but variable `field`.
For each `val` in `vals`, a new model will be made, and run up to a time.
The output directory... | [
"def",
"run_kwarg_scan",
"(",
"ModelClass",
",",
"model_kwarg_sets",
",",
"t_output_every",
",",
"t_upto",
",",
"force_resume",
"=",
"True",
",",
"parallel",
"=",
"False",
")",
":",
"task_runner",
"=",
"_TaskRunner",
"(",
"ModelClass",
",",
"t_output_every",
","... | Run many models with the same parameters but variable `field`.
For each `val` in `vals`, a new model will be made, and run up to a time.
The output directory is automatically generated from the model arguments.
Parameters
----------
ModelClass: type
A class or factory function that returns... | [
"Run",
"many",
"models",
"with",
"the",
"same",
"parameters",
"but",
"variable",
"field",
"."
] | train | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/run_utils.py#L74-L99 |
eddiejessup/agaro | agaro/run_utils.py | run_field_scan | def run_field_scan(ModelClass, model_kwargs, t_output_every, t_upto, field,
vals, force_resume=True, parallel=False):
"""Run many models with a range of parameter sets.
Parameters
----------
ModelClass: callable
A class or factory function that returns a model object by
... | python | def run_field_scan(ModelClass, model_kwargs, t_output_every, t_upto, field,
vals, force_resume=True, parallel=False):
"""Run many models with a range of parameter sets.
Parameters
----------
ModelClass: callable
A class or factory function that returns a model object by
... | [
"def",
"run_field_scan",
"(",
"ModelClass",
",",
"model_kwargs",
",",
"t_output_every",
",",
"t_upto",
",",
"field",
",",
"vals",
",",
"force_resume",
"=",
"True",
",",
"parallel",
"=",
"False",
")",
":",
"model_kwarg_sets",
"=",
"[",
"dict",
"(",
"model_kwa... | Run many models with a range of parameter sets.
Parameters
----------
ModelClass: callable
A class or factory function that returns a model object by
calling `ModelClass(model_kwargs)`
model_kwargs: dict
See `ModelClass` explanation.
t_output_every: float
see :class:... | [
"Run",
"many",
"models",
"with",
"a",
"range",
"of",
"parameter",
"sets",
"."
] | train | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/run_utils.py#L102-L128 |
iamsteadman/bambu-mail | bambu_mail/views.py | subscribe | def subscribe(request):
"""
Takes POST data (``email`` and optional ``next`` fields), submitting the ``email`` field to
the newsletter provider for subscription to a mailing list, and redirecting the user to the value
of ``next`` (this can also be provided in the querystring), or the homepage if no foll... | python | def subscribe(request):
"""
Takes POST data (``email`` and optional ``next`` fields), submitting the ``email`` field to
the newsletter provider for subscription to a mailing list, and redirecting the user to the value
of ``next`` (this can also be provided in the querystring), or the homepage if no foll... | [
"def",
"subscribe",
"(",
"request",
")",
":",
"email",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'email'",
")",
"next",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'next'",
",",
"request",
".",
"GET",
".",
"get",
"(",
"'next'",
",",
"'/'",
... | Takes POST data (``email`` and optional ``next`` fields), submitting the ``email`` field to
the newsletter provider for subscription to a mailing list, and redirecting the user to the value
of ``next`` (this can also be provided in the querystring), or the homepage if no follow-on URL is
supplied, with a me... | [
"Takes",
"POST",
"data",
"(",
"email",
"and",
"optional",
"next",
"fields",
")",
"submitting",
"the",
"email",
"field",
"to",
"the",
"newsletter",
"provider",
"for",
"subscription",
"to",
"a",
"mailing",
"list",
"and",
"redirecting",
"the",
"user",
"to",
"th... | train | https://github.com/iamsteadman/bambu-mail/blob/5298e6ab861cabc8859c8356ccb2354b1b902cd1/bambu_mail/views.py#L7-L36 |
telminov/sw-python-utils | swutils/date.py | age_to_date | def age_to_date(age):
"""
преобразует возраст в год рождения. (Для фильтрации по дате рождения)
"""
today = datetime.date.today()
date = datetime.date(today.year - age - 1, today.month, today.day) + datetime.timedelta(days=1)
return date | python | def age_to_date(age):
"""
преобразует возраст в год рождения. (Для фильтрации по дате рождения)
"""
today = datetime.date.today()
date = datetime.date(today.year - age - 1, today.month, today.day) + datetime.timedelta(days=1)
return date | [
"def",
"age_to_date",
"(",
"age",
")",
":",
"today",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"date",
"=",
"datetime",
".",
"date",
"(",
"today",
".",
"year",
"-",
"age",
"-",
"1",
",",
"today",
".",
"month",
",",
"today",
".",
"day"... | преобразует возраст в год рождения. (Для фильтрации по дате рождения) | [
"преобразует",
"возраст",
"в",
"год",
"рождения",
".",
"(",
"Для",
"фильтрации",
"по",
"дате",
"рождения",
")"
] | train | https://github.com/telminov/sw-python-utils/blob/68f976122dd26a581b8d833c023f7f06542ca85c/swutils/date.py#L112-L118 |
telminov/sw-python-utils | swutils/date.py | is_date_ranges_intersection | def is_date_ranges_intersection(t1start, t1end, t2start, t2end):
"""
Проверяем совпадают ли периоды
"""
return (t1start <= t2start <= t1end) or (t2start <= t1start <= t2end) | python | def is_date_ranges_intersection(t1start, t1end, t2start, t2end):
"""
Проверяем совпадают ли периоды
"""
return (t1start <= t2start <= t1end) or (t2start <= t1start <= t2end) | [
"def",
"is_date_ranges_intersection",
"(",
"t1start",
",",
"t1end",
",",
"t2start",
",",
"t2end",
")",
":",
"return",
"(",
"t1start",
"<=",
"t2start",
"<=",
"t1end",
")",
"or",
"(",
"t2start",
"<=",
"t1start",
"<=",
"t2end",
")"
] | Проверяем совпадают ли периоды | [
"Проверяем",
"совпадают",
"ли",
"периоды"
] | train | https://github.com/telminov/sw-python-utils/blob/68f976122dd26a581b8d833c023f7f06542ca85c/swutils/date.py#L142-L146 |
EricCrosson/stump | stump/stump.py | configure | def configure(logger=None):
"""Pass stump a logger to use. If no logger is supplied, a basic logger
of level INFO will print to stdout.
"""
global LOGGER
if logger is None:
LOGGER = logging.basicConfig(stream=sys.stdout, level=logging.INFO)
else:
LOGGER = logger | python | def configure(logger=None):
"""Pass stump a logger to use. If no logger is supplied, a basic logger
of level INFO will print to stdout.
"""
global LOGGER
if logger is None:
LOGGER = logging.basicConfig(stream=sys.stdout, level=logging.INFO)
else:
LOGGER = logger | [
"def",
"configure",
"(",
"logger",
"=",
"None",
")",
":",
"global",
"LOGGER",
"if",
"logger",
"is",
"None",
":",
"LOGGER",
"=",
"logging",
".",
"basicConfig",
"(",
"stream",
"=",
"sys",
".",
"stdout",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
"... | Pass stump a logger to use. If no logger is supplied, a basic logger
of level INFO will print to stdout. | [
"Pass",
"stump",
"a",
"logger",
"to",
"use",
".",
"If",
"no",
"logger",
"is",
"supplied",
"a",
"basic",
"logger",
"of",
"level",
"INFO",
"will",
"print",
"to",
"stdout",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L19-L28 |
EricCrosson/stump | stump/stump.py | ret | def ret(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: info. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted wit... | python | def ret(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: info. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted wit... | [
"def",
"ret",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'print_return'",
":",
"True",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry and exit. Default logging
value: info. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decor... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Default",
"logging",
"value",
":",
"info",
".",
"The",
"function",
"s",
"return",
"value",
"will",
"be",
"included",
"in",
"the",
"logs",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L32-L54 |
EricCrosson/stump | stump/stump.py | pre | def pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | python | def pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | [
"def",
"pre",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'prefix_only'",
":",
"True",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the value of
... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
".",
"Default",
"logging",
"value",
":",
"info",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L58-L80 |
EricCrosson/stump | stump/stump.py | post | def post(f, *args, **kwargs):
"""Automatically log progress on function exit. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | python | def post(f, *args, **kwargs):
"""Automatically log progress on function exit. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | [
"def",
"post",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'postfix_only'",
":",
"True",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function exit. Default logging value:
info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the value of
... | [
"Automatically",
"log",
"progress",
"on",
"function",
"exit",
".",
"Default",
"logging",
"value",
":",
"info",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L84-L106 |
EricCrosson/stump | stump/stump.py | date | def date(f, *args, **kwargs):
"""Automatically log progress on function entry and exit with date- and
time- stamp. Default logging value: info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the... | python | def date(f, *args, **kwargs):
"""Automatically log progress on function entry and exit with date- and
time- stamp. Default logging value: info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the... | [
"def",
"date",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'print_time'",
":",
"True",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry and exit with date- and
time- stamp. Default logging value: info.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}'... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
"with",
"date",
"-",
"and",
"time",
"-",
"stamp",
".",
"Default",
"logging",
"value",
":",
"info",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L110-L132 |
EricCrosson/stump | stump/stump.py | debug | def debug(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each... | python | def debug(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each... | [
"def",
"debug",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"DEBUG",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry and exit. Default logging
value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the v... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Default",
"logging",
"value",
":",
"debug",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L161-L183 |
EricCrosson/stump | stump/stump.py | warning | def warning(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: warning.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. ... | python | def warning(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: warning.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. ... | [
"def",
"warning",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"WARNING",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
... | Automatically log progress on function entry and exit. Default logging
value: warning.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Default",
"logging",
"value",
":",
"warning",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L187-L209 |
EricCrosson/stump | stump/stump.py | error | def error(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each... | python | def error(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Default logging
value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each... | [
"def",
"error",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"ERROR",
"}",
")",
"return",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Automatically log progress on function entry and exit. Default logging
value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the v... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Default",
"logging",
"value",
":",
"error",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L213-L235 |
EricCrosson/stump | stump/stump.py | debug_pre | def debug_pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Logging value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will... | python | def debug_pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Logging value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will... | [
"def",
"debug_pre",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"DEBUG",
"}",
")",
"kwargs",
".",
"update",
"(",
"{",
"'prefix_only'",
":",
"True",
"}",
")",
"ret... | Automatically log progress on function entry. Logging value: debug.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the value of
the param... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
".",
"Logging",
"value",
":",
"debug",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L286-L303 |
EricCrosson/stump | stump/stump.py | warning_ret | def warning_ret(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Logging
value: warning. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted ... | python | def warning_ret(f, *args, **kwargs):
"""Automatically log progress on function entry and exit. Logging
value: warning. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted ... | [
"def",
"warning_ret",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"WARNING",
"}",
")",
"kwargs",
".",
"update",
"(",
"{",
"'print_return'",
":",
"True",
"}",
")",
... | Automatically log progress on function entry and exit. Logging
value: warning. The function's return value will be included in the logs.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated ... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
"and",
"exit",
".",
"Logging",
"value",
":",
"warning",
".",
"The",
"function",
"s",
"return",
"value",
"will",
"be",
"included",
"in",
"the",
"logs",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L350-L368 |
EricCrosson/stump | stump/stump.py | error_pre | def error_pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Logging value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will... | python | def error_pre(f, *args, **kwargs):
"""Automatically log progress on function entry. Logging value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will... | [
"def",
"error_pre",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"'log'",
":",
"logging",
".",
"ERROR",
"}",
")",
"kwargs",
".",
"update",
"(",
"{",
"'prefix_only'",
":",
"True",
"}",
")",
"ret... | Automatically log progress on function entry. Logging value: error.
*Logging with values contained in the parameters of the decorated function*
Message (args[0]) may be a string to be formatted with parameters passed to
the decorated function. Each '{varname}' will be replaced by the value of
the param... | [
"Automatically",
"log",
"progress",
"on",
"function",
"entry",
".",
"Logging",
"value",
":",
"error",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L458-L475 |
EricCrosson/stump | stump/stump.py | _stump | def _stump(f, *args, **kwargs):
"""Worker for the common actions of all stump methods, aka the secret
sauce.
*Keyword parameters*
- log :: integer
- Specifies a custom level of logging to pass to the active logger.
- Default: INFO
- print_time :: bool
- Include timestamp in messag... | python | def _stump(f, *args, **kwargs):
"""Worker for the common actions of all stump methods, aka the secret
sauce.
*Keyword parameters*
- log :: integer
- Specifies a custom level of logging to pass to the active logger.
- Default: INFO
- print_time :: bool
- Include timestamp in messag... | [
"def",
"_stump",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"LOGGER",
"def",
"aux",
"(",
"*",
"xs",
",",
"*",
"*",
"kws",
")",
":",
"f_kws",
"=",
"kws",
".",
"copy",
"(",
")",
"f_kws",
".",
"update",
"(",
"dict",... | Worker for the common actions of all stump methods, aka the secret
sauce.
*Keyword parameters*
- log :: integer
- Specifies a custom level of logging to pass to the active logger.
- Default: INFO
- print_time :: bool
- Include timestamp in message
- print_return :: bool
- in... | [
"Worker",
"for",
"the",
"common",
"actions",
"of",
"all",
"stump",
"methods",
"aka",
"the",
"secret",
"sauce",
"."
] | train | https://github.com/EricCrosson/stump/blob/eb4d9f0dbe2642f86d47ca1b5f51fb7801bb09ab/stump/stump.py#L526-L602 |
uda/djaccount | account/models.py | Account.get_full_name | def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
"""
full_name = '{first_name} {last_name}'.format(first_name=self.first_name, last_name=self.last_name)
return full_name.strip() | python | def get_full_name(self):
"""
Returns the first_name plus the last_name, with a space in between.
"""
full_name = '{first_name} {last_name}'.format(first_name=self.first_name, last_name=self.last_name)
return full_name.strip() | [
"def",
"get_full_name",
"(",
"self",
")",
":",
"full_name",
"=",
"'{first_name} {last_name}'",
".",
"format",
"(",
"first_name",
"=",
"self",
".",
"first_name",
",",
"last_name",
"=",
"self",
".",
"last_name",
")",
"return",
"full_name",
".",
"strip",
"(",
"... | Returns the first_name plus the last_name, with a space in between. | [
"Returns",
"the",
"first_name",
"plus",
"the",
"last_name",
"with",
"a",
"space",
"in",
"between",
"."
] | train | https://github.com/uda/djaccount/blob/3012659ada04008d6c03a191b206c6d218aff836/account/models.py#L47-L52 |
dustinmm80/healthy | package_utils.py | create_sandbox | def create_sandbox(name='healthybox'):
"""
Create a temporary sandbox directory
:param name: name of the directory to create
:return: The directory created
"""
sandbox = tempfile.mkdtemp(prefix=name)
if not os.path.isdir(sandbox):
os.mkdir(sandbox)
return sandbox | python | def create_sandbox(name='healthybox'):
"""
Create a temporary sandbox directory
:param name: name of the directory to create
:return: The directory created
"""
sandbox = tempfile.mkdtemp(prefix=name)
if not os.path.isdir(sandbox):
os.mkdir(sandbox)
return sandbox | [
"def",
"create_sandbox",
"(",
"name",
"=",
"'healthybox'",
")",
":",
"sandbox",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"name",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"sandbox",
")",
":",
"os",
".",
"mkdir",
"(",
"sandbo... | Create a temporary sandbox directory
:param name: name of the directory to create
:return: The directory created | [
"Create",
"a",
"temporary",
"sandbox",
"directory",
":",
"param",
"name",
":",
"name",
"of",
"the",
"directory",
"to",
"create",
":",
"return",
":",
"The",
"directory",
"created"
] | train | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/package_utils.py#L14-L24 |
dustinmm80/healthy | package_utils.py | download_package_to_sandbox | def download_package_to_sandbox(sandbox, package_url):
"""
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
"""
response = requests.get(package_url)
package_ta... | python | def download_package_to_sandbox(sandbox, package_url):
"""
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
"""
response = requests.get(package_url)
package_ta... | [
"def",
"download_package_to_sandbox",
"(",
"sandbox",
",",
"package_url",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"package_url",
")",
"package_tar",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sandbox",
",",
"'package.tar.gz'",
")",
"with",
"o... | Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory | [
"Downloads",
"an",
"unzips",
"a",
"package",
"to",
"the",
"sandbox",
":",
"param",
"sandbox",
":",
"temporary",
"directory",
"name",
":",
"param",
"package_url",
":",
"link",
"to",
"package",
"download",
":",
"returns",
":",
"name",
"of",
"unzipped",
"packag... | train | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/package_utils.py#L26-L48 |
dustinmm80/healthy | package_utils.py | main | def main():
"""
Main function for this module
"""
sandbox = create_sandbox()
directory = download_package_to_sandbox(
sandbox,
'https://pypi.python.org/packages/source/c/checkmyreqs/checkmyreqs-0.1.6.tar.gz'
)
print(directory)
destroy_sandbox(sandbox) | python | def main():
"""
Main function for this module
"""
sandbox = create_sandbox()
directory = download_package_to_sandbox(
sandbox,
'https://pypi.python.org/packages/source/c/checkmyreqs/checkmyreqs-0.1.6.tar.gz'
)
print(directory)
destroy_sandbox(sandbox) | [
"def",
"main",
"(",
")",
":",
"sandbox",
"=",
"create_sandbox",
"(",
")",
"directory",
"=",
"download_package_to_sandbox",
"(",
"sandbox",
",",
"'https://pypi.python.org/packages/source/c/checkmyreqs/checkmyreqs-0.1.6.tar.gz'",
")",
"print",
"(",
"directory",
")",
"destro... | Main function for this module | [
"Main",
"function",
"for",
"this",
"module"
] | train | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/package_utils.py#L60-L70 |
jkenlooper/chill | src/chill/public.py | check_map | def check_map(uri, url_root):
"""
return a tuple of the rule and kw.
"""
# TODO: Building the Map each time this is called seems like it could be more effiecent.
result = []
try:
result = db.execute(text(fetch_query_string('select_route_where_dynamic.sql'))).fetchall()
except Operati... | python | def check_map(uri, url_root):
"""
return a tuple of the rule and kw.
"""
# TODO: Building the Map each time this is called seems like it could be more effiecent.
result = []
try:
result = db.execute(text(fetch_query_string('select_route_where_dynamic.sql'))).fetchall()
except Operati... | [
"def",
"check_map",
"(",
"uri",
",",
"url_root",
")",
":",
"# TODO: Building the Map each time this is called seems like it could be more effiecent.",
"result",
"=",
"[",
"]",
"try",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"("... | return a tuple of the rule and kw. | [
"return",
"a",
"tuple",
"of",
"the",
"rule",
"and",
"kw",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L29-L54 |
jkenlooper/chill | src/chill/public.py | route_handler | def route_handler(context, content, pargs, kwargs):
"""
Route shortcode works a lot like rendering a page based on the url or
route. This allows inserting in rendered HTML within another page.
Activate it with the 'shortcodes' template filter. Within the content use
the chill route shortcode: "[ch... | python | def route_handler(context, content, pargs, kwargs):
"""
Route shortcode works a lot like rendering a page based on the url or
route. This allows inserting in rendered HTML within another page.
Activate it with the 'shortcodes' template filter. Within the content use
the chill route shortcode: "[ch... | [
"def",
"route_handler",
"(",
"context",
",",
"content",
",",
"pargs",
",",
"kwargs",
")",
":",
"(",
"node",
",",
"rule_kw",
")",
"=",
"node_from_uri",
"(",
"pargs",
"[",
"0",
"]",
")",
"if",
"node",
"==",
"None",
":",
"return",
"u\"<!-- 404 '{0}' -->\"",... | Route shortcode works a lot like rendering a page based on the url or
route. This allows inserting in rendered HTML within another page.
Activate it with the 'shortcodes' template filter. Within the content use
the chill route shortcode: "[chill route /path/to/something/]" where the
'[chill' and ']' a... | [
"Route",
"shortcode",
"works",
"a",
"lot",
"like",
"rendering",
"a",
"page",
"based",
"on",
"the",
"url",
"or",
"route",
".",
"This",
"allows",
"inserting",
"in",
"rendered",
"HTML",
"within",
"another",
"page",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L241-L276 |
jkenlooper/chill | src/chill/public.py | page_uri_handler | def page_uri_handler(context, content, pargs, kwargs):
"""
Shortcode for getting the link to internal pages using the flask `url_for`
method.
Activate with 'shortcodes' template filter. Within the content use the
chill page_uri shortcode: "[chill page_uri idofapage]". The argument is the
'uri' ... | python | def page_uri_handler(context, content, pargs, kwargs):
"""
Shortcode for getting the link to internal pages using the flask `url_for`
method.
Activate with 'shortcodes' template filter. Within the content use the
chill page_uri shortcode: "[chill page_uri idofapage]". The argument is the
'uri' ... | [
"def",
"page_uri_handler",
"(",
"context",
",",
"content",
",",
"pargs",
",",
"kwargs",
")",
":",
"uri",
"=",
"pargs",
"[",
"0",
"]",
"return",
"url_for",
"(",
"'.page_uri'",
",",
"uri",
"=",
"uri",
")"
] | Shortcode for getting the link to internal pages using the flask `url_for`
method.
Activate with 'shortcodes' template filter. Within the content use the
chill page_uri shortcode: "[chill page_uri idofapage]". The argument is the
'uri' for a page that chill uses.
Does not verify the link to see if... | [
"Shortcode",
"for",
"getting",
"the",
"link",
"to",
"internal",
"pages",
"using",
"the",
"flask",
"url_for",
"method",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L279-L291 |
jkenlooper/chill | src/chill/public.py | PageView.get | def get(self, uri=''):
"For sql queries that start with 'SELECT ...'"
(node, rule_kw) = node_from_uri(uri)
if node == None:
abort(404)
rule_kw.update( node )
values = rule_kw
xhr_data = request.get_json()
if xhr_data:
values.update( xhr_da... | python | def get(self, uri=''):
"For sql queries that start with 'SELECT ...'"
(node, rule_kw) = node_from_uri(uri)
if node == None:
abort(404)
rule_kw.update( node )
values = rule_kw
xhr_data = request.get_json()
if xhr_data:
values.update( xhr_da... | [
"def",
"get",
"(",
"self",
",",
"uri",
"=",
"''",
")",
":",
"(",
"node",
",",
"rule_kw",
")",
"=",
"node_from_uri",
"(",
"uri",
")",
"if",
"node",
"==",
"None",
":",
"abort",
"(",
"404",
")",
"rule_kw",
".",
"update",
"(",
"node",
")",
"values",
... | For sql queries that start with 'SELECT ... | [
"For",
"sql",
"queries",
"that",
"start",
"with",
"SELECT",
"..."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L123-L153 |
jkenlooper/chill | src/chill/public.py | PageView.post | def post(self, uri=''):
"For sql queries that start with 'INSERT ...'"
# get node...
(node, rule_kw) = node_from_uri(uri, method=request.method)
rule_kw.update( node )
values = rule_kw
xhr_data = request.get_json()
if xhr_data:
values.update( xhr_dat... | python | def post(self, uri=''):
"For sql queries that start with 'INSERT ...'"
# get node...
(node, rule_kw) = node_from_uri(uri, method=request.method)
rule_kw.update( node )
values = rule_kw
xhr_data = request.get_json()
if xhr_data:
values.update( xhr_dat... | [
"def",
"post",
"(",
"self",
",",
"uri",
"=",
"''",
")",
":",
"# get node...",
"(",
"node",
",",
"rule_kw",
")",
"=",
"node_from_uri",
"(",
"uri",
",",
"method",
"=",
"request",
".",
"method",
")",
"rule_kw",
".",
"update",
"(",
"node",
")",
"values",... | For sql queries that start with 'INSERT ... | [
"For",
"sql",
"queries",
"that",
"start",
"with",
"INSERT",
"..."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/public.py#L156-L175 |
tiany/django-aliyun-storage | aliyunstorage/backends.py | get_aliyun_config | def get_aliyun_config(name, default=None):
'''
Get configuration variable from environment variable or
or django settings.py
'''
config = os.environ.get(name, getattr(settings, name, default))
if config is not None:
if isinstance(config, str):
return config.strip()
el... | python | def get_aliyun_config(name, default=None):
'''
Get configuration variable from environment variable or
or django settings.py
'''
config = os.environ.get(name, getattr(settings, name, default))
if config is not None:
if isinstance(config, str):
return config.strip()
el... | [
"def",
"get_aliyun_config",
"(",
"name",
",",
"default",
"=",
"None",
")",
":",
"config",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"name",
",",
"getattr",
"(",
"settings",
",",
"name",
",",
"default",
")",
")",
"if",
"config",
"is",
"not",
"None",... | Get configuration variable from environment variable or
or django settings.py | [
"Get",
"configuration",
"variable",
"from",
"environment",
"variable",
"or",
"or",
"django",
"settings",
".",
"py"
] | train | https://github.com/tiany/django-aliyun-storage/blob/582760ea05d333d37ff1a3bebff94437d7965a88/aliyunstorage/backends.py#L18-L32 |
minhhoit/yacms | yacms/twitter/templatetags/twitter_tags.py | tweets_for | def tweets_for(query_type, args, per_user=None):
"""
Retrieve tweets for a user, list or search term. The optional
``per_user`` arg limits the number of tweets per user, for
example to allow a fair spread of tweets per user for a list.
"""
lookup = {"query_type": query_type, "value": args[0]}
... | python | def tweets_for(query_type, args, per_user=None):
"""
Retrieve tweets for a user, list or search term. The optional
``per_user`` arg limits the number of tweets per user, for
example to allow a fair spread of tweets per user for a list.
"""
lookup = {"query_type": query_type, "value": args[0]}
... | [
"def",
"tweets_for",
"(",
"query_type",
",",
"args",
",",
"per_user",
"=",
"None",
")",
":",
"lookup",
"=",
"{",
"\"query_type\"",
":",
"query_type",
",",
"\"value\"",
":",
"args",
"[",
"0",
"]",
"}",
"try",
":",
"tweets",
"=",
"Tweet",
".",
"objects",... | Retrieve tweets for a user, list or search term. The optional
``per_user`` arg limits the number of tweets per user, for
example to allow a fair spread of tweets per user for a list. | [
"Retrieve",
"tweets",
"for",
"a",
"user",
"list",
"or",
"search",
"term",
".",
"The",
"optional",
"per_user",
"arg",
"limits",
"the",
"number",
"of",
"tweets",
"per",
"user",
"for",
"example",
"to",
"allow",
"a",
"fair",
"spread",
"of",
"tweets",
"per",
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/twitter/templatetags/twitter_tags.py#L16-L36 |
minhhoit/yacms | yacms/twitter/templatetags/twitter_tags.py | tweets_default | def tweets_default(*args):
"""
Tweets for the default settings.
"""
query_type = settings.TWITTER_DEFAULT_QUERY_TYPE
args = (settings.TWITTER_DEFAULT_QUERY,
settings.TWITTER_DEFAULT_NUM_TWEETS)
per_user = None
if query_type == QUERY_TYPE_LIST:
per_user = 1
return twee... | python | def tweets_default(*args):
"""
Tweets for the default settings.
"""
query_type = settings.TWITTER_DEFAULT_QUERY_TYPE
args = (settings.TWITTER_DEFAULT_QUERY,
settings.TWITTER_DEFAULT_NUM_TWEETS)
per_user = None
if query_type == QUERY_TYPE_LIST:
per_user = 1
return twee... | [
"def",
"tweets_default",
"(",
"*",
"args",
")",
":",
"query_type",
"=",
"settings",
".",
"TWITTER_DEFAULT_QUERY_TYPE",
"args",
"=",
"(",
"settings",
".",
"TWITTER_DEFAULT_QUERY",
",",
"settings",
".",
"TWITTER_DEFAULT_NUM_TWEETS",
")",
"per_user",
"=",
"None",
"if... | Tweets for the default settings. | [
"Tweets",
"for",
"the",
"default",
"settings",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/twitter/templatetags/twitter_tags.py#L64-L74 |
kejbaly2/members | members/mailman2.py | _download | def _download(uri, user, password):
'''
# FIXME DOCS
'''
if user and password:
logr.debug('AUTH {} at {}'.format(user, uri))
cookieJar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))
opener.addheaders = [("User-agent", "Mozil... | python | def _download(uri, user, password):
'''
# FIXME DOCS
'''
if user and password:
logr.debug('AUTH {} at {}'.format(user, uri))
cookieJar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))
opener.addheaders = [("User-agent", "Mozil... | [
"def",
"_download",
"(",
"uri",
",",
"user",
",",
"password",
")",
":",
"if",
"user",
"and",
"password",
":",
"logr",
".",
"debug",
"(",
"'AUTH {} at {}'",
".",
"format",
"(",
"user",
",",
"uri",
")",
")",
"cookieJar",
"=",
"cookielib",
".",
"CookieJar... | # FIXME DOCS | [
"#",
"FIXME",
"DOCS"
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/mailman2.py#L27-L45 |
kejbaly2/members | members/mailman2.py | extract | def extract(list_name, base_url, list_config=None, user=None, password=None):
'''
# FIXME DOCS
'''
if not (base_url and list_name):
raise RuntimeError(
"base_url [{}] and list_name [{}] can not be NULL".format(
base_url, list_name))
list_config = list_config or {... | python | def extract(list_name, base_url, list_config=None, user=None, password=None):
'''
# FIXME DOCS
'''
if not (base_url and list_name):
raise RuntimeError(
"base_url [{}] and list_name [{}] can not be NULL".format(
base_url, list_name))
list_config = list_config or {... | [
"def",
"extract",
"(",
"list_name",
",",
"base_url",
",",
"list_config",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"if",
"not",
"(",
"base_url",
"and",
"list_name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"base_url ... | # FIXME DOCS | [
"#",
"FIXME",
"DOCS"
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/mailman2.py#L48-L75 |
gebn/nibble | nibble/util.py | decode_cli_arg | def decode_cli_arg(arg):
"""
Turn a bytestring provided by `argparse` into unicode.
:param arg: The bytestring to decode.
:return: The argument as a unicode object.
:raises ValueError: If arg is None.
"""
if arg is None:
raise ValueError('Argument cannot be None')
if sys.versio... | python | def decode_cli_arg(arg):
"""
Turn a bytestring provided by `argparse` into unicode.
:param arg: The bytestring to decode.
:return: The argument as a unicode object.
:raises ValueError: If arg is None.
"""
if arg is None:
raise ValueError('Argument cannot be None')
if sys.versio... | [
"def",
"decode_cli_arg",
"(",
"arg",
")",
":",
"if",
"arg",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Argument cannot be None'",
")",
"if",
"sys",
".",
"version_info",
".",
"major",
"==",
"3",
":",
"# already decoded",
"return",
"arg",
"return",
"arg"... | Turn a bytestring provided by `argparse` into unicode.
:param arg: The bytestring to decode.
:return: The argument as a unicode object.
:raises ValueError: If arg is None. | [
"Turn",
"a",
"bytestring",
"provided",
"by",
"argparse",
"into",
"unicode",
"."
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/util.py#L17-L32 |
gebn/nibble | nibble/util.py | log_level_from_vebosity | def log_level_from_vebosity(verbosity):
"""
Get the `logging` module log level from a verbosity.
:param verbosity: The number of times the `-v` option was specified.
:return: The corresponding log level.
"""
if verbosity == 0:
return logging.WARNING
if verbosity == 1:
return... | python | def log_level_from_vebosity(verbosity):
"""
Get the `logging` module log level from a verbosity.
:param verbosity: The number of times the `-v` option was specified.
:return: The corresponding log level.
"""
if verbosity == 0:
return logging.WARNING
if verbosity == 1:
return... | [
"def",
"log_level_from_vebosity",
"(",
"verbosity",
")",
":",
"if",
"verbosity",
"==",
"0",
":",
"return",
"logging",
".",
"WARNING",
"if",
"verbosity",
"==",
"1",
":",
"return",
"logging",
".",
"INFO",
"return",
"logging",
".",
"DEBUG"
] | Get the `logging` module log level from a verbosity.
:param verbosity: The number of times the `-v` option was specified.
:return: The corresponding log level. | [
"Get",
"the",
"logging",
"module",
"log",
"level",
"from",
"a",
"verbosity",
"."
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/util.py#L35-L46 |
gebn/nibble | nibble/util.py | round_two_non_zero_dp | def round_two_non_zero_dp(decimal):
"""
Rounds a number to the first two non-zero decimal places.
Adapted from https://stackoverflow.com/a/38838513/2765666.
:param decimal: The decimal number to round.
:return: A new decimal representing the rounded value.
"""
log10 = decimal.log10().to... | python | def round_two_non_zero_dp(decimal):
"""
Rounds a number to the first two non-zero decimal places.
Adapted from https://stackoverflow.com/a/38838513/2765666.
:param decimal: The decimal number to round.
:return: A new decimal representing the rounded value.
"""
log10 = decimal.log10().to... | [
"def",
"round_two_non_zero_dp",
"(",
"decimal",
")",
":",
"log10",
"=",
"decimal",
".",
"log10",
"(",
")",
".",
"to_integral_exact",
"(",
"rounding",
"=",
"ROUND_FLOOR",
")",
"if",
"decimal",
"else",
"0",
"div",
"=",
"Decimal",
"(",
"10",
")",
"**",
"(",... | Rounds a number to the first two non-zero decimal places.
Adapted from https://stackoverflow.com/a/38838513/2765666.
:param decimal: The decimal number to round.
:return: A new decimal representing the rounded value. | [
"Rounds",
"a",
"number",
"to",
"the",
"first",
"two",
"non",
"-",
"zero",
"decimal",
"places",
".",
"Adapted",
"from",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"38838513",
"/",
"2765666",
".",
":",
"param",
"decimal",
":",
"The",... | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/util.py#L49-L60 |
riquito/richinput | richinput/richinput.py | get_rich_char | def get_rich_char(prompt=u'', term=None):
"""Iterator that returns the next meaningful input given to a terminal,
whenever a key is pressed.
`term` is an instance of terminfo.Term, needed to understand what the
escape sequences mean.
The yielded value will be one of
- PrintableChar
- Co... | python | def get_rich_char(prompt=u'', term=None):
"""Iterator that returns the next meaningful input given to a terminal,
whenever a key is pressed.
`term` is an instance of terminfo.Term, needed to understand what the
escape sequences mean.
The yielded value will be one of
- PrintableChar
- Co... | [
"def",
"get_rich_char",
"(",
"prompt",
"=",
"u''",
",",
"term",
"=",
"None",
")",
":",
"if",
"not",
"term",
":",
"term",
"=",
"terminfo",
".",
"load_terminfo",
"(",
")",
"iterator",
"=",
"get_char",
"(",
"prompt",
")",
"for",
"c",
"in",
"iterator",
"... | Iterator that returns the next meaningful input given to a terminal,
whenever a key is pressed.
`term` is an instance of terminfo.Term, needed to understand what the
escape sequences mean.
The yielded value will be one of
- PrintableChar
- ControlKey
- EscapeSequence
Note that ... | [
"Iterator",
"that",
"returns",
"the",
"next",
"meaningful",
"input",
"given",
"to",
"a",
"terminal",
"whenever",
"a",
"key",
"is",
"pressed",
".",
"term",
"is",
"an",
"instance",
"of",
"terminfo",
".",
"Term",
"needed",
"to",
"understand",
"what",
"the",
"... | train | https://github.com/riquito/richinput/blob/858c6068d80377148b89dcf9107f4e46a2b464d4/richinput/richinput.py#L103-L143 |
riquito/richinput | richinput/richinput.py | consume_escape_sequence | def consume_escape_sequence(iterator, starter):
"""Given an input `iterator` and the character that started an escape
sequence, consume the whole escape sequence and return it.
May raise StartEscapeSequenceException if a new escape sequence
is started midway.
The escape sequence is returne... | python | def consume_escape_sequence(iterator, starter):
"""Given an input `iterator` and the character that started an escape
sequence, consume the whole escape sequence and return it.
May raise StartEscapeSequenceException if a new escape sequence
is started midway.
The escape sequence is returne... | [
"def",
"consume_escape_sequence",
"(",
"iterator",
",",
"starter",
")",
":",
"seq",
"=",
"[",
"u'['",
"]",
"if",
"is_char_single_character_csi",
"(",
"starter",
")",
"else",
"[",
"next",
"(",
"iterator",
")",
"]",
"raise_if_start_escape_sequence",
"(",
"seq",
... | Given an input `iterator` and the character that started an escape
sequence, consume the whole escape sequence and return it.
May raise StartEscapeSequenceException if a new escape sequence
is started midway.
The escape sequence is returned as an unicode string and is always
formatted as i... | [
"Given",
"an",
"input",
"iterator",
"and",
"the",
"character",
"that",
"started",
"an",
"escape",
"sequence",
"consume",
"the",
"whole",
"escape",
"sequence",
"and",
"return",
"it",
".",
"May",
"raise",
"StartEscapeSequenceException",
"if",
"a",
"new",
"escape",... | train | https://github.com/riquito/richinput/blob/858c6068d80377148b89dcf9107f4e46a2b464d4/richinput/richinput.py#L173-L198 |
riquito/richinput | richinput/richinput.py | get_cursor_position | def get_cursor_position():
"""Write an escape sequence to ask for the current cursor position.
Since the result is written on the standard input, this function
should not be used if you expect that your input has been pasted,
because the characters in the buffer would be read before the
answer about... | python | def get_cursor_position():
"""Write an escape sequence to ask for the current cursor position.
Since the result is written on the standard input, this function
should not be used if you expect that your input has been pasted,
because the characters in the buffer would be read before the
answer about... | [
"def",
"get_cursor_position",
"(",
")",
":",
"# \"cursor position report\" in ECMA-48.",
"it",
"=",
"get_char",
"(",
"u'\\x1b[6n'",
")",
"sequence",
"=",
"consume_escape_sequence",
"(",
"it",
",",
"next",
"(",
"it",
")",
")",
"# sequence format is \\x1b[<row>;<col>R",
... | Write an escape sequence to ask for the current cursor position.
Since the result is written on the standard input, this function
should not be used if you expect that your input has been pasted,
because the characters in the buffer would be read before the
answer about the cursor. | [
"Write",
"an",
"escape",
"sequence",
"to",
"ask",
"for",
"the",
"current",
"cursor",
"position",
".",
"Since",
"the",
"result",
"is",
"written",
"on",
"the",
"standard",
"input",
"this",
"function",
"should",
"not",
"be",
"used",
"if",
"you",
"expect",
"th... | train | https://github.com/riquito/richinput/blob/858c6068d80377148b89dcf9107f4e46a2b464d4/richinput/richinput.py#L221-L233 |
klen/bottle-jade | bottle_jade.py | Environment.get_template | def get_template(self, path):
""" Load and compile template. """
if self.options['debug'] and self.options['cache_size']:
return self.cache.get(path, self.cache_template(path))
return self.load_template(path) | python | def get_template(self, path):
""" Load and compile template. """
if self.options['debug'] and self.options['cache_size']:
return self.cache.get(path, self.cache_template(path))
return self.load_template(path) | [
"def",
"get_template",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"options",
"[",
"'debug'",
"]",
"and",
"self",
".",
"options",
"[",
"'cache_size'",
"]",
":",
"return",
"self",
".",
"cache",
".",
"get",
"(",
"path",
",",
"self",
".",
"... | Load and compile template. | [
"Load",
"and",
"compile",
"template",
"."
] | train | https://github.com/klen/bottle-jade/blob/a8eb3b5d8e741540ea85cbc0c18952fbd68d7476/bottle_jade.py#L150-L155 |
klmitch/framer | framer/framers.py | IdentityFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# Convert the data to bytes",
"frame",
"=",
"six",
".",
"binary_type",
"(",
"data",
")",
"# Clear the buffer",
"del",
"data",
"[",
":",
"]",
"# Return the frame",
"return",
"frame"
] | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L225-L249 |
klmitch/framer | framer/framers.py | ChunkFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# If we've read all the data, let the caller know",
"if",
"state",
".",
"chunk_remaining",
"<=",
"0",
":",
"raise",
"exc",
".",
"NoFrames",
"(",
")",
"# OK, how much data do we send on?",
"data_le... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L302-L334 |
klmitch/framer | framer/framers.py | LineFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# Find the next newline",
"data_len",
"=",
"data",
".",
"find",
"(",
"b'\\n'",
")",
"if",
"data_len",
"<",
"0",
":",
"# No line to extract",
"raise",
"exc",
".",
"NoFrames",
"(",
")",
... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L363-L400 |
klmitch/framer | framer/framers.py | LengthEncodedFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# First, determine the length we're looking for",
"length",
"=",
"state",
".",
"length",
"if",
"length",
"is",
"None",
":",
"# Try decoding a length from the data buffer",
"length",
"=",
"self",
"... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L445-L481 |
klmitch/framer | framer/framers.py | LengthEncodedFramer.to_bytes | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | python | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | [
"def",
"to_bytes",
"(",
"self",
",",
"frame",
",",
"state",
")",
":",
"# Generate the bytes from the frame",
"frame",
"=",
"six",
".",
"binary_type",
"(",
"frame",
")",
"return",
"self",
".",
"encode_length",
"(",
"frame",
",",
"state",
")",
"+",
"frame"
] | Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. This object may
be used to track... | [
"Convert",
"a",
"single",
"frame",
"into",
"bytes",
"that",
"can",
"be",
"transmitted",
"on",
"the",
"stream",
"."
] | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L483-L499 |
klmitch/framer | framer/framers.py | StructFramer.decode_length | def decode_length(self, data, state):
"""
Extract and decode a frame length from the data buffer. The
consumed data should be removed from the buffer. If the
length data is incomplete, must raise a ``NoFrames``
exception.
:param data: A ``bytearray`` instance containin... | python | def decode_length(self, data, state):
"""
Extract and decode a frame length from the data buffer. The
consumed data should be removed from the buffer. If the
length data is incomplete, must raise a ``NoFrames``
exception.
:param data: A ``bytearray`` instance containin... | [
"def",
"decode_length",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# Do we have enough data yet?",
"if",
"len",
"(",
"data",
")",
"<",
"self",
".",
"fmt",
".",
"size",
":",
"raise",
"exc",
".",
"NoFrames",
"(",
")",
"# Extract the length",
"length"... | Extract and decode a frame length from the data buffer. The
consumed data should be removed from the buffer. If the
length data is incomplete, must raise a ``NoFrames``
exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:para... | [
"Extract",
"and",
"decode",
"a",
"frame",
"length",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"the",
"length",
"data",
"is",
"incomplete",
"must",
"raise",
"a",
"NoFrames... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L600-L626 |
klmitch/framer | framer/framers.py | StuffingFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# Find the next packet start",
"if",
"not",
"state",
".",
"frame_start",
":",
"# Find the begin sequence",
"idx",
"=",
"data",
".",
"find",
"(",
"self",
".",
"begin",
")",
"if",
"idx",
"... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L700-L743 |
klmitch/framer | framer/framers.py | StuffingFramer.to_bytes | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | python | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | [
"def",
"to_bytes",
"(",
"self",
",",
"frame",
",",
"state",
")",
":",
"# Generate and return the frame",
"return",
"(",
"self",
".",
"begin",
"+",
"self",
".",
"nop",
".",
"join",
"(",
"six",
".",
"binary_type",
"(",
"frame",
")",
".",
"split",
"(",
"s... | Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. This object may
be used to track... | [
"Convert",
"a",
"single",
"frame",
"into",
"bytes",
"that",
"can",
"be",
"transmitted",
"on",
"the",
"stream",
"."
] | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L745-L762 |
klmitch/framer | framer/framers.py | COBSFramer.to_frame | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | python | def to_frame(self, data, state):
"""
Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
... | [
"def",
"to_frame",
"(",
"self",
",",
"data",
",",
"state",
")",
":",
"# Find the next null byte",
"data_len",
"=",
"data",
".",
"find",
"(",
"b'\\0'",
")",
"if",
"data_len",
"<",
"0",
":",
"# No full frame yet",
"raise",
"exc",
".",
"NoFrames",
"(",
")",
... | Extract a single frame from the data buffer. The consumed
data should be removed from the buffer. If no complete frame
can be read, must raise a ``NoFrames`` exception.
:param data: A ``bytearray`` instance containing the data so
far read.
:param state: An instanc... | [
"Extract",
"a",
"single",
"frame",
"from",
"the",
"data",
"buffer",
".",
"The",
"consumed",
"data",
"should",
"be",
"removed",
"from",
"the",
"buffer",
".",
"If",
"no",
"complete",
"frame",
"can",
"be",
"read",
"must",
"raise",
"a",
"NoFrames",
"exception"... | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L803-L836 |
klmitch/framer | framer/framers.py | COBSFramer.to_bytes | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | python | def to_bytes(self, frame, state):
"""
Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. ... | [
"def",
"to_bytes",
"(",
"self",
",",
"frame",
",",
"state",
")",
":",
"# Encode the frame and append the delimiter",
"return",
"six",
".",
"binary_type",
"(",
"self",
".",
"variant",
".",
"encode",
"(",
"six",
".",
"binary_type",
"(",
"frame",
")",
")",
")",... | Convert a single frame into bytes that can be transmitted on
the stream.
:param frame: The frame to convert. Should be the same type
of object returned by ``to_frame()``.
:param state: An instance of ``FramerState``. This object may
be used to track... | [
"Convert",
"a",
"single",
"frame",
"into",
"bytes",
"that",
"can",
"be",
"transmitted",
"on",
"the",
"stream",
"."
] | train | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/framers.py#L838-L854 |
openbermuda/ripl | ripl/csv2json.py | Csv2Json.interpret | def interpret(self, infile):
""" Process a file of rest and return json """
# need row headings
data = pandas.read_csv(infile)
# FIXME find the right foo
return json.dumps(data.foo()) | python | def interpret(self, infile):
""" Process a file of rest and return json """
# need row headings
data = pandas.read_csv(infile)
# FIXME find the right foo
return json.dumps(data.foo()) | [
"def",
"interpret",
"(",
"self",
",",
"infile",
")",
":",
"# need row headings",
"data",
"=",
"pandas",
".",
"read_csv",
"(",
"infile",
")",
"# FIXME find the right foo",
"return",
"json",
".",
"dumps",
"(",
"data",
".",
"foo",
"(",
")",
")"
] | Process a file of rest and return json | [
"Process",
"a",
"file",
"of",
"rest",
"and",
"return",
"json"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/csv2json.py#L23-L30 |
bsdlp/solutions | solutions/__init__.py | binary_search | def binary_search(data, target, lo=0, hi=None):
"""
Perform binary search on sorted list data for target. Returns int
representing position of target in data.
"""
hi = hi if hi is not None else len(data)
mid = (lo + hi) // 2
if hi < 2 or hi > len(data) or target > data[-1] or target < data[0... | python | def binary_search(data, target, lo=0, hi=None):
"""
Perform binary search on sorted list data for target. Returns int
representing position of target in data.
"""
hi = hi if hi is not None else len(data)
mid = (lo + hi) // 2
if hi < 2 or hi > len(data) or target > data[-1] or target < data[0... | [
"def",
"binary_search",
"(",
"data",
",",
"target",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"hi",
"=",
"hi",
"if",
"hi",
"is",
"not",
"None",
"else",
"len",
"(",
"data",
")",
"mid",
"=",
"(",
"lo",
"+",
"hi",
")",
"//",
"2",
... | Perform binary search on sorted list data for target. Returns int
representing position of target in data. | [
"Perform",
"binary",
"search",
"on",
"sorted",
"list",
"data",
"for",
"target",
".",
"Returns",
"int",
"representing",
"position",
"of",
"target",
"in",
"data",
"."
] | train | https://github.com/bsdlp/solutions/blob/e85daeaab10796d5746fcfa7157e65e5210fa07b/solutions/__init__.py#L14-L28 |
gnarlychicken/ticket_auth | ticket_auth/ticket_factory.py | TicketFactory.new | def new(self, user_id, tokens=None, user_data=None, valid_until=None,
client_ip=None, encoding='utf-8'):
"""Creates a new authentication ticket.
Args:
user_id: User id to store in ticket (stored in plain text)
tokens: Optional sequence of token strings to store in th... | python | def new(self, user_id, tokens=None, user_data=None, valid_until=None,
client_ip=None, encoding='utf-8'):
"""Creates a new authentication ticket.
Args:
user_id: User id to store in ticket (stored in plain text)
tokens: Optional sequence of token strings to store in th... | [
"def",
"new",
"(",
"self",
",",
"user_id",
",",
"tokens",
"=",
"None",
",",
"user_data",
"=",
"None",
",",
"valid_until",
"=",
"None",
",",
"client_ip",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"valid_until",
"is",
"None",
":",
"... | Creates a new authentication ticket.
Args:
user_id: User id to store in ticket (stored in plain text)
tokens: Optional sequence of token strings to store in the ticket
(stored in plain text).
user_data: Optional user data to store in the ticket (string like
... | [
"Creates",
"a",
"new",
"authentication",
"ticket",
"."
] | train | https://github.com/gnarlychicken/ticket_auth/blob/814eaa2cbe9c8dd9f4ded611def85fdd57763f8d/ticket_auth/ticket_factory.py#L34-L81 |
gnarlychicken/ticket_auth | ticket_auth/ticket_factory.py | TicketFactory.validate | def validate(self, ticket, client_ip=None, now=None, encoding='utf-8'):
"""Validates the passed ticket, , raises a TicketError
on failure
Args:
ticket: String value (possibly generated by new function)
client_ip: Optional IPAddress of client, should be passed if the
... | python | def validate(self, ticket, client_ip=None, now=None, encoding='utf-8'):
"""Validates the passed ticket, , raises a TicketError
on failure
Args:
ticket: String value (possibly generated by new function)
client_ip: Optional IPAddress of client, should be passed if the
... | [
"def",
"validate",
"(",
"self",
",",
"ticket",
",",
"client_ip",
"=",
"None",
",",
"now",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"parts",
"=",
"self",
".",
"parse",
"(",
"ticket",
")",
"# Check if our ticket matches",
"new_ticket",
"=",
... | Validates the passed ticket, , raises a TicketError
on failure
Args:
ticket: String value (possibly generated by new function)
client_ip: Optional IPAddress of client, should be passed if the
ip address was passed on ticket creation.
now: Optional (de... | [
"Validates",
"the",
"passed",
"ticket",
"raises",
"a",
"TicketError",
"on",
"failure"
] | train | https://github.com/gnarlychicken/ticket_auth/blob/814eaa2cbe9c8dd9f4ded611def85fdd57763f8d/ticket_auth/ticket_factory.py#L83-L118 |
gnarlychicken/ticket_auth | ticket_auth/ticket_factory.py | TicketFactory.parse | def parse(self, ticket):
"""Parses the passed ticket, returning a tuple containing the digest,
user_id, valid_until, tokens, and user_data fields
"""
if len(ticket) < self._min_ticket_size():
raise TicketParseError(ticket, 'Invalid ticket length')
digest_len = self._... | python | def parse(self, ticket):
"""Parses the passed ticket, returning a tuple containing the digest,
user_id, valid_until, tokens, and user_data fields
"""
if len(ticket) < self._min_ticket_size():
raise TicketParseError(ticket, 'Invalid ticket length')
digest_len = self._... | [
"def",
"parse",
"(",
"self",
",",
"ticket",
")",
":",
"if",
"len",
"(",
"ticket",
")",
"<",
"self",
".",
"_min_ticket_size",
"(",
")",
":",
"raise",
"TicketParseError",
"(",
"ticket",
",",
"'Invalid ticket length'",
")",
"digest_len",
"=",
"self",
".",
"... | Parses the passed ticket, returning a tuple containing the digest,
user_id, valid_until, tokens, and user_data fields | [
"Parses",
"the",
"passed",
"ticket",
"returning",
"a",
"tuple",
"containing",
"the",
"digest",
"user_id",
"valid_until",
"tokens",
"and",
"user_data",
"fields"
] | train | https://github.com/gnarlychicken/ticket_auth/blob/814eaa2cbe9c8dd9f4ded611def85fdd57763f8d/ticket_auth/ticket_factory.py#L120-L147 |
sbusard/wagoner | wagoner/tree.py | Tree.from_table | def from_table(cls, table, length, prefix=0, flatten=False):
"""
Extract from the given table a tree for word length, taking only
prefixes of prefix length (if greater than 0) into account to compute
successors.
:param table: the table to extract the tree from;
:... | python | def from_table(cls, table, length, prefix=0, flatten=False):
"""
Extract from the given table a tree for word length, taking only
prefixes of prefix length (if greater than 0) into account to compute
successors.
:param table: the table to extract the tree from;
:... | [
"def",
"from_table",
"(",
"cls",
",",
"table",
",",
"length",
",",
"prefix",
"=",
"0",
",",
"flatten",
"=",
"False",
")",
":",
"# Build the expanded tree with necessary suffix and length",
"tree",
"=",
"defaultdict",
"(",
"dict",
")",
"# The tree",
"pending",
"=... | Extract from the given table a tree for word length, taking only
prefixes of prefix length (if greater than 0) into account to compute
successors.
:param table: the table to extract the tree from;
:param length: the length of words generated by the extracted tree;
... | [
"Extract",
"from",
"the",
"given",
"table",
"a",
"tree",
"for",
"word",
"length",
"taking",
"only",
"prefixes",
"of",
"prefix",
"length",
"(",
"if",
"greater",
"than",
"0",
")",
"into",
"account",
"to",
"compute",
"successors",
".",
":",
"param",
"table",
... | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/tree.py#L33-L70 |
sbusard/wagoner | wagoner/tree.py | Tree.trim_tree | def trim_tree(tree):
"""
Remove the dead branches of tree, that is, the resulting tree accepts
the same language as the original one (that is, the same words that end
with the < character), but parts of the tree that lead to nothing are
removed.
:param tree: the tree;
... | python | def trim_tree(tree):
"""
Remove the dead branches of tree, that is, the resulting tree accepts
the same language as the original one (that is, the same words that end
with the < character), but parts of the tree that lead to nothing are
removed.
:param tree: the tree;
... | [
"def",
"trim_tree",
"(",
"tree",
")",
":",
"# Remove empty nodes",
"new_tree",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"tree",
".",
"items",
"(",
")",
"if",
"v",
"}",
"# Remove missing successors",
"new_tree",
"=",
"{",
"k",
":",
"{",
"s... | Remove the dead branches of tree, that is, the resulting tree accepts
the same language as the original one (that is, the same words that end
with the < character), but parts of the tree that lead to nothing are
removed.
:param tree: the tree;
:return: the tree without dead bran... | [
"Remove",
"the",
"dead",
"branches",
"of",
"tree",
"that",
"is",
"the",
"resulting",
"tree",
"accepts",
"the",
"same",
"language",
"as",
"the",
"original",
"one",
"(",
"that",
"is",
"the",
"same",
"words",
"that",
"end",
"with",
"the",
"<",
"character",
... | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/tree.py#L73-L98 |
sbusard/wagoner | wagoner/tree.py | Tree.random_word | def random_word(self, *args, **kwargs):
"""
Return a random word from this tree. The length of the word depends on
the this tree.
:return: a random word from this tree.
args and kwargs are ignored.
"""
word = ""
current = (">", 0)
while current[0... | python | def random_word(self, *args, **kwargs):
"""
Return a random word from this tree. The length of the word depends on
the this tree.
:return: a random word from this tree.
args and kwargs are ignored.
"""
word = ""
current = (">", 0)
while current[0... | [
"def",
"random_word",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"word",
"=",
"\"\"",
"current",
"=",
"(",
"\">\"",
",",
"0",
")",
"while",
"current",
"[",
"0",
"]",
"!=",
"\"<\"",
":",
"choices",
"=",
"self",
"[",
"current... | Return a random word from this tree. The length of the word depends on
the this tree.
:return: a random word from this tree.
args and kwargs are ignored. | [
"Return",
"a",
"random",
"word",
"from",
"this",
"tree",
".",
"The",
"length",
"of",
"the",
"word",
"depends",
"on",
"the",
"this",
"tree",
"."
] | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/tree.py#L112-L128 |
Othernet-Project/hwd | hwd/storage.py | Mountable.mount_points | def mount_points(self):
"""
Iterator of partition's mount points obtained by reading /proc/mounts.
Returns empty list if /proc/mounts is not readable or if there are no
mount points.
"""
aliases = self.aliases
try:
return [e.mdir for e in mounts() if e... | python | def mount_points(self):
"""
Iterator of partition's mount points obtained by reading /proc/mounts.
Returns empty list if /proc/mounts is not readable or if there are no
mount points.
"""
aliases = self.aliases
try:
return [e.mdir for e in mounts() if e... | [
"def",
"mount_points",
"(",
"self",
")",
":",
"aliases",
"=",
"self",
".",
"aliases",
"try",
":",
"return",
"[",
"e",
".",
"mdir",
"for",
"e",
"in",
"mounts",
"(",
")",
"if",
"e",
".",
"dev",
"in",
"aliases",
"]",
"except",
"(",
"OSError",
",",
"... | Iterator of partition's mount points obtained by reading /proc/mounts.
Returns empty list if /proc/mounts is not readable or if there are no
mount points. | [
"Iterator",
"of",
"partition",
"s",
"mount",
"points",
"obtained",
"by",
"reading",
"/",
"proc",
"/",
"mounts",
".",
"Returns",
"empty",
"list",
"if",
"/",
"proc",
"/",
"mounts",
"is",
"not",
"readable",
"or",
"if",
"there",
"are",
"no",
"mount",
"points... | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/storage.py#L45-L55 |
Othernet-Project/hwd | hwd/storage.py | Mountable.stat | def stat(self):
"""
Return disk usage information for the partition in :py:class:`Fstat`
format. If disk usage information is not available, then ``None`` is
returned. Disk usage information is only available for regular
filesystems that are mounted.
"""
try:
... | python | def stat(self):
"""
Return disk usage information for the partition in :py:class:`Fstat`
format. If disk usage information is not available, then ``None`` is
returned. Disk usage information is only available for regular
filesystems that are mounted.
"""
try:
... | [
"def",
"stat",
"(",
"self",
")",
":",
"try",
":",
"# Always use the last mount point because it's a very common",
"# situation when mount points are moved, or sotorage is",
"# double-mounted. Last mount point is always the newest.",
"mp",
"=",
"self",
".",
"mount_points",
"[",
"-",... | Return disk usage information for the partition in :py:class:`Fstat`
format. If disk usage information is not available, then ``None`` is
returned. Disk usage information is only available for regular
filesystems that are mounted. | [
"Return",
"disk",
"usage",
"information",
"for",
"the",
"partition",
"in",
":",
"py",
":",
"class",
":",
"Fstat",
"format",
".",
"If",
"disk",
"usage",
"information",
"is",
"not",
"available",
"then",
"None",
"is",
"returned",
".",
"Disk",
"usage",
"inform... | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/storage.py#L58-L78 |
Othernet-Project/hwd | hwd/storage.py | Disk.partitions | def partitions(self):
"""
Iterable containing disk's partition objects. Objects in the iterable
are :py:class:`~hwd.storage.Partition` instances.
"""
if not self._partitions:
self._partitions = [Partition(d, self)
for d in self.device.c... | python | def partitions(self):
"""
Iterable containing disk's partition objects. Objects in the iterable
are :py:class:`~hwd.storage.Partition` instances.
"""
if not self._partitions:
self._partitions = [Partition(d, self)
for d in self.device.c... | [
"def",
"partitions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_partitions",
":",
"self",
".",
"_partitions",
"=",
"[",
"Partition",
"(",
"d",
",",
"self",
")",
"for",
"d",
"in",
"self",
".",
"device",
".",
"children",
"]",
"return",
"self",
... | Iterable containing disk's partition objects. Objects in the iterable
are :py:class:`~hwd.storage.Partition` instances. | [
"Iterable",
"containing",
"disk",
"s",
"partition",
"objects",
".",
"Objects",
"in",
"the",
"iterable",
"are",
":",
"py",
":",
"class",
":",
"~hwd",
".",
"storage",
".",
"Partition",
"instances",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/storage.py#L114-L122 |
Othernet-Project/hwd | hwd/storage.py | UbiVolume.aliases | def aliases(self):
"""
Aliases for UBI volume. This propery evaluates to device node itself
plus the ``'ubi${INDEX}:${LABEL}'`` string. The latter is used to
identify the device in /proc/mounts table, and is not really an alias.
"""
return ['ubi{}:{}'.format(self.device.p... | python | def aliases(self):
"""
Aliases for UBI volume. This propery evaluates to device node itself
plus the ``'ubi${INDEX}:${LABEL}'`` string. The latter is used to
identify the device in /proc/mounts table, and is not really an alias.
"""
return ['ubi{}:{}'.format(self.device.p... | [
"def",
"aliases",
"(",
"self",
")",
":",
"return",
"[",
"'ubi{}:{}'",
".",
"format",
"(",
"self",
".",
"device",
".",
"parent",
".",
"sys_number",
",",
"self",
".",
"label",
")",
",",
"self",
".",
"node",
"]"
] | Aliases for UBI volume. This propery evaluates to device node itself
plus the ``'ubi${INDEX}:${LABEL}'`` string. The latter is used to
identify the device in /proc/mounts table, and is not really an alias. | [
"Aliases",
"for",
"UBI",
"volume",
".",
"This",
"propery",
"evaluates",
"to",
"device",
"node",
"itself",
"plus",
"the",
"ubi$",
"{",
"INDEX",
"}",
":",
"$",
"{",
"LABEL",
"}",
"string",
".",
"The",
"latter",
"is",
"used",
"to",
"identify",
"the",
"dev... | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/storage.py#L323-L330 |
jmgilman/Neolib | neolib/item/UserShopFrontItem.py | UserShopFrontItem.buy | def buy(self):
""" Attempts to purchase a user shop item, returns result
Uses the associated user and buyURL to attempt to purchase the user shop item. Returns
whether or not the item was successfully bought.
Returns
bool - True if successful, false other... | python | def buy(self):
""" Attempts to purchase a user shop item, returns result
Uses the associated user and buyURL to attempt to purchase the user shop item. Returns
whether or not the item was successfully bought.
Returns
bool - True if successful, false other... | [
"def",
"buy",
"(",
"self",
")",
":",
"# Buy the item",
"pg",
"=",
"self",
".",
"usr",
".",
"getPage",
"(",
"\"http://www.neopets.com/\"",
"+",
"self",
".",
"buyURL",
",",
"vars",
"=",
"{",
"'Referer'",
":",
"'http://www.neopets.com/browseshop.phtml?owner='",
"+"... | Attempts to purchase a user shop item, returns result
Uses the associated user and buyURL to attempt to purchase the user shop item. Returns
whether or not the item was successfully bought.
Returns
bool - True if successful, false otherwise | [
"Attempts",
"to",
"purchase",
"a",
"user",
"shop",
"item",
"returns",
"result",
"Uses",
"the",
"associated",
"user",
"and",
"buyURL",
"to",
"attempt",
"to",
"purchase",
"the",
"user",
"shop",
"item",
".",
"Returns",
"whether",
"or",
"not",
"the",
"item",
"... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/item/UserShopFrontItem.py#L33-L52 |
Pringley/spyglass | spyglass/torrent.py | Torrent.fetch | def fetch(self, cache=None):
"""Query the info page to fill in the property cache.
Return a dictionary with the fetched properties and values.
"""
self.reset()
soup = get(self.url).soup
details = soup.find(id="detailsframe")
getdef = lambda s: [elem
... | python | def fetch(self, cache=None):
"""Query the info page to fill in the property cache.
Return a dictionary with the fetched properties and values.
"""
self.reset()
soup = get(self.url).soup
details = soup.find(id="detailsframe")
getdef = lambda s: [elem
... | [
"def",
"fetch",
"(",
"self",
",",
"cache",
"=",
"None",
")",
":",
"self",
".",
"reset",
"(",
")",
"soup",
"=",
"get",
"(",
"self",
".",
"url",
")",
".",
"soup",
"details",
"=",
"soup",
".",
"find",
"(",
"id",
"=",
"\"detailsframe\"",
")",
"getdef... | Query the info page to fill in the property cache.
Return a dictionary with the fetched properties and values. | [
"Query",
"the",
"info",
"page",
"to",
"fill",
"in",
"the",
"property",
"cache",
"."
] | train | https://github.com/Pringley/spyglass/blob/091d74f34837673af936daa9f462ad8216be9916/spyglass/torrent.py#L47-L76 |
Pringley/spyglass | spyglass/torrent.py | Torrent.get | def get(self, item, cache=None):
"""Lookup a torrent info property.
If cache is True, check the cache first. If the cache is empty, then
fetch torrent info before returning it.
"""
if item not in self._keys:
raise KeyError(item)
if self._use_cache(cache) and... | python | def get(self, item, cache=None):
"""Lookup a torrent info property.
If cache is True, check the cache first. If the cache is empty, then
fetch torrent info before returning it.
"""
if item not in self._keys:
raise KeyError(item)
if self._use_cache(cache) and... | [
"def",
"get",
"(",
"self",
",",
"item",
",",
"cache",
"=",
"None",
")",
":",
"if",
"item",
"not",
"in",
"self",
".",
"_keys",
":",
"raise",
"KeyError",
"(",
"item",
")",
"if",
"self",
".",
"_use_cache",
"(",
"cache",
")",
"and",
"(",
"self",
".",... | Lookup a torrent info property.
If cache is True, check the cache first. If the cache is empty, then
fetch torrent info before returning it. | [
"Lookup",
"a",
"torrent",
"info",
"property",
"."
] | train | https://github.com/Pringley/spyglass/blob/091d74f34837673af936daa9f462ad8216be9916/spyglass/torrent.py#L78-L91 |
Pringley/spyglass | spyglass/torrent.py | Torrent.as_dict | def as_dict(self, cache=None, fetch=True):
"""Return torrent properties as a dictionary.
Set the cache flag to False to disable the cache. On the other hand,
set the fetch flag to False to avoid fetching data if it's not cached.
"""
if not self._fetched and fetch:
i... | python | def as_dict(self, cache=None, fetch=True):
"""Return torrent properties as a dictionary.
Set the cache flag to False to disable the cache. On the other hand,
set the fetch flag to False to avoid fetching data if it's not cached.
"""
if not self._fetched and fetch:
i... | [
"def",
"as_dict",
"(",
"self",
",",
"cache",
"=",
"None",
",",
"fetch",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"_fetched",
"and",
"fetch",
":",
"info",
"=",
"self",
".",
"fetch",
"(",
"cache",
")",
"elif",
"self",
".",
"_use_cache",
"(",
... | Return torrent properties as a dictionary.
Set the cache flag to False to disable the cache. On the other hand,
set the fetch flag to False to avoid fetching data if it's not cached. | [
"Return",
"torrent",
"properties",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/Pringley/spyglass/blob/091d74f34837673af936daa9f462ad8216be9916/spyglass/torrent.py#L114-L128 |
fedora-infra/fmn.rules | fmn/rules/generic.py | user_filter | def user_filter(config, message, fasnick=None, *args, **kw):
""" A particular user
Use this rule to include messages that are associated with a
specific user.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
return fasnick in fmn.rules.utils.msg2usernames(message, **config) | python | def user_filter(config, message, fasnick=None, *args, **kw):
""" A particular user
Use this rule to include messages that are associated with a
specific user.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
return fasnick in fmn.rules.utils.msg2usernames(message, **config) | [
"def",
"user_filter",
"(",
"config",
",",
"message",
",",
"fasnick",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fasnick",
"=",
"kw",
".",
"get",
"(",
"'fasnick'",
",",
"fasnick",
")",
"if",
"fasnick",
":",
"return",
"fasnick",
"... | A particular user
Use this rule to include messages that are associated with a
specific user. | [
"A",
"particular",
"user"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L12-L21 |
fedora-infra/fmn.rules | fmn/rules/generic.py | not_user_filter | def not_user_filter(config, message, fasnick=None, *args, **kw):
""" Everything except a particular user
Use this rule to exclude messages that are associated with one or more
users. Specify several users by separating them with a comma ','.
"""
fasnick = kw.get('fasnick', fasnick)
if not fasn... | python | def not_user_filter(config, message, fasnick=None, *args, **kw):
""" Everything except a particular user
Use this rule to exclude messages that are associated with one or more
users. Specify several users by separating them with a comma ','.
"""
fasnick = kw.get('fasnick', fasnick)
if not fasn... | [
"def",
"not_user_filter",
"(",
"config",
",",
"message",
",",
"fasnick",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fasnick",
"=",
"kw",
".",
"get",
"(",
"'fasnick'",
",",
"fasnick",
")",
"if",
"not",
"fasnick",
":",
"return",
"... | Everything except a particular user
Use this rule to exclude messages that are associated with one or more
users. Specify several users by separating them with a comma ','. | [
"Everything",
"except",
"a",
"particular",
"user"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L26-L44 |
fedora-infra/fmn.rules | fmn/rules/generic.py | _get_users_of_group | def _get_users_of_group(config, group):
""" Utility to query fas for users of a group. """
if not group:
return set()
fas = fmn.rules.utils.get_fas(config)
return fmn.rules.utils.get_user_of_group(config, fas, group) | python | def _get_users_of_group(config, group):
""" Utility to query fas for users of a group. """
if not group:
return set()
fas = fmn.rules.utils.get_fas(config)
return fmn.rules.utils.get_user_of_group(config, fas, group) | [
"def",
"_get_users_of_group",
"(",
"config",
",",
"group",
")",
":",
"if",
"not",
"group",
":",
"return",
"set",
"(",
")",
"fas",
"=",
"fmn",
".",
"rules",
".",
"utils",
".",
"get_fas",
"(",
"config",
")",
"return",
"fmn",
".",
"rules",
".",
"utils",... | Utility to query fas for users of a group. | [
"Utility",
"to",
"query",
"fas",
"for",
"users",
"of",
"a",
"group",
"."
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L47-L52 |
fedora-infra/fmn.rules | fmn/rules/generic.py | fas_group_member_filter | def fas_group_member_filter(config, message, group=None, *args, **kw):
""" Messages regarding any member of a FAS group
Use this rule to include messages that have anything to do with **any
user** belonging to a particular fas group. You might want to use this
to monitor the activity of a group for wh... | python | def fas_group_member_filter(config, message, group=None, *args, **kw):
""" Messages regarding any member of a FAS group
Use this rule to include messages that have anything to do with **any
user** belonging to a particular fas group. You might want to use this
to monitor the activity of a group for wh... | [
"def",
"fas_group_member_filter",
"(",
"config",
",",
"message",
",",
"group",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"group",
":",
"return",
"False",
"fasusers",
"=",
"_get_users_of_group",
"(",
"config",
",",
"group"... | Messages regarding any member of a FAS group
Use this rule to include messages that have anything to do with **any
user** belonging to a particular fas group. You might want to use this
to monitor the activity of a group for which you are responsible. | [
"Messages",
"regarding",
"any",
"member",
"of",
"a",
"FAS",
"group"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L56-L67 |
fedora-infra/fmn.rules | fmn/rules/generic.py | user_package_filter | def user_package_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (any acl)
This rule includes messages that relate to packages where the
specified user has *either* commit ACLs or the watchcommits flag.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
... | python | def user_package_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (any acl)
This rule includes messages that relate to packages where the
specified user has *either* commit ACLs or the watchcommits flag.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
... | [
"def",
"user_package_filter",
"(",
"config",
",",
"message",
",",
"fasnick",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fasnick",
"=",
"kw",
".",
"get",
"(",
"'fasnick'",
",",
"fasnick",
")",
"if",
"fasnick",
":",
"msg_packages",
... | A particular user's packages (any acl)
This rule includes messages that relate to packages where the
specified user has *either* commit ACLs or the watchcommits flag. | [
"A",
"particular",
"user",
"s",
"packages",
"(",
"any",
"acl",
")"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L79-L99 |
fedora-infra/fmn.rules | fmn/rules/generic.py | user_package_commit_filter | def user_package_commit_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (commit acl)
This rule includes messages that relate to packages where the
specified user has commit ACLs.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
msg_packages = fm... | python | def user_package_commit_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (commit acl)
This rule includes messages that relate to packages where the
specified user has commit ACLs.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
msg_packages = fm... | [
"def",
"user_package_commit_filter",
"(",
"config",
",",
"message",
",",
"fasnick",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fasnick",
"=",
"kw",
".",
"get",
"(",
"'fasnick'",
",",
"fasnick",
")",
"if",
"fasnick",
":",
"msg_packag... | A particular user's packages (commit acl)
This rule includes messages that relate to packages where the
specified user has commit ACLs. | [
"A",
"particular",
"user",
"s",
"packages",
"(",
"commit",
"acl",
")"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L103-L123 |
fedora-infra/fmn.rules | fmn/rules/generic.py | user_package_watch_filter | def user_package_watch_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (watchcommits flag)
This rule includes messages that relate to packages where the
specified user has the watchcommits flag set.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
... | python | def user_package_watch_filter(config, message, fasnick=None, *args, **kw):
""" A particular user's packages (watchcommits flag)
This rule includes messages that relate to packages where the
specified user has the watchcommits flag set.
"""
fasnick = kw.get('fasnick', fasnick)
if fasnick:
... | [
"def",
"user_package_watch_filter",
"(",
"config",
",",
"message",
",",
"fasnick",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fasnick",
"=",
"kw",
".",
"get",
"(",
"'fasnick'",
",",
"fasnick",
")",
"if",
"fasnick",
":",
"msg_package... | A particular user's packages (watchcommits flag)
This rule includes messages that relate to packages where the
specified user has the watchcommits flag set. | [
"A",
"particular",
"user",
"s",
"packages",
"(",
"watchcommits",
"flag",
")"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L128-L148 |
fedora-infra/fmn.rules | fmn/rules/generic.py | package_filter | def package_filter(config, message, package=None, *args, **kw):
""" A particular package
Use this rule to include messages that relate to a certain package
(*i.e., nethack*).
"""
package = kw.get('package', package)
if package:
return package in fmn.rules.utils.msg2packages(message, **... | python | def package_filter(config, message, package=None, *args, **kw):
""" A particular package
Use this rule to include messages that relate to a certain package
(*i.e., nethack*).
"""
package = kw.get('package', package)
if package:
return package in fmn.rules.utils.msg2packages(message, **... | [
"def",
"package_filter",
"(",
"config",
",",
"message",
",",
"package",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"package",
"=",
"kw",
".",
"get",
"(",
"'package'",
",",
"package",
")",
"if",
"package",
":",
"return",
"package",
... | A particular package
Use this rule to include messages that relate to a certain package
(*i.e., nethack*). | [
"A",
"particular",
"package"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L152-L161 |
fedora-infra/fmn.rules | fmn/rules/generic.py | package_regex_filter | def package_regex_filter(config, message, pattern=None, *args, **kw):
""" All packages matching a regular expression
Use this rule to include messages that relate to packages that match
particular regular expressions
(*i.e., (maven|javapackages-tools|maven-surefire)*).
"""
pattern = kw.get('pa... | python | def package_regex_filter(config, message, pattern=None, *args, **kw):
""" All packages matching a regular expression
Use this rule to include messages that relate to packages that match
particular regular expressions
(*i.e., (maven|javapackages-tools|maven-surefire)*).
"""
pattern = kw.get('pa... | [
"def",
"package_regex_filter",
"(",
"config",
",",
"message",
",",
"pattern",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"pattern",
"=",
"kw",
".",
"get",
"(",
"'pattern'",
",",
"pattern",
")",
"if",
"pattern",
":",
"packages",
"="... | All packages matching a regular expression
Use this rule to include messages that relate to packages that match
particular regular expressions
(*i.e., (maven|javapackages-tools|maven-surefire)*). | [
"All",
"packages",
"matching",
"a",
"regular",
"expression"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L165-L177 |
fedora-infra/fmn.rules | fmn/rules/generic.py | regex_filter | def regex_filter(config, message, pattern=None, *args, **kw):
""" All messages matching a regular expression
Use this rule to include messages that bear a certain pattern.
This can be anything that appears anywhere in the message (for instance,
you could combine this with rules for wiki updates or Ask ... | python | def regex_filter(config, message, pattern=None, *args, **kw):
""" All messages matching a regular expression
Use this rule to include messages that bear a certain pattern.
This can be anything that appears anywhere in the message (for instance,
you could combine this with rules for wiki updates or Ask ... | [
"def",
"regex_filter",
"(",
"config",
",",
"message",
",",
"pattern",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"pattern",
"=",
"kw",
".",
"get",
"(",
"'pattern'",
",",
"pattern",
")",
"if",
"pattern",
":",
"regex",
"=",
"fmn",
... | All messages matching a regular expression
Use this rule to include messages that bear a certain pattern.
This can be anything that appears anywhere in the message (for instance,
you could combine this with rules for wiki updates or Ask Fedora changes
to alert yourself of activity in your area of exper... | [
"All",
"messages",
"matching",
"a",
"regular",
"expression"
] | train | https://github.com/fedora-infra/fmn.rules/blob/f9ec790619fcc8b41803077c4dec094e5127fc24/fmn/rules/generic.py#L181-L197 |
kodexlab/reliure | reliure/pipeline.py | Optionable.add_option | def add_option(self, opt_name, otype, hidden=False):
""" Add an option to the object
:param opt_name: option name
:type opt_name: str
:param otype: option type
:type otype: subclass of :class:`.GenericType`
:param hidden: if True the option will be hidden
:type h... | python | def add_option(self, opt_name, otype, hidden=False):
""" Add an option to the object
:param opt_name: option name
:type opt_name: str
:param otype: option type
:type otype: subclass of :class:`.GenericType`
:param hidden: if True the option will be hidden
:type h... | [
"def",
"add_option",
"(",
"self",
",",
"opt_name",
",",
"otype",
",",
"hidden",
"=",
"False",
")",
":",
"if",
"self",
".",
"has_option",
"(",
"opt_name",
")",
":",
"raise",
"ValueError",
"(",
"\"The option is already present !\"",
")",
"opt",
"=",
"ValueOpti... | Add an option to the object
:param opt_name: option name
:type opt_name: str
:param otype: option type
:type otype: subclass of :class:`.GenericType`
:param hidden: if True the option will be hidden
:type hidden: bool | [
"Add",
"an",
"option",
"to",
"the",
"object"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L143-L157 |
kodexlab/reliure | reliure/pipeline.py | Optionable.print_options | def print_options(self):
""" print description of the component options
"""
summary = []
for opt_name, opt in self.options.items():
if opt.hidden:
continue
summary.append(opt.summary())
print("\n".join(summary)) | python | def print_options(self):
""" print description of the component options
"""
summary = []
for opt_name, opt in self.options.items():
if opt.hidden:
continue
summary.append(opt.summary())
print("\n".join(summary)) | [
"def",
"print_options",
"(",
"self",
")",
":",
"summary",
"=",
"[",
"]",
"for",
"opt_name",
",",
"opt",
"in",
"self",
".",
"options",
".",
"items",
"(",
")",
":",
"if",
"opt",
".",
"hidden",
":",
"continue",
"summary",
".",
"append",
"(",
"opt",
".... | print description of the component options | [
"print",
"description",
"of",
"the",
"component",
"options"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L164-L172 |
kodexlab/reliure | reliure/pipeline.py | Optionable.set_option_value | def set_option_value(self, opt_name, value, parse=False):
""" Set the value of one option.
# TODO/FIXME
* add force/hide argument
* add default argument
* remove methods force option value
* remove change_option_default
:para... | python | def set_option_value(self, opt_name, value, parse=False):
""" Set the value of one option.
# TODO/FIXME
* add force/hide argument
* add default argument
* remove methods force option value
* remove change_option_default
:para... | [
"def",
"set_option_value",
"(",
"self",
",",
"opt_name",
",",
"value",
",",
"parse",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"has_option",
"(",
"opt_name",
")",
":",
"raise",
"ValueError",
"(",
"\"Unknow option name (%s)\"",
"%",
"opt_name",
")",
... | Set the value of one option.
# TODO/FIXME
* add force/hide argument
* add default argument
* remove methods force option value
* remove change_option_default
:param opt_name: option name
:type opt_name: str
:param val... | [
"Set",
"the",
"value",
"of",
"one",
"option",
".",
"#",
"TODO",
"/",
"FIXME",
"*",
"add",
"force",
"/",
"hide",
"argument",
"*",
"add",
"default",
"argument",
"*",
"remove",
"methods",
"force",
"option",
"value",
"*",
"remove",
"change_option_default",
":"... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L179-L197 |
kodexlab/reliure | reliure/pipeline.py | Optionable.clear_option_value | def clear_option_value(self, opt_name):
""" Clear the stored option value (so the default will be used)
:param opt_name: option name
:type opt_name: str
"""
if not self.has_option(opt_name):
raise ValueError("Unknow option name (%s)" % opt_name)
self._options... | python | def clear_option_value(self, opt_name):
""" Clear the stored option value (so the default will be used)
:param opt_name: option name
:type opt_name: str
"""
if not self.has_option(opt_name):
raise ValueError("Unknow option name (%s)" % opt_name)
self._options... | [
"def",
"clear_option_value",
"(",
"self",
",",
"opt_name",
")",
":",
"if",
"not",
"self",
".",
"has_option",
"(",
"opt_name",
")",
":",
"raise",
"ValueError",
"(",
"\"Unknow option name (%s)\"",
"%",
"opt_name",
")",
"self",
".",
"_options",
"[",
"opt_name",
... | Clear the stored option value (so the default will be used)
:param opt_name: option name
:type opt_name: str | [
"Clear",
"the",
"stored",
"option",
"value",
"(",
"so",
"the",
"default",
"will",
"be",
"used",
")"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L199-L207 |
kodexlab/reliure | reliure/pipeline.py | Optionable.get_option_value | def get_option_value(self, opt_name):
""" Return the value of a given option
:param opt_name: option name
:type opt_name: str
:returns: the value of the option
"""
if not self.has_option(opt_name):
raise ValueError("Unknow option name (%s)" %... | python | def get_option_value(self, opt_name):
""" Return the value of a given option
:param opt_name: option name
:type opt_name: str
:returns: the value of the option
"""
if not self.has_option(opt_name):
raise ValueError("Unknow option name (%s)" %... | [
"def",
"get_option_value",
"(",
"self",
",",
"opt_name",
")",
":",
"if",
"not",
"self",
".",
"has_option",
"(",
"opt_name",
")",
":",
"raise",
"ValueError",
"(",
"\"Unknow option name (%s)\"",
"%",
"opt_name",
")",
"return",
"self",
".",
"_options",
"[",
"op... | Return the value of a given option
:param opt_name: option name
:type opt_name: str
:returns: the value of the option | [
"Return",
"the",
"value",
"of",
"a",
"given",
"option",
":",
"param",
"opt_name",
":",
"option",
"name",
":",
"type",
"opt_name",
":",
"str",
":",
"returns",
":",
"the",
"value",
"of",
"the",
"option"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/pipeline.py#L209-L219 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.