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 |
|---|---|---|---|---|---|---|---|---|---|---|
FujiMakoto/IPS-Vagrant | ips_vagrant/installer/V_4_1_3_2.py | Installer.start | def start(self):
"""
Start the installation wizard
"""
self.log.debug('Starting the installation process')
self.browser.open(self.url)
self.system_check() | python | def start(self):
"""
Start the installation wizard
"""
self.log.debug('Starting the installation process')
self.browser.open(self.url)
self.system_check() | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Starting the installation process'",
")",
"self",
".",
"browser",
".",
"open",
"(",
"self",
".",
"url",
")",
"self",
".",
"system_check",
"(",
")"
] | Start the installation wizard | [
"Start",
"the",
"installation",
"wizard"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/V_4_1_3_2.py#L13-L21 |
FujiMakoto/IPS-Vagrant | ips_vagrant/installer/V_4_1_3_2.py | Installer.admin | def admin(self):
"""
Provide admin login credentials
"""
self._check_title(self.browser.title())
self.browser.select_form(nr=0)
# Get the admin credentials
prompted = []
user = self.ctx.config.get('User', 'AdminUser')
if not user:
user... | python | def admin(self):
"""
Provide admin login credentials
"""
self._check_title(self.browser.title())
self.browser.select_form(nr=0)
# Get the admin credentials
prompted = []
user = self.ctx.config.get('User', 'AdminUser')
if not user:
user... | [
"def",
"admin",
"(",
"self",
")",
":",
"self",
".",
"_check_title",
"(",
"self",
".",
"browser",
".",
"title",
"(",
")",
")",
"self",
".",
"browser",
".",
"select_form",
"(",
"nr",
"=",
"0",
")",
"# Get the admin credentials",
"prompted",
"=",
"[",
"]"... | Provide admin login credentials | [
"Provide",
"admin",
"login",
"credentials"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/V_4_1_3_2.py#L23-L65 |
FujiMakoto/IPS-Vagrant | ips_vagrant/installer/V_4_1_3_2.py | Installer._start_install | def _start_install(self):
"""
Start the installation
"""
self._check_title(self.browser.title())
continue_link = next(self.browser.links(text_regex='Start Installation'))
self.browser.follow_link(continue_link) | python | def _start_install(self):
"""
Start the installation
"""
self._check_title(self.browser.title())
continue_link = next(self.browser.links(text_regex='Start Installation'))
self.browser.follow_link(continue_link) | [
"def",
"_start_install",
"(",
"self",
")",
":",
"self",
".",
"_check_title",
"(",
"self",
".",
"browser",
".",
"title",
"(",
")",
")",
"continue_link",
"=",
"next",
"(",
"self",
".",
"browser",
".",
"links",
"(",
"text_regex",
"=",
"'Start Installation'",
... | Start the installation | [
"Start",
"the",
"installation"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/V_4_1_3_2.py#L67-L73 |
FujiMakoto/IPS-Vagrant | ips_vagrant/installer/V_4_1_3_2.py | Installer.install | def install(self):
"""
Run the actual installation
"""
self._start_install()
mr_link = self._get_mr_link()
# Set up the progress bar
pbar = ProgressBar(100, 'Running installation...')
pbar.start()
mr_j, mr_r = self._ajax(mr_link)
# Loop u... | python | def install(self):
"""
Run the actual installation
"""
self._start_install()
mr_link = self._get_mr_link()
# Set up the progress bar
pbar = ProgressBar(100, 'Running installation...')
pbar.start()
mr_j, mr_r = self._ajax(mr_link)
# Loop u... | [
"def",
"install",
"(",
"self",
")",
":",
"self",
".",
"_start_install",
"(",
")",
"mr_link",
"=",
"self",
".",
"_get_mr_link",
"(",
")",
"# Set up the progress bar",
"pbar",
"=",
"ProgressBar",
"(",
"100",
",",
"'Running installation...'",
")",
"pbar",
".",
... | Run the actual installation | [
"Run",
"the",
"actual",
"installation"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/V_4_1_3_2.py#L76-L113 |
redhog/pieshell | pieshell/pipe.py | pipe_cloexec | def pipe_cloexec():
"""Create a pipe with FDs set CLOEXEC."""
# Pipes' FDs are set CLOEXEC by default because we don't want them
# to be inherited by other subprocesses: the CLOEXEC flag is removed
# from the child's FDs by _dup2(), between fork() and exec().
# This is not atomic: we would need the ... | python | def pipe_cloexec():
"""Create a pipe with FDs set CLOEXEC."""
# Pipes' FDs are set CLOEXEC by default because we don't want them
# to be inherited by other subprocesses: the CLOEXEC flag is removed
# from the child's FDs by _dup2(), between fork() and exec().
# This is not atomic: we would need the ... | [
"def",
"pipe_cloexec",
"(",
")",
":",
"# Pipes' FDs are set CLOEXEC by default because we don't want them",
"# to be inherited by other subprocesses: the CLOEXEC flag is removed",
"# from the child's FDs by _dup2(), between fork() and exec().",
"# This is not atomic: we would need the pipe2() syscal... | Create a pipe with FDs set CLOEXEC. | [
"Create",
"a",
"pipe",
"with",
"FDs",
"set",
"CLOEXEC",
"."
] | train | https://github.com/redhog/pieshell/blob/11cff3b93785ee4446f99b9134be20380edeb767/pieshell/pipe.py#L17-L26 |
naphatkrit/easyci | easyci/vcs/git.py | GitVcs.get_signature | def get_signature(self, base_commit=None):
"""Get the signature of the current state of the repository
TODO right now `get_signature` is an effectful process in that
it adds all untracked file to staging. This is the only way to get
accruate diff on new files. This is ok because we only... | python | def get_signature(self, base_commit=None):
"""Get the signature of the current state of the repository
TODO right now `get_signature` is an effectful process in that
it adds all untracked file to staging. This is the only way to get
accruate diff on new files. This is ok because we only... | [
"def",
"get_signature",
"(",
"self",
",",
"base_commit",
"=",
"None",
")",
":",
"if",
"base_commit",
"is",
"None",
":",
"base_commit",
"=",
"'HEAD'",
"self",
".",
"run",
"(",
"'add'",
",",
"'-A'",
",",
"self",
".",
"path",
")",
"sha",
"=",
"self",
".... | Get the signature of the current state of the repository
TODO right now `get_signature` is an effectful process in that
it adds all untracked file to staging. This is the only way to get
accruate diff on new files. This is ok because we only use it on a
disposable copy of the repo.
... | [
"Get",
"the",
"signature",
"of",
"the",
"current",
"state",
"of",
"the",
"repository"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/vcs/git.py#L82-L109 |
naphatkrit/easyci | easyci/vcs/git.py | GitVcs.install_hook | def install_hook(self, hook_name, hook_content):
"""Install the repository hook for this repo.
Args:
hook_name (str)
hook_content (str)
"""
hook_path = os.path.join(self.path, '.git/hooks', hook_name)
with open(hook_path, 'w') as f:
f.write(ho... | python | def install_hook(self, hook_name, hook_content):
"""Install the repository hook for this repo.
Args:
hook_name (str)
hook_content (str)
"""
hook_path = os.path.join(self.path, '.git/hooks', hook_name)
with open(hook_path, 'w') as f:
f.write(ho... | [
"def",
"install_hook",
"(",
"self",
",",
"hook_name",
",",
"hook_content",
")",
":",
"hook_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"'.git/hooks'",
",",
"hook_name",
")",
"with",
"open",
"(",
"hook_path",
",",
"'w'",
"... | Install the repository hook for this repo.
Args:
hook_name (str)
hook_content (str) | [
"Install",
"the",
"repository",
"hook",
"for",
"this",
"repo",
"."
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/vcs/git.py#L111-L121 |
naphatkrit/easyci | easyci/vcs/git.py | GitVcs.get_ignored_files | def get_ignored_files(self):
"""Returns the list of files being ignored in this repository.
Note that file names, not directories, are returned.
So, we will get the following:
a/b.txt
a/c.txt
instead of just:
a/
Returns:
List[str] - list ... | python | def get_ignored_files(self):
"""Returns the list of files being ignored in this repository.
Note that file names, not directories, are returned.
So, we will get the following:
a/b.txt
a/c.txt
instead of just:
a/
Returns:
List[str] - list ... | [
"def",
"get_ignored_files",
"(",
"self",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"p",
")",
"for",
"p",
"in",
"self",
".",
"run",
"(",
"'ls-files'",
",",
"'--ignored'",
",",
"'--exclude-standard'",
",",
... | Returns the list of files being ignored in this repository.
Note that file names, not directories, are returned.
So, we will get the following:
a/b.txt
a/c.txt
instead of just:
a/
Returns:
List[str] - list of ignored files. The paths are absolute... | [
"Returns",
"the",
"list",
"of",
"files",
"being",
"ignored",
"in",
"this",
"repository",
"."
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/vcs/git.py#L123-L143 |
naphatkrit/easyci | easyci/vcs/git.py | GitVcs.path_is_ignored | def path_is_ignored(self, path):
"""Given a path, check if the path would be ignored.
Returns:
boolean
"""
try:
self.run('check-ignore', '--quiet', path)
except CommandError as e:
if e.retcode == 1:
# path is ignored
... | python | def path_is_ignored(self, path):
"""Given a path, check if the path would be ignored.
Returns:
boolean
"""
try:
self.run('check-ignore', '--quiet', path)
except CommandError as e:
if e.retcode == 1:
# path is ignored
... | [
"def",
"path_is_ignored",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"self",
".",
"run",
"(",
"'check-ignore'",
",",
"'--quiet'",
",",
"path",
")",
"except",
"CommandError",
"as",
"e",
":",
"if",
"e",
".",
"retcode",
"==",
"1",
":",
"# path is ign... | Given a path, check if the path would be ignored.
Returns:
boolean | [
"Given",
"a",
"path",
"check",
"if",
"the",
"path",
"would",
"be",
"ignored",
"."
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/vcs/git.py#L155-L170 |
etgalloway/newtabmagic | newtabmagic.py | _get_object_pydoc_page_name | def _get_object_pydoc_page_name(obj):
"""Returns fully qualified name, including module name, except for the
built-in module."""
page_name = fullqualname.fullqualname(obj)
if page_name is not None:
page_name = _remove_builtin_prefix(page_name)
return page_name | python | def _get_object_pydoc_page_name(obj):
"""Returns fully qualified name, including module name, except for the
built-in module."""
page_name = fullqualname.fullqualname(obj)
if page_name is not None:
page_name = _remove_builtin_prefix(page_name)
return page_name | [
"def",
"_get_object_pydoc_page_name",
"(",
"obj",
")",
":",
"page_name",
"=",
"fullqualname",
".",
"fullqualname",
"(",
"obj",
")",
"if",
"page_name",
"is",
"not",
"None",
":",
"page_name",
"=",
"_remove_builtin_prefix",
"(",
"page_name",
")",
"return",
"page_na... | Returns fully qualified name, including module name, except for the
built-in module. | [
"Returns",
"fully",
"qualified",
"name",
"including",
"module",
"name",
"except",
"for",
"the",
"built",
"-",
"in",
"module",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L242-L248 |
etgalloway/newtabmagic | newtabmagic.py | _remove_builtin_prefix | def _remove_builtin_prefix(name):
"""Strip name of builtin module from start of name."""
if name.startswith('builtins.'):
return name[len('builtins.'):]
elif name.startswith('__builtin__.'):
return name[len('__builtin__.'):]
return name | python | def _remove_builtin_prefix(name):
"""Strip name of builtin module from start of name."""
if name.startswith('builtins.'):
return name[len('builtins.'):]
elif name.startswith('__builtin__.'):
return name[len('__builtin__.'):]
return name | [
"def",
"_remove_builtin_prefix",
"(",
"name",
")",
":",
"if",
"name",
".",
"startswith",
"(",
"'builtins.'",
")",
":",
"return",
"name",
"[",
"len",
"(",
"'builtins.'",
")",
":",
"]",
"elif",
"name",
".",
"startswith",
"(",
"'__builtin__.'",
")",
":",
"r... | Strip name of builtin module from start of name. | [
"Strip",
"name",
"of",
"builtin",
"module",
"from",
"start",
"of",
"name",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L251-L257 |
etgalloway/newtabmagic | newtabmagic.py | _get_user_ns_object | def _get_user_ns_object(shell, path):
"""Get object from the user namespace, given a path containing
zero or more dots. Return None if the path is not valid.
"""
parts = path.split('.', 1)
name, attr = parts[0], parts[1:]
if name in shell.user_ns:
if attr:
try:
... | python | def _get_user_ns_object(shell, path):
"""Get object from the user namespace, given a path containing
zero or more dots. Return None if the path is not valid.
"""
parts = path.split('.', 1)
name, attr = parts[0], parts[1:]
if name in shell.user_ns:
if attr:
try:
... | [
"def",
"_get_user_ns_object",
"(",
"shell",
",",
"path",
")",
":",
"parts",
"=",
"path",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"name",
",",
"attr",
"=",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
":",
"]",
"if",
"name",
"in",
"shell",
"... | Get object from the user namespace, given a path containing
zero or more dots. Return None if the path is not valid. | [
"Get",
"object",
"from",
"the",
"user",
"namespace",
"given",
"a",
"path",
"containing",
"zero",
"or",
"more",
"dots",
".",
"Return",
"None",
"if",
"the",
"path",
"is",
"not",
"valid",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L260-L274 |
etgalloway/newtabmagic | newtabmagic.py | _stop_process | def _stop_process(p, name):
"""Stop process, by applying terminate and kill."""
# Based on code in IPython.core.magics.script.ScriptMagics.shebang
if p.poll() is not None:
print("{} is already stopped.".format(name))
return
p.terminate()
time.sleep(0.1)
if p.poll() is not None:
... | python | def _stop_process(p, name):
"""Stop process, by applying terminate and kill."""
# Based on code in IPython.core.magics.script.ScriptMagics.shebang
if p.poll() is not None:
print("{} is already stopped.".format(name))
return
p.terminate()
time.sleep(0.1)
if p.poll() is not None:
... | [
"def",
"_stop_process",
"(",
"p",
",",
"name",
")",
":",
"# Based on code in IPython.core.magics.script.ScriptMagics.shebang",
"if",
"p",
".",
"poll",
"(",
")",
"is",
"not",
"None",
":",
"print",
"(",
"\"{} is already stopped.\"",
".",
"format",
"(",
"name",
")",
... | Stop process, by applying terminate and kill. | [
"Stop",
"process",
"by",
"applying",
"terminate",
"and",
"kill",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L285-L297 |
etgalloway/newtabmagic | newtabmagic.py | pydoc_cli_monkey_patched | def pydoc_cli_monkey_patched(port):
"""In Python 3, run pydoc.cli with builtins.input monkey-patched
so that pydoc can be run as a process.
"""
# Monkey-patch input so that input does not raise EOFError when
# called by pydoc.cli
def input(_): # pylint: disable=W0622
"""Monkey-patched ... | python | def pydoc_cli_monkey_patched(port):
"""In Python 3, run pydoc.cli with builtins.input monkey-patched
so that pydoc can be run as a process.
"""
# Monkey-patch input so that input does not raise EOFError when
# called by pydoc.cli
def input(_): # pylint: disable=W0622
"""Monkey-patched ... | [
"def",
"pydoc_cli_monkey_patched",
"(",
"port",
")",
":",
"# Monkey-patch input so that input does not raise EOFError when",
"# called by pydoc.cli",
"def",
"input",
"(",
"_",
")",
":",
"# pylint: disable=W0622",
"\"\"\"Monkey-patched version of builtins.input\"\"\"",
"while",
"1",... | In Python 3, run pydoc.cli with builtins.input monkey-patched
so that pydoc can be run as a process. | [
"In",
"Python",
"3",
"run",
"pydoc",
".",
"cli",
"with",
"builtins",
".",
"input",
"monkey",
"-",
"patched",
"so",
"that",
"pydoc",
"can",
"be",
"run",
"as",
"a",
"process",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L300-L315 |
etgalloway/newtabmagic | newtabmagic.py | start_server_background | def start_server_background(port):
"""Start the newtab server as a background process."""
if sys.version_info[0] == 2:
lines = ('import pydoc\n'
'pydoc.serve({port})')
cell = lines.format(port=port)
else:
# The location of newtabmagic (normally $IPYTHONDIR/extension... | python | def start_server_background(port):
"""Start the newtab server as a background process."""
if sys.version_info[0] == 2:
lines = ('import pydoc\n'
'pydoc.serve({port})')
cell = lines.format(port=port)
else:
# The location of newtabmagic (normally $IPYTHONDIR/extension... | [
"def",
"start_server_background",
"(",
"port",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"lines",
"=",
"(",
"'import pydoc\\n'",
"'pydoc.serve({port})'",
")",
"cell",
"=",
"lines",
".",
"format",
"(",
"port",
"=",
"port",
... | Start the newtab server as a background process. | [
"Start",
"the",
"newtab",
"server",
"as",
"a",
"background",
"process",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L318-L341 |
etgalloway/newtabmagic | newtabmagic.py | _port_not_in_use | def _port_not_in_use():
"""Use the port 0 trick to find a port not in use."""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 0
s.bind(('', port))
_, port = s.getsockname()
return port | python | def _port_not_in_use():
"""Use the port 0 trick to find a port not in use."""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 0
s.bind(('', port))
_, port = s.getsockname()
return port | [
"def",
"_port_not_in_use",
"(",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"port",
"=",
"0",
"s",
".",
"bind",
"(",
"(",
"''",
",",
"port",
")",
")",
"_",
",",
"port",
"=",
... | Use the port 0 trick to find a port not in use. | [
"Use",
"the",
"port",
"0",
"trick",
"to",
"find",
"a",
"port",
"not",
"in",
"use",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L344-L350 |
etgalloway/newtabmagic | newtabmagic.py | ServerProcess.start | def start(self):
"""Start server if not previously started."""
msg = ''
if not self.running():
if self._port == 0:
self._port = _port_not_in_use()
self._process = start_server_background(self._port)
else:
msg = 'Server already started\n... | python | def start(self):
"""Start server if not previously started."""
msg = ''
if not self.running():
if self._port == 0:
self._port = _port_not_in_use()
self._process = start_server_background(self._port)
else:
msg = 'Server already started\n... | [
"def",
"start",
"(",
"self",
")",
":",
"msg",
"=",
"''",
"if",
"not",
"self",
".",
"running",
"(",
")",
":",
"if",
"self",
".",
"_port",
"==",
"0",
":",
"self",
".",
"_port",
"=",
"_port_not_in_use",
"(",
")",
"self",
".",
"_process",
"=",
"start... | Start server if not previously started. | [
"Start",
"server",
"if",
"not",
"previously",
"started",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L173-L183 |
etgalloway/newtabmagic | newtabmagic.py | ServerProcess.read | def read(self):
"""Read stdout and stdout pipes if process is no longer running."""
if self._process and self._process.poll() is not None:
ip = get_ipython()
err = ip.user_ns['error'].read().decode()
out = ip.user_ns['output'].read().decode()
else:
... | python | def read(self):
"""Read stdout and stdout pipes if process is no longer running."""
if self._process and self._process.poll() is not None:
ip = get_ipython()
err = ip.user_ns['error'].read().decode()
out = ip.user_ns['output'].read().decode()
else:
... | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"self",
".",
"_process",
"and",
"self",
".",
"_process",
".",
"poll",
"(",
")",
"is",
"not",
"None",
":",
"ip",
"=",
"get_ipython",
"(",
")",
"err",
"=",
"ip",
".",
"user_ns",
"[",
"'error'",
"]",
".",
... | Read stdout and stdout pipes if process is no longer running. | [
"Read",
"stdout",
"and",
"stdout",
"pipes",
"if",
"process",
"is",
"no",
"longer",
"running",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L185-L194 |
etgalloway/newtabmagic | newtabmagic.py | ServerProcess.stop | def stop(self):
"""Stop server process."""
msg = ''
if self._process:
_stop_process(self._process, 'Server process')
else:
msg += 'Server not started.\n'
if msg:
print(msg, end='') | python | def stop(self):
"""Stop server process."""
msg = ''
if self._process:
_stop_process(self._process, 'Server process')
else:
msg += 'Server not started.\n'
if msg:
print(msg, end='') | [
"def",
"stop",
"(",
"self",
")",
":",
"msg",
"=",
"''",
"if",
"self",
".",
"_process",
":",
"_stop_process",
"(",
"self",
".",
"_process",
",",
"'Server process'",
")",
"else",
":",
"msg",
"+=",
"'Server not started.\\n'",
"if",
"msg",
":",
"print",
"(",... | Stop server process. | [
"Stop",
"server",
"process",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L196-L205 |
etgalloway/newtabmagic | newtabmagic.py | ServerProcess.show | def show(self):
"""Show state."""
msg = ''
if self._process:
msg += 'server pid: {}\n'.format(self._process.pid)
msg += 'server poll: {}\n'.format(self._process.poll())
msg += 'server running: {}\n'.format(self.running())
msg += 'server port: {}\n'.format(... | python | def show(self):
"""Show state."""
msg = ''
if self._process:
msg += 'server pid: {}\n'.format(self._process.pid)
msg += 'server poll: {}\n'.format(self._process.poll())
msg += 'server running: {}\n'.format(self.running())
msg += 'server port: {}\n'.format(... | [
"def",
"show",
"(",
"self",
")",
":",
"msg",
"=",
"''",
"if",
"self",
".",
"_process",
":",
"msg",
"+=",
"'server pid: {}\\n'",
".",
"format",
"(",
"self",
".",
"_process",
".",
"pid",
")",
"msg",
"+=",
"'server poll: {}\\n'",
".",
"format",
"(",
"self... | Show state. | [
"Show",
"state",
"."
] | train | https://github.com/etgalloway/newtabmagic/blob/7d5e88654ed7dc564f42d4e6aadb0b6e92d38bd6/newtabmagic.py#L211-L220 |
mqopen/mqreceive | mqreceive/receiving.py | BrokerThreadManager.start | def start(self):
"""!
Start all receiving threads.
"""
if self.isThreadsRunning:
raise ThreadManagerException("Broker threads are already running")
self.isThreadsRunning = True
for client in self.clients:
threading.Thread(target = client).start() | python | def start(self):
"""!
Start all receiving threads.
"""
if self.isThreadsRunning:
raise ThreadManagerException("Broker threads are already running")
self.isThreadsRunning = True
for client in self.clients:
threading.Thread(target = client).start() | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"isThreadsRunning",
":",
"raise",
"ThreadManagerException",
"(",
"\"Broker threads are already running\"",
")",
"self",
".",
"isThreadsRunning",
"=",
"True",
"for",
"client",
"in",
"self",
".",
"clients",
... | !
Start all receiving threads. | [
"!",
"Start",
"all",
"receiving",
"threads",
"."
] | train | https://github.com/mqopen/mqreceive/blob/cb35b5d0ab89a9af4217ab88ab9e8953c80d10bf/mqreceive/receiving.py#L50-L58 |
mqopen/mqreceive | mqreceive/receiving.py | BrokerThreadManager.stop | def stop(self):
"""!
Stop all receving threads.
"""
if not self.isThreadsRunning:
raise ThreadManagerException("Broker threads are already stopped")
self.isThreadsRunning = False
for client in self.clients:
client.stop() | python | def stop(self):
"""!
Stop all receving threads.
"""
if not self.isThreadsRunning:
raise ThreadManagerException("Broker threads are already stopped")
self.isThreadsRunning = False
for client in self.clients:
client.stop() | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"isThreadsRunning",
":",
"raise",
"ThreadManagerException",
"(",
"\"Broker threads are already stopped\"",
")",
"self",
".",
"isThreadsRunning",
"=",
"False",
"for",
"client",
"in",
"self",
".",
"cl... | !
Stop all receving threads. | [
"!",
"Stop",
"all",
"receving",
"threads",
"."
] | train | https://github.com/mqopen/mqreceive/blob/cb35b5d0ab89a9af4217ab88ab9e8953c80d10bf/mqreceive/receiving.py#L60-L68 |
mqopen/mqreceive | mqreceive/receiving.py | BrokerReceiver.onConnect | def onConnect(self, client, userdata, flags, rc):
"""!
The callback for when the client receives a CONNACK response from the server.
@param client
@param userdata
@param flags
@param rc
"""
for sub in self.subsciption:
(result, mid) = self.cli... | python | def onConnect(self, client, userdata, flags, rc):
"""!
The callback for when the client receives a CONNACK response from the server.
@param client
@param userdata
@param flags
@param rc
"""
for sub in self.subsciption:
(result, mid) = self.cli... | [
"def",
"onConnect",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"flags",
",",
"rc",
")",
":",
"for",
"sub",
"in",
"self",
".",
"subsciption",
":",
"(",
"result",
",",
"mid",
")",
"=",
"self",
".",
"client",
".",
"subscribe",
"(",
"sub",
")"
] | !
The callback for when the client receives a CONNACK response from the server.
@param client
@param userdata
@param flags
@param rc | [
"!",
"The",
"callback",
"for",
"when",
"the",
"client",
"receives",
"a",
"CONNACK",
"response",
"from",
"the",
"server",
"."
] | train | https://github.com/mqopen/mqreceive/blob/cb35b5d0ab89a9af4217ab88ab9e8953c80d10bf/mqreceive/receiving.py#L151-L161 |
mqopen/mqreceive | mqreceive/receiving.py | BrokerReceiver.onMessage | def onMessage(self, client, userdata, msg):
"""!
The callback for when a PUBLISH message is received from the server.
@param client
@param userdata
@param msg
"""
dataIdentifier = DataIdentifier(self.broker, msg.topic)
self.dataHandler.onNewData(dataIdent... | python | def onMessage(self, client, userdata, msg):
"""!
The callback for when a PUBLISH message is received from the server.
@param client
@param userdata
@param msg
"""
dataIdentifier = DataIdentifier(self.broker, msg.topic)
self.dataHandler.onNewData(dataIdent... | [
"def",
"onMessage",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"msg",
")",
":",
"dataIdentifier",
"=",
"DataIdentifier",
"(",
"self",
".",
"broker",
",",
"msg",
".",
"topic",
")",
"self",
".",
"dataHandler",
".",
"onNewData",
"(",
"dataIdentifier",
... | !
The callback for when a PUBLISH message is received from the server.
@param client
@param userdata
@param msg | [
"!",
"The",
"callback",
"for",
"when",
"a",
"PUBLISH",
"message",
"is",
"received",
"from",
"the",
"server",
"."
] | train | https://github.com/mqopen/mqreceive/blob/cb35b5d0ab89a9af4217ab88ab9e8953c80d10bf/mqreceive/receiving.py#L172-L181 |
mqopen/mqreceive | mqreceive/receiving.py | BrokerReceiverIDManager.createReceiverID | def createReceiverID(self):
"""!
Create new receiver ID.
@return Receiver ID.
"""
_receiverID = self.receiverCounter
self.receiverCounter += 1
return BrokerReceiverID(self.hostname, self.pid, _receiverID) | python | def createReceiverID(self):
"""!
Create new receiver ID.
@return Receiver ID.
"""
_receiverID = self.receiverCounter
self.receiverCounter += 1
return BrokerReceiverID(self.hostname, self.pid, _receiverID) | [
"def",
"createReceiverID",
"(",
"self",
")",
":",
"_receiverID",
"=",
"self",
".",
"receiverCounter",
"self",
".",
"receiverCounter",
"+=",
"1",
"return",
"BrokerReceiverID",
"(",
"self",
".",
"hostname",
",",
"self",
".",
"pid",
",",
"_receiverID",
")"
] | !
Create new receiver ID.
@return Receiver ID. | [
"!",
"Create",
"new",
"receiver",
"ID",
"."
] | train | https://github.com/mqopen/mqreceive/blob/cb35b5d0ab89a9af4217ab88ab9e8953c80d10bf/mqreceive/receiving.py#L282-L290 |
ionata/dj-core-drf | dj_core_drf/metadata.py | ModelChoicesMetadata.determine_actions | def determine_actions(self, request, view):
"""Allow all allowed methods"""
from rest_framework.generics import GenericAPIView
actions = {}
excluded_methods = {'HEAD', 'OPTIONS', 'PATCH', 'DELETE'}
for method in set(view.allowed_methods) - excluded_methods:
view.reque... | python | def determine_actions(self, request, view):
"""Allow all allowed methods"""
from rest_framework.generics import GenericAPIView
actions = {}
excluded_methods = {'HEAD', 'OPTIONS', 'PATCH', 'DELETE'}
for method in set(view.allowed_methods) - excluded_methods:
view.reque... | [
"def",
"determine_actions",
"(",
"self",
",",
"request",
",",
"view",
")",
":",
"from",
"rest_framework",
".",
"generics",
"import",
"GenericAPIView",
"actions",
"=",
"{",
"}",
"excluded_methods",
"=",
"{",
"'HEAD'",
",",
"'OPTIONS'",
",",
"'PATCH'",
",",
"'... | Allow all allowed methods | [
"Allow",
"all",
"allowed",
"methods"
] | train | https://github.com/ionata/dj-core-drf/blob/c0fa709b8167d4888a3311fe3ebee1c6a288a7b0/dj_core_drf/metadata.py#L29-L59 |
praekelt/vumi-http-api | vumi_http_api/resource.py | MsgCheckHelpers.is_within_content_length_limit | def is_within_content_length_limit(payload, api_config):
"""
Check that the message content is within the configured length limit.
"""
length_limit = api_config.get('content_length_limit')
if (length_limit is not None) and (payload["content"] is not None):
content_len... | python | def is_within_content_length_limit(payload, api_config):
"""
Check that the message content is within the configured length limit.
"""
length_limit = api_config.get('content_length_limit')
if (length_limit is not None) and (payload["content"] is not None):
content_len... | [
"def",
"is_within_content_length_limit",
"(",
"payload",
",",
"api_config",
")",
":",
"length_limit",
"=",
"api_config",
".",
"get",
"(",
"'content_length_limit'",
")",
"if",
"(",
"length_limit",
"is",
"not",
"None",
")",
"and",
"(",
"payload",
"[",
"\"content\"... | Check that the message content is within the configured length limit. | [
"Check",
"that",
"the",
"message",
"content",
"is",
"within",
"the",
"configured",
"length",
"limit",
"."
] | train | https://github.com/praekelt/vumi-http-api/blob/0d7cf1cb71794c93272c19095cf8c37f4c250a59/vumi_http_api/resource.py#L105-L115 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | handle_durability | def handle_durability(parent, **kwargs):
"""
Handle durability requirements passed inside options
:param parent: The parent bucket import
:param kwargs: The arguments
:return: A tuple of `(found, persist_to, replicate_to)`. The first
element is True if either persistence or replication has been
... | python | def handle_durability(parent, **kwargs):
"""
Handle durability requirements passed inside options
:param parent: The parent bucket import
:param kwargs: The arguments
:return: A tuple of `(found, persist_to, replicate_to)`. The first
element is True if either persistence or replication has been
... | [
"def",
"handle_durability",
"(",
"parent",
",",
"*",
"*",
"kwargs",
")",
":",
"persist_to",
"=",
"kwargs",
".",
"get",
"(",
"'persist_to'",
")",
"replicate_to",
"=",
"kwargs",
".",
"get",
"(",
"'replicate_to'",
")",
"if",
"not",
"persist_to",
"and",
"not",... | Handle durability requirements passed inside options
:param parent: The parent bucket import
:param kwargs: The arguments
:return: A tuple of `(found, persist_to, replicate_to)`. The first
element is True if either persistence or replication has been
found | [
"Handle",
"durability",
"requirements",
"passed",
"inside",
"options",
":",
"param",
"parent",
":",
"The",
"parent",
"bucket",
"import",
":",
"param",
"kwargs",
":",
"The",
"arguments",
":",
"return",
":",
"A",
"tuple",
"of",
"(",
"found",
"persist_to",
"rep... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L20-L43 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | create_key | def create_key(tc, pykey):
"""
Creates a C key from a Python key
:param tc: The transcoder to use
:param pykey: The python key to encode
:return: A tuple of `encoded_key, encoded_length`
"""
try:
k_enc = tc.encode_key(pykey)
if not k_enc:
if not pykey:
... | python | def create_key(tc, pykey):
"""
Creates a C key from a Python key
:param tc: The transcoder to use
:param pykey: The python key to encode
:return: A tuple of `encoded_key, encoded_length`
"""
try:
k_enc = tc.encode_key(pykey)
if not k_enc:
if not pykey:
... | [
"def",
"create_key",
"(",
"tc",
",",
"pykey",
")",
":",
"try",
":",
"k_enc",
"=",
"tc",
".",
"encode_key",
"(",
"pykey",
")",
"if",
"not",
"k_enc",
":",
"if",
"not",
"pykey",
":",
"excls",
"=",
"ArgumentError",
"else",
":",
"excls",
"=",
"ValueFormat... | Creates a C key from a Python key
:param tc: The transcoder to use
:param pykey: The python key to encode
:return: A tuple of `encoded_key, encoded_length` | [
"Creates",
"a",
"C",
"key",
"from",
"a",
"Python",
"key",
":",
"param",
"tc",
":",
"The",
"transcoder",
"to",
"use",
":",
"param",
"pykey",
":",
"The",
"python",
"key",
"to",
"encode",
":",
"return",
":",
"A",
"tuple",
"of",
"encoded_key",
"encoded_len... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L46-L68 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | get_option | def get_option(name, key_options, global_options, default=None):
"""
Search the key-specific options and the global options for a given
setting. Either dictionary may be None.
This will first search the key settings and then the global settings.
:param name: The setting to search for
:param ke... | python | def get_option(name, key_options, global_options, default=None):
"""
Search the key-specific options and the global options for a given
setting. Either dictionary may be None.
This will first search the key settings and then the global settings.
:param name: The setting to search for
:param ke... | [
"def",
"get_option",
"(",
"name",
",",
"key_options",
",",
"global_options",
",",
"default",
"=",
"None",
")",
":",
"if",
"key_options",
":",
"try",
":",
"return",
"key_options",
"[",
"name",
"]",
"except",
"KeyError",
":",
"pass",
"if",
"global_options",
... | Search the key-specific options and the global options for a given
setting. Either dictionary may be None.
This will first search the key settings and then the global settings.
:param name: The setting to search for
:param key_options: The item specific settings
:param global_options: General meth... | [
"Search",
"the",
"key",
"-",
"specific",
"options",
"and",
"the",
"global",
"options",
"for",
"a",
"given",
"setting",
".",
"Either",
"dictionary",
"may",
"be",
"None",
"."
] | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L71-L94 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | set_quiet | def set_quiet(mres, parent, global_options):
"""
Sets the 'quiet' property on the MultiResult
"""
quiet = global_options.get('quiet')
if quiet is not None:
mres._quiet = quiet
else:
mres._quiet = parent.quiet | python | def set_quiet(mres, parent, global_options):
"""
Sets the 'quiet' property on the MultiResult
"""
quiet = global_options.get('quiet')
if quiet is not None:
mres._quiet = quiet
else:
mres._quiet = parent.quiet | [
"def",
"set_quiet",
"(",
"mres",
",",
"parent",
",",
"global_options",
")",
":",
"quiet",
"=",
"global_options",
".",
"get",
"(",
"'quiet'",
")",
"if",
"quiet",
"is",
"not",
"None",
":",
"mres",
".",
"_quiet",
"=",
"quiet",
"else",
":",
"mres",
".",
... | Sets the 'quiet' property on the MultiResult | [
"Sets",
"the",
"quiet",
"property",
"on",
"the",
"MultiResult"
] | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L97-L105 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | get_cas | def get_cas(key_options, global_options, item):
"""
Get the CAS from various inputs. This will properly honor
the ``ignore_cas`` flag, if present.
:param key_options: Key specific options
:param global_options: Global options
:param item: The item
:return: The cas, or 0 if no cas
"""
... | python | def get_cas(key_options, global_options, item):
"""
Get the CAS from various inputs. This will properly honor
the ``ignore_cas`` flag, if present.
:param key_options: Key specific options
:param global_options: Global options
:param item: The item
:return: The cas, or 0 if no cas
"""
... | [
"def",
"get_cas",
"(",
"key_options",
",",
"global_options",
",",
"item",
")",
":",
"if",
"item",
":",
"ign_cas",
"=",
"get_option",
"(",
"'ignore_cas'",
",",
"key_options",
",",
"globals",
"(",
")",
",",
"False",
")",
"return",
"0",
"if",
"ign_cas",
"el... | Get the CAS from various inputs. This will properly honor
the ``ignore_cas`` flag, if present.
:param key_options: Key specific options
:param global_options: Global options
:param item: The item
:return: The cas, or 0 if no cas | [
"Get",
"the",
"CAS",
"from",
"various",
"inputs",
".",
"This",
"will",
"properly",
"honor",
"the",
"ignore_cas",
"flag",
"if",
"present",
"."
] | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L108-L131 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | process_opres_input | def process_opres_input(key, value, key_options):
"""
Check if `value` or `key` is a Result object and populate the
options accordingly.
:param key:
:param value:
:param key_options:
:return:
"""
opres = None
if isinstance(value, OperationResult):
opres = value
elif ... | python | def process_opres_input(key, value, key_options):
"""
Check if `value` or `key` is a Result object and populate the
options accordingly.
:param key:
:param value:
:param key_options:
:return:
"""
opres = None
if isinstance(value, OperationResult):
opres = value
elif ... | [
"def",
"process_opres_input",
"(",
"key",
",",
"value",
",",
"key_options",
")",
":",
"opres",
"=",
"None",
"if",
"isinstance",
"(",
"value",
",",
"OperationResult",
")",
":",
"opres",
"=",
"value",
"elif",
"isinstance",
"(",
"key",
",",
"OperationResult",
... | Check if `value` or `key` is a Result object and populate the
options accordingly.
:param key:
:param value:
:param key_options:
:return: | [
"Check",
"if",
"value",
"or",
"key",
"is",
"a",
"Result",
"object",
"and",
"populate",
"the",
"options",
"accordingly",
".",
":",
"param",
"key",
":",
":",
"param",
"value",
":",
":",
"param",
"key_options",
":",
":",
"return",
":"
] | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L134-L155 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | get_ttl | def get_ttl(key_options, global_options, *_):
"""
Quick function to extract the expiration time from options. Throws
appropriate exceptions when necessary
:param key_options:
:param global_options:
:return:
"""
ttl = get_option('ttl', key_options, global_options)
if ttl is None or tt... | python | def get_ttl(key_options, global_options, *_):
"""
Quick function to extract the expiration time from options. Throws
appropriate exceptions when necessary
:param key_options:
:param global_options:
:return:
"""
ttl = get_option('ttl', key_options, global_options)
if ttl is None or tt... | [
"def",
"get_ttl",
"(",
"key_options",
",",
"global_options",
",",
"*",
"_",
")",
":",
"ttl",
"=",
"get_option",
"(",
"'ttl'",
",",
"key_options",
",",
"global_options",
")",
"if",
"ttl",
"is",
"None",
"or",
"ttl",
"==",
"0",
":",
"return",
"0",
"try",
... | Quick function to extract the expiration time from options. Throws
appropriate exceptions when necessary
:param key_options:
:param global_options:
:return: | [
"Quick",
"function",
"to",
"extract",
"the",
"expiration",
"time",
"from",
"options",
".",
"Throws",
"appropriate",
"exceptions",
"when",
"necessary",
":",
"param",
"key_options",
":",
":",
"param",
"global_options",
":",
":",
"return",
":"
] | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L158-L180 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | BaseExecutor.make_result | def make_result(self, key, value):
"""
Makes a single result which is then stored in the multi result object
:param key: The actual key for the command
:param value: The value passed (may be None)
:return: A result object
"""
v = OperationResult()
v.key = ... | python | def make_result(self, key, value):
"""
Makes a single result which is then stored in the multi result object
:param key: The actual key for the command
:param value: The value passed (may be None)
:return: A result object
"""
v = OperationResult()
v.key = ... | [
"def",
"make_result",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"v",
"=",
"OperationResult",
"(",
")",
"v",
".",
"key",
"=",
"key",
"return",
"v"
] | Makes a single result which is then stored in the multi result object
:param key: The actual key for the command
:param value: The value passed (may be None)
:return: A result object | [
"Makes",
"a",
"single",
"result",
"which",
"is",
"then",
"stored",
"in",
"the",
"multi",
"result",
"object",
":",
"param",
"key",
":",
"The",
"actual",
"key",
"for",
"the",
"command",
":",
"param",
"value",
":",
"The",
"value",
"passed",
"(",
"may",
"b... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L227-L236 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | BaseExecutor.submit_single | def submit_single(self, c_key, c_len, value, item, key_options, global_options, mres):
"""
Submit a single item
:param c_key: The pointer to the key
:param c_len: The length of the key
:param value: The value object. May be None
:param item: The Item. May be None
... | python | def submit_single(self, c_key, c_len, value, item, key_options, global_options, mres):
"""
Submit a single item
:param c_key: The pointer to the key
:param c_len: The length of the key
:param value: The value object. May be None
:param item: The Item. May be None
... | [
"def",
"submit_single",
"(",
"self",
",",
"c_key",
",",
"c_len",
",",
"value",
",",
"item",
",",
"key_options",
",",
"global_options",
",",
"mres",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Submit a single item
:param c_key: The pointer to the key
:param c_len: The length of the key
:param value: The value object. May be None
:param item: The Item. May be None
:param key_options: Key-specific options (may be None)
:param global_options: Global options for th... | [
"Submit",
"a",
"single",
"item",
":",
"param",
"c_key",
":",
"The",
"pointer",
"to",
"the",
"key",
":",
"param",
"c_len",
":",
"The",
"length",
"of",
"the",
"key",
":",
"param",
"value",
":",
"The",
"value",
"object",
".",
"May",
"be",
"None",
":",
... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L274-L286 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | BaseExecutor._invoke_submit | def _invoke_submit(self, iterobj, is_dict, is_itmcoll, mres, global_kw):
"""
Internal function to invoke the actual submit_single function
:param iterobj: The raw object returned as the next item of the iterator
:param is_dict: True if iterator is a dictionary
:param is_itmcoll: ... | python | def _invoke_submit(self, iterobj, is_dict, is_itmcoll, mres, global_kw):
"""
Internal function to invoke the actual submit_single function
:param iterobj: The raw object returned as the next item of the iterator
:param is_dict: True if iterator is a dictionary
:param is_itmcoll: ... | [
"def",
"_invoke_submit",
"(",
"self",
",",
"iterobj",
",",
"is_dict",
",",
"is_itmcoll",
",",
"mres",
",",
"global_kw",
")",
":",
"if",
"is_itmcoll",
":",
"item",
",",
"key_options",
"=",
"next",
"(",
"iterobj",
")",
"key",
"=",
"item",
".",
"key",
"va... | Internal function to invoke the actual submit_single function
:param iterobj: The raw object returned as the next item of the iterator
:param is_dict: True if iterator is a dictionary
:param is_itmcoll: True if the iterator contains Item objects
:param mres: The multi result object
... | [
"Internal",
"function",
"to",
"invoke",
"the",
"actual",
"submit_single",
"function",
":",
"param",
"iterobj",
":",
"The",
"raw",
"object",
"returned",
"as",
"the",
"next",
"item",
"of",
"the",
"iterator",
":",
"param",
"is_dict",
":",
"True",
"if",
"iterato... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L288-L333 |
ardydedase/pycouchbase | couchbase-python-cffi/couchbase_ffi/executors.py | BaseExecutor.execute | def execute(self, kv, **kwargs):
"""
Execute the operation scheduling items as needed
:param kv: An iterable of keys (or key-values, or Items)
:param kwargs: Settings for the operation
:return: A MultiResult object
"""
self._verify_iter(kv)
if not len(kv):... | python | def execute(self, kv, **kwargs):
"""
Execute the operation scheduling items as needed
:param kv: An iterable of keys (or key-values, or Items)
:param kwargs: Settings for the operation
:return: A MultiResult object
"""
self._verify_iter(kv)
if not len(kv):... | [
"def",
"execute",
"(",
"self",
",",
"kv",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_verify_iter",
"(",
"kv",
")",
"if",
"not",
"len",
"(",
"kv",
")",
":",
"raise",
"ArgumentError",
".",
"pyexc",
"(",
"obj",
"=",
"kv",
",",
"message",
"=",... | Execute the operation scheduling items as needed
:param kv: An iterable of keys (or key-values, or Items)
:param kwargs: Settings for the operation
:return: A MultiResult object | [
"Execute",
"the",
"operation",
"scheduling",
"items",
"as",
"needed",
":",
"param",
"kv",
":",
"An",
"iterable",
"of",
"keys",
"(",
"or",
"key",
"-",
"values",
"or",
"Items",
")",
":",
"param",
"kwargs",
":",
"Settings",
"for",
"the",
"operation",
":",
... | train | https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/couchbase-python-cffi/couchbase_ffi/executors.py#L335-L382 |
roaet/eh | eh/cli.py | main | def main(context, subject, debug, no_colors):
"""
Eh is a terminal program that will provide you with
quick reminders about a subject.
To get started run: eh help
To figure out what eh knows about run: eh list
To update the list of subjects: eh update
Note:
Eh will make a directory ... | python | def main(context, subject, debug, no_colors):
"""
Eh is a terminal program that will provide you with
quick reminders about a subject.
To get started run: eh help
To figure out what eh knows about run: eh list
To update the list of subjects: eh update
Note:
Eh will make a directory ... | [
"def",
"main",
"(",
"context",
",",
"subject",
",",
"debug",
",",
"no_colors",
")",
":",
"eho",
"=",
"Eh",
"(",
"debug",
",",
"no_colors",
")",
"if",
"subject",
"==",
"'list'",
":",
"eho",
".",
"subject_list",
"(",
")",
"exit",
"(",
"0",
")",
"if",... | Eh is a terminal program that will provide you with
quick reminders about a subject.
To get started run: eh help
To figure out what eh knows about run: eh list
To update the list of subjects: eh update
Note:
Eh will make a directory in your userhome called .eh
where it will store downlo... | [
"Eh",
"is",
"a",
"terminal",
"program",
"that",
"will",
"provide",
"you",
"with",
"quick",
"reminders",
"about",
"a",
"subject",
"."
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/cli.py#L167-L191 |
JHowell45/helium-cli | helium/utility_functions/json_functions.py | store_data | def store_data(data):
"""Use this function to store data in a JSON file.
This function is used for loading up a JSON file and appending additional
data to the JSON file.
:param data: the data to add to the JSON file.
:type data: dict
"""
with open(url_json_path) as json_file:
try:
... | python | def store_data(data):
"""Use this function to store data in a JSON file.
This function is used for loading up a JSON file and appending additional
data to the JSON file.
:param data: the data to add to the JSON file.
:type data: dict
"""
with open(url_json_path) as json_file:
try:
... | [
"def",
"store_data",
"(",
"data",
")",
":",
"with",
"open",
"(",
"url_json_path",
")",
"as",
"json_file",
":",
"try",
":",
"json_file_data",
"=",
"load",
"(",
"json_file",
")",
"json_file_data",
".",
"update",
"(",
"data",
")",
"except",
"(",
"AttributeErr... | Use this function to store data in a JSON file.
This function is used for loading up a JSON file and appending additional
data to the JSON file.
:param data: the data to add to the JSON file.
:type data: dict | [
"Use",
"this",
"function",
"to",
"store",
"data",
"in",
"a",
"JSON",
"file",
"."
] | train | https://github.com/JHowell45/helium-cli/blob/8decc2f410a17314440eeed411a4b19dd4b4e780/helium/utility_functions/json_functions.py#L10-L26 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.default_to_hashed_rows | def default_to_hashed_rows(self, default=None):
""" Gets the current setting with no parameters, sets it if a boolean is passed in
:param default: the value to set
:return: the current value, or new value if default is set to True or False
"""
if default is not None:
... | python | def default_to_hashed_rows(self, default=None):
""" Gets the current setting with no parameters, sets it if a boolean is passed in
:param default: the value to set
:return: the current value, or new value if default is set to True or False
"""
if default is not None:
... | [
"def",
"default_to_hashed_rows",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"not",
"None",
":",
"self",
".",
"_default_to_hashed_rows",
"=",
"(",
"default",
"is",
"True",
")",
"return",
"self",
".",
"_default_to_hashed_rows"
] | Gets the current setting with no parameters, sets it if a boolean is passed in
:param default: the value to set
:return: the current value, or new value if default is set to True or False | [
"Gets",
"the",
"current",
"setting",
"with",
"no",
"parameters",
"sets",
"it",
"if",
"a",
"boolean",
"is",
"passed",
"in"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L40-L49 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix._update_internal_column_state | def _update_internal_column_state(self, column_names):
""" Update the internal state with some (possibly) new columns
:param column_names: an iterable which contains new column names
"""
for k in column_names:
if k not in self._column_name_idx:
self._column_n... | python | def _update_internal_column_state(self, column_names):
""" Update the internal state with some (possibly) new columns
:param column_names: an iterable which contains new column names
"""
for k in column_names:
if k not in self._column_name_idx:
self._column_n... | [
"def",
"_update_internal_column_state",
"(",
"self",
",",
"column_names",
")",
":",
"for",
"k",
"in",
"column_names",
":",
"if",
"k",
"not",
"in",
"self",
".",
"_column_name_idx",
":",
"self",
".",
"_column_name_idx",
"[",
"k",
"]",
"=",
"len",
"(",
"self"... | Update the internal state with some (possibly) new columns
:param column_names: an iterable which contains new column names | [
"Update",
"the",
"internal",
"state",
"with",
"some",
"(",
"possibly",
")",
"new",
"columns"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L51-L59 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix._add_dict_row | def _add_dict_row(self, feature_dict, key=None):
""" Add a dict row to the matrix
:param str key: key used when rows is a dict rather than an array
:param dict feature_dict: a dictionary of features and weights
"""
self._update_internal_column_state(set(feature_dict.keys()))
... | python | def _add_dict_row(self, feature_dict, key=None):
""" Add a dict row to the matrix
:param str key: key used when rows is a dict rather than an array
:param dict feature_dict: a dictionary of features and weights
"""
self._update_internal_column_state(set(feature_dict.keys()))
... | [
"def",
"_add_dict_row",
"(",
"self",
",",
"feature_dict",
",",
"key",
"=",
"None",
")",
":",
"self",
".",
"_update_internal_column_state",
"(",
"set",
"(",
"feature_dict",
".",
"keys",
"(",
")",
")",
")",
"# reset the row memoization",
"self",
".",
"_row_memo"... | Add a dict row to the matrix
:param str key: key used when rows is a dict rather than an array
:param dict feature_dict: a dictionary of features and weights | [
"Add",
"a",
"dict",
"row",
"to",
"the",
"matrix"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L61-L80 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix._add_list_row | def _add_list_row(self, feature_list, key=None):
""" Add a list row to the matrix
:param str key: key used when rows is a dict rather than an array
:param feature_list: a list of features in the same order as column_names
:raise IndexError: if the list doesnt match the expected number ... | python | def _add_list_row(self, feature_list, key=None):
""" Add a list row to the matrix
:param str key: key used when rows is a dict rather than an array
:param feature_list: a list of features in the same order as column_names
:raise IndexError: if the list doesnt match the expected number ... | [
"def",
"_add_list_row",
"(",
"self",
",",
"feature_list",
",",
"key",
"=",
"None",
")",
":",
"if",
"len",
"(",
"feature_list",
")",
">",
"len",
"(",
"self",
".",
"_column_name_list",
")",
":",
"raise",
"IndexError",
"(",
"\"Input list must have %s columns or l... | Add a list row to the matrix
:param str key: key used when rows is a dict rather than an array
:param feature_list: a list of features in the same order as column_names
:raise IndexError: if the list doesnt match the expected number of columns | [
"Add",
"a",
"list",
"row",
"to",
"the",
"matrix"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L82-L104 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.set_column_names | def set_column_names(self, column_names):
""" Setup the feature vector with some column names
:param column_names: the column names we want
:return:
"""
if len(self._rows):
raise NotImplementedError("You can't manually set columns once data has been added")
s... | python | def set_column_names(self, column_names):
""" Setup the feature vector with some column names
:param column_names: the column names we want
:return:
"""
if len(self._rows):
raise NotImplementedError("You can't manually set columns once data has been added")
s... | [
"def",
"set_column_names",
"(",
"self",
",",
"column_names",
")",
":",
"if",
"len",
"(",
"self",
".",
"_rows",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"You can't manually set columns once data has been added\"",
")",
"self",
".",
"_update_internal_column_state"... | Setup the feature vector with some column names
:param column_names: the column names we want
:return: | [
"Setup",
"the",
"feature",
"vector",
"with",
"some",
"column",
"names",
":",
"param",
"column_names",
":",
"the",
"column",
"names",
"we",
"want",
":",
"return",
":"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L106-L114 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.set_row_names | def set_row_names(self, row_names):
""" Setup the feature vector with some column names
:param row_names: the column names we want
:return:
"""
if self.row_count() != len(row_names) or len(self._row_name_list) > 0 or len(self._row_name_idx) > 0:
raise NotImplementedEr... | python | def set_row_names(self, row_names):
""" Setup the feature vector with some column names
:param row_names: the column names we want
:return:
"""
if self.row_count() != len(row_names) or len(self._row_name_list) > 0 or len(self._row_name_idx) > 0:
raise NotImplementedEr... | [
"def",
"set_row_names",
"(",
"self",
",",
"row_names",
")",
":",
"if",
"self",
".",
"row_count",
"(",
")",
"!=",
"len",
"(",
"row_names",
")",
"or",
"len",
"(",
"self",
".",
"_row_name_list",
")",
">",
"0",
"or",
"len",
"(",
"self",
".",
"_row_name_i... | Setup the feature vector with some column names
:param row_names: the column names we want
:return: | [
"Setup",
"the",
"feature",
"vector",
"with",
"some",
"column",
"names",
":",
"param",
"row_names",
":",
"the",
"column",
"names",
"we",
"want",
":",
"return",
":"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L116-L127 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.add_row | def add_row(self, list_or_dict, key=None):
""" Adds a list or dict as a row in the FVM data structure
:param str key: key used when rows is a dict rather than an array
:param list_or_dict: a feature list or dict
"""
if isinstance(list_or_dict, list):
self._add_list_r... | python | def add_row(self, list_or_dict, key=None):
""" Adds a list or dict as a row in the FVM data structure
:param str key: key used when rows is a dict rather than an array
:param list_or_dict: a feature list or dict
"""
if isinstance(list_or_dict, list):
self._add_list_r... | [
"def",
"add_row",
"(",
"self",
",",
"list_or_dict",
",",
"key",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"list_or_dict",
",",
"list",
")",
":",
"self",
".",
"_add_list_row",
"(",
"list_or_dict",
",",
"key",
")",
"else",
":",
"self",
".",
"_add_d... | Adds a list or dict as a row in the FVM data structure
:param str key: key used when rows is a dict rather than an array
:param list_or_dict: a feature list or dict | [
"Adds",
"a",
"list",
"or",
"dict",
"as",
"a",
"row",
"in",
"the",
"FVM",
"data",
"structure"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L143-L152 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.extend_rows | def extend_rows(self, list_or_dict):
""" Add multiple rows at once
:param list_or_dict: a 2 dimensional structure for adding multiple rows at once
:return:
"""
if isinstance(list_or_dict, list):
for r in list_or_dict:
self.add_row(r)
else:
... | python | def extend_rows(self, list_or_dict):
""" Add multiple rows at once
:param list_or_dict: a 2 dimensional structure for adding multiple rows at once
:return:
"""
if isinstance(list_or_dict, list):
for r in list_or_dict:
self.add_row(r)
else:
... | [
"def",
"extend_rows",
"(",
"self",
",",
"list_or_dict",
")",
":",
"if",
"isinstance",
"(",
"list_or_dict",
",",
"list",
")",
":",
"for",
"r",
"in",
"list_or_dict",
":",
"self",
".",
"add_row",
"(",
"r",
")",
"else",
":",
"for",
"k",
",",
"r",
"in",
... | Add multiple rows at once
:param list_or_dict: a 2 dimensional structure for adding multiple rows at once
:return: | [
"Add",
"multiple",
"rows",
"at",
"once"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L154-L165 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.get_row_list | def get_row_list(self, row_idx):
""" get a feature vector for the nth row
:param row_idx: which row
:return: a list of feature values, ordered by column_names
"""
try:
row = self._rows[row_idx]
except TypeError:
row = self._rows[self._row_name_id... | python | def get_row_list(self, row_idx):
""" get a feature vector for the nth row
:param row_idx: which row
:return: a list of feature values, ordered by column_names
"""
try:
row = self._rows[row_idx]
except TypeError:
row = self._rows[self._row_name_id... | [
"def",
"get_row_list",
"(",
"self",
",",
"row_idx",
")",
":",
"try",
":",
"row",
"=",
"self",
".",
"_rows",
"[",
"row_idx",
"]",
"except",
"TypeError",
":",
"row",
"=",
"self",
".",
"_rows",
"[",
"self",
".",
"_row_name_idx",
"[",
"row_idx",
"]",
"]"... | get a feature vector for the nth row
:param row_idx: which row
:return: a list of feature values, ordered by column_names | [
"get",
"a",
"feature",
"vector",
"for",
"the",
"nth",
"row"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L184-L204 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.get_row_dict | def get_row_dict(self, row_idx):
""" Return a dictionary representation for a matrix row
:param row_idx: which row
:return: a dict of feature keys/values, not including ones which are the default value
"""
try:
row = self._rows[row_idx]
except TypeError:
... | python | def get_row_dict(self, row_idx):
""" Return a dictionary representation for a matrix row
:param row_idx: which row
:return: a dict of feature keys/values, not including ones which are the default value
"""
try:
row = self._rows[row_idx]
except TypeError:
... | [
"def",
"get_row_dict",
"(",
"self",
",",
"row_idx",
")",
":",
"try",
":",
"row",
"=",
"self",
".",
"_rows",
"[",
"row_idx",
"]",
"except",
"TypeError",
":",
"row",
"=",
"self",
".",
"_rows",
"[",
"self",
".",
"_row_name_idx",
"[",
"row_idx",
"]",
"]"... | Return a dictionary representation for a matrix row
:param row_idx: which row
:return: a dict of feature keys/values, not including ones which are the default value | [
"Return",
"a",
"dictionary",
"representation",
"for",
"a",
"matrix",
"row"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L206-L225 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.get_matrix | def get_matrix(self):
""" Use numpy to create a real matrix object from the data
:return: the matrix representation of the fvm
"""
return np.array([ self.get_row_list(i) for i in range(self.row_count()) ]) | python | def get_matrix(self):
""" Use numpy to create a real matrix object from the data
:return: the matrix representation of the fvm
"""
return np.array([ self.get_row_list(i) for i in range(self.row_count()) ]) | [
"def",
"get_matrix",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"self",
".",
"get_row_list",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"row_count",
"(",
")",
")",
"]",
")"
] | Use numpy to create a real matrix object from the data
:return: the matrix representation of the fvm | [
"Use",
"numpy",
"to",
"create",
"a",
"real",
"matrix",
"object",
"from",
"the",
"data"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L227-L232 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.transpose | def transpose(self):
""" Create a matrix, transpose it, and then create a new FVM
:raise NotImplementedError: if all existing rows aren't keyed
:return: a new FVM rotated from self
"""
if len(self._row_name_list) != len(self._rows):
raise NotImplementedError("You can... | python | def transpose(self):
""" Create a matrix, transpose it, and then create a new FVM
:raise NotImplementedError: if all existing rows aren't keyed
:return: a new FVM rotated from self
"""
if len(self._row_name_list) != len(self._rows):
raise NotImplementedError("You can... | [
"def",
"transpose",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_row_name_list",
")",
"!=",
"len",
"(",
"self",
".",
"_rows",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"You can't rotate a FVM that doesn't have all rows keyed\"",
")",
"fvm",
"="... | Create a matrix, transpose it, and then create a new FVM
:raise NotImplementedError: if all existing rows aren't keyed
:return: a new FVM rotated from self | [
"Create",
"a",
"matrix",
"transpose",
"it",
"and",
"then",
"create",
"a",
"new",
"FVM"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L234-L248 |
talentpair/featurevectormatrix | featurevectormatrix/__init__.py | FeatureVectorMatrix.keys | def keys(self):
""" Returns all row keys
:raise NotImplementedError: if all rows aren't keyed
:return: all row keys
"""
if len(self._row_name_list) != len(self._rows):
raise NotImplementedError("You can't get row keys for a FVM that doesn't have all rows keyed")
... | python | def keys(self):
""" Returns all row keys
:raise NotImplementedError: if all rows aren't keyed
:return: all row keys
"""
if len(self._row_name_list) != len(self._rows):
raise NotImplementedError("You can't get row keys for a FVM that doesn't have all rows keyed")
... | [
"def",
"keys",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_row_name_list",
")",
"!=",
"len",
"(",
"self",
".",
"_rows",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"You can't get row keys for a FVM that doesn't have all rows keyed\"",
")",
"return... | Returns all row keys
:raise NotImplementedError: if all rows aren't keyed
:return: all row keys | [
"Returns",
"all",
"row",
"keys"
] | train | https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L250-L259 |
testing-cabal/systemfixtures | systemfixtures/processes/fixture.py | FakeProcesses.add | def add(self, process, name=None):
"""Add a new process to the registry.
:param process: A callable (either plain function or object
implementing __calll).
:param name: The name of the executable to match. If not given
it must be provided as 'name' attribute of the given... | python | def add(self, process, name=None):
"""Add a new process to the registry.
:param process: A callable (either plain function or object
implementing __calll).
:param name: The name of the executable to match. If not given
it must be provided as 'name' attribute of the given... | [
"def",
"add",
"(",
"self",
",",
"process",
",",
"name",
"=",
"None",
")",
":",
"name",
"=",
"name",
"or",
"process",
".",
"name",
"assert",
"name",
",",
"\"No executable name given.\"",
"\"\"",
"self",
".",
"_registry",
"[",
"name",
"]",
"=",
"process"
] | Add a new process to the registry.
:param process: A callable (either plain function or object
implementing __calll).
:param name: The name of the executable to match. If not given
it must be provided as 'name' attribute of the given `process`.
callable. | [
"Add",
"a",
"new",
"process",
"to",
"the",
"registry",
"."
] | train | https://github.com/testing-cabal/systemfixtures/blob/adf1b822bf83dc2a2f6bf7b85b5d8055e5e6ccd4/systemfixtures/processes/fixture.py#L20-L31 |
dossier/dossier.fc | python/dossier/fc/exceptions.py | uni | def uni(key):
'''as a crutch, we allow str-type keys, but they really should be
unicode.
'''
if isinstance(key, str):
logger.warn('assuming utf8 on: %r', key)
return unicode(key, 'utf-8')
elif isinstance(key, unicode):
return key
else:
raise NonUnicodeKeyError(ke... | python | def uni(key):
'''as a crutch, we allow str-type keys, but they really should be
unicode.
'''
if isinstance(key, str):
logger.warn('assuming utf8 on: %r', key)
return unicode(key, 'utf-8')
elif isinstance(key, unicode):
return key
else:
raise NonUnicodeKeyError(ke... | [
"def",
"uni",
"(",
"key",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"logger",
".",
"warn",
"(",
"'assuming utf8 on: %r'",
",",
"key",
")",
"return",
"unicode",
"(",
"key",
",",
"'utf-8'",
")",
"elif",
"isinstance",
"(",
"key",
"... | as a crutch, we allow str-type keys, but they really should be
unicode. | [
"as",
"a",
"crutch",
"we",
"allow",
"str",
"-",
"type",
"keys",
"but",
"they",
"really",
"should",
"be",
"unicode",
"."
] | train | https://github.com/dossier/dossier.fc/blob/3e969d0cb2592fc06afc1c849d2b22283450b5e2/python/dossier/fc/exceptions.py#L54-L65 |
markomanninen/abnum | romanize/romanizer.py | romanizer.convert | def convert(self, string, preprocess = None):
"""
Swap characters from a script to transliteration and vice versa.
Optionally sanitize string by using preprocess function.
:param preprocess:
:param string:
:return:
"""
string = unicode(preprocess(string)... | python | def convert(self, string, preprocess = None):
"""
Swap characters from a script to transliteration and vice versa.
Optionally sanitize string by using preprocess function.
:param preprocess:
:param string:
:return:
"""
string = unicode(preprocess(string)... | [
"def",
"convert",
"(",
"self",
",",
"string",
",",
"preprocess",
"=",
"None",
")",
":",
"string",
"=",
"unicode",
"(",
"preprocess",
"(",
"string",
")",
"if",
"preprocess",
"else",
"string",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"if",
"self",
".",
"r... | Swap characters from a script to transliteration and vice versa.
Optionally sanitize string by using preprocess function.
:param preprocess:
:param string:
:return: | [
"Swap",
"characters",
"from",
"a",
"script",
"to",
"transliteration",
"and",
"vice",
"versa",
".",
"Optionally",
"sanitize",
"string",
"by",
"using",
"preprocess",
"function",
"."
] | train | https://github.com/markomanninen/abnum/blob/9bfc8f06f34d9a51aab038638f87e2bb5f9f4c99/romanize/romanizer.py#L28-L41 |
openbermuda/ripl | ripl/caption.py | SlideShow.interpret | def interpret(self, msg):
""" Load input """
slides = msg.get('slides', [])
self.cache = msg.get('folder')
self.gallery = msg.get('gallery', '..')
with open(self.cache + '/slides.txt', 'w') as logfile:
for ix, item in enumerate(slides):
image = self.p... | python | def interpret(self, msg):
""" Load input """
slides = msg.get('slides', [])
self.cache = msg.get('folder')
self.gallery = msg.get('gallery', '..')
with open(self.cache + '/slides.txt', 'w') as logfile:
for ix, item in enumerate(slides):
image = self.p... | [
"def",
"interpret",
"(",
"self",
",",
"msg",
")",
":",
"slides",
"=",
"msg",
".",
"get",
"(",
"'slides'",
",",
"[",
"]",
")",
"self",
".",
"cache",
"=",
"msg",
".",
"get",
"(",
"'folder'",
")",
"self",
".",
"gallery",
"=",
"msg",
".",
"get",
"(... | Load input | [
"Load",
"input"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/caption.py#L23-L43 |
openbermuda/ripl | ripl/caption.py | SlideShow.create_image | def create_image(self, image_file, caption):
""" Create an image with a caption """
suffix = 'png'
if image_file:
img = Image.open(os.path.join(self.gallery, image_file))
width, height = img.size
ratio = width/WIDTH
img = img.resize((int(width // r... | python | def create_image(self, image_file, caption):
""" Create an image with a caption """
suffix = 'png'
if image_file:
img = Image.open(os.path.join(self.gallery, image_file))
width, height = img.size
ratio = width/WIDTH
img = img.resize((int(width // r... | [
"def",
"create_image",
"(",
"self",
",",
"image_file",
",",
"caption",
")",
":",
"suffix",
"=",
"'png'",
"if",
"image_file",
":",
"img",
"=",
"Image",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"gallery",
",",
"image_file",
"... | Create an image with a caption | [
"Create",
"an",
"image",
"with",
"a",
"caption"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/caption.py#L65-L81 |
openbermuda/ripl | ripl/caption.py | SlideShow.add_caption | def add_caption(self, image, caption, colour=None):
""" Add a caption to the image """
if colour is None:
colour = "white"
width, height = image.size
draw = ImageDraw.Draw(image)
draw.font = self.font
draw.font = self.font
draw.text((width // 1... | python | def add_caption(self, image, caption, colour=None):
""" Add a caption to the image """
if colour is None:
colour = "white"
width, height = image.size
draw = ImageDraw.Draw(image)
draw.font = self.font
draw.font = self.font
draw.text((width // 1... | [
"def",
"add_caption",
"(",
"self",
",",
"image",
",",
"caption",
",",
"colour",
"=",
"None",
")",
":",
"if",
"colour",
"is",
"None",
":",
"colour",
"=",
"\"white\"",
"width",
",",
"height",
"=",
"image",
".",
"size",
"draw",
"=",
"ImageDraw",
".",
"D... | Add a caption to the image | [
"Add",
"a",
"caption",
"to",
"the",
"image"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/caption.py#L105-L120 |
corrni/scenario | scenario/plugins/har_to_loadimpact/plugin.py | HarToLoadimpactPlugin.identifier | def identifier(self):
# type: () -> str
"""[ID] Built-in HAR v1.2 Converter to loadimpact.com Lua scripts."""
version = "_".join(self._version.split('.'))
return "%s_%s" % (self._namespace, version) | python | def identifier(self):
# type: () -> str
"""[ID] Built-in HAR v1.2 Converter to loadimpact.com Lua scripts."""
version = "_".join(self._version.split('.'))
return "%s_%s" % (self._namespace, version) | [
"def",
"identifier",
"(",
"self",
")",
":",
"# type: () -> str",
"version",
"=",
"\"_\"",
".",
"join",
"(",
"self",
".",
"_version",
".",
"split",
"(",
"'.'",
")",
")",
"return",
"\"%s_%s\"",
"%",
"(",
"self",
".",
"_namespace",
",",
"version",
")"
] | [ID] Built-in HAR v1.2 Converter to loadimpact.com Lua scripts. | [
"[",
"ID",
"]",
"Built",
"-",
"in",
"HAR",
"v1",
".",
"2",
"Converter",
"to",
"loadimpact",
".",
"com",
"Lua",
"scripts",
"."
] | train | https://github.com/corrni/scenario/blob/42986c5a8ff6f2d70eb81b8c4b642728ec6a4a90/scenario/plugins/har_to_loadimpact/plugin.py#L15-L19 |
Cologler/fsoopify-python | fsoopify/paths.py | Path.from_caller_file | def from_caller_file():
'''return a `Path` from the path of caller file'''
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
filename = calframe[1].filename
if not os.path.isfile(filename):
raise RuntimeError('call... | python | def from_caller_file():
'''return a `Path` from the path of caller file'''
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
filename = calframe[1].filename
if not os.path.isfile(filename):
raise RuntimeError('call... | [
"def",
"from_caller_file",
"(",
")",
":",
"import",
"inspect",
"curframe",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"calframe",
"=",
"inspect",
".",
"getouterframes",
"(",
"curframe",
",",
"2",
")",
"filename",
"=",
"calframe",
"[",
"1",
"]",
".",
... | return a `Path` from the path of caller file | [
"return",
"a",
"Path",
"from",
"the",
"path",
"of",
"caller",
"file"
] | train | https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/paths.py#L152-L160 |
Cologler/fsoopify-python | fsoopify/paths.py | Path.from_caller_module_root | def from_caller_module_root():
'''return a `Path` from module root which include the caller'''
import inspect
all_stack = list(inspect.stack())
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
module = inspect.getmodule(calframe[1].frame)
... | python | def from_caller_module_root():
'''return a `Path` from module root which include the caller'''
import inspect
all_stack = list(inspect.stack())
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
module = inspect.getmodule(calframe[1].frame)
... | [
"def",
"from_caller_module_root",
"(",
")",
":",
"import",
"inspect",
"all_stack",
"=",
"list",
"(",
"inspect",
".",
"stack",
"(",
")",
")",
"curframe",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"calframe",
"=",
"inspect",
".",
"getouterframes",
"(",
... | return a `Path` from module root which include the caller | [
"return",
"a",
"Path",
"from",
"module",
"root",
"which",
"include",
"the",
"caller"
] | train | https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/paths.py#L163-L174 |
abe-winter/pg13-py | pg13/pool_psyco.py | PgPoolPsyco.commitreturn | def commitreturn(self,qstring,vals=()):
"commit and return result. This is intended for sql UPDATE ... RETURNING"
with self.withcur() as cur:
cur.execute(qstring,vals)
return cur.fetchone() | python | def commitreturn(self,qstring,vals=()):
"commit and return result. This is intended for sql UPDATE ... RETURNING"
with self.withcur() as cur:
cur.execute(qstring,vals)
return cur.fetchone() | [
"def",
"commitreturn",
"(",
"self",
",",
"qstring",
",",
"vals",
"=",
"(",
")",
")",
":",
"with",
"self",
".",
"withcur",
"(",
")",
"as",
"cur",
":",
"cur",
".",
"execute",
"(",
"qstring",
",",
"vals",
")",
"return",
"cur",
".",
"fetchone",
"(",
... | commit and return result. This is intended for sql UPDATE ... RETURNING | [
"commit",
"and",
"return",
"result",
".",
"This",
"is",
"intended",
"for",
"sql",
"UPDATE",
"...",
"RETURNING"
] | train | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pool_psyco.py#L35-L39 |
jmgilman/Neolib | neolib/pyamf/remoting/gateway/django.py | DjangoGateway.getResponse | def getResponse(self, http_request, request):
"""
Processes the AMF request, returning an AMF response.
@param http_request: The underlying HTTP Request.
@type http_request: U{HTTPRequest<http://docs.djangoproject.com
/en/dev/ref/request-response/#httprequest-objects>}
... | python | def getResponse(self, http_request, request):
"""
Processes the AMF request, returning an AMF response.
@param http_request: The underlying HTTP Request.
@type http_request: U{HTTPRequest<http://docs.djangoproject.com
/en/dev/ref/request-response/#httprequest-objects>}
... | [
"def",
"getResponse",
"(",
"self",
",",
"http_request",
",",
"request",
")",
":",
"response",
"=",
"remoting",
".",
"Envelope",
"(",
"request",
".",
"amfVersion",
")",
"for",
"name",
",",
"message",
"in",
"request",
":",
"http_request",
".",
"amf_request",
... | Processes the AMF request, returning an AMF response.
@param http_request: The underlying HTTP Request.
@type http_request: U{HTTPRequest<http://docs.djangoproject.com
/en/dev/ref/request-response/#httprequest-objects>}
@param request: The AMF Request.
@type request: L{Envel... | [
"Processes",
"the",
"AMF",
"request",
"returning",
"an",
"AMF",
"response",
"."
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/django.py#L66-L85 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | get_driver | def get_driver(driver='ASCII_RS232', *args, **keywords):
""" Gets a driver for a Parker Motion Gemini drive.
Gets and connects a particular driver in ``drivers`` to a Parker
Motion Gemini GV-6 or GT-6 servo/stepper motor drive.
The only driver currently supported is the ``'ASCII_RS232'`` driver
wh... | python | def get_driver(driver='ASCII_RS232', *args, **keywords):
""" Gets a driver for a Parker Motion Gemini drive.
Gets and connects a particular driver in ``drivers`` to a Parker
Motion Gemini GV-6 or GT-6 servo/stepper motor drive.
The only driver currently supported is the ``'ASCII_RS232'`` driver
wh... | [
"def",
"get_driver",
"(",
"driver",
"=",
"'ASCII_RS232'",
",",
"*",
"args",
",",
"*",
"*",
"keywords",
")",
":",
"if",
"driver",
".",
"upper",
"(",
")",
"==",
"'ASCII_RS232'",
":",
"return",
"drivers",
".",
"ASCII_RS232",
"(",
"*",
"args",
",",
"*",
... | Gets a driver for a Parker Motion Gemini drive.
Gets and connects a particular driver in ``drivers`` to a Parker
Motion Gemini GV-6 or GT-6 servo/stepper motor drive.
The only driver currently supported is the ``'ASCII_RS232'`` driver
which corresponds to ``drivers.ASCII_RS232``.
Parameters
-... | [
"Gets",
"a",
"driver",
"for",
"a",
"Parker",
"Motion",
"Gemini",
"drive",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L41-L85 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6._get_parameter | def _get_parameter(self, name, tp, timeout=1.0, max_retries=2):
""" Gets the specified drive parameter.
Gets a parameter from the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
Name of the parameter to chec... | python | def _get_parameter(self, name, tp, timeout=1.0, max_retries=2):
""" Gets the specified drive parameter.
Gets a parameter from the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
Name of the parameter to chec... | [
"def",
"_get_parameter",
"(",
"self",
",",
"name",
",",
"tp",
",",
"timeout",
"=",
"1.0",
",",
"max_retries",
"=",
"2",
")",
":",
"# Raise a TypeError if tp isn't one of the valid types.",
"if",
"tp",
"not",
"in",
"(",
"bool",
",",
"int",
",",
"float",
")",
... | Gets the specified drive parameter.
Gets a parameter from the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
Name of the parameter to check. It is always the command to
set it but without the value.
... | [
"Gets",
"the",
"specified",
"drive",
"parameter",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L145-L219 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6._set_parameter | def _set_parameter(self, name, value, tp, timeout=1.0,
max_retries=2):
""" Sets the specified drive parameter.
Sets a parameter on the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
N... | python | def _set_parameter(self, name, value, tp, timeout=1.0,
max_retries=2):
""" Sets the specified drive parameter.
Sets a parameter on the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
N... | [
"def",
"_set_parameter",
"(",
"self",
",",
"name",
",",
"value",
",",
"tp",
",",
"timeout",
"=",
"1.0",
",",
"max_retries",
"=",
"2",
")",
":",
"# Return False if tp isn't one of the valid types.",
"if",
"tp",
"not",
"in",
"(",
"bool",
",",
"int",
",",
"fl... | Sets the specified drive parameter.
Sets a parameter on the drive. Only supports ``bool``,
``int``, and ``float`` parameters.
Parameters
----------
name : str
Name of the parameter to set. It is always the command to
set it when followed by the value.
... | [
"Sets",
"the",
"specified",
"drive",
"parameter",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L221-L278 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6.pause | def pause(self, max_retries=0):
""" Pauses the drive (execution of commands).
Causes the drive to pause execution of commands till it is
unpaused. Commands will be queued until it is unpaused. Motion
is not stopped.
Parameters
----------
max_retries : int, optio... | python | def pause(self, max_retries=0):
""" Pauses the drive (execution of commands).
Causes the drive to pause execution of commands till it is
unpaused. Commands will be queued until it is unpaused. Motion
is not stopped.
Parameters
----------
max_retries : int, optio... | [
"def",
"pause",
"(",
"self",
",",
"max_retries",
"=",
"0",
")",
":",
"return",
"(",
"not",
"self",
".",
"driver",
".",
"command_error",
"(",
"self",
".",
"driver",
".",
"send_command",
"(",
"'PS'",
",",
"timeout",
"=",
"1.0",
",",
"immediate",
"=",
"... | Pauses the drive (execution of commands).
Causes the drive to pause execution of commands till it is
unpaused. Commands will be queued until it is unpaused. Motion
is not stopped.
Parameters
----------
max_retries : int, optional
Maximum number of retries to... | [
"Pauses",
"the",
"drive",
"(",
"execution",
"of",
"commands",
")",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L280-L311 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6.get_program | def get_program(self, n, timeout=2.0, max_retries=2):
""" Get a program from the drive.
Gets program 'n' from the drive and returns its commands.
Parameters
----------
n : int
Which program to get.
timeout : number, optional
Optional timeout in s... | python | def get_program(self, n, timeout=2.0, max_retries=2):
""" Get a program from the drive.
Gets program 'n' from the drive and returns its commands.
Parameters
----------
n : int
Which program to get.
timeout : number, optional
Optional timeout in s... | [
"def",
"get_program",
"(",
"self",
",",
"n",
",",
"timeout",
"=",
"2.0",
",",
"max_retries",
"=",
"2",
")",
":",
"# Send the 'TPROG PROGn' command to read the program.",
"response",
"=",
"self",
".",
"driver",
".",
"send_command",
"(",
"'TPROG PROG'",
"+",
"str"... | Get a program from the drive.
Gets program 'n' from the drive and returns its commands.
Parameters
----------
n : int
Which program to get.
timeout : number, optional
Optional timeout in seconds to use when reading the
response. A negative va... | [
"Get",
"a",
"program",
"from",
"the",
"drive",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L433-L480 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6.set_program_profile | def set_program_profile(self, n, commands,
program_or_profile='program',
timeout=1.0, max_retries=0):
""" Sets a program/profile on the drive.
Sets program or profile 'n' on the drive to the sequence of
commands in 'commands'. If the exist... | python | def set_program_profile(self, n, commands,
program_or_profile='program',
timeout=1.0, max_retries=0):
""" Sets a program/profile on the drive.
Sets program or profile 'n' on the drive to the sequence of
commands in 'commands'. If the exist... | [
"def",
"set_program_profile",
"(",
"self",
",",
"n",
",",
"commands",
",",
"program_or_profile",
"=",
"'program'",
",",
"timeout",
"=",
"1.0",
",",
"max_retries",
"=",
"0",
")",
":",
"# Grab the n'th program on the drive and strip commands. If we",
"# are doing a profil... | Sets a program/profile on the drive.
Sets program or profile 'n' on the drive to the sequence of
commands in 'commands'. If the existing program is identical, it
is not overwritten (can't check this for a profile). Returns
whether the program or profile was successfully set or not (if
... | [
"Sets",
"a",
"program",
"/",
"profile",
"on",
"the",
"drive",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L482-L581 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6.run_program_profile | def run_program_profile(self, n, program_or_profile='program',
timeout=10.0):
""" Runs a program/profile on the drive.
Runs program or profile 'n' on the drive, grabs its output, and
processes the output. The response from the drive is broken down
into the ec... | python | def run_program_profile(self, n, program_or_profile='program',
timeout=10.0):
""" Runs a program/profile on the drive.
Runs program or profile 'n' on the drive, grabs its output, and
processes the output. The response from the drive is broken down
into the ec... | [
"def",
"run_program_profile",
"(",
"self",
",",
"n",
",",
"program_or_profile",
"=",
"'program'",
",",
"timeout",
"=",
"10.0",
")",
":",
"if",
"program_or_profile",
"!=",
"'profile'",
":",
"return",
"self",
".",
"driver",
".",
"send_command",
"(",
"'RUN PROG'"... | Runs a program/profile on the drive.
Runs program or profile 'n' on the drive, grabs its output, and
processes the output. The response from the drive is broken down
into the echoed command (drive echoes it back), any error
returned by the drive (leading '*' is stripped), and the
... | [
"Runs",
"a",
"program",
"/",
"profile",
"on",
"the",
"drive",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L583-L639 |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/__init__.py | GeminiG6.motion_commanded | def motion_commanded(self):
""" Whether motion is commanded or not.
``bool``
Can't be set.
Notes
-----
It is the value of the first bit of the 'TAS' command.
"""
rsp = self.driver.send_command('TAS', immediate=True)
if self.driver.command_error... | python | def motion_commanded(self):
""" Whether motion is commanded or not.
``bool``
Can't be set.
Notes
-----
It is the value of the first bit of the 'TAS' command.
"""
rsp = self.driver.send_command('TAS', immediate=True)
if self.driver.command_error... | [
"def",
"motion_commanded",
"(",
"self",
")",
":",
"rsp",
"=",
"self",
".",
"driver",
".",
"send_command",
"(",
"'TAS'",
",",
"immediate",
"=",
"True",
")",
"if",
"self",
".",
"driver",
".",
"command_error",
"(",
"rsp",
")",
"or",
"len",
"(",
"rsp",
"... | Whether motion is commanded or not.
``bool``
Can't be set.
Notes
-----
It is the value of the first bit of the 'TAS' command. | [
"Whether",
"motion",
"is",
"commanded",
"or",
"not",
"."
] | train | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/__init__.py#L750-L767 |
jldantas/libmft | libmft/util/functions.py | apply_fixup_array | def apply_fixup_array(bin_view, fx_offset, fx_count, entry_size):
'''This function reads the fixup array and apply the correct values
to the underlying binary stream. This function changes the bin_view
in memory.
Args:
bin_view (memoryview of bytearray) - The binary stream
fx_offset (in... | python | def apply_fixup_array(bin_view, fx_offset, fx_count, entry_size):
'''This function reads the fixup array and apply the correct values
to the underlying binary stream. This function changes the bin_view
in memory.
Args:
bin_view (memoryview of bytearray) - The binary stream
fx_offset (in... | [
"def",
"apply_fixup_array",
"(",
"bin_view",
",",
"fx_offset",
",",
"fx_count",
",",
"entry_size",
")",
":",
"fx_array",
"=",
"bin_view",
"[",
"fx_offset",
":",
"fx_offset",
"+",
"(",
"2",
"*",
"fx_count",
")",
"]",
"#the array is composed of the signature + subst... | This function reads the fixup array and apply the correct values
to the underlying binary stream. This function changes the bin_view
in memory.
Args:
bin_view (memoryview of bytearray) - The binary stream
fx_offset (int) - Offset to the fixup array
fx_count (int) - Number of element... | [
"This",
"function",
"reads",
"the",
"fixup",
"array",
"and",
"apply",
"the",
"correct",
"values",
"to",
"the",
"underlying",
"binary",
"stream",
".",
"This",
"function",
"changes",
"the",
"bin_view",
"in",
"memory",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/util/functions.py#L46-L73 |
jldantas/libmft | libmft/util/functions.py | flatten | def flatten(iterable):
'''This function allows a simple a way to iterate over a "complex" iterable, for example,
if the input [12, [23], (4, 3), "lkjasddf"], this will return an Iterable that returns
12, 23, 4, 3 and "lkjasddf".
Args:
iterable (Iterable) - A complex iterable that will be flatte... | python | def flatten(iterable):
'''This function allows a simple a way to iterate over a "complex" iterable, for example,
if the input [12, [23], (4, 3), "lkjasddf"], this will return an Iterable that returns
12, 23, 4, 3 and "lkjasddf".
Args:
iterable (Iterable) - A complex iterable that will be flatte... | [
"def",
"flatten",
"(",
"iterable",
")",
":",
"return",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"a",
"if",
"isinstance",
"(",
"a",
",",
"Iterable",
")",
"and",
"not",
"isinstance",
"(",
"a",
",",
"str",
")",
"else",
"[",
"a",
"]",
"for",... | This function allows a simple a way to iterate over a "complex" iterable, for example,
if the input [12, [23], (4, 3), "lkjasddf"], this will return an Iterable that returns
12, 23, 4, 3 and "lkjasddf".
Args:
iterable (Iterable) - A complex iterable that will be flattened
Returns:
(Ite... | [
"This",
"function",
"allows",
"a",
"simple",
"a",
"way",
"to",
"iterate",
"over",
"a",
"complex",
"iterable",
"for",
"example",
"if",
"the",
"input",
"[",
"12",
"[",
"23",
"]",
"(",
"4",
"3",
")",
"lkjasddf",
"]",
"this",
"will",
"return",
"an",
"Ite... | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/util/functions.py#L75-L85 |
jldantas/libmft | libmft/util/functions.py | get_file_size | def get_file_size(file_object):
'''Returns the size, in bytes, of a file. Expects an object that supports
seek and tell methods.
Args:
file_object (file_object) - The object that represents the file
Returns:
(int): size of the file, in bytes'''
position = file_object.tell()
fi... | python | def get_file_size(file_object):
'''Returns the size, in bytes, of a file. Expects an object that supports
seek and tell methods.
Args:
file_object (file_object) - The object that represents the file
Returns:
(int): size of the file, in bytes'''
position = file_object.tell()
fi... | [
"def",
"get_file_size",
"(",
"file_object",
")",
":",
"position",
"=",
"file_object",
".",
"tell",
"(",
")",
"file_object",
".",
"seek",
"(",
"0",
",",
"2",
")",
"file_size",
"=",
"file_object",
".",
"tell",
"(",
")",
"file_object",
".",
"seek",
"(",
"... | Returns the size, in bytes, of a file. Expects an object that supports
seek and tell methods.
Args:
file_object (file_object) - The object that represents the file
Returns:
(int): size of the file, in bytes | [
"Returns",
"the",
"size",
"in",
"bytes",
"of",
"a",
"file",
".",
"Expects",
"an",
"object",
"that",
"supports",
"seek",
"and",
"tell",
"methods",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/util/functions.py#L87-L102 |
ulf1/oxyba | oxyba/rand_imancon.py | rand_imancon | def rand_imancon(X, rho):
"""Iman-Conover Method to generate random ordinal variables
(Implementation adopted from Ekstrom, 2005)
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Correlation Matrix
Links
... | python | def rand_imancon(X, rho):
"""Iman-Conover Method to generate random ordinal variables
(Implementation adopted from Ekstrom, 2005)
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Correlation Matrix
Links
... | [
"def",
"rand_imancon",
"(",
"X",
",",
"rho",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"scipy",
".",
"stats",
"as",
"sstat",
"import",
"scipy",
".",
"special",
"as",
"sspec",
"# data prep",
"n",
",",
"d",
"=",
"X",
".",
"shape",
"# Ordering",
... | Iman-Conover Method to generate random ordinal variables
(Implementation adopted from Ekstrom, 2005)
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Correlation Matrix
Links
* Iman, R.L., Conover, W.J., 1... | [
"Iman",
"-",
"Conover",
"Method",
"to",
"generate",
"random",
"ordinal",
"variables",
"(",
"Implementation",
"adopted",
"from",
"Ekstrom",
"2005",
")"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/rand_imancon.py#L2-L59 |
ulf1/oxyba | oxyba/rand_imancon.py | rand_imancon_NOTWORKING | def rand_imancon_NOTWORKING(x, rho):
"""Iman-Conover Method to generate random ordinal variables.
Implementation from Mildenhall (2005) that is NOT working.
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Corr... | python | def rand_imancon_NOTWORKING(x, rho):
"""Iman-Conover Method to generate random ordinal variables.
Implementation from Mildenhall (2005) that is NOT working.
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Corr... | [
"def",
"rand_imancon_NOTWORKING",
"(",
"x",
",",
"rho",
")",
":",
"import",
"numpy",
"as",
"np",
"from",
"scipy",
".",
"stats",
"import",
"norm",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"(",
"\"This implementation of the the Iman-Conover methods is \"",
... | Iman-Conover Method to generate random ordinal variables.
Implementation from Mildenhall (2005) that is NOT working.
x : ndarray
<obs x cols> matrix with "cols" ordinal variables
that are uncorrelated.
rho : ndarray
Spearman Rank Correlation Matrix
Links
* Iman, R.L., ... | [
"Iman",
"-",
"Conover",
"Method",
"to",
"generate",
"random",
"ordinal",
"variables",
".",
"Implementation",
"from",
"Mildenhall",
"(",
"2005",
")",
"that",
"is",
"NOT",
"working",
"."
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/rand_imancon.py#L62-L130 |
klen/muffin-jinja2 | muffin_jinja2.py | Plugin.setup | def setup(self, app):
""" Setup the plugin from an application. """
super().setup(app)
if isinstance(self.cfg.template_folders, str):
self.cfg.template_folders = [self.cfg.template_folders]
self.cfg.template_folders = list(self.cfg.template_folders)
if not self.cfg.... | python | def setup(self, app):
""" Setup the plugin from an application. """
super().setup(app)
if isinstance(self.cfg.template_folders, str):
self.cfg.template_folders = [self.cfg.template_folders]
self.cfg.template_folders = list(self.cfg.template_folders)
if not self.cfg.... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"super",
"(",
")",
".",
"setup",
"(",
"app",
")",
"if",
"isinstance",
"(",
"self",
".",
"cfg",
".",
"template_folders",
",",
"str",
")",
":",
"self",
".",
"cfg",
".",
"template_folders",
"=",
"[",
... | Setup the plugin from an application. | [
"Setup",
"the",
"plugin",
"from",
"an",
"application",
"."
] | train | https://github.com/klen/muffin-jinja2/blob/0458c9b4d88370de3ff8f0ef432ea888dd3a3dd2/muffin_jinja2.py#L40-L68 |
klen/muffin-jinja2 | muffin_jinja2.py | Plugin.context_processor | def context_processor(self, func):
""" Decorate a given function to use as a context processor.
::
@app.ps.jinja2.context_processor
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return fun... | python | def context_processor(self, func):
""" Decorate a given function to use as a context processor.
::
@app.ps.jinja2.context_processor
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return fun... | [
"def",
"context_processor",
"(",
"self",
",",
"func",
")",
":",
"func",
"=",
"to_coroutine",
"(",
"func",
")",
"self",
".",
"providers",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Decorate a given function to use as a context processor.
::
@app.ps.jinja2.context_processor
def my_context():
return {...} | [
"Decorate",
"a",
"given",
"function",
"to",
"use",
"as",
"a",
"context",
"processor",
"."
] | train | https://github.com/klen/muffin-jinja2/blob/0458c9b4d88370de3ff8f0ef432ea888dd3a3dd2/muffin_jinja2.py#L70-L80 |
klen/muffin-jinja2 | muffin_jinja2.py | Plugin.register | def register(self, value):
""" Register function to globals. """
if self.env is None:
raise PluginException('The plugin must be installed to application.')
def wrapper(func):
name = func.__name__
if isinstance(value, str):
name = value
... | python | def register(self, value):
""" Register function to globals. """
if self.env is None:
raise PluginException('The plugin must be installed to application.')
def wrapper(func):
name = func.__name__
if isinstance(value, str):
name = value
... | [
"def",
"register",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"env",
"is",
"None",
":",
"raise",
"PluginException",
"(",
"'The plugin must be installed to application.'",
")",
"def",
"wrapper",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
... | Register function to globals. | [
"Register",
"function",
"to",
"globals",
"."
] | train | https://github.com/klen/muffin-jinja2/blob/0458c9b4d88370de3ff8f0ef432ea888dd3a3dd2/muffin_jinja2.py#L82-L98 |
klen/muffin-jinja2 | muffin_jinja2.py | Plugin.filter | def filter(self, value):
""" Register function to filters. """
if self.env is None:
raise PluginException('The plugin must be installed to application.')
def wrapper(func):
name = func.__name__
if isinstance(value, str):
name = value
... | python | def filter(self, value):
""" Register function to filters. """
if self.env is None:
raise PluginException('The plugin must be installed to application.')
def wrapper(func):
name = func.__name__
if isinstance(value, str):
name = value
... | [
"def",
"filter",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"env",
"is",
"None",
":",
"raise",
"PluginException",
"(",
"'The plugin must be installed to application.'",
")",
"def",
"wrapper",
"(",
"func",
")",
":",
"name",
"=",
"func",
".",
"_... | Register function to filters. | [
"Register",
"function",
"to",
"filters",
"."
] | train | https://github.com/klen/muffin-jinja2/blob/0458c9b4d88370de3ff8f0ef432ea888dd3a3dd2/muffin_jinja2.py#L100-L116 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.handle_event | def handle_event(self, event):
"""
An abstract method that must be overwritten by child classes used to handle events.
event - the event to be handled
returns true or false if the event could be handled here
default code is given for this method, however subclasses must still ... | python | def handle_event(self, event):
"""
An abstract method that must be overwritten by child classes used to handle events.
event - the event to be handled
returns true or false if the event could be handled here
default code is given for this method, however subclasses must still ... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"# loop through the handlers associated with the event type.",
"for",
"h",
"in",
"self",
".",
"_events",
".",
"get",
"(",
"event",
".",
"type",
",",
"[",
"]",
")",
":",
"# Iterate through the handler's di... | An abstract method that must be overwritten by child classes used to handle events.
event - the event to be handled
returns true or false if the event could be handled here
default code is given for this method, however subclasses must still override this method to insure the subclass has the... | [
"An",
"abstract",
"method",
"that",
"must",
"be",
"overwritten",
"by",
"child",
"classes",
"used",
"to",
"handle",
"events",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L32-L57 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.logger | def logger(self, logger):
"""Set the logger if is not None, and it is of type Logger."""
if logger is None or not isinstance(logger, Logger):
raise ValueError("Logger can not be set to None, and must be of type logging.Logger")
self._logger = logger | python | def logger(self, logger):
"""Set the logger if is not None, and it is of type Logger."""
if logger is None or not isinstance(logger, Logger):
raise ValueError("Logger can not be set to None, and must be of type logging.Logger")
self._logger = logger | [
"def",
"logger",
"(",
"self",
",",
"logger",
")",
":",
"if",
"logger",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"logger",
",",
"Logger",
")",
":",
"raise",
"ValueError",
"(",
"\"Logger can not be set to None, and must be of type logging.Logger\"",
")",
"self"... | Set the logger if is not None, and it is of type Logger. | [
"Set",
"the",
"logger",
"if",
"is",
"not",
"None",
"and",
"it",
"is",
"of",
"type",
"Logger",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L70-L75 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.add_handler | def add_handler(self, type, actions, **kwargs):
"""
Add an event handler to be processed by this session.
type - The type of the event (pygame.QUIT, pygame.KEYUP ETC).
actions - The methods which should be called when an event matching this specification is received.
more than ... | python | def add_handler(self, type, actions, **kwargs):
"""
Add an event handler to be processed by this session.
type - The type of the event (pygame.QUIT, pygame.KEYUP ETC).
actions - The methods which should be called when an event matching this specification is received.
more than ... | [
"def",
"add_handler",
"(",
"self",
",",
"type",
",",
"actions",
",",
"*",
"*",
"kwargs",
")",
":",
"l",
"=",
"self",
".",
"_events",
".",
"get",
"(",
"type",
",",
"[",
"]",
")",
"h",
"=",
"Handler",
"(",
"self",
",",
"type",
",",
"kwargs",
",",... | Add an event handler to be processed by this session.
type - The type of the event (pygame.QUIT, pygame.KEYUP ETC).
actions - The methods which should be called when an event matching this specification is received.
more than one action can be tied to a single event. This allows for secondary ... | [
"Add",
"an",
"event",
"handler",
"to",
"be",
"processed",
"by",
"this",
"session",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L77-L101 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.remove_handler | def remove_handler(self, handler):
"""
Remove a handler from the list.
handler - The handler (as returned by add_handler) to remove.
Returns True on success, False otherwise.
"""
try:
self._events[handler.type].remove(handler)
return True
... | python | def remove_handler(self, handler):
"""
Remove a handler from the list.
handler - The handler (as returned by add_handler) to remove.
Returns True on success, False otherwise.
"""
try:
self._events[handler.type].remove(handler)
return True
... | [
"def",
"remove_handler",
"(",
"self",
",",
"handler",
")",
":",
"try",
":",
"self",
".",
"_events",
"[",
"handler",
".",
"type",
"]",
".",
"remove",
"(",
"handler",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | Remove a handler from the list.
handler - The handler (as returned by add_handler) to remove.
Returns True on success, False otherwise. | [
"Remove",
"a",
"handler",
"from",
"the",
"list",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L103-L115 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.add_keydown | def add_keydown(self, actions, **kwargs):
"""
Add a pygame.KEYDOWN event handler.
actions - The methods to be called when this key is pressed.
kwargs - The kwargs to be passed to self.add_handler.
See the documentation for self.add_handler for examples.
"""
ret... | python | def add_keydown(self, actions, **kwargs):
"""
Add a pygame.KEYDOWN event handler.
actions - The methods to be called when this key is pressed.
kwargs - The kwargs to be passed to self.add_handler.
See the documentation for self.add_handler for examples.
"""
ret... | [
"def",
"add_keydown",
"(",
"self",
",",
"actions",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"add_handler",
"(",
"pygame",
".",
"KEYDOWN",
",",
"actions",
",",
"*",
"*",
"kwargs",
")"
] | Add a pygame.KEYDOWN event handler.
actions - The methods to be called when this key is pressed.
kwargs - The kwargs to be passed to self.add_handler.
See the documentation for self.add_handler for examples. | [
"Add",
"a",
"pygame",
".",
"KEYDOWN",
"event",
"handler",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L117-L127 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.add_keyup | def add_keyup(self, actions, **kwargs):
"""See the documentation for self.add_keydown."""
return self.add_handler(pygame.KEYUP, actions, **kwargs) | python | def add_keyup(self, actions, **kwargs):
"""See the documentation for self.add_keydown."""
return self.add_handler(pygame.KEYUP, actions, **kwargs) | [
"def",
"add_keyup",
"(",
"self",
",",
"actions",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"add_handler",
"(",
"pygame",
".",
"KEYUP",
",",
"actions",
",",
"*",
"*",
"kwargs",
")"
] | See the documentation for self.add_keydown. | [
"See",
"the",
"documentation",
"for",
"self",
".",
"add_keydown",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L129-L131 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.change_event_params | def change_event_params(self, handler, **kwargs):
"""
This allows the client to change the parameters for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
kwargs - t... | python | def change_event_params(self, handler, **kwargs):
"""
This allows the client to change the parameters for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
kwargs - t... | [
"def",
"change_event_params",
"(",
"self",
",",
"handler",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"Handler",
")",
":",
"raise",
"TypeError",
"(",
"\"given object must be of type Handler.\"",
")",
"if",
"not",
"self",... | This allows the client to change the parameters for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
kwargs - the variable number of keyword arguments for the parameters that must m... | [
"This",
"allows",
"the",
"client",
"to",
"change",
"the",
"parameters",
"for",
"an",
"event",
"in",
"the",
"case",
"that",
"there",
"is",
"a",
"desire",
"for",
"slightly",
"different",
"behavior",
"such",
"as",
"reasigning",
"keys",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L133-L147 |
tbreitenfeldt/invisible_ui | invisible_ui/events/eventManager.py | EventManager.change_event_actions | def change_event_actions(self, handler, actions):
"""
This allows the client to change the actions for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
actions - The... | python | def change_event_actions(self, handler, actions):
"""
This allows the client to change the actions for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
actions - The... | [
"def",
"change_event_actions",
"(",
"self",
",",
"handler",
",",
"actions",
")",
":",
"if",
"not",
"isinstance",
"(",
"handler",
",",
"Handler",
")",
":",
"raise",
"TypeError",
"(",
"\"given object must be of type Handler.\"",
")",
"if",
"not",
"self",
".",
"r... | This allows the client to change the actions for an event, in the case that there is a desire for slightly different behavior, such as reasigning keys.
handler - the handler object that the desired changes are made to.
actions - The methods that are called when this handler is varified against the cur... | [
"This",
"allows",
"the",
"client",
"to",
"change",
"the",
"actions",
"for",
"an",
"event",
"in",
"the",
"case",
"that",
"there",
"is",
"a",
"desire",
"for",
"slightly",
"different",
"behavior",
"such",
"as",
"reasigning",
"keys",
"."
] | train | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/events/eventManager.py#L149-L163 |
kejbaly2/members | members/orgchart3.py | download | def download(uri, user=None, password=None, saveas=None, ssl_verify=False,
get_args=None):
'''
FIXME: DOCS...
'''
if saveas is None:
temp = tempfile.NamedTemporaryFile(prefix='requests_', dir='/tmp')
saveas = temp.name
temp.close()
if not (user or password):
... | python | def download(uri, user=None, password=None, saveas=None, ssl_verify=False,
get_args=None):
'''
FIXME: DOCS...
'''
if saveas is None:
temp = tempfile.NamedTemporaryFile(prefix='requests_', dir='/tmp')
saveas = temp.name
temp.close()
if not (user or password):
... | [
"def",
"download",
"(",
"uri",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"saveas",
"=",
"None",
",",
"ssl_verify",
"=",
"False",
",",
"get_args",
"=",
"None",
")",
":",
"if",
"saveas",
"is",
"None",
":",
"temp",
"=",
"tempfile",
... | FIXME: DOCS... | [
"FIXME",
":",
"DOCS",
"..."
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/orgchart3.py#L52-L80 |
kejbaly2/members | members/orgchart3.py | extract | def extract(uid=None, base_url=None, use_default_email_domain=False,
default_email_domain=None, user=None, password=None):
'''
FIXME: DOCS...
'''
assert base_url and isinstance(base_url, (unicode, str))
export_url = os.path.join(base_url, 'export_csv')
# ded is shortform for "defaul... | python | def extract(uid=None, base_url=None, use_default_email_domain=False,
default_email_domain=None, user=None, password=None):
'''
FIXME: DOCS...
'''
assert base_url and isinstance(base_url, (unicode, str))
export_url = os.path.join(base_url, 'export_csv')
# ded is shortform for "defaul... | [
"def",
"extract",
"(",
"uid",
"=",
"None",
",",
"base_url",
"=",
"None",
",",
"use_default_email_domain",
"=",
"False",
",",
"default_email_domain",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"assert",
"base_url",
"and",... | FIXME: DOCS... | [
"FIXME",
":",
"DOCS",
"..."
] | train | https://github.com/kejbaly2/members/blob/28e70a25cceade514c550e3ce9963f73167e8572/members/orgchart3.py#L83-L116 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/ssl.py | CertificateFactory.get | def get(self, bits=2048, type=crypto.TYPE_RSA, digest='sha1'):
"""
Get a new self-signed certificate
@type bits: int
@type digest: str
@rtype: Certificate
"""
self.log.debug('Creating a new self-signed SSL certificate')
# Generate the key and ready o... | python | def get(self, bits=2048, type=crypto.TYPE_RSA, digest='sha1'):
"""
Get a new self-signed certificate
@type bits: int
@type digest: str
@rtype: Certificate
"""
self.log.debug('Creating a new self-signed SSL certificate')
# Generate the key and ready o... | [
"def",
"get",
"(",
"self",
",",
"bits",
"=",
"2048",
",",
"type",
"=",
"crypto",
".",
"TYPE_RSA",
",",
"digest",
"=",
"'sha1'",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Creating a new self-signed SSL certificate'",
")",
"# Generate the key and ready ... | Get a new self-signed certificate
@type bits: int
@type digest: str
@rtype: Certificate | [
"Get",
"a",
"new",
"self",
"-",
"signed",
"certificate"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/ssl.py#L18-L53 |
treycucco/bidon | bidon/util/convert.py | to_compressed_string | def to_compressed_string(val, max_length=0):
"""Converts val to a compressed string.
A compressed string is one with no leading or trailing spaces.
If val is None, or is blank (all spaces) None is returned.
If max_length > 0 and the stripped val is greater than max_length, val[:max_length] is returned.
""... | python | def to_compressed_string(val, max_length=0):
"""Converts val to a compressed string.
A compressed string is one with no leading or trailing spaces.
If val is None, or is blank (all spaces) None is returned.
If max_length > 0 and the stripped val is greater than max_length, val[:max_length] is returned.
""... | [
"def",
"to_compressed_string",
"(",
"val",
",",
"max_length",
"=",
"0",
")",
":",
"if",
"val",
"is",
"None",
"or",
"len",
"(",
"val",
")",
"==",
"0",
":",
"return",
"None",
"rval",
"=",
"\" \"",
".",
"join",
"(",
"val",
".",
"split",
"(",
")",
")... | Converts val to a compressed string.
A compressed string is one with no leading or trailing spaces.
If val is None, or is blank (all spaces) None is returned.
If max_length > 0 and the stripped val is greater than max_length, val[:max_length] is returned. | [
"Converts",
"val",
"to",
"a",
"compressed",
"string",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/convert.py#L55-L72 |
treycucco/bidon | bidon/util/convert.py | incrementor | def incrementor(start=0, step=1):
"""Returns a function that first returns the start value, and returns previous value + step on
each subsequent call.
"""
def fxn(_):
"""Returns the next value in the sequnce defined by [start::step)"""
nonlocal start
rval = start
start += step
return rval
... | python | def incrementor(start=0, step=1):
"""Returns a function that first returns the start value, and returns previous value + step on
each subsequent call.
"""
def fxn(_):
"""Returns the next value in the sequnce defined by [start::step)"""
nonlocal start
rval = start
start += step
return rval
... | [
"def",
"incrementor",
"(",
"start",
"=",
"0",
",",
"step",
"=",
"1",
")",
":",
"def",
"fxn",
"(",
"_",
")",
":",
"\"\"\"Returns the next value in the sequnce defined by [start::step)\"\"\"",
"nonlocal",
"start",
"rval",
"=",
"start",
"start",
"+=",
"step",
"retu... | Returns a function that first returns the start value, and returns previous value + step on
each subsequent call. | [
"Returns",
"a",
"function",
"that",
"first",
"returns",
"the",
"start",
"value",
"and",
"returns",
"previous",
"value",
"+",
"step",
"on",
"each",
"subsequent",
"call",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/convert.py#L122-L132 |
treycucco/bidon | bidon/util/convert.py | index_resolver | def index_resolver(index, strict=False):
"""Returns a function that accepts a value and returns index[value]."""
if strict:
return lambda id_: index[id_]
else:
return index.get | python | def index_resolver(index, strict=False):
"""Returns a function that accepts a value and returns index[value]."""
if strict:
return lambda id_: index[id_]
else:
return index.get | [
"def",
"index_resolver",
"(",
"index",
",",
"strict",
"=",
"False",
")",
":",
"if",
"strict",
":",
"return",
"lambda",
"id_",
":",
"index",
"[",
"id_",
"]",
"else",
":",
"return",
"index",
".",
"get"
] | Returns a function that accepts a value and returns index[value]. | [
"Returns",
"a",
"function",
"that",
"accepts",
"a",
"value",
"and",
"returns",
"index",
"[",
"value",
"]",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/convert.py#L150-L155 |
treycucco/bidon | bidon/util/convert.py | try_wrapper | def try_wrapper(fxn):
"""Wraps a function, returning (True, fxn(val)) if successful, (False, val) if not."""
def wrapper(val):
"""Try to call fxn with the given value. If successful, return (True, fxn(val)), otherwise
returns (False, val).
"""
try:
return (True, fxn(val))
except Exception:... | python | def try_wrapper(fxn):
"""Wraps a function, returning (True, fxn(val)) if successful, (False, val) if not."""
def wrapper(val):
"""Try to call fxn with the given value. If successful, return (True, fxn(val)), otherwise
returns (False, val).
"""
try:
return (True, fxn(val))
except Exception:... | [
"def",
"try_wrapper",
"(",
"fxn",
")",
":",
"def",
"wrapper",
"(",
"val",
")",
":",
"\"\"\"Try to call fxn with the given value. If successful, return (True, fxn(val)), otherwise\n returns (False, val).\n \"\"\"",
"try",
":",
"return",
"(",
"True",
",",
"fxn",
"(",
"v... | Wraps a function, returning (True, fxn(val)) if successful, (False, val) if not. | [
"Wraps",
"a",
"function",
"returning",
"(",
"True",
"fxn",
"(",
"val",
"))",
"if",
"successful",
"(",
"False",
"val",
")",
"if",
"not",
"."
] | train | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/convert.py#L171-L181 |
frommie/rasahub-google-calendar | rasahub_google_calendar/__init__.py | get_google_calendar_items | def get_google_calendar_items(user_id):
"""
Returns Google calendar items of a specific user
:param int user_id: (Humhub) User ID
:return: Busy appointments
:rtype: list
"""
global client_id
global client_secret
with open('tokens.json') as f:
try:
data = json.lo... | python | def get_google_calendar_items(user_id):
"""
Returns Google calendar items of a specific user
:param int user_id: (Humhub) User ID
:return: Busy appointments
:rtype: list
"""
global client_id
global client_secret
with open('tokens.json') as f:
try:
data = json.lo... | [
"def",
"get_google_calendar_items",
"(",
"user_id",
")",
":",
"global",
"client_id",
"global",
"client_secret",
"with",
"open",
"(",
"'tokens.json'",
")",
"as",
"f",
":",
"try",
":",
"data",
"=",
"json",
".",
"load",
"(",
"f",
")",
"except",
"ValueError",
... | Returns Google calendar items of a specific user
:param int user_id: (Humhub) User ID
:return: Busy appointments
:rtype: list | [
"Returns",
"Google",
"calendar",
"items",
"of",
"a",
"specific",
"user"
] | train | https://github.com/frommie/rasahub-google-calendar/blob/f5525b3798e84c01595c7505e2c7fbe43a1e9a05/rasahub_google_calendar/__init__.py#L72-L255 |
hirokiky/uiro | uiro/static.py | generate_static_matching | def generate_static_matching(app,
directory_serve_app=DirectoryApp):
""" Creating a matching for WSGI application to serve static files
for passed app.
Static files will be collected from directory named 'static'
under passed application::
./blog/static/
This ... | python | def generate_static_matching(app,
directory_serve_app=DirectoryApp):
""" Creating a matching for WSGI application to serve static files
for passed app.
Static files will be collected from directory named 'static'
under passed application::
./blog/static/
This ... | [
"def",
"generate_static_matching",
"(",
"app",
",",
"directory_serve_app",
"=",
"DirectoryApp",
")",
":",
"static_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"app",
".",
"__file__",
")",
",",
"'static'",
")",
"... | Creating a matching for WSGI application to serve static files
for passed app.
Static files will be collected from directory named 'static'
under passed application::
./blog/static/
This example is with an application named `blog`.
URLs for static files in static directory will begin with... | [
"Creating",
"a",
"matching",
"for",
"WSGI",
"application",
"to",
"serve",
"static",
"files",
"for",
"passed",
"app",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/static.py#L8-L37 |
hirokiky/uiro | uiro/static.py | get_static_app_matching | def get_static_app_matching(apps):
""" Returning a matching containing applications to serve static files
correspond to each passed applications.
"""
return reduce(lambda a, b: a + b,
[generate_static_matching(app)
for app in apps if app is not None]) | python | def get_static_app_matching(apps):
""" Returning a matching containing applications to serve static files
correspond to each passed applications.
"""
return reduce(lambda a, b: a + b,
[generate_static_matching(app)
for app in apps if app is not None]) | [
"def",
"get_static_app_matching",
"(",
"apps",
")",
":",
"return",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"+",
"b",
",",
"[",
"generate_static_matching",
"(",
"app",
")",
"for",
"app",
"in",
"apps",
"if",
"app",
"is",
"not",
"None",
"]",
"... | Returning a matching containing applications to serve static files
correspond to each passed applications. | [
"Returning",
"a",
"matching",
"containing",
"applications",
"to",
"serve",
"static",
"files",
"correspond",
"to",
"each",
"passed",
"applications",
"."
] | train | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/static.py#L40-L46 |
echinopsii/net.echinopsii.ariane.community.cli.python3 | ariane_clip3/directory.py | LocationService.find_location | def find_location(loc_id=None, loc_name=None):
"""
find the location according location id (prioritary) or location name
:param loc_id: the location id
:param loc_name: the location name
:return: found location or None if not found
"""
LOGGER.debug("LocationServic... | python | def find_location(loc_id=None, loc_name=None):
"""
find the location according location id (prioritary) or location name
:param loc_id: the location id
:param loc_name: the location name
:return: found location or None if not found
"""
LOGGER.debug("LocationServic... | [
"def",
"find_location",
"(",
"loc_id",
"=",
"None",
",",
"loc_name",
"=",
"None",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"LocationService.find_location\"",
")",
"if",
"(",
"loc_id",
"is",
"None",
"or",
"not",
"loc_id",
")",
"and",
"(",
"loc_name",
"is",
... | find the location according location id (prioritary) or location name
:param loc_id: the location id
:param loc_name: the location name
:return: found location or None if not found | [
"find",
"the",
"location",
"according",
"location",
"id",
"(",
"prioritary",
")",
"or",
"location",
"name",
":",
"param",
"loc_id",
":",
"the",
"location",
"id",
":",
"param",
"loc_name",
":",
"the",
"location",
"name",
":",
"return",
":",
"found",
"locati... | train | https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/directory.py#L55-L89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.