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 |
|---|---|---|---|---|---|---|---|---|---|---|
ClericPy/torequests | torequests/utils.py | Regex.show_all | def show_all(self, as_string=True):
""", python2 will not show flags"""
result = []
for item in self.container:
pattern = str(item[0])[10:] if PY3 else item[0].pattern
instances = item[2] or []
value = (
'%s "%s"' % (item[1].__name__, (item[1].... | python | def show_all(self, as_string=True):
""", python2 will not show flags"""
result = []
for item in self.container:
pattern = str(item[0])[10:] if PY3 else item[0].pattern
instances = item[2] or []
value = (
'%s "%s"' % (item[1].__name__, (item[1].... | [
"def",
"show_all",
"(",
"self",
",",
"as_string",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"container",
":",
"pattern",
"=",
"str",
"(",
"item",
"[",
"0",
"]",
")",
"[",
"10",
":",
"]",
"if",
"PY3",
"els... | , python2 will not show flags | [
"python2",
"will",
"not",
"show",
"flags"
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L666-L679 |
ClericPy/torequests | torequests/utils.py | Timer.x | def x(self):
"""Call self.log_func(self) and return expect_string."""
self._log_after_del = False
passed_string = self.string
if self.log_func:
self.log_func(self)
else:
print_info(
"Timer [%(passed)s]: %(name)s, start at %(start)s."
... | python | def x(self):
"""Call self.log_func(self) and return expect_string."""
self._log_after_del = False
passed_string = self.string
if self.log_func:
self.log_func(self)
else:
print_info(
"Timer [%(passed)s]: %(name)s, start at %(start)s."
... | [
"def",
"x",
"(",
"self",
")",
":",
"self",
".",
"_log_after_del",
"=",
"False",
"passed_string",
"=",
"self",
".",
"string",
"if",
"self",
".",
"log_func",
":",
"self",
".",
"log_func",
"(",
"self",
")",
"else",
":",
"print_info",
"(",
"\"Timer [%(passed... | Call self.log_func(self) and return expect_string. | [
"Call",
"self",
".",
"log_func",
"(",
"self",
")",
"and",
"return",
"expect_string",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L865-L880 |
ClericPy/torequests | torequests/utils.py | Timer.tick | def tick(self):
"""Return the time cost string as expect."""
string = self.passed
if self.rounding:
string = round(string)
if self.readable:
string = self.readable(string)
return string | python | def tick(self):
"""Return the time cost string as expect."""
string = self.passed
if self.rounding:
string = round(string)
if self.readable:
string = self.readable(string)
return string | [
"def",
"tick",
"(",
"self",
")",
":",
"string",
"=",
"self",
".",
"passed",
"if",
"self",
".",
"rounding",
":",
"string",
"=",
"round",
"(",
"string",
")",
"if",
"self",
".",
"readable",
":",
"string",
"=",
"self",
".",
"readable",
"(",
"string",
"... | Return the time cost string as expect. | [
"Return",
"the",
"time",
"cost",
"string",
"as",
"expect",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L887-L894 |
ClericPy/torequests | torequests/utils.py | Timer.watch | def watch(*timer_args, **timer_kwargs):
"""Decorator for Timer."""
def wrapper(function):
@wraps(function)
def inner(*args, **kwargs):
args1 = ", ".join(map(repr, args)) if args else ""
kwargs1 = ", ".join(
["%s=%s" % (i, repr(... | python | def watch(*timer_args, **timer_kwargs):
"""Decorator for Timer."""
def wrapper(function):
@wraps(function)
def inner(*args, **kwargs):
args1 = ", ".join(map(repr, args)) if args else ""
kwargs1 = ", ".join(
["%s=%s" % (i, repr(... | [
"def",
"watch",
"(",
"*",
"timer_args",
",",
"*",
"*",
"timer_kwargs",
")",
":",
"def",
"wrapper",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args1",
"=",
"... | Decorator for Timer. | [
"Decorator",
"for",
"Timer",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L897-L915 |
ClericPy/torequests | torequests/utils.py | ClipboardWatcher.default_callback | def default_callback(self, text):
"""Default clean the \\n in text."""
text = text.replace("\r\n", "\n")
text = "%s\n" % text
flush_print(text, sep="", end="")
return text | python | def default_callback(self, text):
"""Default clean the \\n in text."""
text = text.replace("\r\n", "\n")
text = "%s\n" % text
flush_print(text, sep="", end="")
return text | [
"def",
"default_callback",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
")",
"text",
"=",
"\"%s\\n\"",
"%",
"text",
"flush_print",
"(",
"text",
",",
"sep",
"=",
"\"\"",
",",
"end",
"=",
"... | Default clean the \\n in text. | [
"Default",
"clean",
"the",
"\\\\",
"n",
"in",
"text",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L964-L969 |
ClericPy/torequests | torequests/utils.py | ClipboardWatcher.watch | def watch(self, limit=None, timeout=None):
"""Block method to watch the clipboard changing."""
start_time = time.time()
count = 0
while not timeout or time.time() - start_time < timeout:
new = self.read()
if new != self.temp:
count += 1
... | python | def watch(self, limit=None, timeout=None):
"""Block method to watch the clipboard changing."""
start_time = time.time()
count = 0
while not timeout or time.time() - start_time < timeout:
new = self.read()
if new != self.temp:
count += 1
... | [
"def",
"watch",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"count",
"=",
"0",
"while",
"not",
"timeout",
"or",
"time",
".",
"time",
"(",
")",
"-",
"start_time",
... | Block method to watch the clipboard changing. | [
"Block",
"method",
"to",
"watch",
"the",
"clipboard",
"changing",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L971-L983 |
ClericPy/torequests | torequests/utils.py | ClipboardWatcher.watch_async | def watch_async(self, limit=None, timeout=None):
"""Non-block method to watch the clipboard changing."""
return self.watch(limit=limit, timeout=timeout) | python | def watch_async(self, limit=None, timeout=None):
"""Non-block method to watch the clipboard changing."""
return self.watch(limit=limit, timeout=timeout) | [
"def",
"watch_async",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"self",
".",
"watch",
"(",
"limit",
"=",
"limit",
",",
"timeout",
"=",
"timeout",
")"
] | Non-block method to watch the clipboard changing. | [
"Non",
"-",
"block",
"method",
"to",
"watch",
"the",
"clipboard",
"changing",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L991-L993 |
ClericPy/torequests | torequests/utils.py | RegMatch.find_one | def find_one(cls, pattern, string, flags=0):
"""JS-like match object. Use index number to get groups, if not match or no group, will return ''.
Basic Usage::
>>> from torequests.utils import find_one
>>> string = "abcd"
>>> find_one("a.*", string)
<toreq... | python | def find_one(cls, pattern, string, flags=0):
"""JS-like match object. Use index number to get groups, if not match or no group, will return ''.
Basic Usage::
>>> from torequests.utils import find_one
>>> string = "abcd"
>>> find_one("a.*", string)
<toreq... | [
"def",
"find_one",
"(",
"cls",
",",
"pattern",
",",
"string",
",",
"flags",
"=",
"0",
")",
":",
"item",
"=",
"re",
".",
"search",
"(",
"pattern",
",",
"string",
",",
"flags",
"=",
"flags",
")",
"return",
"cls",
"(",
"item",
")"
] | JS-like match object. Use index number to get groups, if not match or no group, will return ''.
Basic Usage::
>>> from torequests.utils import find_one
>>> string = "abcd"
>>> find_one("a.*", string)
<torequests.utils.RegMatch object at 0x0705F1D0>
>... | [
"JS",
"-",
"like",
"match",
"object",
".",
"Use",
"index",
"number",
"to",
"get",
"groups",
"if",
"not",
"match",
"or",
"no",
"group",
"will",
"return",
"."
] | train | https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L1460-L1499 |
vsoch/helpme | helpme/main/github/utils.py | create_issue | def create_issue(title, body, repo, token):
'''create a Github issue, given a title, body, repo, and token.
Parameters
==========
title: the issue title
body: the issue body
repo: the full name of the repo
token: the user's personal Github token
'''
owner, name = ... | python | def create_issue(title, body, repo, token):
'''create a Github issue, given a title, body, repo, and token.
Parameters
==========
title: the issue title
body: the issue body
repo: the full name of the repo
token: the user's personal Github token
'''
owner, name = ... | [
"def",
"create_issue",
"(",
"title",
",",
"body",
",",
"repo",
",",
"token",
")",
":",
"owner",
",",
"name",
"=",
"repo",
".",
"split",
"(",
"'/'",
")",
"url",
"=",
"'https://api.github.com/repos/%s/%s/issues'",
"%",
"(",
"owner",
",",
"name",
")",
"data... | create a Github issue, given a title, body, repo, and token.
Parameters
==========
title: the issue title
body: the issue body
repo: the full name of the repo
token: the user's personal Github token | [
"create",
"a",
"Github",
"issue",
"given",
"a",
"title",
"body",
"repo",
"and",
"token",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/github/utils.py#L26-L59 |
PlaidWeb/Pushl | pushl/webmentions.py | get_target | async def get_target(config, url):
""" Given a URL, get the webmention endpoint """
previous = config.cache.get(
'target', url, schema_version=SCHEMA_VERSION) if config.cache else None
headers = previous.caching if previous else None
request = await utils.retry_get(config, url, headers=header... | python | async def get_target(config, url):
""" Given a URL, get the webmention endpoint """
previous = config.cache.get(
'target', url, schema_version=SCHEMA_VERSION) if config.cache else None
headers = previous.caching if previous else None
request = await utils.retry_get(config, url, headers=header... | [
"async",
"def",
"get_target",
"(",
"config",
",",
"url",
")",
":",
"previous",
"=",
"config",
".",
"cache",
".",
"get",
"(",
"'target'",
",",
"url",
",",
"schema_version",
"=",
"SCHEMA_VERSION",
")",
"if",
"config",
".",
"cache",
"else",
"None",
"headers... | Given a URL, get the webmention endpoint | [
"Given",
"a",
"URL",
"get",
"the",
"webmention",
"endpoint"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/webmentions.py#L160-L180 |
PlaidWeb/Pushl | pushl/webmentions.py | Target.send | async def send(self, config, entry):
""" Send a webmention to this target from the specified entry """
if self.endpoint:
LOGGER.debug("%s -> %s", entry.url, self.url)
try:
await self.endpoint.send(config, entry.url, self.url)
except Exception as err: ... | python | async def send(self, config, entry):
""" Send a webmention to this target from the specified entry """
if self.endpoint:
LOGGER.debug("%s -> %s", entry.url, self.url)
try:
await self.endpoint.send(config, entry.url, self.url)
except Exception as err: ... | [
"async",
"def",
"send",
"(",
"self",
",",
"config",
",",
"entry",
")",
":",
"if",
"self",
".",
"endpoint",
":",
"LOGGER",
".",
"debug",
"(",
"\"%s -> %s\"",
",",
"entry",
".",
"url",
",",
"self",
".",
"url",
")",
"try",
":",
"await",
"self",
".",
... | Send a webmention to this target from the specified entry | [
"Send",
"a",
"webmention",
"to",
"this",
"target",
"from",
"the",
"specified",
"entry"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/webmentions.py#L148-L156 |
vsoch/helpme | helpme/main/__init__.py | get_helper | def get_helper(name=None, quiet=True, **kwargs):
'''
get the correct helper depending on the environment variable
HELPME_CLIENT
quiet: if True, suppress most output about the client (e.g. speak)
'''
# Second priority, from environment
from helpme.defaults import HELPME_CLIENT
... | python | def get_helper(name=None, quiet=True, **kwargs):
'''
get the correct helper depending on the environment variable
HELPME_CLIENT
quiet: if True, suppress most output about the client (e.g. speak)
'''
# Second priority, from environment
from helpme.defaults import HELPME_CLIENT
... | [
"def",
"get_helper",
"(",
"name",
"=",
"None",
",",
"quiet",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Second priority, from environment",
"from",
"helpme",
".",
"defaults",
"import",
"HELPME_CLIENT",
"# First priority, from command line",
"if",
"name",
"... | get the correct helper depending on the environment variable
HELPME_CLIENT
quiet: if True, suppress most output about the client (e.g. speak) | [
"get",
"the",
"correct",
"helper",
"depending",
"on",
"the",
"environment",
"variable",
"HELPME_CLIENT"
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/__init__.py#L23-L48 |
iotile/baBLE | interfaces/python/bable_interface/scripts/mock_bable_interface.py | mock_bable | def mock_bable(monkeypatch):
""" Mock the BaBLEInterface class with some controllers inside. """
mocked_bable = MockBaBLE()
mocked_bable.set_controllers([
Controller(0, '11:22:33:44:55:66', '#0'),
Controller(1, '22:33:44:55:66:11', '#1', settings={'powered': True, 'low_energy': True}),
... | python | def mock_bable(monkeypatch):
""" Mock the BaBLEInterface class with some controllers inside. """
mocked_bable = MockBaBLE()
mocked_bable.set_controllers([
Controller(0, '11:22:33:44:55:66', '#0'),
Controller(1, '22:33:44:55:66:11', '#1', settings={'powered': True, 'low_energy': True}),
... | [
"def",
"mock_bable",
"(",
"monkeypatch",
")",
":",
"mocked_bable",
"=",
"MockBaBLE",
"(",
")",
"mocked_bable",
".",
"set_controllers",
"(",
"[",
"Controller",
"(",
"0",
",",
"'11:22:33:44:55:66'",
",",
"'#0'",
")",
",",
"Controller",
"(",
"1",
",",
"'22:33:4... | Mock the BaBLEInterface class with some controllers inside. | [
"Mock",
"the",
"BaBLEInterface",
"class",
"with",
"some",
"controllers",
"inside",
"."
] | train | https://github.com/iotile/baBLE/blob/faedca2c70b7fe91ea8ae0c3d8aff6bf843bd9db/interfaces/python/bable_interface/scripts/mock_bable_interface.py#L542-L553 |
SetBased/py-stratum | pystratum/command/PyStratumCommand.py | PyStratumCommand.handle | def handle(self):
"""
Executes the actual Stratum program.
"""
self.output = PyStratumStyle(self.input, self.output)
command = self.get_application().find('constants')
ret = command.execute(self.input, self.output)
if ret:
return ret
command ... | python | def handle(self):
"""
Executes the actual Stratum program.
"""
self.output = PyStratumStyle(self.input, self.output)
command = self.get_application().find('constants')
ret = command.execute(self.input, self.output)
if ret:
return ret
command ... | [
"def",
"handle",
"(",
"self",
")",
":",
"self",
".",
"output",
"=",
"PyStratumStyle",
"(",
"self",
".",
"input",
",",
"self",
".",
"output",
")",
"command",
"=",
"self",
".",
"get_application",
"(",
")",
".",
"find",
"(",
"'constants'",
")",
"ret",
"... | Executes the actual Stratum program. | [
"Executes",
"the",
"actual",
"Stratum",
"program",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/command/PyStratumCommand.py#L26-L47 |
nephila/djangocms-helper | djangocms_helper/utils.py | load_from_file | def load_from_file(module_path):
"""
Load a python module from its absolute filesystem path
Borrowed from django-cms
"""
from imp import load_module, PY_SOURCE
imported = None
if module_path:
with open(module_path, 'r') as openfile:
imported = load_module('mod', openfil... | python | def load_from_file(module_path):
"""
Load a python module from its absolute filesystem path
Borrowed from django-cms
"""
from imp import load_module, PY_SOURCE
imported = None
if module_path:
with open(module_path, 'r') as openfile:
imported = load_module('mod', openfil... | [
"def",
"load_from_file",
"(",
"module_path",
")",
":",
"from",
"imp",
"import",
"load_module",
",",
"PY_SOURCE",
"imported",
"=",
"None",
"if",
"module_path",
":",
"with",
"open",
"(",
"module_path",
",",
"'r'",
")",
"as",
"openfile",
":",
"imported",
"=",
... | Load a python module from its absolute filesystem path
Borrowed from django-cms | [
"Load",
"a",
"python",
"module",
"from",
"its",
"absolute",
"filesystem",
"path"
] | train | https://github.com/nephila/djangocms-helper/blob/3fe53aee7b06922112c5e4445b74afeb86f6d836/djangocms_helper/utils.py#L58-L70 |
nephila/djangocms-helper | djangocms_helper/utils.py | work_in | def work_in(dirname=None):
"""
Context manager version of os.chdir. When exited, returns to the working
directory prior to entering.
Grabbed from cookiecutter, thanks audreyr!
"""
curdir = os.getcwd()
try:
if dirname is not None:
if dirname not in sys.path:
... | python | def work_in(dirname=None):
"""
Context manager version of os.chdir. When exited, returns to the working
directory prior to entering.
Grabbed from cookiecutter, thanks audreyr!
"""
curdir = os.getcwd()
try:
if dirname is not None:
if dirname not in sys.path:
... | [
"def",
"work_in",
"(",
"dirname",
"=",
"None",
")",
":",
"curdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"if",
"dirname",
"is",
"not",
"None",
":",
"if",
"dirname",
"not",
"in",
"sys",
".",
"path",
":",
"sys",
".",
"path",
".",
"insert"... | Context manager version of os.chdir. When exited, returns to the working
directory prior to entering.
Grabbed from cookiecutter, thanks audreyr! | [
"Context",
"manager",
"version",
"of",
"os",
".",
"chdir",
".",
"When",
"exited",
"returns",
"to",
"the",
"working",
"directory",
"prior",
"to",
"entering",
"."
] | train | https://github.com/nephila/djangocms-helper/blob/3fe53aee7b06922112c5e4445b74afeb86f6d836/djangocms_helper/utils.py#L74-L89 |
nephila/djangocms-helper | djangocms_helper/utils.py | _reset_django | def _reset_django(settings):
"""
Hackish way to reset the django instance settings and AppConfig
:param settings: django settings module
"""
if settings._wrapped != empty:
clear_url_caches()
from django.apps import apps
apps.clear_cache()
settings._wrapped = empty
... | python | def _reset_django(settings):
"""
Hackish way to reset the django instance settings and AppConfig
:param settings: django settings module
"""
if settings._wrapped != empty:
clear_url_caches()
from django.apps import apps
apps.clear_cache()
settings._wrapped = empty
... | [
"def",
"_reset_django",
"(",
"settings",
")",
":",
"if",
"settings",
".",
"_wrapped",
"!=",
"empty",
":",
"clear_url_caches",
"(",
")",
"from",
"django",
".",
"apps",
"import",
"apps",
"apps",
".",
"clear_cache",
"(",
")",
"settings",
".",
"_wrapped",
"=",... | Hackish way to reset the django instance settings and AppConfig
:param settings: django settings module | [
"Hackish",
"way",
"to",
"reset",
"the",
"django",
"instance",
"settings",
"and",
"AppConfig",
":",
"param",
"settings",
":",
"django",
"settings",
"module"
] | train | https://github.com/nephila/djangocms-helper/blob/3fe53aee7b06922112c5e4445b74afeb86f6d836/djangocms_helper/utils.py#L130-L140 |
nephila/djangocms-helper | djangocms_helper/utils.py | _make_settings | def _make_settings(args, application, settings, STATIC_ROOT, MEDIA_ROOT):
"""
Setup the Django settings
:param args: docopt arguments
:param default_settings: default Django settings
:param settings: Django settings module
:param STATIC_ROOT: static root directory
:param MEDIA_ROOT: media ro... | python | def _make_settings(args, application, settings, STATIC_ROOT, MEDIA_ROOT):
"""
Setup the Django settings
:param args: docopt arguments
:param default_settings: default Django settings
:param settings: Django settings module
:param STATIC_ROOT: static root directory
:param MEDIA_ROOT: media ro... | [
"def",
"_make_settings",
"(",
"args",
",",
"application",
",",
"settings",
",",
"STATIC_ROOT",
",",
"MEDIA_ROOT",
")",
":",
"import",
"dj_database_url",
"from",
".",
"default_settings",
"import",
"get_default_settings",
",",
"get_boilerplates_settings",
"try",
":",
... | Setup the Django settings
:param args: docopt arguments
:param default_settings: default Django settings
:param settings: Django settings module
:param STATIC_ROOT: static root directory
:param MEDIA_ROOT: media root directory
:return: | [
"Setup",
"the",
"Django",
"settings",
":",
"param",
"args",
":",
"docopt",
"arguments",
":",
"param",
"default_settings",
":",
"default",
"Django",
"settings",
":",
"param",
"settings",
":",
"Django",
"settings",
"module",
":",
"param",
"STATIC_ROOT",
":",
"st... | train | https://github.com/nephila/djangocms-helper/blob/3fe53aee7b06922112c5e4445b74afeb86f6d836/djangocms_helper/utils.py#L150-L314 |
nephila/djangocms-helper | djangocms_helper/utils.py | ensure_unicoded_and_unique | def ensure_unicoded_and_unique(args_list, application):
"""
Iterate over args_list, make it unicode if needed and ensure that there
are no duplicates.
Returns list of unicoded arguments in the same order.
"""
unicoded_args = []
for argument in args_list:
argument = (six.u(argument)
... | python | def ensure_unicoded_and_unique(args_list, application):
"""
Iterate over args_list, make it unicode if needed and ensure that there
are no duplicates.
Returns list of unicoded arguments in the same order.
"""
unicoded_args = []
for argument in args_list:
argument = (six.u(argument)
... | [
"def",
"ensure_unicoded_and_unique",
"(",
"args_list",
",",
"application",
")",
":",
"unicoded_args",
"=",
"[",
"]",
"for",
"argument",
"in",
"args_list",
":",
"argument",
"=",
"(",
"six",
".",
"u",
"(",
"argument",
")",
"if",
"not",
"isinstance",
"(",
"ar... | Iterate over args_list, make it unicode if needed and ensure that there
are no duplicates.
Returns list of unicoded arguments in the same order. | [
"Iterate",
"over",
"args_list",
"make",
"it",
"unicode",
"if",
"needed",
"and",
"ensure",
"that",
"there",
"are",
"no",
"duplicates",
".",
"Returns",
"list",
"of",
"unicoded",
"arguments",
"in",
"the",
"same",
"order",
"."
] | train | https://github.com/nephila/djangocms-helper/blob/3fe53aee7b06922112c5e4445b74afeb86f6d836/djangocms_helper/utils.py#L407-L419 |
MozillaSecurity/fuzzfetch | src/fuzzfetch/path.py | rmtree | def rmtree(path):
"""shutil.rmtree() but also handle junction points and access errors on Windows.
"""
if islink(path):
unlink(path)
elif os.path.isdir(path):
for sub in os.listdir(path):
sub = os.path.join(path, sub)
if os.path.isfile(sub):
if not... | python | def rmtree(path):
"""shutil.rmtree() but also handle junction points and access errors on Windows.
"""
if islink(path):
unlink(path)
elif os.path.isdir(path):
for sub in os.listdir(path):
sub = os.path.join(path, sub)
if os.path.isfile(sub):
if not... | [
"def",
"rmtree",
"(",
"path",
")",
":",
"if",
"islink",
"(",
"path",
")",
":",
"unlink",
"(",
"path",
")",
"elif",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"for",
"sub",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"sub",
... | shutil.rmtree() but also handle junction points and access errors on Windows. | [
"shutil",
".",
"rmtree",
"()",
"but",
"also",
"handle",
"junction",
"points",
"and",
"access",
"errors",
"on",
"Windows",
"."
] | train | https://github.com/MozillaSecurity/fuzzfetch/blob/166cbfc71b679db019b9ac777dce12ccfdfc2c10/src/fuzzfetch/path.py#L21-L38 |
MozillaSecurity/fuzzfetch | src/fuzzfetch/path.py | islink | def islink(path):
"""os.path.islink() but return True for junction points on Windows.
"""
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
try:
# pylint: disable=undefined-variable
attrs = ctypes.windll.kernel32.GetFileAttributesW(unico... | python | def islink(path):
"""os.path.islink() but return True for junction points on Windows.
"""
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
try:
# pylint: disable=undefined-variable
attrs = ctypes.windll.kernel32.GetFileAttributesW(unico... | [
"def",
"islink",
"(",
"path",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Windows\"",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"<",
"(",
"3",
",",
"5",
")",
":",
"try",
":",
"# pylint: disable=undefined-variable",
... | os.path.islink() but return True for junction points on Windows. | [
"os",
".",
"path",
".",
"islink",
"()",
"but",
"return",
"True",
"for",
"junction",
"points",
"on",
"Windows",
"."
] | train | https://github.com/MozillaSecurity/fuzzfetch/blob/166cbfc71b679db019b9ac777dce12ccfdfc2c10/src/fuzzfetch/path.py#L41-L59 |
MozillaSecurity/fuzzfetch | src/fuzzfetch/path.py | unlink | def unlink(link):
"""os.unlink() but handle junction points on Windows.
"""
if islink(link) and platform.system() == "Windows" and sys.version_info[:2] < (3, 5):
# deleting junction points was added to os.unlink in 3.5
# https://bugs.python.org/issue18314
subprocess.check_call(["rmdi... | python | def unlink(link):
"""os.unlink() but handle junction points on Windows.
"""
if islink(link) and platform.system() == "Windows" and sys.version_info[:2] < (3, 5):
# deleting junction points was added to os.unlink in 3.5
# https://bugs.python.org/issue18314
subprocess.check_call(["rmdi... | [
"def",
"unlink",
"(",
"link",
")",
":",
"if",
"islink",
"(",
"link",
")",
"and",
"platform",
".",
"system",
"(",
")",
"==",
"\"Windows\"",
"and",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"<",
"(",
"3",
",",
"5",
")",
":",
"# deleting junctio... | os.unlink() but handle junction points on Windows. | [
"os",
".",
"unlink",
"()",
"but",
"handle",
"junction",
"points",
"on",
"Windows",
"."
] | train | https://github.com/MozillaSecurity/fuzzfetch/blob/166cbfc71b679db019b9ac777dce12ccfdfc2c10/src/fuzzfetch/path.py#L62-L70 |
MozillaSecurity/fuzzfetch | src/fuzzfetch/path.py | symlink | def symlink(target, link):
"""os.symlink() but use a junction point on Windows.
"""
if islink(link):
unlink(link)
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
with open(os.devnull, "w") as nul:
subprocess.check_call(["mklink", "/J", lin... | python | def symlink(target, link):
"""os.symlink() but use a junction point on Windows.
"""
if islink(link):
unlink(link)
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
with open(os.devnull, "w") as nul:
subprocess.check_call(["mklink", "/J", lin... | [
"def",
"symlink",
"(",
"target",
",",
"link",
")",
":",
"if",
"islink",
"(",
"link",
")",
":",
"unlink",
"(",
"link",
")",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"\"Windows\"",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
... | os.symlink() but use a junction point on Windows. | [
"os",
".",
"symlink",
"()",
"but",
"use",
"a",
"junction",
"point",
"on",
"Windows",
"."
] | train | https://github.com/MozillaSecurity/fuzzfetch/blob/166cbfc71b679db019b9ac777dce12ccfdfc2c10/src/fuzzfetch/path.py#L73-L85 |
SetBased/py-stratum | pystratum/Util.py | Util.write_two_phases | def write_two_phases(filename, data, io):
"""
Writes a file in two phase to the filesystem.
First write the data to a temporary file (in the same directory) and than renames the temporary file. If the
file already exists and its content is equal to the data that must be written no actio... | python | def write_two_phases(filename, data, io):
"""
Writes a file in two phase to the filesystem.
First write the data to a temporary file (in the same directory) and than renames the temporary file. If the
file already exists and its content is equal to the data that must be written no actio... | [
"def",
"write_two_phases",
"(",
"filename",
",",
"data",
",",
"io",
")",
":",
"write_flag",
"=",
"True",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"file",
":",
"old_data... | Writes a file in two phase to the filesystem.
First write the data to a temporary file (in the same directory) and than renames the temporary file. If the
file already exists and its content is equal to the data that must be written no action is taken. This has the
following advantages:
... | [
"Writes",
"a",
"file",
"in",
"two",
"phase",
"to",
"the",
"filesystem",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/Util.py#L14-L43 |
PlaidWeb/Pushl | pushl/entries.py | get_entry | async def get_entry(config, url):
""" Given an entry URL, return the entry
Arguments:
config -- the configuration
url -- the URL of the entry
Returns: 3-tuple of (current, previous, updated) """
previous = config.cache.get(
'entry', url,
schema_version=SCHEMA_VERSION) if conf... | python | async def get_entry(config, url):
""" Given an entry URL, return the entry
Arguments:
config -- the configuration
url -- the URL of the entry
Returns: 3-tuple of (current, previous, updated) """
previous = config.cache.get(
'entry', url,
schema_version=SCHEMA_VERSION) if conf... | [
"async",
"def",
"get_entry",
"(",
"config",
",",
"url",
")",
":",
"previous",
"=",
"config",
".",
"cache",
".",
"get",
"(",
"'entry'",
",",
"url",
",",
"schema_version",
"=",
"SCHEMA_VERSION",
")",
"if",
"config",
".",
"cache",
"else",
"None",
"headers",... | Given an entry URL, return the entry
Arguments:
config -- the configuration
url -- the URL of the entry
Returns: 3-tuple of (current, previous, updated) | [
"Given",
"an",
"entry",
"URL",
"return",
"the",
"entry"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/entries.py#L108-L142 |
PlaidWeb/Pushl | pushl/entries.py | Entry._check_rel | def _check_rel(attrs, rel_whitelist, rel_blacklist):
""" Check a link's relations against the whitelist or blacklist.
First, this will reject based on blacklist.
Next, if there is a whitelist, there must be at least one rel that matches.
To explicitly allow links without a rel you can ... | python | def _check_rel(attrs, rel_whitelist, rel_blacklist):
""" Check a link's relations against the whitelist or blacklist.
First, this will reject based on blacklist.
Next, if there is a whitelist, there must be at least one rel that matches.
To explicitly allow links without a rel you can ... | [
"def",
"_check_rel",
"(",
"attrs",
",",
"rel_whitelist",
",",
"rel_blacklist",
")",
":",
"rels",
"=",
"attrs",
".",
"get",
"(",
"'rel'",
",",
"[",
"None",
"]",
")",
"if",
"rel_blacklist",
":",
"# Never return True for a link whose rel appears in the blacklist",
"f... | Check a link's relations against the whitelist or blacklist.
First, this will reject based on blacklist.
Next, if there is a whitelist, there must be at least one rel that matches.
To explicitly allow links without a rel you can add None to the whitelist
(e.g. ['in-reply-to',None]) | [
"Check",
"a",
"link",
"s",
"relations",
"against",
"the",
"whitelist",
"or",
"blacklist",
"."
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/entries.py#L61-L88 |
PlaidWeb/Pushl | pushl/entries.py | Entry._domain_differs | def _domain_differs(self, href):
""" Check that a link is not on the same domain as the source URL """
target = utils.get_domain(href)
if not target:
return False
origin = utils.get_domain(self.url)
return target != origin | python | def _domain_differs(self, href):
""" Check that a link is not on the same domain as the source URL """
target = utils.get_domain(href)
if not target:
return False
origin = utils.get_domain(self.url)
return target != origin | [
"def",
"_domain_differs",
"(",
"self",
",",
"href",
")",
":",
"target",
"=",
"utils",
".",
"get_domain",
"(",
"href",
")",
"if",
"not",
"target",
":",
"return",
"False",
"origin",
"=",
"utils",
".",
"get_domain",
"(",
"self",
".",
"url",
")",
"return",... | Check that a link is not on the same domain as the source URL | [
"Check",
"that",
"a",
"link",
"is",
"not",
"on",
"the",
"same",
"domain",
"as",
"the",
"source",
"URL"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/entries.py#L90-L97 |
PlaidWeb/Pushl | pushl/entries.py | Entry.get_targets | def get_targets(self, config):
""" Given an Entry object, return all of the outgoing links. """
return {urllib.parse.urljoin(self.url, attrs['href'])
for attrs in self._targets
if self._check_rel(attrs, config.rel_whitelist, config.rel_blacklist)
and self... | python | def get_targets(self, config):
""" Given an Entry object, return all of the outgoing links. """
return {urllib.parse.urljoin(self.url, attrs['href'])
for attrs in self._targets
if self._check_rel(attrs, config.rel_whitelist, config.rel_blacklist)
and self... | [
"def",
"get_targets",
"(",
"self",
",",
"config",
")",
":",
"return",
"{",
"urllib",
".",
"parse",
".",
"urljoin",
"(",
"self",
".",
"url",
",",
"attrs",
"[",
"'href'",
"]",
")",
"for",
"attrs",
"in",
"self",
".",
"_targets",
"if",
"self",
".",
"_c... | Given an Entry object, return all of the outgoing links. | [
"Given",
"an",
"Entry",
"object",
"return",
"all",
"of",
"the",
"outgoing",
"links",
"."
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/entries.py#L99-L105 |
SetBased/py-stratum | pystratum/command/LoaderCommand.py | LoaderCommand.handle | def handle(self):
"""
Executes loader command.
"""
self.output = PyStratumStyle(self.input, self.output)
config_file = self.argument('config_file')
sources = self.argument('file_names')
status = self.run_command(config_file, sources)
return status | python | def handle(self):
"""
Executes loader command.
"""
self.output = PyStratumStyle(self.input, self.output)
config_file = self.argument('config_file')
sources = self.argument('file_names')
status = self.run_command(config_file, sources)
return status | [
"def",
"handle",
"(",
"self",
")",
":",
"self",
".",
"output",
"=",
"PyStratumStyle",
"(",
"self",
".",
"input",
",",
"self",
".",
"output",
")",
"config_file",
"=",
"self",
".",
"argument",
"(",
"'config_file'",
")",
"sources",
"=",
"self",
".",
"argu... | Executes loader command. | [
"Executes",
"loader",
"command",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/command/LoaderCommand.py#L29-L40 |
SetBased/py-stratum | pystratum/command/LoaderCommand.py | LoaderCommand.run_command | def run_command(self, config_file, sources):
"""
:param str config_file: The name of config file.
:param list sources: The list with source files.
"""
config = configparser.ConfigParser()
config.read(config_file)
rdbms = config.get('database', 'rdbms').lower()
... | python | def run_command(self, config_file, sources):
"""
:param str config_file: The name of config file.
:param list sources: The list with source files.
"""
config = configparser.ConfigParser()
config.read(config_file)
rdbms = config.get('database', 'rdbms').lower()
... | [
"def",
"run_command",
"(",
"self",
",",
"config_file",
",",
"sources",
")",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"read",
"(",
"config_file",
")",
"rdbms",
"=",
"config",
".",
"get",
"(",
"'database'",
",",
"'r... | :param str config_file: The name of config file.
:param list sources: The list with source files. | [
":",
"param",
"str",
"config_file",
":",
"The",
"name",
"of",
"config",
"file",
".",
":",
"param",
"list",
"sources",
":",
"The",
"list",
"with",
"source",
"files",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/command/LoaderCommand.py#L43-L56 |
SetBased/py-stratum | pystratum/command/LoaderCommand.py | LoaderCommand.create_routine_loader | def create_routine_loader(self, rdbms):
"""
Factory for creating a Routine Loader objects (i.e. objects for loading stored routines into a RDBMS instance
from (pseudo) SQL files.
:param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql).
:rtype: pystratum.RoutineLoader.Ro... | python | def create_routine_loader(self, rdbms):
"""
Factory for creating a Routine Loader objects (i.e. objects for loading stored routines into a RDBMS instance
from (pseudo) SQL files.
:param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql).
:rtype: pystratum.RoutineLoader.Ro... | [
"def",
"create_routine_loader",
"(",
"self",
",",
"rdbms",
")",
":",
"# Note: We load modules and classes dynamically such that on the end user's system only the required modules",
"# and other dependencies for the targeted RDBMS must be installed (and required modules and other",
"# ... | Factory for creating a Routine Loader objects (i.e. objects for loading stored routines into a RDBMS instance
from (pseudo) SQL files.
:param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql).
:rtype: pystratum.RoutineLoader.RoutineLoader | [
"Factory",
"for",
"creating",
"a",
"Routine",
"Loader",
"objects",
"(",
"i",
".",
"e",
".",
"objects",
"for",
"loading",
"stored",
"routines",
"into",
"a",
"RDBMS",
"instance",
"from",
"(",
"pseudo",
")",
"SQL",
"files",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/command/LoaderCommand.py#L59-L84 |
DreamLab/VmShepherd | src/vmshepherd/iaas/dummy_driver.py | DummyIaasDriver.create_vm | async def create_vm(self, *, preset_name, image, flavor, security_groups=None,
userdata=None, key_name=None, availability_zone=None,
subnet=None):
"""
Dummy create_vm func.
"""
info = {
'id': next(self._id_it),
'name... | python | async def create_vm(self, *, preset_name, image, flavor, security_groups=None,
userdata=None, key_name=None, availability_zone=None,
subnet=None):
"""
Dummy create_vm func.
"""
info = {
'id': next(self._id_it),
'name... | [
"async",
"def",
"create_vm",
"(",
"self",
",",
"*",
",",
"preset_name",
",",
"image",
",",
"flavor",
",",
"security_groups",
"=",
"None",
",",
"userdata",
"=",
"None",
",",
"key_name",
"=",
"None",
",",
"availability_zone",
"=",
"None",
",",
"subnet",
"=... | Dummy create_vm func. | [
"Dummy",
"create_vm",
"func",
"."
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/dummy_driver.py#L34-L56 |
DreamLab/VmShepherd | src/vmshepherd/iaas/dummy_driver.py | DummyIaasDriver.list_vms | async def list_vms(self, preset_name):
"""Dummy list_vms func"""
return list(vm for vm in self._vms.values() if vm.name == preset_name) | python | async def list_vms(self, preset_name):
"""Dummy list_vms func"""
return list(vm for vm in self._vms.values() if vm.name == preset_name) | [
"async",
"def",
"list_vms",
"(",
"self",
",",
"preset_name",
")",
":",
"return",
"list",
"(",
"vm",
"for",
"vm",
"in",
"self",
".",
"_vms",
".",
"values",
"(",
")",
"if",
"vm",
".",
"name",
"==",
"preset_name",
")"
] | Dummy list_vms func | [
"Dummy",
"list_vms",
"func"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/dummy_driver.py#L59-L61 |
DreamLab/VmShepherd | src/vmshepherd/iaas/dummy_driver.py | DummyIaasDriver.terminate_vm | async def terminate_vm(self, vm_id):
""" Dummy terminate_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
del self._vms[vm_id]
return None | python | async def terminate_vm(self, vm_id):
""" Dummy terminate_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
del self._vms[vm_id]
return None | [
"async",
"def",
"terminate_vm",
"(",
"self",
",",
"vm_id",
")",
":",
"if",
"vm_id",
"not",
"in",
"self",
".",
"_vms",
":",
"raise",
"DummyIaasVmNotFound",
"(",
")",
"del",
"self",
".",
"_vms",
"[",
"vm_id",
"]",
"return",
"None"
] | Dummy terminate_vm func | [
"Dummy",
"terminate_vm",
"func"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/dummy_driver.py#L64-L69 |
DreamLab/VmShepherd | src/vmshepherd/iaas/dummy_driver.py | DummyIaasDriver.get_vm | async def get_vm(self, vm_id):
""" Dummy get_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
return self._vms[vm_id] | python | async def get_vm(self, vm_id):
""" Dummy get_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
return self._vms[vm_id] | [
"async",
"def",
"get_vm",
"(",
"self",
",",
"vm_id",
")",
":",
"if",
"vm_id",
"not",
"in",
"self",
".",
"_vms",
":",
"raise",
"DummyIaasVmNotFound",
"(",
")",
"return",
"self",
".",
"_vms",
"[",
"vm_id",
"]"
] | Dummy get_vm func | [
"Dummy",
"get_vm",
"func"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/iaas/dummy_driver.py#L72-L76 |
mjirik/io3d | io3d/misc.py | suggest_filename | def suggest_filename(file_path, exists=None):
"""
Try if exist path and append number to its end.
For debug you can set as input if file exists or not.
"""
import os.path
import re
if not isinstance(exists, bool):
exists = os.path.exists(file_path)
if exists:
file_path, ... | python | def suggest_filename(file_path, exists=None):
"""
Try if exist path and append number to its end.
For debug you can set as input if file exists or not.
"""
import os.path
import re
if not isinstance(exists, bool):
exists = os.path.exists(file_path)
if exists:
file_path, ... | [
"def",
"suggest_filename",
"(",
"file_path",
",",
"exists",
"=",
"None",
")",
":",
"import",
"os",
".",
"path",
"import",
"re",
"if",
"not",
"isinstance",
"(",
"exists",
",",
"bool",
")",
":",
"exists",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"fi... | Try if exist path and append number to its end.
For debug you can set as input if file exists or not. | [
"Try",
"if",
"exist",
"path",
"and",
"append",
"number",
"to",
"its",
"end",
".",
"For",
"debug",
"you",
"can",
"set",
"as",
"input",
"if",
"file",
"exists",
"or",
"not",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L30-L58 |
mjirik/io3d | io3d/misc.py | obj_from_file | def obj_from_file(filename='annotation.yaml', filetype='auto'):
''' Read object from file '''
if filetype == 'auto':
_, ext = os.path.splitext(filename)
filetype = ext[1:]
if filetype in ('yaml', 'yml'):
from ruamel.yaml import YAML
yaml = YAML(typ="unsafe")
with op... | python | def obj_from_file(filename='annotation.yaml', filetype='auto'):
''' Read object from file '''
if filetype == 'auto':
_, ext = os.path.splitext(filename)
filetype = ext[1:]
if filetype in ('yaml', 'yml'):
from ruamel.yaml import YAML
yaml = YAML(typ="unsafe")
with op... | [
"def",
"obj_from_file",
"(",
"filename",
"=",
"'annotation.yaml'",
",",
"filetype",
"=",
"'auto'",
")",
":",
"if",
"filetype",
"==",
"'auto'",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"filetype",
"=",
"ext",
... | Read object from file | [
"Read",
"object",
"from",
"file"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L61-L93 |
mjirik/io3d | io3d/misc.py | read_pkl_and_pklz | def read_pkl_and_pklz(filename):
"""
Try read zipped or not zipped pickle file
"""
fcontent = None
try:
import gzip
f = gzip.open(filename, 'rb')
fcontent = f.read()
f.close()
except IOError as e:
# if the problem is in not gzip file
logger.info("I... | python | def read_pkl_and_pklz(filename):
"""
Try read zipped or not zipped pickle file
"""
fcontent = None
try:
import gzip
f = gzip.open(filename, 'rb')
fcontent = f.read()
f.close()
except IOError as e:
# if the problem is in not gzip file
logger.info("I... | [
"def",
"read_pkl_and_pklz",
"(",
"filename",
")",
":",
"fcontent",
"=",
"None",
"try",
":",
"import",
"gzip",
"f",
"=",
"gzip",
".",
"open",
"(",
"filename",
",",
"'rb'",
")",
"fcontent",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"close",
"(",
")"... | Try read zipped or not zipped pickle file | [
"Try",
"read",
"zipped",
"or",
"not",
"zipped",
"pickle",
"file"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L96-L118 |
mjirik/io3d | io3d/misc.py | obj_to_file | def obj_to_file(obj, filename, filetype='auto', ndarray_to_list=False, squeeze=True):
'''Writes annotation in file.
:param filetype:
auto
yaml
pkl, pickle
pklz, picklezip
:param ndarray_to_list: convert ndarrays in obj to lists
:param squeeze: squeeze ndarray
'''
... | python | def obj_to_file(obj, filename, filetype='auto', ndarray_to_list=False, squeeze=True):
'''Writes annotation in file.
:param filetype:
auto
yaml
pkl, pickle
pklz, picklezip
:param ndarray_to_list: convert ndarrays in obj to lists
:param squeeze: squeeze ndarray
'''
... | [
"def",
"obj_to_file",
"(",
"obj",
",",
"filename",
",",
"filetype",
"=",
"'auto'",
",",
"ndarray_to_list",
"=",
"False",
",",
"squeeze",
"=",
"True",
")",
":",
"# import json",
"# with open(filename, mode='w') as f:",
"# json.dump(annotation,f)",
"if",
"ndarray_to_... | Writes annotation in file.
:param filetype:
auto
yaml
pkl, pickle
pklz, picklezip
:param ndarray_to_list: convert ndarrays in obj to lists
:param squeeze: squeeze ndarray | [
"Writes",
"annotation",
"in",
"file",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L121-L189 |
mjirik/io3d | io3d/misc.py | resize_to_shape | def resize_to_shape(data, shape, zoom=None, mode='nearest', order=0):
"""
Function resize input data to specific shape.
:param data: input 3d array-like data
:param shape: shape of output data
:param zoom: zoom is used for back compatibility
:mode: default is 'nearest'
"""
# @TODO remov... | python | def resize_to_shape(data, shape, zoom=None, mode='nearest', order=0):
"""
Function resize input data to specific shape.
:param data: input 3d array-like data
:param shape: shape of output data
:param zoom: zoom is used for back compatibility
:mode: default is 'nearest'
"""
# @TODO remov... | [
"def",
"resize_to_shape",
"(",
"data",
",",
"shape",
",",
"zoom",
"=",
"None",
",",
"mode",
"=",
"'nearest'",
",",
"order",
"=",
"0",
")",
":",
"# @TODO remove old code in except part",
"try",
":",
"# rint 'pred vyjimkou'",
"# aise Exception ('test without skimage')",... | Function resize input data to specific shape.
:param data: input 3d array-like data
:param shape: shape of output data
:param zoom: zoom is used for back compatibility
:mode: default is 'nearest' | [
"Function",
"resize",
"input",
"data",
"to",
"specific",
"shape",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L191-L253 |
mjirik/io3d | io3d/misc.py | resize_to_mm | def resize_to_mm(data3d, voxelsize_mm, new_voxelsize_mm, mode='nearest'):
"""
Function can resize data3d or segmentation to specifed voxelsize_mm
:new_voxelsize_mm: requested voxelsize. List of 3 numbers, also
can be a string 'orig', 'orgi*2' and 'orgi*4'.
:voxelsize_mm: size of voxel
:mode... | python | def resize_to_mm(data3d, voxelsize_mm, new_voxelsize_mm, mode='nearest'):
"""
Function can resize data3d or segmentation to specifed voxelsize_mm
:new_voxelsize_mm: requested voxelsize. List of 3 numbers, also
can be a string 'orig', 'orgi*2' and 'orgi*4'.
:voxelsize_mm: size of voxel
:mode... | [
"def",
"resize_to_mm",
"(",
"data3d",
",",
"voxelsize_mm",
",",
"new_voxelsize_mm",
",",
"mode",
"=",
"'nearest'",
")",
":",
"import",
"scipy",
"import",
"scipy",
".",
"ndimage",
"if",
"np",
".",
"all",
"(",
"list",
"(",
"new_voxelsize_mm",
")",
"==",
"'or... | Function can resize data3d or segmentation to specifed voxelsize_mm
:new_voxelsize_mm: requested voxelsize. List of 3 numbers, also
can be a string 'orig', 'orgi*2' and 'orgi*4'.
:voxelsize_mm: size of voxel
:mode: default is 'nearest' | [
"Function",
"can",
"resize",
"data3d",
"or",
"segmentation",
"to",
"specifed",
"voxelsize_mm",
":",
"new_voxelsize_mm",
":",
"requested",
"voxelsize",
".",
"List",
"of",
"3",
"numbers",
"also",
"can",
"be",
"a",
"string",
"orig",
"orgi",
"*",
"2",
"and",
"or... | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L256-L283 |
mjirik/io3d | io3d/misc.py | suits_with_dtype | def suits_with_dtype(mn, mx, dtype):
"""
Check whether range of values can be stored into defined data type.
:param mn: range minimum
:param mx: range maximum
:param dtype:
:return:
"""
type_info = np.iinfo(dtype)
if mx <= type_info.max and mn >= type_info.min:
return True
... | python | def suits_with_dtype(mn, mx, dtype):
"""
Check whether range of values can be stored into defined data type.
:param mn: range minimum
:param mx: range maximum
:param dtype:
:return:
"""
type_info = np.iinfo(dtype)
if mx <= type_info.max and mn >= type_info.min:
return True
... | [
"def",
"suits_with_dtype",
"(",
"mn",
",",
"mx",
",",
"dtype",
")",
":",
"type_info",
"=",
"np",
".",
"iinfo",
"(",
"dtype",
")",
"if",
"mx",
"<=",
"type_info",
".",
"max",
"and",
"mn",
">=",
"type_info",
".",
"min",
":",
"return",
"True",
"else",
... | Check whether range of values can be stored into defined data type.
:param mn: range minimum
:param mx: range maximum
:param dtype:
:return: | [
"Check",
"whether",
"range",
"of",
"values",
"can",
"be",
"stored",
"into",
"defined",
"data",
"type",
".",
":",
"param",
"mn",
":",
"range",
"minimum",
":",
"param",
"mx",
":",
"range",
"maximum",
":",
"param",
"dtype",
":",
":",
"return",
":"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L285-L297 |
mjirik/io3d | io3d/misc.py | use_economic_dtype | def use_economic_dtype(data3d, slope=1, inter=0, dtype=None):
""" Use more economic integer-like dtype if it is possible.
:param data3d:
:param dtype: if dtype is not used, the automatic is used
:return:
"""
if dtype is None:
dtype = data3d.dtype
if issubclass(dtype.type, np.in... | python | def use_economic_dtype(data3d, slope=1, inter=0, dtype=None):
""" Use more economic integer-like dtype if it is possible.
:param data3d:
:param dtype: if dtype is not used, the automatic is used
:return:
"""
if dtype is None:
dtype = data3d.dtype
if issubclass(dtype.type, np.in... | [
"def",
"use_economic_dtype",
"(",
"data3d",
",",
"slope",
"=",
"1",
",",
"inter",
"=",
"0",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"data3d",
".",
"dtype",
"if",
"issubclass",
"(",
"dtype",
".",
"type",
... | Use more economic integer-like dtype if it is possible.
:param data3d:
:param dtype: if dtype is not used, the automatic is used
:return: | [
"Use",
"more",
"economic",
"integer",
"-",
"like",
"dtype",
"if",
"it",
"is",
"possible",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L299-L331 |
mjirik/io3d | io3d/dcmtools.py | get_sitk_image_from_ndarray | def get_sitk_image_from_ndarray(data3d):
"""
Prepare SimpleItk Image object and rescale data to unsigned types.
Simple ITK with version higher than 1.0.0 can not write signed int16. This function check
the SimpleITK version and use work around with Rescale Intercept and Rescale Slope
:param data3d:... | python | def get_sitk_image_from_ndarray(data3d):
"""
Prepare SimpleItk Image object and rescale data to unsigned types.
Simple ITK with version higher than 1.0.0 can not write signed int16. This function check
the SimpleITK version and use work around with Rescale Intercept and Rescale Slope
:param data3d:... | [
"def",
"get_sitk_image_from_ndarray",
"(",
"data3d",
")",
":",
"import",
"SimpleITK",
"as",
"sitk",
"rescale_intercept",
"=",
"None",
"if",
"sitk",
".",
"Version",
".",
"MajorVersion",
"(",
")",
">",
"0",
":",
"if",
"data3d",
".",
"dtype",
"==",
"np",
".",... | Prepare SimpleItk Image object and rescale data to unsigned types.
Simple ITK with version higher than 1.0.0 can not write signed int16. This function check
the SimpleITK version and use work around with Rescale Intercept and Rescale Slope
:param data3d:
:return: | [
"Prepare",
"SimpleItk",
"Image",
"object",
"and",
"rescale",
"data",
"to",
"unsigned",
"types",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmtools.py#L27-L59 |
mjirik/io3d | io3d/dcmtools.py | get_slope_and_intercept_from_pdcm | def get_slope_and_intercept_from_pdcm(dcmdata):
"""
Get scale and intercept from pydicom file object.
:param dcmdata:
:return:
"""
if hasattr(dcmdata, "RescaleSlope") and hasattr(dcmdata, "RescaleIntercept"):
rescale_slope = dcmdata.RescaleSlope
rescale_intercept = dcmdata.Resca... | python | def get_slope_and_intercept_from_pdcm(dcmdata):
"""
Get scale and intercept from pydicom file object.
:param dcmdata:
:return:
"""
if hasattr(dcmdata, "RescaleSlope") and hasattr(dcmdata, "RescaleIntercept"):
rescale_slope = dcmdata.RescaleSlope
rescale_intercept = dcmdata.Resca... | [
"def",
"get_slope_and_intercept_from_pdcm",
"(",
"dcmdata",
")",
":",
"if",
"hasattr",
"(",
"dcmdata",
",",
"\"RescaleSlope\"",
")",
"and",
"hasattr",
"(",
"dcmdata",
",",
"\"RescaleIntercept\"",
")",
":",
"rescale_slope",
"=",
"dcmdata",
".",
"RescaleSlope",
"res... | Get scale and intercept from pydicom file object.
:param dcmdata:
:return: | [
"Get",
"scale",
"and",
"intercept",
"from",
"pydicom",
"file",
"object",
".",
":",
"param",
"dcmdata",
":",
":",
"return",
":"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/dcmtools.py#L74-L89 |
bhearsum/chunkify | chunkify/__init__.py | split_evenly | def split_evenly(n, chunks):
"""Split an integer into evenly distributed list
>>> split_evenly(7, 3)
[3, 2, 2]
>>> split_evenly(12, 3)
[4, 4, 4]
>>> split_evenly(35, 10)
[4, 4, 4, 4, 4, 3, 3, 3, 3, 3]
>>> split_evenly(1, 2)
Traceback (most recent call last):
...
Chunk... | python | def split_evenly(n, chunks):
"""Split an integer into evenly distributed list
>>> split_evenly(7, 3)
[3, 2, 2]
>>> split_evenly(12, 3)
[4, 4, 4]
>>> split_evenly(35, 10)
[4, 4, 4, 4, 4, 3, 3, 3, 3, 3]
>>> split_evenly(1, 2)
Traceback (most recent call last):
...
Chunk... | [
"def",
"split_evenly",
"(",
"n",
",",
"chunks",
")",
":",
"if",
"n",
"<",
"chunks",
":",
"raise",
"ChunkingError",
"(",
"\"Number of chunks is greater than number\"",
")",
"if",
"n",
"%",
"chunks",
"==",
"0",
":",
"# Either we can evenly split or only 1 chunk left",... | Split an integer into evenly distributed list
>>> split_evenly(7, 3)
[3, 2, 2]
>>> split_evenly(12, 3)
[4, 4, 4]
>>> split_evenly(35, 10)
[4, 4, 4, 4, 4, 3, 3, 3, 3, 3]
>>> split_evenly(1, 2)
Traceback (most recent call last):
...
ChunkingError: Number of chunks is greate... | [
"Split",
"an",
"integer",
"into",
"evenly",
"distributed",
"list"
] | train | https://github.com/bhearsum/chunkify/blob/f3a693b17c80626852523955bf3c01b4fd93439b/chunkify/__init__.py#L8-L33 |
vsoch/helpme | helpme/main/discourse/__init__.py | Helper.check_env | def check_env(self, envar, value):
'''ensure that variable envar is set to some value,
otherwise exit on error.
Parameters
==========
envar: the environment variable name
value: the setting that shouldn't be None
'''
if value is No... | python | def check_env(self, envar, value):
'''ensure that variable envar is set to some value,
otherwise exit on error.
Parameters
==========
envar: the environment variable name
value: the setting that shouldn't be None
'''
if value is No... | [
"def",
"check_env",
"(",
"self",
",",
"envar",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"bot",
".",
"error",
"(",
"'You must export %s to use Discourse'",
"%",
"envar",
")",
"print",
"(",
"'https://vsoch.github.io/helpme/helper-discourse'",
")",
... | ensure that variable envar is set to some value,
otherwise exit on error.
Parameters
==========
envar: the environment variable name
value: the setting that shouldn't be None | [
"ensure",
"that",
"variable",
"envar",
"is",
"set",
"to",
"some",
"value",
"otherwise",
"exit",
"on",
"error",
".",
"Parameters",
"==========",
"envar",
":",
"the",
"environment",
"variable",
"name",
"value",
":",
"the",
"setting",
"that",
"shouldn",
"t",
"b... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/discourse/__init__.py#L65-L77 |
vsoch/helpme | helpme/main/discourse/__init__.py | Helper._generate_keys | def _generate_keys(self):
'''the discourse API requires the interactions to be signed, so we
generate a keypair on behalf of the user
'''
from helpme.defaults import HELPME_CLIENT_SECRETS
keypair_dir = os.path.join(os.path.dirname(HELPME_CLIENT_SECRETS),
... | python | def _generate_keys(self):
'''the discourse API requires the interactions to be signed, so we
generate a keypair on behalf of the user
'''
from helpme.defaults import HELPME_CLIENT_SECRETS
keypair_dir = os.path.join(os.path.dirname(HELPME_CLIENT_SECRETS),
... | [
"def",
"_generate_keys",
"(",
"self",
")",
":",
"from",
"helpme",
".",
"defaults",
"import",
"HELPME_CLIENT_SECRETS",
"keypair_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"HELPME_CLIENT_SECRETS",
")",
",",
"'discou... | the discourse API requires the interactions to be signed, so we
generate a keypair on behalf of the user | [
"the",
"discourse",
"API",
"requires",
"the",
"interactions",
"to",
"be",
"signed",
"so",
"we",
"generate",
"a",
"keypair",
"on",
"behalf",
"of",
"the",
"user"
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/discourse/__init__.py#L80-L97 |
vsoch/helpme | helpme/main/discourse/__init__.py | Helper._submit | def _submit(self):
'''submit the question to the board. When we get here we should have
(under self.data)
{'record_environment': [('DISPLAY', ':0')],
'user_prompt_board': 'http://127.0.0.1',
'user_prompt_issue': 'I want to know why dinosa... | python | def _submit(self):
'''submit the question to the board. When we get here we should have
(under self.data)
{'record_environment': [('DISPLAY', ':0')],
'user_prompt_board': 'http://127.0.0.1',
'user_prompt_issue': 'I want to know why dinosa... | [
"def",
"_submit",
"(",
"self",
")",
":",
"body",
"=",
"self",
".",
"data",
"[",
"'user_prompt_issue'",
"]",
"title",
"=",
"self",
".",
"data",
"[",
"'user_prompt_title'",
"]",
"board",
"=",
"self",
".",
"data",
"[",
"'user_prompt_board'",
"]",
"username",
... | submit the question to the board. When we get here we should have
(under self.data)
{'record_environment': [('DISPLAY', ':0')],
'user_prompt_board': 'http://127.0.0.1',
'user_prompt_issue': 'I want to know why dinosaurs are so great!',
... | [
"submit",
"the",
"question",
"to",
"the",
"board",
".",
"When",
"we",
"get",
"here",
"we",
"should",
"have",
"(",
"under",
"self",
".",
"data",
")",
"{",
"record_environment",
":",
"[",
"(",
"DISPLAY",
":",
"0",
")",
"]",
"user_prompt_board",
":",
"htt... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/discourse/__init__.py#L121-L167 |
closeio/cachecow | cachecow/__init__.py | CacheCow.get | def get(self, cls, id_field, id_val):
"""
Retrieve an object which `id_field` matches `id_val`. If it exists in
the cache, it will be fetched from Redis. If not, it will be fetched
via the `fetch` method and cached in Redis (unless the cache flag got
invalidated in the meantime).... | python | def get(self, cls, id_field, id_val):
"""
Retrieve an object which `id_field` matches `id_val`. If it exists in
the cache, it will be fetched from Redis. If not, it will be fetched
via the `fetch` method and cached in Redis (unless the cache flag got
invalidated in the meantime).... | [
"def",
"get",
"(",
"self",
",",
"cls",
",",
"id_field",
",",
"id_val",
")",
":",
"cache_key",
",",
"flag_key",
"=",
"self",
".",
"get_keys",
"(",
"cls",
",",
"id_field",
",",
"id_val",
")",
"result",
"=",
"self",
".",
"get_cached_or_set_flag",
"(",
"ke... | Retrieve an object which `id_field` matches `id_val`. If it exists in
the cache, it will be fetched from Redis. If not, it will be fetched
via the `fetch` method and cached in Redis (unless the cache flag got
invalidated in the meantime). | [
"Retrieve",
"an",
"object",
"which",
"id_field",
"matches",
"id_val",
".",
"If",
"it",
"exists",
"in",
"the",
"cache",
"it",
"will",
"be",
"fetched",
"from",
"Redis",
".",
"If",
"not",
"it",
"will",
"be",
"fetched",
"via",
"the",
"fetch",
"method",
"and"... | train | https://github.com/closeio/cachecow/blob/a0531686db40baa81b3cfa0076a23a53d2762cc6/cachecow/__init__.py#L60-L99 |
closeio/cachecow | cachecow/__init__.py | CacheCow.verify | def verify(self, cls, id_field, id_val, obj_from_cache):
"""
Verify that the object we retrieved from cache matches the requested
`id_field`/`id_val`.
"""
return getattr(obj_from_cache, id_field) == id_val | python | def verify(self, cls, id_field, id_val, obj_from_cache):
"""
Verify that the object we retrieved from cache matches the requested
`id_field`/`id_val`.
"""
return getattr(obj_from_cache, id_field) == id_val | [
"def",
"verify",
"(",
"self",
",",
"cls",
",",
"id_field",
",",
"id_val",
",",
"obj_from_cache",
")",
":",
"return",
"getattr",
"(",
"obj_from_cache",
",",
"id_field",
")",
"==",
"id_val"
] | Verify that the object we retrieved from cache matches the requested
`id_field`/`id_val`. | [
"Verify",
"that",
"the",
"object",
"we",
"retrieved",
"from",
"cache",
"matches",
"the",
"requested",
"id_field",
"/",
"id_val",
"."
] | train | https://github.com/closeio/cachecow/blob/a0531686db40baa81b3cfa0076a23a53d2762cc6/cachecow/__init__.py#L101-L106 |
closeio/cachecow | cachecow/__init__.py | CacheCow.invalidate | def invalidate(self, cls, id_field, id_val):
"""
Invalidate the cache for a given Mongo object by deleting the cached
data and the cache flag.
"""
cache_key, flag_key = self.get_keys(cls, id_field, id_val)
pipeline = self.redis.pipeline()
pipeline.delete(cache_ke... | python | def invalidate(self, cls, id_field, id_val):
"""
Invalidate the cache for a given Mongo object by deleting the cached
data and the cache flag.
"""
cache_key, flag_key = self.get_keys(cls, id_field, id_val)
pipeline = self.redis.pipeline()
pipeline.delete(cache_ke... | [
"def",
"invalidate",
"(",
"self",
",",
"cls",
",",
"id_field",
",",
"id_val",
")",
":",
"cache_key",
",",
"flag_key",
"=",
"self",
".",
"get_keys",
"(",
"cls",
",",
"id_field",
",",
"id_val",
")",
"pipeline",
"=",
"self",
".",
"redis",
".",
"pipeline",... | Invalidate the cache for a given Mongo object by deleting the cached
data and the cache flag. | [
"Invalidate",
"the",
"cache",
"for",
"a",
"given",
"Mongo",
"object",
"by",
"deleting",
"the",
"cached",
"data",
"and",
"the",
"cache",
"flag",
"."
] | train | https://github.com/closeio/cachecow/blob/a0531686db40baa81b3cfa0076a23a53d2762cc6/cachecow/__init__.py#L120-L130 |
DreamLab/VmShepherd | src/vmshepherd/presets/preset.py | Preset.manage | async def manage(self):
""" Manage function docstring"""
self._vms = await self.iaas.list_vms(self.name)
vms_stat = Counter([vm.get_state() for vm in self._vms])
missing = self.count - len(self._vms) if len(self._vms) < self.count else 0
logging.info(
'VMs Status: %s... | python | async def manage(self):
""" Manage function docstring"""
self._vms = await self.iaas.list_vms(self.name)
vms_stat = Counter([vm.get_state() for vm in self._vms])
missing = self.count - len(self._vms) if len(self._vms) < self.count else 0
logging.info(
'VMs Status: %s... | [
"async",
"def",
"manage",
"(",
"self",
")",
":",
"self",
".",
"_vms",
"=",
"await",
"self",
".",
"iaas",
".",
"list_vms",
"(",
"self",
".",
"name",
")",
"vms_stat",
"=",
"Counter",
"(",
"[",
"vm",
".",
"get_state",
"(",
")",
"for",
"vm",
"in",
"s... | Manage function docstring | [
"Manage",
"function",
"docstring"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/presets/preset.py#L76-L103 |
pschmitt/pynuki | pynuki/pynuki.py | NukiLock.update | def update(self, aggressive=False):
"""
Update the state of the NukiLock
:param aggressive: Whether to aggressively poll the Bridge. If set to
True, this will actively query the Lock, thus using more battery.
:type aggressive: bool
"""
if aggressive:
d... | python | def update(self, aggressive=False):
"""
Update the state of the NukiLock
:param aggressive: Whether to aggressively poll the Bridge. If set to
True, this will actively query the Lock, thus using more battery.
:type aggressive: bool
"""
if aggressive:
d... | [
"def",
"update",
"(",
"self",
",",
"aggressive",
"=",
"False",
")",
":",
"if",
"aggressive",
":",
"data",
"=",
"self",
".",
"_bridge",
".",
"lock_state",
"(",
"self",
".",
"nuki_id",
")",
"if",
"not",
"data",
"[",
"'success'",
"]",
":",
"logger",
"."... | Update the state of the NukiLock
:param aggressive: Whether to aggressively poll the Bridge. If set to
True, this will actively query the Lock, thus using more battery.
:type aggressive: bool | [
"Update",
"the",
"state",
"of",
"the",
"NukiLock",
":",
"param",
"aggressive",
":",
"Whether",
"to",
"aggressively",
"poll",
"the",
"Bridge",
".",
"If",
"set",
"to",
"True",
"this",
"will",
"actively",
"query",
"the",
"Lock",
"thus",
"using",
"more",
"batt... | train | https://github.com/pschmitt/pynuki/blob/4258dec17bd333e1d475b2cb62438bd67dd017a7/pynuki/pynuki.py#L84-L103 |
CentOS/python-cicoclient | cicoclient/utils.py | get_dict_properties | def get_dict_properties(item, fields, mixed_case_fields=[], formatters={}):
"""Return a tuple containing the item properties.
:param item: a single dict resource
:param fields: tuple of strings with the desired field names
:param mixed_case_fields: tuple of field names to preserve case
:param format... | python | def get_dict_properties(item, fields, mixed_case_fields=[], formatters={}):
"""Return a tuple containing the item properties.
:param item: a single dict resource
:param fields: tuple of strings with the desired field names
:param mixed_case_fields: tuple of field names to preserve case
:param format... | [
"def",
"get_dict_properties",
"(",
"item",
",",
"fields",
",",
"mixed_case_fields",
"=",
"[",
"]",
",",
"formatters",
"=",
"{",
"}",
")",
":",
"row",
"=",
"[",
"]",
"for",
"field",
"in",
"fields",
":",
"if",
"field",
"in",
"mixed_case_fields",
":",
"fi... | Return a tuple containing the item properties.
:param item: a single dict resource
:param fields: tuple of strings with the desired field names
:param mixed_case_fields: tuple of field names to preserve case
:param formatters: dictionary mapping field names to callables
to format the values | [
"Return",
"a",
"tuple",
"containing",
"the",
"item",
"properties",
".",
":",
"param",
"item",
":",
"a",
"single",
"dict",
"resource",
":",
"param",
"fields",
":",
"tuple",
"of",
"strings",
"with",
"the",
"desired",
"field",
"names",
":",
"param",
"mixed_ca... | train | https://github.com/CentOS/python-cicoclient/blob/ffee34f446ceb25348b13a500d5c545df202c182/cicoclient/utils.py#L21-L41 |
CentOS/python-cicoclient | cicoclient/utils.py | log_method | def log_method(log, level=logging.DEBUG):
"""Logs a method and its arguments when entered."""
def decorator(func):
func_name = func.__name__
@six.wraps(func)
def wrapper(self, *args, **kwargs):
if log.isEnabledFor(level):
pretty_args = []
if ... | python | def log_method(log, level=logging.DEBUG):
"""Logs a method and its arguments when entered."""
def decorator(func):
func_name = func.__name__
@six.wraps(func)
def wrapper(self, *args, **kwargs):
if log.isEnabledFor(level):
pretty_args = []
if ... | [
"def",
"log_method",
"(",
"log",
",",
"level",
"=",
"logging",
".",
"DEBUG",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"func_name",
"=",
"func",
".",
"__name__",
"@",
"six",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
... | Logs a method and its arguments when entered. | [
"Logs",
"a",
"method",
"and",
"its",
"arguments",
"when",
"entered",
"."
] | train | https://github.com/CentOS/python-cicoclient/blob/ffee34f446ceb25348b13a500d5c545df202c182/cicoclient/utils.py#L44-L64 |
launchdarkly/relayCommander | relay_commander/replay_builder.py | check_local | def check_local() -> None:
"""
Verify required directories exist.
This functions checks the current working directory to ensure that
the required directories exist. If they do not exist, it will create them.
"""
to_check = ['./replay', './replay/toDo', './replay/archive']
for i in to_check... | python | def check_local() -> None:
"""
Verify required directories exist.
This functions checks the current working directory to ensure that
the required directories exist. If they do not exist, it will create them.
"""
to_check = ['./replay', './replay/toDo', './replay/archive']
for i in to_check... | [
"def",
"check_local",
"(",
")",
"->",
"None",
":",
"to_check",
"=",
"[",
"'./replay'",
",",
"'./replay/toDo'",
",",
"'./replay/archive'",
"]",
"for",
"i",
"in",
"to_check",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"i",
")",
":",
"os",
... | Verify required directories exist.
This functions checks the current working directory to ensure that
the required directories exist. If they do not exist, it will create them. | [
"Verify",
"required",
"directories",
"exist",
"."
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/replay_builder.py#L33-L44 |
launchdarkly/relayCommander | relay_commander/replay_builder.py | create_file | def create_file(project: str, environment: str, feature: str, state: str) -> None:
"""
Create file to replay.
Create file with ``rc`` command that will be called against the
LaunchDarkly API when ``rc playback`` is called from the main CLI.
:param project: LaunchDarkly Project
:param environme... | python | def create_file(project: str, environment: str, feature: str, state: str) -> None:
"""
Create file to replay.
Create file with ``rc`` command that will be called against the
LaunchDarkly API when ``rc playback`` is called from the main CLI.
:param project: LaunchDarkly Project
:param environme... | [
"def",
"create_file",
"(",
"project",
":",
"str",
",",
"environment",
":",
"str",
",",
"feature",
":",
"str",
",",
"state",
":",
"str",
")",
"->",
"None",
":",
"check_local",
"(",
")",
"save_path",
"=",
"'./replay/toDo/'",
"filename",
"=",
"'{0}.txt'",
"... | Create file to replay.
Create file with ``rc`` command that will be called against the
LaunchDarkly API when ``rc playback`` is called from the main CLI.
:param project: LaunchDarkly Project
:param environment: LaunchDarkly Environment
:param feature: LaunchDarkly Feature
:param state: State t... | [
"Create",
"file",
"to",
"replay",
"."
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/replay_builder.py#L47-L70 |
launchdarkly/relayCommander | relay_commander/replay_builder.py | execute_replay | def execute_replay() -> None:
"""
Execute all commands.
For every command that is found in replay/toDo, execute each of them
and move the file to the replay/archive directory.
"""
files = glob.glob('./replay/toDo/*')
sorted_files = sorted(files, key=os.path.getctime)
if not sorted_file... | python | def execute_replay() -> None:
"""
Execute all commands.
For every command that is found in replay/toDo, execute each of them
and move the file to the replay/archive directory.
"""
files = glob.glob('./replay/toDo/*')
sorted_files = sorted(files, key=os.path.getctime)
if not sorted_file... | [
"def",
"execute_replay",
"(",
")",
"->",
"None",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"'./replay/toDo/*'",
")",
"sorted_files",
"=",
"sorted",
"(",
"files",
",",
"key",
"=",
"os",
".",
"path",
".",
"getctime",
")",
"if",
"not",
"sorted_files",
... | Execute all commands.
For every command that is found in replay/toDo, execute each of them
and move the file to the replay/archive directory. | [
"Execute",
"all",
"commands",
"."
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/replay_builder.py#L73-L96 |
vsoch/helpme | helpme/utils/terminal.py | choice_prompt | def choice_prompt(prompt, choices=None, choice=None):
'''Ask the user for a prompt, and only return when one of the requested
options is provided.
Parameters
==========
prompt: the prompt to ask the user
choices: a list of choices that are valid, defaults to [Y/N/y/n]
''... | python | def choice_prompt(prompt, choices=None, choice=None):
'''Ask the user for a prompt, and only return when one of the requested
options is provided.
Parameters
==========
prompt: the prompt to ask the user
choices: a list of choices that are valid, defaults to [Y/N/y/n]
''... | [
"def",
"choice_prompt",
"(",
"prompt",
",",
"choices",
"=",
"None",
",",
"choice",
"=",
"None",
")",
":",
"if",
"not",
"choices",
":",
"choices",
"=",
"[",
"\"y\"",
",",
"\"n\"",
",",
"\"Y\"",
",",
"\"N\"",
"]",
"print",
"(",
"prompt",
")",
"get_inpu... | Ask the user for a prompt, and only return when one of the requested
options is provided.
Parameters
==========
prompt: the prompt to ask the user
choices: a list of choices that are valid, defaults to [Y/N/y/n] | [
"Ask",
"the",
"user",
"for",
"a",
"prompt",
"and",
"only",
"return",
"when",
"one",
"of",
"the",
"requested",
"options",
"is",
"provided",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/terminal.py#L46-L68 |
vsoch/helpme | helpme/utils/terminal.py | regexp_prompt | def regexp_prompt(prompt, regexp='.', answer=''):
'''Ask the user for a text entry that matches a regular expression
Parameters
==========
prompt: the prompt to ask the user
regexp: the regular expression to match. defaults to anything.
'''
get_input = getattr(__builtins__,... | python | def regexp_prompt(prompt, regexp='.', answer=''):
'''Ask the user for a text entry that matches a regular expression
Parameters
==========
prompt: the prompt to ask the user
regexp: the regular expression to match. defaults to anything.
'''
get_input = getattr(__builtins__,... | [
"def",
"regexp_prompt",
"(",
"prompt",
",",
"regexp",
"=",
"'.'",
",",
"answer",
"=",
"''",
")",
":",
"get_input",
"=",
"getattr",
"(",
"__builtins__",
",",
"'raw_input'",
",",
"input",
")",
"while",
"not",
"re",
".",
"search",
"(",
"regexp",
",",
"ans... | Ask the user for a text entry that matches a regular expression
Parameters
==========
prompt: the prompt to ask the user
regexp: the regular expression to match. defaults to anything. | [
"Ask",
"the",
"user",
"for",
"a",
"text",
"entry",
"that",
"matches",
"a",
"regular",
"expression"
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/terminal.py#L71-L86 |
vsoch/helpme | helpme/utils/terminal.py | which | def which(software, strip_newline=True):
'''get_install will return the path to where an executable is installed.
'''
if software is None:
software = "singularity"
cmd = ['which', software ]
try:
result = run_command(cmd)
if strip_newline is True:
result['message'... | python | def which(software, strip_newline=True):
'''get_install will return the path to where an executable is installed.
'''
if software is None:
software = "singularity"
cmd = ['which', software ]
try:
result = run_command(cmd)
if strip_newline is True:
result['message'... | [
"def",
"which",
"(",
"software",
",",
"strip_newline",
"=",
"True",
")",
":",
"if",
"software",
"is",
"None",
":",
"software",
"=",
"\"singularity\"",
"cmd",
"=",
"[",
"'which'",
",",
"software",
"]",
"try",
":",
"result",
"=",
"run_command",
"(",
"cmd",... | get_install will return the path to where an executable is installed. | [
"get_install",
"will",
"return",
"the",
"path",
"to",
"where",
"an",
"executable",
"is",
"installed",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/utils/terminal.py#L91-L104 |
PlaidWeb/Pushl | pushl/utils.py | guess_encoding | def guess_encoding(request):
""" Try to guess the encoding of a request without going through the slow chardet process"""
ctype = request.headers.get('content-type')
if not ctype:
# we don't have a content-type, somehow, so...
LOGGER.warning("%s: no content-type; headers are %s",
... | python | def guess_encoding(request):
""" Try to guess the encoding of a request without going through the slow chardet process"""
ctype = request.headers.get('content-type')
if not ctype:
# we don't have a content-type, somehow, so...
LOGGER.warning("%s: no content-type; headers are %s",
... | [
"def",
"guess_encoding",
"(",
"request",
")",
":",
"ctype",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"'content-type'",
")",
"if",
"not",
"ctype",
":",
"# we don't have a content-type, somehow, so...",
"LOGGER",
".",
"warning",
"(",
"\"%s: no content-type; he... | Try to guess the encoding of a request without going through the slow chardet process | [
"Try",
"to",
"guess",
"the",
"encoding",
"of",
"a",
"request",
"without",
"going",
"through",
"the",
"slow",
"chardet",
"process"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/utils.py#L15-L34 |
PlaidWeb/Pushl | pushl/utils.py | _make_headers | def _make_headers(config, kwargs):
""" Replace the kwargs with one where the headers include our user-agent """
headers = kwargs.get('headers')
headers = headers.copy() if headers is not None else {}
headers['User-Agent'] = config.args.user_agent
kwargs = kwargs.copy()
kwargs['headers'] = head... | python | def _make_headers(config, kwargs):
""" Replace the kwargs with one where the headers include our user-agent """
headers = kwargs.get('headers')
headers = headers.copy() if headers is not None else {}
headers['User-Agent'] = config.args.user_agent
kwargs = kwargs.copy()
kwargs['headers'] = head... | [
"def",
"_make_headers",
"(",
"config",
",",
"kwargs",
")",
":",
"headers",
"=",
"kwargs",
".",
"get",
"(",
"'headers'",
")",
"headers",
"=",
"headers",
".",
"copy",
"(",
")",
"if",
"headers",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"[",
"'U... | Replace the kwargs with one where the headers include our user-agent | [
"Replace",
"the",
"kwargs",
"with",
"one",
"where",
"the",
"headers",
"include",
"our",
"user",
"-",
"agent"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/utils.py#L97-L106 |
PlaidWeb/Pushl | pushl/utils.py | retry_get | async def retry_get(config, url, *args, **kwargs):
""" aiohttp wrapper for GET """
return await _retry_do(config.session.get, url, *args,
**_make_headers(config, kwargs)) | python | async def retry_get(config, url, *args, **kwargs):
""" aiohttp wrapper for GET """
return await _retry_do(config.session.get, url, *args,
**_make_headers(config, kwargs)) | [
"async",
"def",
"retry_get",
"(",
"config",
",",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"await",
"_retry_do",
"(",
"config",
".",
"session",
".",
"get",
",",
"url",
",",
"*",
"args",
",",
"*",
"*",
"_make_headers",
"(... | aiohttp wrapper for GET | [
"aiohttp",
"wrapper",
"for",
"GET"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/utils.py#L109-L112 |
PlaidWeb/Pushl | pushl/utils.py | retry_post | async def retry_post(config, url, *args, **kwargs):
""" aiohttp wrapper for POST """
return await _retry_do(config.session.post, url, *args,
**_make_headers(config, kwargs)) | python | async def retry_post(config, url, *args, **kwargs):
""" aiohttp wrapper for POST """
return await _retry_do(config.session.post, url, *args,
**_make_headers(config, kwargs)) | [
"async",
"def",
"retry_post",
"(",
"config",
",",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"await",
"_retry_do",
"(",
"config",
".",
"session",
".",
"post",
",",
"url",
",",
"*",
"args",
",",
"*",
"*",
"_make_headers",
... | aiohttp wrapper for POST | [
"aiohttp",
"wrapper",
"for",
"POST"
] | train | https://github.com/PlaidWeb/Pushl/blob/5ea92275c37a6c1989e3d5f53e26c6e0ebfb9a8c/pushl/utils.py#L115-L118 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.run | def run(self, positionals=None):
'''run the entire helper procedure, including:
- start: initialize the helper, collection preferences
- record: record any relevant features for the environment / session
- interact: interact with the user for additional informatoin
... | python | def run(self, positionals=None):
'''run the entire helper procedure, including:
- start: initialize the helper, collection preferences
- record: record any relevant features for the environment / session
- interact: interact with the user for additional informatoin
... | [
"def",
"run",
"(",
"self",
",",
"positionals",
"=",
"None",
")",
":",
"# Step 0: Each run session is given a fun name",
"self",
".",
"run_id",
"=",
"RobotNamer",
"(",
")",
".",
"generate",
"(",
")",
"# Step 1: get config steps",
"steps",
"=",
"self",
".",
"confi... | run the entire helper procedure, including:
- start: initialize the helper, collection preferences
- record: record any relevant features for the environment / session
- interact: interact with the user for additional informatoin
- submit: submit the completed reques... | [
"run",
"the",
"entire",
"helper",
"procedure",
"including",
":"
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L71-L102 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.start | def start(self, positionals=None):
'''start the helper flow. We check helper system configurations to
determine components that should be collected for the submission.
This is where the client can also pass on any extra (positional)
arguments in a list from the user.
'''... | python | def start(self, positionals=None):
'''start the helper flow. We check helper system configurations to
determine components that should be collected for the submission.
This is where the client can also pass on any extra (positional)
arguments in a list from the user.
'''... | [
"def",
"start",
"(",
"self",
",",
"positionals",
"=",
"None",
")",
":",
"bot",
".",
"info",
"(",
"'[helpme|%s]'",
"%",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"speak",
"(",
")",
"self",
".",
"_start",
"(",
"positionals",
")"
] | start the helper flow. We check helper system configurations to
determine components that should be collected for the submission.
This is where the client can also pass on any extra (positional)
arguments in a list from the user. | [
"start",
"the",
"helper",
"flow",
".",
"We",
"check",
"helper",
"system",
"configurations",
"to",
"determine",
"components",
"that",
"should",
"be",
"collected",
"for",
"the",
"submission",
".",
"This",
"is",
"where",
"the",
"client",
"can",
"also",
"pass",
... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L105-L113 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.collect | def collect(self, step, content):
'''given a name of a configuration key and the provided content, collect
the required metadata from the user.
Parameters
==========
step: the key in the configuration. Can be one of:
user_message_<name>
... | python | def collect(self, step, content):
'''given a name of a configuration key and the provided content, collect
the required metadata from the user.
Parameters
==========
step: the key in the configuration. Can be one of:
user_message_<name>
... | [
"def",
"collect",
"(",
"self",
",",
"step",
",",
"content",
")",
":",
"# Option 1: The step is just a message to print to the user",
"if",
"step",
".",
"startswith",
"(",
"'user_message'",
")",
":",
"print",
"(",
"content",
")",
"# Option 2: The step is to collect a use... | given a name of a configuration key and the provided content, collect
the required metadata from the user.
Parameters
==========
step: the key in the configuration. Can be one of:
user_message_<name>
runtime_arg_<name>
... | [
"given",
"a",
"name",
"of",
"a",
"configuration",
"key",
"and",
"the",
"provided",
"content",
"collect",
"the",
"required",
"metadata",
"from",
"the",
"user",
".",
"Parameters",
"==========",
"step",
":",
"the",
"key",
"in",
"the",
"configuration",
".",
"Can... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L138-L169 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.collect_argument | def collect_argument(self, step, message):
'''given a key in the configuration, collect the runtime argument if
provided. Otherwise, prompt the user for the value.
Parameters
==========
step: the name of the step, should be 'runtime_arg_<name>'
message: th... | python | def collect_argument(self, step, message):
'''given a key in the configuration, collect the runtime argument if
provided. Otherwise, prompt the user for the value.
Parameters
==========
step: the name of the step, should be 'runtime_arg_<name>'
message: th... | [
"def",
"collect_argument",
"(",
"self",
",",
"step",
",",
"message",
")",
":",
"if",
"step",
"not",
"in",
"self",
".",
"data",
":",
"self",
".",
"data",
"[",
"step",
"]",
"=",
"regexp_prompt",
"(",
"message",
")"
] | given a key in the configuration, collect the runtime argument if
provided. Otherwise, prompt the user for the value.
Parameters
==========
step: the name of the step, should be 'runtime_arg_<name>'
message: the content of the step, the message to show the user if... | [
"given",
"a",
"key",
"in",
"the",
"configuration",
"collect",
"the",
"runtime",
"argument",
"if",
"provided",
".",
"Otherwise",
"prompt",
"the",
"user",
"for",
"the",
"value",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L172-L184 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.record_environment | def record_environment(self):
'''collect a limited set of environment variables based on the list
under record_envirionment in the configuration file.
'''
# whitelist is a newline separated list under record_environment
envars = self._get_setting(name='whitelist',
... | python | def record_environment(self):
'''collect a limited set of environment variables based on the list
under record_envirionment in the configuration file.
'''
# whitelist is a newline separated list under record_environment
envars = self._get_setting(name='whitelist',
... | [
"def",
"record_environment",
"(",
"self",
")",
":",
"# whitelist is a newline separated list under record_environment",
"envars",
"=",
"self",
".",
"_get_setting",
"(",
"name",
"=",
"'whitelist'",
",",
"section",
"=",
"'record_environment'",
",",
"user",
"=",
"False",
... | collect a limited set of environment variables based on the list
under record_envirionment in the configuration file. | [
"collect",
"a",
"limited",
"set",
"of",
"environment",
"variables",
"based",
"on",
"the",
"list",
"under",
"record_envirionment",
"in",
"the",
"configuration",
"file",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L189-L219 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.record_asciinema | def record_asciinema(self):
'''record an asciinema from the user session, saving the file to
a temporary file and showing the user so if he/she needs to do it
again, the file can be provided. The flow of events below makes
the following checks:
1. The user confirms i... | python | def record_asciinema(self):
'''record an asciinema from the user session, saving the file to
a temporary file and showing the user so if he/she needs to do it
again, the file can be provided. The flow of events below makes
the following checks:
1. The user confirms i... | [
"def",
"record_asciinema",
"(",
"self",
")",
":",
"# If the user already provided a file, we don't need to ask again",
"if",
"'record_asciinema'",
"not",
"in",
"self",
".",
"data",
":",
"if",
"confirm_prompt",
"(",
"\"Would you like to send a terminal recording?\"",
")",
":",... | record an asciinema from the user session, saving the file to
a temporary file and showing the user so if he/she needs to do it
again, the file can be provided. The flow of events below makes
the following checks:
1. The user confirms it is ok to record
2. The rec... | [
"record",
"an",
"asciinema",
"from",
"the",
"user",
"session",
"saving",
"the",
"file",
"to",
"a",
"temporary",
"file",
"and",
"showing",
"the",
"user",
"so",
"if",
"he",
"/",
"she",
"needs",
"to",
"do",
"it",
"again",
"the",
"file",
"can",
"be",
"prov... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L222-L252 |
vsoch/helpme | helpme/main/base/__init__.py | HelperBase.speak | def speak(self):
'''
a function for the helper to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client.
'''
if self.quiet is Fals... | python | def speak(self):
'''
a function for the helper to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client.
'''
if self.quiet is Fals... | [
"def",
"speak",
"(",
"self",
")",
":",
"if",
"self",
".",
"quiet",
"is",
"False",
":",
"bot",
".",
"info",
"(",
"'[helper|%s]'",
"%",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"_speak",
"(",
")"
] | a function for the helper to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client. | [
"a",
"function",
"for",
"the",
"helper",
"to",
"announce",
"him",
"or",
"herself",
"depending",
"on",
"the",
"level",
"specified",
".",
"If",
"you",
"want",
"your",
"client",
"to",
"have",
"additional",
"announced",
"things",
"here",
"then",
"implement",
"th... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/base/__init__.py#L257-L267 |
SetBased/py-stratum | pystratum/Constants.py | Constants.main | def main(self, config_filename, regex):
"""
:param str config_filename: The config filename.
:param str regex: The regular expression for columns which we want to use.
:rtype: int
"""
self._read_configuration_file(config_filename)
if self._constants_filename:
... | python | def main(self, config_filename, regex):
"""
:param str config_filename: The config filename.
:param str regex: The regular expression for columns which we want to use.
:rtype: int
"""
self._read_configuration_file(config_filename)
if self._constants_filename:
... | [
"def",
"main",
"(",
"self",
",",
"config_filename",
",",
"regex",
")",
":",
"self",
".",
"_read_configuration_file",
"(",
"config_filename",
")",
"if",
"self",
".",
"_constants_filename",
":",
"self",
".",
"_io",
".",
"title",
"(",
"'Constants'",
")",
"self"... | :param str config_filename: The config filename.
:param str regex: The regular expression for columns which we want to use.
:rtype: int | [
":",
"param",
"str",
"config_filename",
":",
"The",
"config",
"filename",
".",
":",
"param",
"str",
"regex",
":",
"The",
"regular",
"expression",
"for",
"columns",
"which",
"we",
"want",
"to",
"use",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/Constants.py#L90-L116 |
SetBased/py-stratum | pystratum/Constants.py | Constants.__log_number_of_constants | def __log_number_of_constants(self):
"""
Logs the number of constants generated.
"""
n_id = len(self._labels)
n_widths = len(self._constants) - n_id
self._io.writeln('')
self._io.text('Number of constants based on column widths: {0}'.format(n_widths))
sel... | python | def __log_number_of_constants(self):
"""
Logs the number of constants generated.
"""
n_id = len(self._labels)
n_widths = len(self._constants) - n_id
self._io.writeln('')
self._io.text('Number of constants based on column widths: {0}'.format(n_widths))
sel... | [
"def",
"__log_number_of_constants",
"(",
"self",
")",
":",
"n_id",
"=",
"len",
"(",
"self",
".",
"_labels",
")",
"n_widths",
"=",
"len",
"(",
"self",
".",
"_constants",
")",
"-",
"n_id",
"self",
".",
"_io",
".",
"writeln",
"(",
"''",
")",
"self",
"."... | Logs the number of constants generated. | [
"Logs",
"the",
"number",
"of",
"constants",
"generated",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/Constants.py#L119-L128 |
SetBased/py-stratum | pystratum/Constants.py | Constants._read_configuration_file | def _read_configuration_file(self, config_filename):
"""
Reads parameters from the configuration file.
:param str config_filename: The name of the configuration file.
"""
config = configparser.ConfigParser()
config.read(config_filename)
self._constants_filename ... | python | def _read_configuration_file(self, config_filename):
"""
Reads parameters from the configuration file.
:param str config_filename: The name of the configuration file.
"""
config = configparser.ConfigParser()
config.read(config_filename)
self._constants_filename ... | [
"def",
"_read_configuration_file",
"(",
"self",
",",
"config_filename",
")",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"read",
"(",
"config_filename",
")",
"self",
".",
"_constants_filename",
"=",
"config",
".",
"get",
"... | Reads parameters from the configuration file.
:param str config_filename: The name of the configuration file. | [
"Reads",
"parameters",
"from",
"the",
"configuration",
"file",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/Constants.py#L131-L142 |
SetBased/py-stratum | pystratum/Constants.py | Constants.__write_constant_class | def __write_constant_class(self):
"""
Inserts new and replaces old (if any) constant declaration statements in the class that acts like a namespace
for constants.
"""
helper = ConstantClass(self._class_name, self._io)
content = helper.source_with_constants(self._constant... | python | def __write_constant_class(self):
"""
Inserts new and replaces old (if any) constant declaration statements in the class that acts like a namespace
for constants.
"""
helper = ConstantClass(self._class_name, self._io)
content = helper.source_with_constants(self._constant... | [
"def",
"__write_constant_class",
"(",
"self",
")",
":",
"helper",
"=",
"ConstantClass",
"(",
"self",
".",
"_class_name",
",",
"self",
".",
"_io",
")",
"content",
"=",
"helper",
".",
"source_with_constants",
"(",
"self",
".",
"_constants",
")",
"Util",
".",
... | Inserts new and replaces old (if any) constant declaration statements in the class that acts like a namespace
for constants. | [
"Inserts",
"new",
"and",
"replaces",
"old",
"(",
"if",
"any",
")",
"constant",
"declaration",
"statements",
"in",
"the",
"class",
"that",
"acts",
"like",
"a",
"namespace",
"for",
"constants",
"."
] | train | https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/Constants.py#L205-L214 |
launchdarkly/relayCommander | relay_commander/validator.py | _check_env_var | def _check_env_var(envvar: str) -> bool:
"""Check Environment Variable to verify that it is set and not empty.
:param envvar: Environment Variable to Check.
:returns: True if Environment Variable is set and not empty.
:raises: KeyError if Environment Variable is not set or is empty.
.. versionad... | python | def _check_env_var(envvar: str) -> bool:
"""Check Environment Variable to verify that it is set and not empty.
:param envvar: Environment Variable to Check.
:returns: True if Environment Variable is set and not empty.
:raises: KeyError if Environment Variable is not set or is empty.
.. versionad... | [
"def",
"_check_env_var",
"(",
"envvar",
":",
"str",
")",
"->",
"bool",
":",
"if",
"os",
".",
"getenv",
"(",
"envvar",
")",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"\"Required ENVVAR: {0} is not set\"",
".",
"format",
"(",
"envvar",
")",
")",
"if",
"... | Check Environment Variable to verify that it is set and not empty.
:param envvar: Environment Variable to Check.
:returns: True if Environment Variable is set and not empty.
:raises: KeyError if Environment Variable is not set or is empty.
.. versionadded:: 0.0.12 | [
"Check",
"Environment",
"Variable",
"to",
"verify",
"that",
"it",
"is",
"set",
"and",
"not",
"empty",
"."
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/validator.py#L19-L36 |
launchdarkly/relayCommander | relay_commander/validator.py | valid_state | def valid_state(state: str) -> bool:
"""Validate State Argument
Checks that either 'on' or 'off' was entered as an argument to the
CLI and make it lower case.
:param state: state to validate.
:returns: True if state is valid.
.. versionchanged:: 0.0.12
This moethod was renamed from v... | python | def valid_state(state: str) -> bool:
"""Validate State Argument
Checks that either 'on' or 'off' was entered as an argument to the
CLI and make it lower case.
:param state: state to validate.
:returns: True if state is valid.
.. versionchanged:: 0.0.12
This moethod was renamed from v... | [
"def",
"valid_state",
"(",
"state",
":",
"str",
")",
"->",
"bool",
":",
"lower_case_state",
"=",
"state",
".",
"lower",
"(",
")",
"if",
"lower_case_state",
"in",
"_VALID_STATES",
":",
"return",
"True",
"return",
"False"
] | Validate State Argument
Checks that either 'on' or 'off' was entered as an argument to the
CLI and make it lower case.
:param state: state to validate.
:returns: True if state is valid.
.. versionchanged:: 0.0.12
This moethod was renamed from validateState to valid_state to conform
... | [
"Validate",
"State",
"Argument"
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/validator.py#L39-L58 |
launchdarkly/relayCommander | relay_commander/validator.py | valid_env_vars | def valid_env_vars() -> bool:
"""Validate that required env vars exist.
:returns: True if required env vars exist.
.. versionadded:: 0.0.12
"""
for envvar in _REQUIRED_ENV_VARS:
try:
_check_env_var(envvar)
except KeyError as ex:
LOG.error(ex)
sys... | python | def valid_env_vars() -> bool:
"""Validate that required env vars exist.
:returns: True if required env vars exist.
.. versionadded:: 0.0.12
"""
for envvar in _REQUIRED_ENV_VARS:
try:
_check_env_var(envvar)
except KeyError as ex:
LOG.error(ex)
sys... | [
"def",
"valid_env_vars",
"(",
")",
"->",
"bool",
":",
"for",
"envvar",
"in",
"_REQUIRED_ENV_VARS",
":",
"try",
":",
"_check_env_var",
"(",
"envvar",
")",
"except",
"KeyError",
"as",
"ex",
":",
"LOG",
".",
"error",
"(",
"ex",
")",
"sys",
".",
"exit",
"(... | Validate that required env vars exist.
:returns: True if required env vars exist.
.. versionadded:: 0.0.12 | [
"Validate",
"that",
"required",
"env",
"vars",
"exist",
"."
] | train | https://github.com/launchdarkly/relayCommander/blob/eee7fa22f04edc3854dd53c3ec2db8c599ad1e89/relay_commander/validator.py#L61-L74 |
DreamLab/VmShepherd | src/vmshepherd/http/__init__.py | WebServer.configure_panel | def configure_panel(self):
"""
Configure templates and routing
"""
webroot = os.path.dirname(__file__)
self.template_path = os.path.join(webroot, 'templates')
aiohttp_jinja2.setup(
self, loader=jinja2.FileSystemLoader(self.template_path),
filters=... | python | def configure_panel(self):
"""
Configure templates and routing
"""
webroot = os.path.dirname(__file__)
self.template_path = os.path.join(webroot, 'templates')
aiohttp_jinja2.setup(
self, loader=jinja2.FileSystemLoader(self.template_path),
filters=... | [
"def",
"configure_panel",
"(",
"self",
")",
":",
"webroot",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"self",
".",
"template_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"webroot",
",",
"'templates'",
")",
"aiohttp_jinja2",
".",
... | Configure templates and routing | [
"Configure",
"templates",
"and",
"routing"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/__init__.py#L20-L36 |
DreamLab/VmShepherd | src/vmshepherd/http/__init__.py | WebServer.start | async def start(self):
"""
Initialize and start WebServer
"""
logging.info('Starting server, listening on %s.', self.port)
runner = web.AppRunner(self)
await runner.setup()
site = web.TCPSite(runner, '', self.port)
await site.start() | python | async def start(self):
"""
Initialize and start WebServer
"""
logging.info('Starting server, listening on %s.', self.port)
runner = web.AppRunner(self)
await runner.setup()
site = web.TCPSite(runner, '', self.port)
await site.start() | [
"async",
"def",
"start",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Starting server, listening on %s.'",
",",
"self",
".",
"port",
")",
"runner",
"=",
"web",
".",
"AppRunner",
"(",
"self",
")",
"await",
"runner",
".",
"setup",
"(",
")",
"site"... | Initialize and start WebServer | [
"Initialize",
"and",
"start",
"WebServer"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/__init__.py#L45-L53 |
DreamLab/VmShepherd | src/vmshepherd/http/__init__.py | Panel.get | async def get(self):
"""
Inject all preset data to Panel and Render a Home Page
"""
shepherd = self.request.app.vmshepherd
data = {'presets': {}, 'config': shepherd.config}
presets = await shepherd.preset_manager.list_presets()
runtime = shepherd.runtime_manager
... | python | async def get(self):
"""
Inject all preset data to Panel and Render a Home Page
"""
shepherd = self.request.app.vmshepherd
data = {'presets': {}, 'config': shepherd.config}
presets = await shepherd.preset_manager.list_presets()
runtime = shepherd.runtime_manager
... | [
"async",
"def",
"get",
"(",
"self",
")",
":",
"shepherd",
"=",
"self",
".",
"request",
".",
"app",
".",
"vmshepherd",
"data",
"=",
"{",
"'presets'",
":",
"{",
"}",
",",
"'config'",
":",
"shepherd",
".",
"config",
"}",
"presets",
"=",
"await",
"shephe... | Inject all preset data to Panel and Render a Home Page | [
"Inject",
"all",
"preset",
"data",
"to",
"Panel",
"and",
"Render",
"a",
"Home",
"Page"
] | train | https://github.com/DreamLab/VmShepherd/blob/709a412c372b897d53808039c5c64a8b69c12c8d/src/vmshepherd/http/__init__.py#L59-L76 |
julot/sphinxcontrib-dd | sphinxcontrib/dd/database_diagram.py | serialize | def serialize(dictionary):
"""
Turn dictionary into argument like string.
"""
data = []
for key, value in dictionary.items():
data.append('{0}="{1}"'.format(key, value))
return ', '.join(data) | python | def serialize(dictionary):
"""
Turn dictionary into argument like string.
"""
data = []
for key, value in dictionary.items():
data.append('{0}="{1}"'.format(key, value))
return ', '.join(data) | [
"def",
"serialize",
"(",
"dictionary",
")",
":",
"data",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"data",
".",
"append",
"(",
"'{0}=\"{1}\"'",
".",
"format",
"(",
"key",
",",
"value",
")",
")",
"re... | Turn dictionary into argument like string. | [
"Turn",
"dictionary",
"into",
"argument",
"like",
"string",
"."
] | train | https://github.com/julot/sphinxcontrib-dd/blob/18619b356508b9a99cc329eeae53cbf299a5d1de/sphinxcontrib/dd/database_diagram.py#L12-L21 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.getAmountOfHostsConnected | def getAmountOfHostsConnected(self, lanInterfaceId=1, timeout=1):
"""Execute NewHostNumberOfEntries action to get the amount of known hosts.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the amount... | python | def getAmountOfHostsConnected(self, lanInterfaceId=1, timeout=1):
"""Execute NewHostNumberOfEntries action to get the amount of known hosts.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the amount... | [
"def",
"getAmountOfHostsConnected",
"(",
"self",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"getAmountOfHostsConnected\"",
")",
"+",
"str",
"(",
"lanInterfaceId",
")",
"uri",
"=",... | Execute NewHostNumberOfEntries action to get the amount of known hosts.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the amount of known hosts.
:rtype: int
.. seealso:: :meth:`~simpletr64... | [
"Execute",
"NewHostNumberOfEntries",
"action",
"to",
"get",
"the",
"amount",
"of",
"known",
"hosts",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L91-L106 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.getHostDetailsByIndex | def getHostDetailsByIndex(self, index, lanInterfaceId=1, timeout=1):
"""Execute GetGenericHostEntry action to get detailed information's of a connected host.
:param index: the index of the host
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to w... | python | def getHostDetailsByIndex(self, index, lanInterfaceId=1, timeout=1):
"""Execute GetGenericHostEntry action to get detailed information's of a connected host.
:param index: the index of the host
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to w... | [
"def",
"getHostDetailsByIndex",
"(",
"self",
",",
"index",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"getHostDetailsByIndex\"",
")",
"+",
"str",
"(",
"lanInterfaceId",
")",
"ur... | Execute GetGenericHostEntry action to get detailed information's of a connected host.
:param index: the index of the host
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the detailed information's of... | [
"Execute",
"GetGenericHostEntry",
"action",
"to",
"get",
"detailed",
"information",
"s",
"of",
"a",
"connected",
"host",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L108-L124 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.getHostDetailsByMACAddress | def getHostDetailsByMACAddress(self, macAddress, lanInterfaceId=1, timeout=1):
"""Get host details for a host specified by its MAC address.
:param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might
be case sensitive, depending on the router
... | python | def getHostDetailsByMACAddress(self, macAddress, lanInterfaceId=1, timeout=1):
"""Get host details for a host specified by its MAC address.
:param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might
be case sensitive, depending on the router
... | [
"def",
"getHostDetailsByMACAddress",
"(",
"self",
",",
"macAddress",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"getHostDetailsByMACAddress\"",
")",
"+",
"str",
"(",
"lanInterfaceId... | Get host details for a host specified by its MAC address.
:param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might
be case sensitive, depending on the router
:param int lanInterfaceId: the id of the LAN interface
:param float timeout:... | [
"Get",
"host",
"details",
"for",
"a",
"host",
"specified",
"by",
"its",
"MAC",
"address",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L126-L141 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.getEthernetInfo | def getEthernetInfo(self, lanInterfaceId=1, timeout=1):
"""Execute GetInfo action to get information's about the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: information's abou... | python | def getEthernetInfo(self, lanInterfaceId=1, timeout=1):
"""Execute GetInfo action to get information's about the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: information's abou... | [
"def",
"getEthernetInfo",
"(",
"self",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"getEthernetInfo\"",
")",
"+",
"str",
"(",
"lanInterfaceId",
")",
"uri",
"=",
"self",
".",
... | Execute GetInfo action to get information's about the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: information's about the Ethernet interface.
:rtype: EthernetInfo | [
"Execute",
"GetInfo",
"action",
"to",
"get",
"information",
"s",
"about",
"the",
"Ethernet",
"interface",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L143-L156 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.getEthernetStatistic | def getEthernetStatistic(self, lanInterfaceId=1, timeout=1):
"""Execute GetStatistics action to get statistics of the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: statisticss o... | python | def getEthernetStatistic(self, lanInterfaceId=1, timeout=1):
"""Execute GetStatistics action to get statistics of the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: statisticss o... | [
"def",
"getEthernetStatistic",
"(",
"self",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"getEthernetStatistic\"",
")",
"+",
"str",
"(",
"lanInterfaceId",
")",
"uri",
"=",
"self",... | Execute GetStatistics action to get statistics of the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: statisticss of the Ethernet interface.
:rtype: EthernetStatistic | [
"Execute",
"GetStatistics",
"action",
"to",
"get",
"statistics",
"of",
"the",
"Ethernet",
"interface",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L158-L171 |
bpannier/simpletr64 | simpletr64/actions/lan.py | Lan.setEnable | def setEnable(self, status, lanInterfaceId=1, timeout=1):
"""Set enable status for a LAN interface, be careful you don't cut yourself off.
:param bool status: enable or disable the interface
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait... | python | def setEnable(self, status, lanInterfaceId=1, timeout=1):
"""Set enable status for a LAN interface, be careful you don't cut yourself off.
:param bool status: enable or disable the interface
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait... | [
"def",
"setEnable",
"(",
"self",
",",
"status",
",",
"lanInterfaceId",
"=",
"1",
",",
"timeout",
"=",
"1",
")",
":",
"namespace",
"=",
"Lan",
".",
"getServiceType",
"(",
"\"setEnable\"",
")",
"+",
"str",
"(",
"lanInterfaceId",
")",
"uri",
"=",
"self",
... | Set enable status for a LAN interface, be careful you don't cut yourself off.
:param bool status: enable or disable the interface
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed | [
"Set",
"enable",
"status",
"for",
"a",
"LAN",
"interface",
"be",
"careful",
"you",
"don",
"t",
"cut",
"yourself",
"off",
"."
] | train | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/actions/lan.py#L173-L188 |
vsoch/helpme | helpme/main/uservoice/__init__.py | Helper._submit | def _submit(self):
'''submit a uservoice ticket. When we get here we should have:
{'user_prompt_issue': 'I want to do the thing.',
'record_asciinema': '/tmp/helpme.93o__nt5.json',
'record_environment': ((1,1),(2,2)...(N,N))}
Required Client Variables
... | python | def _submit(self):
'''submit a uservoice ticket. When we get here we should have:
{'user_prompt_issue': 'I want to do the thing.',
'record_asciinema': '/tmp/helpme.93o__nt5.json',
'record_environment': ((1,1),(2,2)...(N,N))}
Required Client Variables
... | [
"def",
"_submit",
"(",
"self",
")",
":",
"# Step 0: Authenticate with uservoice API",
"self",
".",
"authenticate",
"(",
")",
"title",
"=",
"\"HelpMe UserVoice Ticket: %s\"",
"%",
"(",
"self",
".",
"run_id",
")",
"body",
"=",
"self",
".",
"data",
"[",
"'user_prom... | submit a uservoice ticket. When we get here we should have:
{'user_prompt_issue': 'I want to do the thing.',
'record_asciinema': '/tmp/helpme.93o__nt5.json',
'record_environment': ((1,1),(2,2)...(N,N))}
Required Client Variables
self.api_key
... | [
"submit",
"a",
"uservoice",
"ticket",
".",
"When",
"we",
"get",
"here",
"we",
"should",
"have",
":",
"{",
"user_prompt_issue",
":",
"I",
"want",
"to",
"do",
"the",
"thing",
".",
"record_asciinema",
":",
"/",
"tmp",
"/",
"helpme",
".",
"93o__nt5",
".",
... | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/uservoice/__init__.py#L53-L99 |
vsoch/helpme | helpme/main/uservoice/__init__.py | Helper.authenticate | def authenticate(self):
'''authenticate with uservoice by creating a client.'''
if not hasattr(self, 'client'):
self.client = uservoice.Client(self.subdomain,
self.api_key,
self.api_secret) | python | def authenticate(self):
'''authenticate with uservoice by creating a client.'''
if not hasattr(self, 'client'):
self.client = uservoice.Client(self.subdomain,
self.api_key,
self.api_secret) | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'client'",
")",
":",
"self",
".",
"client",
"=",
"uservoice",
".",
"Client",
"(",
"self",
".",
"subdomain",
",",
"self",
".",
"api_key",
",",
"self",
".",
"api_s... | authenticate with uservoice by creating a client. | [
"authenticate",
"with",
"uservoice",
"by",
"creating",
"a",
"client",
"."
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/uservoice/__init__.py#L104-L110 |
vsoch/helpme | helpme/main/uservoice/__init__.py | Helper.post_ticket | def post_ticket(self, title, body):
'''post_ticket will post a ticket to the uservoice helpdesk
Parameters
==========
title: the title (subject) of the issue
body: the message to send
'''
# Populate the ticket
ticket = {'subject': title,
... | python | def post_ticket(self, title, body):
'''post_ticket will post a ticket to the uservoice helpdesk
Parameters
==========
title: the title (subject) of the issue
body: the message to send
'''
# Populate the ticket
ticket = {'subject': title,
... | [
"def",
"post_ticket",
"(",
"self",
",",
"title",
",",
"body",
")",
":",
"# Populate the ticket",
"ticket",
"=",
"{",
"'subject'",
":",
"title",
",",
"'message'",
":",
"body",
"}",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"\"/api/v1/tickets... | post_ticket will post a ticket to the uservoice helpdesk
Parameters
==========
title: the title (subject) of the issue
body: the message to send | [
"post_ticket",
"will",
"post",
"a",
"ticket",
"to",
"the",
"uservoice",
"helpdesk"
] | train | https://github.com/vsoch/helpme/blob/e609172260b10cddadb2d2023ab26da8082a9feb/helpme/main/uservoice/__init__.py#L114-L131 |
mjirik/io3d | io3d/datareader.py | read | def read(datapath, qt_app=None, dataplus_format=True, gui=False, start=0, stop=None, step=1, convert_to_gray=True,
series_number=None, dicom_expected=None, **kwargs):
"""Simple read function. Internally calls DataReader.Get3DData()"""
dr = DataReader()
return dr.Get3DData(datapath=datapath, qt_app=... | python | def read(datapath, qt_app=None, dataplus_format=True, gui=False, start=0, stop=None, step=1, convert_to_gray=True,
series_number=None, dicom_expected=None, **kwargs):
"""Simple read function. Internally calls DataReader.Get3DData()"""
dr = DataReader()
return dr.Get3DData(datapath=datapath, qt_app=... | [
"def",
"read",
"(",
"datapath",
",",
"qt_app",
"=",
"None",
",",
"dataplus_format",
"=",
"True",
",",
"gui",
"=",
"False",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
",",
"convert_to_gray",
"=",
"True",
",",
"series_numb... | Simple read function. Internally calls DataReader.Get3DData() | [
"Simple",
"read",
"function",
".",
"Internally",
"calls",
"DataReader",
".",
"Get3DData",
"()"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L34-L40 |
mjirik/io3d | io3d/datareader.py | _metadata | def _metadata(image, datapath):
"""Function which returns metadata dict.
:param image: image to get spacing from
:param datapath: path to data
:return: {'series_number': '', 'datadir': '', 'voxelsize_mm': ''}
"""
metadata = {'series_number': 0, 'datadir': datapath}
spacing = image.GetSpacin... | python | def _metadata(image, datapath):
"""Function which returns metadata dict.
:param image: image to get spacing from
:param datapath: path to data
:return: {'series_number': '', 'datadir': '', 'voxelsize_mm': ''}
"""
metadata = {'series_number': 0, 'datadir': datapath}
spacing = image.GetSpacin... | [
"def",
"_metadata",
"(",
"image",
",",
"datapath",
")",
":",
"metadata",
"=",
"{",
"'series_number'",
":",
"0",
",",
"'datadir'",
":",
"datapath",
"}",
"spacing",
"=",
"image",
".",
"GetSpacing",
"(",
")",
"metadata",
"[",
"'voxelsize_mm'",
"]",
"=",
"["... | Function which returns metadata dict.
:param image: image to get spacing from
:param datapath: path to data
:return: {'series_number': '', 'datadir': '', 'voxelsize_mm': ''} | [
"Function",
"which",
"returns",
"metadata",
"dict",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L44-L58 |
mjirik/io3d | io3d/datareader.py | DataReader.Get3DData | def Get3DData(self, datapath, qt_app=None, dataplus_format=True, gui=False, start=0, stop=None, step=1,
convert_to_gray=True, series_number=None, use_economic_dtype=True, dicom_expected=None, **kwargs):
"""Returns 3D data and its metadata.
# NOTE(:param qt_app:) If it is set to None (... | python | def Get3DData(self, datapath, qt_app=None, dataplus_format=True, gui=False, start=0, stop=None, step=1,
convert_to_gray=True, series_number=None, use_economic_dtype=True, dicom_expected=None, **kwargs):
"""Returns 3D data and its metadata.
# NOTE(:param qt_app:) If it is set to None (... | [
"def",
"Get3DData",
"(",
"self",
",",
"datapath",
",",
"qt_app",
"=",
"None",
",",
"dataplus_format",
"=",
"True",
",",
"gui",
"=",
"False",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
",",
"convert_to_gray",
"=",
"True",... | Returns 3D data and its metadata.
# NOTE(:param qt_app:) If it is set to None (as default) all dialogs for series selection are performed in
terminal. If qt_app is set to QtGui.QApplication() dialogs are in Qt.
:param datapath: directory with input data
:param qt_app: Dialog destinatio... | [
"Returns",
"3D",
"data",
"and",
"its",
"metadata",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L67-L140 |
mjirik/io3d | io3d/datareader.py | DataReader.__ReadFromDirectory | def __ReadFromDirectory(self, datapath, dicom_expected=None):
"""This function is actually the ONE, which reads 3D data from file
:param datapath: path to file
:return: tuple (data3d, metadata)
"""
start = self.start
stop = self.stop
step = self.step
kwar... | python | def __ReadFromDirectory(self, datapath, dicom_expected=None):
"""This function is actually the ONE, which reads 3D data from file
:param datapath: path to file
:return: tuple (data3d, metadata)
"""
start = self.start
stop = self.stop
step = self.step
kwar... | [
"def",
"__ReadFromDirectory",
"(",
"self",
",",
"datapath",
",",
"dicom_expected",
"=",
"None",
")",
":",
"start",
"=",
"self",
".",
"start",
"stop",
"=",
"self",
".",
"stop",
"step",
"=",
"self",
".",
"step",
"kwargs",
"=",
"self",
".",
"kwargs",
"gui... | This function is actually the ONE, which reads 3D data from file
:param datapath: path to file
:return: tuple (data3d, metadata) | [
"This",
"function",
"is",
"actually",
"the",
"ONE",
"which",
"reads",
"3D",
"data",
"from",
"file"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L143-L191 |
mjirik/io3d | io3d/datareader.py | DataReader.__ReadFromFile | def __ReadFromFile(self, datapath):
"""Reads file and returns containing 3D data and its metadata.
Supported formats: pklz, pkl, hdf5, idx, dcm, Dcm, dicom, bz2 and "raw files"
:param datapath: path to file to read
:return: tuple (data3d, metadata)
"""
def _create_meta(_... | python | def __ReadFromFile(self, datapath):
"""Reads file and returns containing 3D data and its metadata.
Supported formats: pklz, pkl, hdf5, idx, dcm, Dcm, dicom, bz2 and "raw files"
:param datapath: path to file to read
:return: tuple (data3d, metadata)
"""
def _create_meta(_... | [
"def",
"__ReadFromFile",
"(",
"self",
",",
"datapath",
")",
":",
"def",
"_create_meta",
"(",
"_datapath",
")",
":",
"\"\"\"Just simply returns some dict. This functions exists in order to keep DRY\"\"\"",
"meta",
"=",
"{",
"'series_number'",
":",
"0",
",",
"'datadir'",
... | Reads file and returns containing 3D data and its metadata.
Supported formats: pklz, pkl, hdf5, idx, dcm, Dcm, dicom, bz2 and "raw files"
:param datapath: path to file to read
:return: tuple (data3d, metadata) | [
"Reads",
"file",
"and",
"returns",
"containing",
"3D",
"data",
"and",
"its",
"metadata",
".",
"Supported",
"formats",
":",
"pklz",
"pkl",
"hdf5",
"idx",
"dcm",
"Dcm",
"dicom",
"bz2",
"and",
"raw",
"files"
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L203-L256 |
mjirik/io3d | io3d/datareader.py | DataReader._read_with_sitk | def _read_with_sitk(datapath):
"""Reads file using SimpleITK. Returns array of pixels (image located in datapath) and its metadata.
:param datapath: path to file (img or dicom)
:return: tuple (data3d, metadata), where data3d is array of pixels
"""
try:
import SimpleI... | python | def _read_with_sitk(datapath):
"""Reads file using SimpleITK. Returns array of pixels (image located in datapath) and its metadata.
:param datapath: path to file (img or dicom)
:return: tuple (data3d, metadata), where data3d is array of pixels
"""
try:
import SimpleI... | [
"def",
"_read_with_sitk",
"(",
"datapath",
")",
":",
"try",
":",
"import",
"SimpleITK",
"as",
"Sitk",
"except",
"ImportError",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"\"Unable to import SimpleITK. On Windows try version 1.0.1\"",
")",
"image",
"=",
"Sitk",
"... | Reads file using SimpleITK. Returns array of pixels (image located in datapath) and its metadata.
:param datapath: path to file (img or dicom)
:return: tuple (data3d, metadata), where data3d is array of pixels | [
"Reads",
"file",
"using",
"SimpleITK",
".",
"Returns",
"array",
"of",
"pixels",
"(",
"image",
"located",
"in",
"datapath",
")",
"and",
"its",
"metadata",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L259-L273 |
mjirik/io3d | io3d/datareader.py | DataReader._fix_sitk_bug | def _fix_sitk_bug(path, metadata):
"""There is a bug in simple ITK for Z axis in 3D images. This is a fix.
:param path: path to dicom file to read
:param metadata: metadata to correct
:return: corrected metadata
"""
ds = dicom.read_file(path)
try:
met... | python | def _fix_sitk_bug(path, metadata):
"""There is a bug in simple ITK for Z axis in 3D images. This is a fix.
:param path: path to dicom file to read
:param metadata: metadata to correct
:return: corrected metadata
"""
ds = dicom.read_file(path)
try:
met... | [
"def",
"_fix_sitk_bug",
"(",
"path",
",",
"metadata",
")",
":",
"ds",
"=",
"dicom",
".",
"read_file",
"(",
"path",
")",
"try",
":",
"metadata",
"[",
"\"voxelsize_mm\"",
"]",
"[",
"0",
"]",
"=",
"ds",
".",
"SpacingBetweenSlices",
"except",
"Exception",
"a... | There is a bug in simple ITK for Z axis in 3D images. This is a fix.
:param path: path to dicom file to read
:param metadata: metadata to correct
:return: corrected metadata | [
"There",
"is",
"a",
"bug",
"in",
"simple",
"ITK",
"for",
"Z",
"axis",
"in",
"3D",
"images",
".",
"This",
"is",
"a",
"fix",
"."
] | train | https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/datareader.py#L276-L288 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.