repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | file_attribs | def file_attribs(location,
mode=None,
owner=None,
group=None,
use_sudo=False,
recursive=True):
"""Updates the mode/owner/group for the remote file at the given
location."""
return dir_attribs(location=location,
... | python | def file_attribs(location,
mode=None,
owner=None,
group=None,
use_sudo=False,
recursive=True):
"""Updates the mode/owner/group for the remote file at the given
location."""
return dir_attribs(location=location,
... | [
"def",
"file_attribs",
"(",
"location",
",",
"mode",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"group",
"=",
"None",
",",
"use_sudo",
"=",
"False",
",",
"recursive",
"=",
"True",
")",
":",
"return",
"dir_attribs",
"(",
"location",
"=",
"location",
"... | Updates the mode/owner/group for the remote file at the given
location. | [
"Updates",
"the",
"mode",
"/",
"owner",
"/",
"group",
"for",
"the",
"remote",
"file",
"at",
"the",
"given",
"location",
"."
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L182-L195 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | os_release | def os_release():
""" returns /etc/os-release in a dictionary """
with settings(hide('warnings', 'running', 'stderr'),
warn_only=True, capture=True):
release = {}
data = run('cat /etc/os-release')
for line in data.split('\n'):
if not line:
c... | python | def os_release():
""" returns /etc/os-release in a dictionary """
with settings(hide('warnings', 'running', 'stderr'),
warn_only=True, capture=True):
release = {}
data = run('cat /etc/os-release')
for line in data.split('\n'):
if not line:
c... | [
"def",
"os_release",
"(",
")",
":",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
",",
"'stderr'",
")",
",",
"warn_only",
"=",
"True",
",",
"capture",
"=",
"True",
")",
":",
"release",
"=",
"{",
"}",
"data",
"=",
"run",
"(",
... | returns /etc/os-release in a dictionary | [
"returns",
"/",
"etc",
"/",
"os",
"-",
"release",
"in",
"a",
"dictionary"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L198-L212 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | linux_distribution | def linux_distribution():
""" returns the linux distribution in lower case """
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True, capture=True):
data = os_release()
return(data['ID']) | python | def linux_distribution():
""" returns the linux distribution in lower case """
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True, capture=True):
data = os_release()
return(data['ID']) | [
"def",
"linux_distribution",
"(",
")",
":",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
",",
"'stdout'",
",",
"'stderr'",
")",
",",
"warn_only",
"=",
"True",
",",
"capture",
"=",
"True",
")",
":",
"data",
"=",
"os_release",
"(",... | returns the linux distribution in lower case | [
"returns",
"the",
"linux",
"distribution",
"in",
"lower",
"case"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L215-L220 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | lsb_release | def lsb_release():
""" returns /etc/lsb-release in a dictionary """
with settings(hide('warnings', 'running'), capture=True):
_lsb_release = {}
data = sudo('cat /etc/lsb-release')
for line in data.split('\n'):
if not line:
continue
parts = line.sp... | python | def lsb_release():
""" returns /etc/lsb-release in a dictionary """
with settings(hide('warnings', 'running'), capture=True):
_lsb_release = {}
data = sudo('cat /etc/lsb-release')
for line in data.split('\n'):
if not line:
continue
parts = line.sp... | [
"def",
"lsb_release",
"(",
")",
":",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
")",
",",
"capture",
"=",
"True",
")",
":",
"_lsb_release",
"=",
"{",
"}",
"data",
"=",
"sudo",
"(",
"'cat /etc/lsb-release'",
")",
"for",
"line",
... | returns /etc/lsb-release in a dictionary | [
"returns",
"/",
"etc",
"/",
"lsb",
"-",
"release",
"in",
"a",
"dictionary"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L223-L236 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | restart_service | def restart_service(service, log=False):
""" restarts a service """
with settings():
if log:
bookshelf2.logging_helpers.log_yellow(
'stoping service %s' % service)
sudo('service %s stop' % service)
if log:
bookshelf2.logging_helpers.log_yellow(
... | python | def restart_service(service, log=False):
""" restarts a service """
with settings():
if log:
bookshelf2.logging_helpers.log_yellow(
'stoping service %s' % service)
sudo('service %s stop' % service)
if log:
bookshelf2.logging_helpers.log_yellow(
... | [
"def",
"restart_service",
"(",
"service",
",",
"log",
"=",
"False",
")",
":",
"with",
"settings",
"(",
")",
":",
"if",
"log",
":",
"bookshelf2",
".",
"logging_helpers",
".",
"log_yellow",
"(",
"'stoping service %s'",
"%",
"service",
")",
"sudo",
"(",
"'ser... | restarts a service | [
"restarts",
"a",
"service"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L246-L257 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | systemd | def systemd(service, start=True, enabled=True, unmask=False, restart=False):
""" manipulates systemd services """
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True, capture=True):
if restart:
sudo('systemctl restart %s' % service)
else:... | python | def systemd(service, start=True, enabled=True, unmask=False, restart=False):
""" manipulates systemd services """
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
warn_only=True, capture=True):
if restart:
sudo('systemctl restart %s' % service)
else:... | [
"def",
"systemd",
"(",
"service",
",",
"start",
"=",
"True",
",",
"enabled",
"=",
"True",
",",
"unmask",
"=",
"False",
",",
"restart",
"=",
"False",
")",
":",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
",",
"'stdout'",
",",
... | manipulates systemd services | [
"manipulates",
"systemd",
"services"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L260-L280 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | install_os_updates | def install_os_updates(distribution, force=False):
""" installs OS updates """
if ('centos' in distribution or
'rhel' in distribution or
'redhat' in distribution):
bookshelf2.logging_helpers.log_green('installing OS updates')
sudo("yum -y --quiet clean all")
sudo(... | python | def install_os_updates(distribution, force=False):
""" installs OS updates """
if ('centos' in distribution or
'rhel' in distribution or
'redhat' in distribution):
bookshelf2.logging_helpers.log_green('installing OS updates')
sudo("yum -y --quiet clean all")
sudo(... | [
"def",
"install_os_updates",
"(",
"distribution",
",",
"force",
"=",
"False",
")",
":",
"if",
"(",
"'centos'",
"in",
"distribution",
"or",
"'rhel'",
"in",
"distribution",
"or",
"'redhat'",
"in",
"distribution",
")",
":",
"bookshelf2",
".",
"logging_helpers",
"... | installs OS updates | [
"installs",
"OS",
"updates"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L319-L341 | train |
moralrecordings/mrcrowbar | mrcrowbar/statistics.py | Stats.ansi_format | def ansi_format( self, width=64, height=12 ):
"""Return a human readable ANSI-terminal printout of the stats.
width
Custom width for the graph (in characters).
height
Custom height for the graph (in characters).
"""
from mrcrowbar.ansi import format_bar_... | python | def ansi_format( self, width=64, height=12 ):
"""Return a human readable ANSI-terminal printout of the stats.
width
Custom width for the graph (in characters).
height
Custom height for the graph (in characters).
"""
from mrcrowbar.ansi import format_bar_... | [
"def",
"ansi_format",
"(",
"self",
",",
"width",
"=",
"64",
",",
"height",
"=",
"12",
")",
":",
"from",
"mrcrowbar",
".",
"ansi",
"import",
"format_bar_graph_iter",
"if",
"(",
"256",
"%",
"width",
")",
"!=",
"0",
":",
"raise",
"ValueError",
"(",
"'Widt... | Return a human readable ANSI-terminal printout of the stats.
width
Custom width for the graph (in characters).
height
Custom height for the graph (in characters). | [
"Return",
"a",
"human",
"readable",
"ANSI",
"-",
"terminal",
"printout",
"of",
"the",
"stats",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/statistics.py#L34-L59 | train |
saltant-org/saltant-py | saltant/models/task_whitelist.py | TaskWhitelist.put | def put(self):
"""Updates this task whitelist on the saltant server.
Returns:
:class:`saltant.models.task_whitelist.TaskWhitelist`:
A task whitelist model instance representing the task
whitelist just updated.
"""
return self.manager.put(
... | python | def put(self):
"""Updates this task whitelist on the saltant server.
Returns:
:class:`saltant.models.task_whitelist.TaskWhitelist`:
A task whitelist model instance representing the task
whitelist just updated.
"""
return self.manager.put(
... | [
"def",
"put",
"(",
"self",
")",
":",
"return",
"self",
".",
"manager",
".",
"put",
"(",
"id",
"=",
"self",
".",
"id",
",",
"name",
"=",
"self",
".",
"name",
",",
"description",
"=",
"self",
".",
"description",
",",
"whitelisted_container_task_types",
"... | Updates this task whitelist on the saltant server.
Returns:
:class:`saltant.models.task_whitelist.TaskWhitelist`:
A task whitelist model instance representing the task
whitelist just updated. | [
"Updates",
"this",
"task",
"whitelist",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_whitelist.py#L96-L114 | train |
saltant-org/saltant-py | saltant/models/task_whitelist.py | TaskWhitelistManager.create | def create(
self,
name,
description="",
whitelisted_container_task_types=None,
whitelisted_executable_task_types=None,
):
"""Create a task whitelist.
Args:
name (str): The name of the task whitelist.
description (str, optional): A desc... | python | def create(
self,
name,
description="",
whitelisted_container_task_types=None,
whitelisted_executable_task_types=None,
):
"""Create a task whitelist.
Args:
name (str): The name of the task whitelist.
description (str, optional): A desc... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"description",
"=",
"\"\"",
",",
"whitelisted_container_task_types",
"=",
"None",
",",
"whitelisted_executable_task_types",
"=",
"None",
",",
")",
":",
"# Translate whitelists None to [] if necessary",
"if",
"whitelisted_c... | Create a task whitelist.
Args:
name (str): The name of the task whitelist.
description (str, optional): A description of the task whitelist.
whitelisted_container_task_types (list, optional): A list of
whitelisted container task type IDs.
whitelis... | [
"Create",
"a",
"task",
"whitelist",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_whitelist.py#L163-L212 | train |
saltant-org/saltant-py | saltant/models/task_whitelist.py | TaskWhitelistManager.patch | def patch(
self,
id,
name=None,
description=None,
whitelisted_container_task_types=None,
whitelisted_executable_task_types=None,
):
"""Partially updates a task whitelist on the saltant server.
Args:
id (int): The ID of the task whitelist.
... | python | def patch(
self,
id,
name=None,
description=None,
whitelisted_container_task_types=None,
whitelisted_executable_task_types=None,
):
"""Partially updates a task whitelist on the saltant server.
Args:
id (int): The ID of the task whitelist.
... | [
"def",
"patch",
"(",
"self",
",",
"id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"whitelisted_container_task_types",
"=",
"None",
",",
"whitelisted_executable_task_types",
"=",
"None",
",",
")",
":",
"# Update the object",
"request_url",
"... | Partially updates a task whitelist on the saltant server.
Args:
id (int): The ID of the task whitelist.
name (str, optional): The name of the task whitelist.
description (str, optional): A description of the task whitelist.
whitelisted_container_task_types (list,... | [
"Partially",
"updates",
"a",
"task",
"whitelist",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_whitelist.py#L214-L270 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | enable_logging | def enable_logging( level='WARNING' ):
"""Enable sending logs to stderr. Useful for shell sessions.
level
Logging threshold, as defined in the logging module of the Python
standard library. Defaults to 'WARNING'.
"""
log = logging.getLogger( 'mrcrowbar' )
log.setLevel( level )
o... | python | def enable_logging( level='WARNING' ):
"""Enable sending logs to stderr. Useful for shell sessions.
level
Logging threshold, as defined in the logging module of the Python
standard library. Defaults to 'WARNING'.
"""
log = logging.getLogger( 'mrcrowbar' )
log.setLevel( level )
o... | [
"def",
"enable_logging",
"(",
"level",
"=",
"'WARNING'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'mrcrowbar'",
")",
"log",
".",
"setLevel",
"(",
"level",
")",
"out",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"out",
".",
"setLevel",... | Enable sending logs to stderr. Useful for shell sessions.
level
Logging threshold, as defined in the logging module of the Python
standard library. Defaults to 'WARNING'. | [
"Enable",
"sending",
"logs",
"to",
"stderr",
".",
"Useful",
"for",
"shell",
"sessions",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L15-L28 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | find_all_iter | def find_all_iter( source, substring, start=None, end=None, overlap=False ):
"""Iterate through every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (d... | python | def find_all_iter( source, substring, start=None, end=None, overlap=False ):
"""Iterate through every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (d... | [
"def",
"find_all_iter",
"(",
"source",
",",
"substring",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"overlap",
"=",
"False",
")",
":",
"data",
"=",
"source",
"base",
"=",
"0",
"if",
"end",
"is",
"not",
"None",
":",
"data",
"=",
"data"... | Iterate through every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
overlap
Whether to return overlapping matches (default: fa... | [
"Iterate",
"through",
"every",
"location",
"a",
"substring",
"can",
"be",
"found",
"in",
"a",
"source",
"string",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L51-L80 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | find_all | def find_all( source, substring, start=None, end=None, overlap=False ):
"""Return every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
... | python | def find_all( source, substring, start=None, end=None, overlap=False ):
"""Return every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
... | [
"def",
"find_all",
"(",
"source",
",",
"substring",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"overlap",
"=",
"False",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"find_all_iter",
"(",
"source",
",",
"substring",
",",
"start",
",",... | Return every location a substring can be found in a source string.
source
The source string to search.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
overlap
Whether to return overlapping matches (default: false) | [
"Return",
"every",
"location",
"a",
"substring",
"can",
"be",
"found",
"in",
"a",
"source",
"string",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L83-L98 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | basic_diff | def basic_diff( source1, source2, start=None, end=None ):
"""Perform a basic diff between two equal-sized binary strings and
return a list of (offset, size) tuples denoting the differences.
source1
The first byte string source.
source2
The second byte string source.
start
... | python | def basic_diff( source1, source2, start=None, end=None ):
"""Perform a basic diff between two equal-sized binary strings and
return a list of (offset, size) tuples denoting the differences.
source1
The first byte string source.
source2
The second byte string source.
start
... | [
"def",
"basic_diff",
"(",
"source1",
",",
"source2",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"start",
"=",
"start",
"if",
"start",
"is",
"not",
"None",
"else",
"0",
"end",
"=",
"end",
"if",
"end",
"is",
"not",
"None",
"else",
... | Perform a basic diff between two equal-sized binary strings and
return a list of (offset, size) tuples denoting the differences.
source1
The first byte string source.
source2
The second byte string source.
start
Start offset to read from (default: start)
end
End o... | [
"Perform",
"a",
"basic",
"diff",
"between",
"two",
"equal",
"-",
"sized",
"binary",
"strings",
"and",
"return",
"a",
"list",
"of",
"(",
"offset",
"size",
")",
"tuples",
"denoting",
"the",
"differences",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L101-L137 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | hexdump_iter | def hexdump_iter( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ):
"""Return the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
e... | python | def hexdump_iter( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ):
"""Return the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
e... | [
"def",
"hexdump_iter",
"(",
"source",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"major_len",
"=",
"8",
",",
"minor_len",
"=",
"4",
",",
"colour",
"=",
"True",
",",
"address_base",
"=",
"None",
")",
":",
"a... | Return the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
length
Length to read in (optional replacement for end)
... | [
"Return",
"the",
"contents",
"of",
"a",
"byte",
"string",
"in",
"tabular",
"hexadecimal",
"/",
"ASCII",
"format",
".",
"source",
"The",
"byte",
"string",
"to",
"print",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L160-L200 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | hexdump | def hexdump( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ):
"""Print the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
end
... | python | def hexdump( source, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, address_base=None ):
"""Print the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
end
... | [
"def",
"hexdump",
"(",
"source",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"major_len",
"=",
"8",
",",
"minor_len",
"=",
"4",
",",
"colour",
"=",
"True",
",",
"address_base",
"=",
"None",
")",
":",
"for",
... | Print the contents of a byte string in tabular hexadecimal/ASCII format.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
length
Length to read in (optional replacement for end)
... | [
"Print",
"the",
"contents",
"of",
"a",
"byte",
"string",
"in",
"tabular",
"hexadecimal",
"/",
"ASCII",
"format",
".",
"source",
"The",
"byte",
"string",
"to",
"print",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L203-L233 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | hexdump_diff_iter | def hexdump_diff_iter( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ):
"""Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
... | python | def hexdump_diff_iter( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ):
"""Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
... | [
"def",
"hexdump_diff_iter",
"(",
"source1",
",",
"source2",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"major_len",
"=",
"8",
",",
"minor_len",
"=",
"4",
",",
"colour",
"=",
"True",
",",
"before",
"=",
"2",
... | Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
The second byte string source.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
le... | [
"Returns",
"the",
"differences",
"between",
"two",
"byte",
"strings",
"in",
"tabular",
"hexadecimal",
"/",
"ASCII",
"format",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L236-L324 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | hexdump_diff | def hexdump_diff( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ):
"""Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
The s... | python | def hexdump_diff( source1, source2, start=None, end=None, length=None, major_len=8, minor_len=4, colour=True, before=2, after=2, address_base=None ):
"""Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
The s... | [
"def",
"hexdump_diff",
"(",
"source1",
",",
"source2",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"major_len",
"=",
"8",
",",
"minor_len",
"=",
"4",
",",
"colour",
"=",
"True",
",",
"before",
"=",
"2",
",",... | Returns the differences between two byte strings in tabular hexadecimal/ASCII format.
source1
The first byte string source.
source2
The second byte string source.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
le... | [
"Returns",
"the",
"differences",
"between",
"two",
"byte",
"strings",
"in",
"tabular",
"hexadecimal",
"/",
"ASCII",
"format",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L327-L366 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | unpack_bits | def unpack_bits( byte ):
"""Expand a bitfield into a 64-bit int (8 bool bytes)."""
longbits = byte & (0x00000000000000ff)
longbits = (longbits | (longbits<<28)) & (0x0000000f0000000f)
longbits = (longbits | (longbits<<14)) & (0x0003000300030003)
longbits = (longbits | (longbits<<7)) & (0x01010101010... | python | def unpack_bits( byte ):
"""Expand a bitfield into a 64-bit int (8 bool bytes)."""
longbits = byte & (0x00000000000000ff)
longbits = (longbits | (longbits<<28)) & (0x0000000f0000000f)
longbits = (longbits | (longbits<<14)) & (0x0003000300030003)
longbits = (longbits | (longbits<<7)) & (0x01010101010... | [
"def",
"unpack_bits",
"(",
"byte",
")",
":",
"longbits",
"=",
"byte",
"&",
"(",
"0x00000000000000ff",
")",
"longbits",
"=",
"(",
"longbits",
"|",
"(",
"longbits",
"<<",
"28",
")",
")",
"&",
"(",
"0x0000000f0000000f",
")",
"longbits",
"=",
"(",
"longbits"... | Expand a bitfield into a 64-bit int (8 bool bytes). | [
"Expand",
"a",
"bitfield",
"into",
"a",
"64",
"-",
"bit",
"int",
"(",
"8",
"bool",
"bytes",
")",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L376-L382 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | pack_bits | def pack_bits( longbits ):
"""Crunch a 64-bit int (8 bool bytes) into a bitfield."""
byte = longbits & (0x0101010101010101)
byte = (byte | (byte>>7)) & (0x0003000300030003)
byte = (byte | (byte>>14)) & (0x0000000f0000000f)
byte = (byte | (byte>>28)) & (0x00000000000000ff)
return byte | python | def pack_bits( longbits ):
"""Crunch a 64-bit int (8 bool bytes) into a bitfield."""
byte = longbits & (0x0101010101010101)
byte = (byte | (byte>>7)) & (0x0003000300030003)
byte = (byte | (byte>>14)) & (0x0000000f0000000f)
byte = (byte | (byte>>28)) & (0x00000000000000ff)
return byte | [
"def",
"pack_bits",
"(",
"longbits",
")",
":",
"byte",
"=",
"longbits",
"&",
"(",
"0x0101010101010101",
")",
"byte",
"=",
"(",
"byte",
"|",
"(",
"byte",
">>",
"7",
")",
")",
"&",
"(",
"0x0003000300030003",
")",
"byte",
"=",
"(",
"byte",
"|",
"(",
"... | Crunch a 64-bit int (8 bool bytes) into a bitfield. | [
"Crunch",
"a",
"64",
"-",
"bit",
"int",
"(",
"8",
"bool",
"bytes",
")",
"into",
"a",
"bitfield",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L385-L391 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | pixdump_iter | def pixdump_iter( source, start=None, end=None, length=None, width=64, height=None, palette=None ):
"""Return the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading a... | python | def pixdump_iter( source, start=None, end=None, length=None, width=64, height=None, palette=None ):
"""Return the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading a... | [
"def",
"pixdump_iter",
"(",
"source",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"width",
"=",
"64",
",",
"height",
"=",
"None",
",",
"palette",
"=",
"None",
")",
":",
"assert",
"is_bytes",
"(",
"source",
"... | Return the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
length
Length to read in (optional replacement for end)
width
Wi... | [
"Return",
"the",
"contents",
"of",
"a",
"byte",
"string",
"as",
"a",
"256",
"colour",
"image",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L394-L447 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | pixdump | def pixdump( source, start=None, end=None, length=None, width=64, height=None, palette=None ):
"""Print the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (def... | python | def pixdump( source, start=None, end=None, length=None, width=64, height=None, palette=None ):
"""Print the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (def... | [
"def",
"pixdump",
"(",
"source",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"length",
"=",
"None",
",",
"width",
"=",
"64",
",",
"height",
"=",
"None",
",",
"palette",
"=",
"None",
")",
":",
"for",
"line",
"in",
"pixdump_iter",
"(",
... | Print the contents of a byte string as a 256 colour image.
source
The byte string to print.
start
Start offset to read from (default: start)
end
End offset to stop reading at (default: end)
length
Length to read in (optional replacement for end)
width
Wid... | [
"Print",
"the",
"contents",
"of",
"a",
"byte",
"string",
"as",
"a",
"256",
"colour",
"image",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L450-L476 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | BitReader.set_offset | def set_offset( self, offset ):
"""Set the current read offset (in bytes) for the instance."""
assert offset in range( len( self.buffer ) )
self.pos = offset
self._fill_buffer() | python | def set_offset( self, offset ):
"""Set the current read offset (in bytes) for the instance."""
assert offset in range( len( self.buffer ) )
self.pos = offset
self._fill_buffer() | [
"def",
"set_offset",
"(",
"self",
",",
"offset",
")",
":",
"assert",
"offset",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"buffer",
")",
")",
"self",
".",
"pos",
"=",
"offset",
"self",
".",
"_fill_buffer",
"(",
")"
] | Set the current read offset (in bytes) for the instance. | [
"Set",
"the",
"current",
"read",
"offset",
"(",
"in",
"bytes",
")",
"for",
"the",
"instance",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L538-L542 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | BitReader.get_bits | def get_bits( self, count ):
"""Get an integer containing the next [count] bits from the source."""
result = 0
for i in range( count ):
if self.bits_remaining <= 0:
self._fill_buffer()
if self.bits_reverse:
bit = (1 if (self.current_bits & ... | python | def get_bits( self, count ):
"""Get an integer containing the next [count] bits from the source."""
result = 0
for i in range( count ):
if self.bits_remaining <= 0:
self._fill_buffer()
if self.bits_reverse:
bit = (1 if (self.current_bits & ... | [
"def",
"get_bits",
"(",
"self",
",",
"count",
")",
":",
"result",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"if",
"self",
".",
"bits_remaining",
"<=",
"0",
":",
"self",
".",
"_fill_buffer",
"(",
")",
"if",
"self",
".",
"bits_reve... | Get an integer containing the next [count] bits from the source. | [
"Get",
"an",
"integer",
"containing",
"the",
"next",
"[",
"count",
"]",
"bits",
"from",
"the",
"source",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L545-L566 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | BitWriter.put_bits | def put_bits( self, value, count ):
"""Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target.
"""
for _ in range( count ):
... | python | def put_bits( self, value, count ):
"""Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target.
"""
for _ in range( count ):
... | [
"def",
"put_bits",
"(",
"self",
",",
"value",
",",
"count",
")",
":",
"for",
"_",
"in",
"range",
"(",
"count",
")",
":",
"# bits are retrieved from the source LSB first",
"bit",
"=",
"(",
"value",
"&",
"1",
")",
"value",
">>=",
"1",
"# however, bits are put ... | Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target. | [
"Push",
"bits",
"into",
"the",
"target",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L592-L627 | train |
moralrecordings/mrcrowbar | mrcrowbar/utils.py | BitWriter.get_buffer | def get_buffer( self ):
"""Return a byte string containing the target as currently written."""
last_byte = self.current_bits if (self.bits_remaining < 8) else None
result = self.output
if last_byte is not None:
result = bytearray( result )
result.append( last_byt... | python | def get_buffer( self ):
"""Return a byte string containing the target as currently written."""
last_byte = self.current_bits if (self.bits_remaining < 8) else None
result = self.output
if last_byte is not None:
result = bytearray( result )
result.append( last_byt... | [
"def",
"get_buffer",
"(",
"self",
")",
":",
"last_byte",
"=",
"self",
".",
"current_bits",
"if",
"(",
"self",
".",
"bits_remaining",
"<",
"8",
")",
"else",
"None",
"result",
"=",
"self",
".",
"output",
"if",
"last_byte",
"is",
"not",
"None",
":",
"resu... | Return a byte string containing the target as currently written. | [
"Return",
"a",
"byte",
"string",
"containing",
"the",
"target",
"as",
"currently",
"written",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L629-L641 | train |
Riffstation/Flask-Philo-SQLAlchemy | flask_philo_sqlalchemy/orm.py | BaseManager.get_for_update | def get_for_update(self, connection_name='DEFAULT', **kwargs):
"""
http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa
"""
if not kwargs:
raise InvalidQueryError(
"Can not execute a query wit... | python | def get_for_update(self, connection_name='DEFAULT', **kwargs):
"""
http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa
"""
if not kwargs:
raise InvalidQueryError(
"Can not execute a query wit... | [
"def",
"get_for_update",
"(",
"self",
",",
"connection_name",
"=",
"'DEFAULT'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
":",
"raise",
"InvalidQueryError",
"(",
"\"Can not execute a query without parameters\"",
")",
"obj",
"=",
"self",
".",
"poo... | http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa | [
"http",
":",
"//",
"docs",
".",
"sqlalchemy",
".",
"org",
"/",
"en",
"/",
"latest",
"/",
"orm",
"/",
"query",
".",
"html?highlight",
"=",
"update#sqlalchemy",
".",
"orm",
".",
"query",
".",
"Query",
".",
"with_for_update",
"#",
"noqa"
] | 71598bb603b8458a2cf9f7989f71d8f1c77fafb9 | https://github.com/Riffstation/Flask-Philo-SQLAlchemy/blob/71598bb603b8458a2cf9f7989f71d8f1c77fafb9/flask_philo_sqlalchemy/orm.py#L35-L49 | train |
tsnaomi/finnsyll | finnsyll/prev/v07.py | syllabify | def syllabify(word, compound=None):
'''Syllabify the given word, whether simplex or complex.'''
if compound is None:
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll, rules
n = 7
if '... | python | def syllabify(word, compound=None):
'''Syllabify the given word, whether simplex or complex.'''
if compound is None:
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll, rules
n = 7
if '... | [
"def",
"syllabify",
"(",
"word",
",",
"compound",
"=",
"None",
")",
":",
"if",
"compound",
"is",
"None",
":",
"compound",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'(-| |=)'",
",",
"word",
")",
")",
"syllabify",
"=",
"_syllabify_compound",
"if",
"c... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v07.py#L17-L43 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.convert_case | def convert_case(name):
"""Converts name from CamelCase to snake_case"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | python | def convert_case(name):
"""Converts name from CamelCase to snake_case"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"def",
"convert_case",
"(",
"name",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"name",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(",
")"... | Converts name from CamelCase to snake_case | [
"Converts",
"name",
"from",
"CamelCase",
"to",
"snake_case"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L35-L38 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.table_name | def table_name(self):
"""Pluralises the class_name using utterly simple algo and returns as table_name"""
if not self.class_name:
raise ValueError
else:
tbl_name = ModelCompiler.convert_case(self.class_name)
last_letter = tbl_name[-1]
if last_letter in ("y... | python | def table_name(self):
"""Pluralises the class_name using utterly simple algo and returns as table_name"""
if not self.class_name:
raise ValueError
else:
tbl_name = ModelCompiler.convert_case(self.class_name)
last_letter = tbl_name[-1]
if last_letter in ("y... | [
"def",
"table_name",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"class_name",
":",
"raise",
"ValueError",
"else",
":",
"tbl_name",
"=",
"ModelCompiler",
".",
"convert_case",
"(",
"self",
".",
"class_name",
")",
"last_letter",
"=",
"tbl_name",
"[",
"-... | Pluralises the class_name using utterly simple algo and returns as table_name | [
"Pluralises",
"the",
"class_name",
"using",
"utterly",
"simple",
"algo",
"and",
"returns",
"as",
"table_name"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L41-L53 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.types | def types(self):
"""All the unique types found in user supplied model"""
res = []
for column in self.column_definitions:
tmp = column.get('type', None)
res.append(ModelCompiler.get_column_type(tmp)) if tmp else False
res = list(set(res))
return res | python | def types(self):
"""All the unique types found in user supplied model"""
res = []
for column in self.column_definitions:
tmp = column.get('type', None)
res.append(ModelCompiler.get_column_type(tmp)) if tmp else False
res = list(set(res))
return res | [
"def",
"types",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"column_definitions",
":",
"tmp",
"=",
"column",
".",
"get",
"(",
"'type'",
",",
"None",
")",
"res",
".",
"append",
"(",
"ModelCompiler",
".",
"get_colum... | All the unique types found in user supplied model | [
"All",
"the",
"unique",
"types",
"found",
"in",
"user",
"supplied",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L71-L78 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.basic_types | def basic_types(self):
"""Returns non-postgres types referenced in user supplied model """
if not self.foreign_key_definitions:
return self.standard_types
else:
tmp = self.standard_types
tmp.append('ForeignKey')
return tmp | python | def basic_types(self):
"""Returns non-postgres types referenced in user supplied model """
if not self.foreign_key_definitions:
return self.standard_types
else:
tmp = self.standard_types
tmp.append('ForeignKey')
return tmp | [
"def",
"basic_types",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"foreign_key_definitions",
":",
"return",
"self",
".",
"standard_types",
"else",
":",
"tmp",
"=",
"self",
".",
"standard_types",
"tmp",
".",
"append",
"(",
"'ForeignKey'",
")",
"return",
... | Returns non-postgres types referenced in user supplied model | [
"Returns",
"non",
"-",
"postgres",
"types",
"referenced",
"in",
"user",
"supplied",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L91-L98 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.primary_keys | def primary_keys(self):
"""Returns the primary keys referenced in user supplied model"""
res = []
for column in self.column_definitions:
if 'primary_key' in column.keys():
tmp = column.get('primary_key', None)
res.append(column['name']) if tmp else Fal... | python | def primary_keys(self):
"""Returns the primary keys referenced in user supplied model"""
res = []
for column in self.column_definitions:
if 'primary_key' in column.keys():
tmp = column.get('primary_key', None)
res.append(column['name']) if tmp else Fal... | [
"def",
"primary_keys",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"column_definitions",
":",
"if",
"'primary_key'",
"in",
"column",
".",
"keys",
"(",
")",
":",
"tmp",
"=",
"column",
".",
"get",
"(",
"'primary_key'"... | Returns the primary keys referenced in user supplied model | [
"Returns",
"the",
"primary",
"keys",
"referenced",
"in",
"user",
"supplied",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L105-L112 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_named_imports | def compiled_named_imports(self):
"""Returns compiled named imports required for the model"""
res = []
if self.postgres_types:
res.append(
ALCHEMY_TEMPLATES.named_import.safe_substitute(
module='sqlalchemy.dialects.postgresql',
... | python | def compiled_named_imports(self):
"""Returns compiled named imports required for the model"""
res = []
if self.postgres_types:
res.append(
ALCHEMY_TEMPLATES.named_import.safe_substitute(
module='sqlalchemy.dialects.postgresql',
... | [
"def",
"compiled_named_imports",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"if",
"self",
".",
"postgres_types",
":",
"res",
".",
"append",
"(",
"ALCHEMY_TEMPLATES",
".",
"named_import",
".",
"safe_substitute",
"(",
"module",
"=",
"'sqlalchemy.dialects.postgre... | Returns compiled named imports required for the model | [
"Returns",
"compiled",
"named",
"imports",
"required",
"for",
"the",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L115-L128 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_orm_imports | def compiled_orm_imports(self):
"""Returns compiled named imports required for the model"""
module = 'sqlalchemy.orm'
labels = []
if self.relationship_definitions:
labels.append("relationship")
return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, label... | python | def compiled_orm_imports(self):
"""Returns compiled named imports required for the model"""
module = 'sqlalchemy.orm'
labels = []
if self.relationship_definitions:
labels.append("relationship")
return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, label... | [
"def",
"compiled_orm_imports",
"(",
"self",
")",
":",
"module",
"=",
"'sqlalchemy.orm'",
"labels",
"=",
"[",
"]",
"if",
"self",
".",
"relationship_definitions",
":",
"labels",
".",
"append",
"(",
"\"relationship\"",
")",
"return",
"ALCHEMY_TEMPLATES",
".",
"name... | Returns compiled named imports required for the model | [
"Returns",
"compiled",
"named",
"imports",
"required",
"for",
"the",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L131-L137 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_columns | def compiled_columns(self):
"""Returns compiled column definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type'):
if arg_name in ('server_default', 'server_onupdate'):
... | python | def compiled_columns(self):
"""Returns compiled column definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type'):
if arg_name in ('server_default', 'server_onupdate'):
... | [
"def",
"compiled_columns",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'",
"... | Returns compiled column definitions | [
"Returns",
"compiled",
"column",
"definitions"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L140-L168 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_foreign_keys | def compiled_foreign_keys(self):
"""Returns compiled foreign key definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference'):
if arg_name in ('server_default', ... | python | def compiled_foreign_keys(self):
"""Returns compiled foreign key definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference'):
if arg_name in ('server_default', ... | [
"def",
"compiled_foreign_keys",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'"... | Returns compiled foreign key definitions | [
"Returns",
"compiled",
"foreign",
"key",
"definitions"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L171-L206 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_relationships | def compiled_relationships(self):
"""Returns compiled relationship definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference', 'class'):
if arg_name in ('back_p... | python | def compiled_relationships(self):
"""Returns compiled relationship definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference', 'class'):
if arg_name in ('back_p... | [
"def",
"compiled_relationships",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'... | Returns compiled relationship definitions | [
"Returns",
"compiled",
"relationship",
"definitions"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L209-L232 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.columns | def columns(self):
"""Return names of all the addressable columns (including foreign keys) referenced in user supplied model"""
res = [col['name'] for col in self.column_definitions]
res.extend([col['name'] for col in self.foreign_key_definitions])
return res | python | def columns(self):
"""Return names of all the addressable columns (including foreign keys) referenced in user supplied model"""
res = [col['name'] for col in self.column_definitions]
res.extend([col['name'] for col in self.foreign_key_definitions])
return res | [
"def",
"columns",
"(",
"self",
")",
":",
"res",
"=",
"[",
"col",
"[",
"'name'",
"]",
"for",
"col",
"in",
"self",
".",
"column_definitions",
"]",
"res",
".",
"extend",
"(",
"[",
"col",
"[",
"'name'",
"]",
"for",
"col",
"in",
"self",
".",
"foreign_ke... | Return names of all the addressable columns (including foreign keys) referenced in user supplied model | [
"Return",
"names",
"of",
"all",
"the",
"addressable",
"columns",
"(",
"including",
"foreign",
"keys",
")",
"referenced",
"in",
"user",
"supplied",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L235-L239 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_init_func | def compiled_init_func(self):
"""Returns compiled init function"""
def get_column_assignment(column_name):
return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg.safe_substitute(ar... | python | def compiled_init_func(self):
"""Returns compiled init function"""
def get_column_assignment(column_name):
return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg.safe_substitute(ar... | [
"def",
"compiled_init_func",
"(",
"self",
")",
":",
"def",
"get_column_assignment",
"(",
"column_name",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"col_assignment",
".",
"safe_substitute",
"(",
"col_name",
"=",
"column_name",
")",
"def",
"get_compiled_args",
"(",... | Returns compiled init function | [
"Returns",
"compiled",
"init",
"function"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L242-L255 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_update_func | def compiled_update_func(self):
"""Returns compiled update function"""
def get_not_none_col_assignment(column_name):
return ALCHEMY_TEMPLATES.not_none_col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg... | python | def compiled_update_func(self):
"""Returns compiled update function"""
def get_not_none_col_assignment(column_name):
return ALCHEMY_TEMPLATES.not_none_col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg... | [
"def",
"compiled_update_func",
"(",
"self",
")",
":",
"def",
"get_not_none_col_assignment",
"(",
"column_name",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"not_none_col_assignment",
".",
"safe_substitute",
"(",
"col_name",
"=",
"column_name",
")",
"def",
"get_compi... | Returns compiled update function | [
"Returns",
"compiled",
"update",
"function"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L258-L273 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_hash_func | def compiled_hash_func(self):
"""Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way"""
def get_primary_key_str(pkey_name):
return "str(self.{})".format(pkey_name)
hash_str = "+ ".join([get_primary_key_str(n) for n in ... | python | def compiled_hash_func(self):
"""Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way"""
def get_primary_key_str(pkey_name):
return "str(self.{})".format(pkey_name)
hash_str = "+ ".join([get_primary_key_str(n) for n in ... | [
"def",
"compiled_hash_func",
"(",
"self",
")",
":",
"def",
"get_primary_key_str",
"(",
"pkey_name",
")",
":",
"return",
"\"str(self.{})\"",
".",
"format",
"(",
"pkey_name",
")",
"hash_str",
"=",
"\"+ \"",
".",
"join",
"(",
"[",
"get_primary_key_str",
"(",
"n",... | Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way | [
"Returns",
"compiled",
"hash",
"function",
"based",
"on",
"hash",
"of",
"stringified",
"primary_keys",
".",
"This",
"isn",
"t",
"the",
"most",
"efficient",
"way"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L276-L284 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.representation_function_compiler | def representation_function_compiler(self, func_name):
"""Generic function can be used to compile __repr__ or __unicode__ or __str__"""
def get_col_accessor(col):
return ALCHEMY_TEMPLATES.col_accessor.safe_substitute(col=col)
def get_col_evaluator(col):
return ALCHEMY_T... | python | def representation_function_compiler(self, func_name):
"""Generic function can be used to compile __repr__ or __unicode__ or __str__"""
def get_col_accessor(col):
return ALCHEMY_TEMPLATES.col_accessor.safe_substitute(col=col)
def get_col_evaluator(col):
return ALCHEMY_T... | [
"def",
"representation_function_compiler",
"(",
"self",
",",
"func_name",
")",
":",
"def",
"get_col_accessor",
"(",
"col",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"col_accessor",
".",
"safe_substitute",
"(",
"col",
"=",
"col",
")",
"def",
"get_col_evaluator"... | Generic function can be used to compile __repr__ or __unicode__ or __str__ | [
"Generic",
"function",
"can",
"be",
"used",
"to",
"compile",
"__repr__",
"or",
"__unicode__",
"or",
"__str__"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L308-L323 | train |
danishabdullah/algen | algen/compilers.py | ModelCompiler.compiled_model | def compiled_model(self):
"""Returns compile ORM class for the user supplied model"""
return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name,
table_name=self.table_name,
colum... | python | def compiled_model(self):
"""Returns compile ORM class for the user supplied model"""
return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name,
table_name=self.table_name,
colum... | [
"def",
"compiled_model",
"(",
"self",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"model",
".",
"safe_substitute",
"(",
"class_name",
"=",
"self",
".",
"class_name",
",",
"table_name",
"=",
"self",
".",
"table_name",
",",
"column_definitions",
"=",
"self",
"... | Returns compile ORM class for the user supplied model | [
"Returns",
"compile",
"ORM",
"class",
"for",
"the",
"user",
"supplied",
"model"
] | 642ba26d8721c588fce505ac67528070c1edc264 | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L346-L370 | train |
saltant-org/saltant-py | saltant/models/task_queue.py | TaskQueue.put | def put(self):
"""Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated.
"""
return self.manager.put(
id=self.id,
... | python | def put(self):
"""Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated.
"""
return self.manager.put(
id=self.id,
... | [
"def",
"put",
"(",
"self",
")",
":",
"return",
"self",
".",
"manager",
".",
"put",
"(",
"id",
"=",
"self",
".",
"id",
",",
"name",
"=",
"self",
".",
"name",
",",
"description",
"=",
"self",
".",
"description",
",",
"private",
"=",
"self",
".",
"p... | Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated. | [
"Updates",
"this",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L119-L137 | train |
saltant-org/saltant-py | saltant/models/task_queue.py | TaskQueueManager.get | def get(self, id=None, name=None):
"""Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:... | python | def get(self, id=None, name=None):
"""Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:... | [
"def",
"get",
"(",
"self",
",",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# Validate arguments - use an xor",
"if",
"not",
"(",
"id",
"is",
"None",
")",
"^",
"(",
"name",
"is",
"None",
")",
":",
"raise",
"ValueError",
"(",
"\"Either id or... | Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
... | [
"Get",
"a",
"task",
"queue",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L156-L183 | train |
saltant-org/saltant-py | saltant/models/task_queue.py | TaskQueueManager.create | def create(
self,
name,
description="",
private=False,
runs_executable_tasks=True,
runs_docker_container_tasks=True,
runs_singularity_container_tasks=True,
active=True,
whitelists=None,
):
"""Create a task queue.
Args:
... | python | def create(
self,
name,
description="",
private=False,
runs_executable_tasks=True,
runs_docker_container_tasks=True,
runs_singularity_container_tasks=True,
active=True,
whitelists=None,
):
"""Create a task queue.
Args:
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"description",
"=",
"\"\"",
",",
"private",
"=",
"False",
",",
"runs_executable_tasks",
"=",
"True",
",",
"runs_docker_container_tasks",
"=",
"True",
",",
"runs_singularity_container_tasks",
"=",
"True",
",",
"acti... | Create a task queue.
Args:
name (str): The name of the task queue.
description (str, optional): A description of the task queue.
private (bool, optional): A boolean specifying whether the
queue is exclusive to its creator. Defaults to False.
runs_... | [
"Create",
"a",
"task",
"queue",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L185-L250 | train |
saltant-org/saltant-py | saltant/models/task_queue.py | TaskQueueManager.patch | def patch(
self,
id,
name=None,
description=None,
private=None,
runs_executable_tasks=None,
runs_docker_container_tasks=None,
runs_singularity_container_tasks=None,
active=None,
whitelists=None,
):
"""Partially updates a task qu... | python | def patch(
self,
id,
name=None,
description=None,
private=None,
runs_executable_tasks=None,
runs_docker_container_tasks=None,
runs_singularity_container_tasks=None,
active=None,
whitelists=None,
):
"""Partially updates a task qu... | [
"def",
"patch",
"(",
"self",
",",
"id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"private",
"=",
"None",
",",
"runs_executable_tasks",
"=",
"None",
",",
"runs_docker_container_tasks",
"=",
"None",
",",
"runs_singularity_container_tasks",
... | Partially updates a task queue on the saltant server.
Args:
id (int): The ID of the task queue.
name (str, optional): The name of the task queue.
description (str, optional): The description of the task
queue.
private (bool, optional): A Booleon s... | [
"Partially",
"updates",
"a",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L252-L334 | train |
saltant-org/saltant-py | saltant/models/task_queue.py | TaskQueueManager.put | def put(
self,
id,
name,
description,
private,
runs_executable_tasks,
runs_docker_container_tasks,
runs_singularity_container_tasks,
active,
whitelists,
):
"""Updates a task queue on the saltant server.
Args:
... | python | def put(
self,
id,
name,
description,
private,
runs_executable_tasks,
runs_docker_container_tasks,
runs_singularity_container_tasks,
active,
whitelists,
):
"""Updates a task queue on the saltant server.
Args:
... | [
"def",
"put",
"(",
"self",
",",
"id",
",",
"name",
",",
"description",
",",
"private",
",",
"runs_executable_tasks",
",",
"runs_docker_container_tasks",
",",
"runs_singularity_container_tasks",
",",
"active",
",",
"whitelists",
",",
")",
":",
"# Update the object",
... | Updates a task queue on the saltant server.
Args:
id (int): The ID of the task queue.
name (str): The name of the task queue.
description (str): The description of the task queue.
private (bool): A Booleon signalling whether the queue can
only be ... | [
"Updates",
"a",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L336-L397 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenSBait.main | def main(self):
"""
Run the required methods in the appropriate order
"""
self.targets()
self.bait(k=49)
self.reversebait(maskmiddle='t', k=19)
self.subsample_reads() | python | def main(self):
"""
Run the required methods in the appropriate order
"""
self.targets()
self.bait(k=49)
self.reversebait(maskmiddle='t', k=19)
self.subsample_reads() | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"targets",
"(",
")",
"self",
".",
"bait",
"(",
"k",
"=",
"49",
")",
"self",
".",
"reversebait",
"(",
"maskmiddle",
"=",
"'t'",
",",
"k",
"=",
"19",
")",
"self",
".",
"subsample_reads",
"(",
")"
] | Run the required methods in the appropriate order | [
"Run",
"the",
"required",
"methods",
"in",
"the",
"appropriate",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L31-L38 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenSBait.targets | def targets(self):
"""
Create the GenObject for the analysis type, create the hash file for baiting (if necessary)
"""
for sample in self.runmetadata:
if sample.general.bestassemblyfile != 'NA':
setattr(sample, self.analysistype, GenObject())
s... | python | def targets(self):
"""
Create the GenObject for the analysis type, create the hash file for baiting (if necessary)
"""
for sample in self.runmetadata:
if sample.general.bestassemblyfile != 'NA':
setattr(sample, self.analysistype, GenObject())
s... | [
"def",
"targets",
"(",
"self",
")",
":",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"setattr",
"(",
"sample",
",",
"self",
".",
"analysistype",
",",
"GenObject",
"("... | Create the GenObject for the analysis type, create the hash file for baiting (if necessary) | [
"Create",
"the",
"GenObject",
"for",
"the",
"analysis",
"type",
"create",
"the",
"hash",
"file",
"for",
"baiting",
"(",
"if",
"necessary",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L40-L61 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenSSipper.targets | def targets(self):
"""
Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code
"""
logging.info('Performi... | python | def targets(self):
"""
Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code
"""
logging.info('Performi... | [
"def",
"targets",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Performing analysis with {} targets folder'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
":",
"if",
"sample",
".",
"gen... | Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code | [
"Using",
"the",
"data",
"from",
"the",
"BLAST",
"analyses",
"set",
"the",
"targets",
"folder",
"and",
"create",
"the",
"mapping",
"file",
".",
"This",
"is",
"the",
"genera",
"-",
"specific",
"FASTA",
"file",
"that",
"will",
"be",
"used",
"for",
"all",
"t... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L82-L106 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.runner | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be false in order ... | python | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be false in order ... | [
"def",
"runner",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# If the metadata has been passed from the method script, s... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L111-L151 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.subsample | def subsample(self):
"""
Subsample 1000 reads from the baited files
"""
# Create the threads for the analysis
logging.info('Subsampling FASTQ reads')
for _ in range(self.cpus):
threads = Thread(target=self.subsamplethreads, args=())
threads.setDaem... | python | def subsample(self):
"""
Subsample 1000 reads from the baited files
"""
# Create the threads for the analysis
logging.info('Subsampling FASTQ reads')
for _ in range(self.cpus):
threads = Thread(target=self.subsamplethreads, args=())
threads.setDaem... | [
"def",
"subsample",
"(",
"self",
")",
":",
"# Create the threads for the analysis",
"logging",
".",
"info",
"(",
"'Subsampling FASTQ reads'",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
"=",
"s... | Subsample 1000 reads from the baited files | [
"Subsample",
"1000",
"reads",
"from",
"the",
"baited",
"files"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L153-L175 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.fasta | def fasta(self):
"""
Convert the subsampled reads to FASTA format using reformat.sh
"""
logging.info('Converting FASTQ files to FASTA format')
# Create the threads for the analysis
for _ in range(self.cpus):
threads = Thread(target=self.fastathreads, args=())
... | python | def fasta(self):
"""
Convert the subsampled reads to FASTA format using reformat.sh
"""
logging.info('Converting FASTQ files to FASTA format')
# Create the threads for the analysis
for _ in range(self.cpus):
threads = Thread(target=self.fastathreads, args=())
... | [
"def",
"fasta",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Converting FASTQ files to FASTA format'",
")",
"# Create the threads for the analysis",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
... | Convert the subsampled reads to FASTA format using reformat.sh | [
"Convert",
"the",
"subsampled",
"reads",
"to",
"FASTA",
"format",
"using",
"reformat",
".",
"sh"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L194-L216 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.makeblastdb | def makeblastdb(self):
"""
Makes blast database files from targets as necessary
"""
# Iterate through the samples to set the bait file.
for sample in self.runmetadata.samples:
if sample.general.bestassemblyfile != 'NA':
# Remove the file extension
... | python | def makeblastdb(self):
"""
Makes blast database files from targets as necessary
"""
# Iterate through the samples to set the bait file.
for sample in self.runmetadata.samples:
if sample.general.bestassemblyfile != 'NA':
# Remove the file extension
... | [
"def",
"makeblastdb",
"(",
"self",
")",
":",
"# Iterate through the samples to set the bait file.",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"# Remove the file... | Makes blast database files from targets as necessary | [
"Makes",
"blast",
"database",
"files",
"from",
"targets",
"as",
"necessary"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L235-L259 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.blast | def blast(self):
"""
Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database
"""
logging.info('BLASTing FASTA files against {} database'.format(self.analysistype))
for _ in range(self.cpus):
threads = Thread(target=self.blastthreads, a... | python | def blast(self):
"""
Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database
"""
logging.info('BLASTing FASTA files against {} database'.format(self.analysistype))
for _ in range(self.cpus):
threads = Thread(target=self.blastthreads, a... | [
"def",
"blast",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'BLASTing FASTA files against {} database'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"T... | Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database | [
"Run",
"BLAST",
"analyses",
"of",
"the",
"subsampled",
"FASTQ",
"reads",
"against",
"the",
"NCBI",
"16S",
"reference",
"database"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L261-L289 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.blastparse | def blastparse(self):
"""
Parse the blast results, and store necessary data in dictionaries in sample object
"""
logging.info('Parsing BLAST results')
# Load the NCBI 16S reference database as a dictionary
for sample in self.runmetadata.samples:
if sample.gene... | python | def blastparse(self):
"""
Parse the blast results, and store necessary data in dictionaries in sample object
"""
logging.info('Parsing BLAST results')
# Load the NCBI 16S reference database as a dictionary
for sample in self.runmetadata.samples:
if sample.gene... | [
"def",
"blastparse",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Parsing BLAST results'",
")",
"# Load the NCBI 16S reference database as a dictionary",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"if",
"sample",
".",
"general",... | Parse the blast results, and store necessary data in dictionaries in sample object | [
"Parse",
"the",
"blast",
"results",
"and",
"store",
"necessary",
"data",
"in",
"dictionaries",
"in",
"sample",
"object"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L304-L361 | train |
OLC-Bioinformatics/sipprverse | sixteenS/sixteens_full.py | SixteenS.reporter | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
logging.info('Creating {} report'.format(self.analysistype))
# Initialise the header and data strings
header = 'Strain,... | python | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
logging.info('Creating {} report'.format(self.analysistype))
# Initialise the header and data strings
header = 'Strain,... | [
"def",
"reporter",
"(",
"self",
")",
":",
"# Create the path in which the reports are stored",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"# Init... | Creates a report of the results | [
"Creates",
"a",
"report",
"of",
"the",
"results"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L364-L413 | train |
QunarOPS/qg.core | qg/core/observer.py | Observable.add_listener | def add_listener(self, evt_name, fn):
"""添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。
"""
self._listeners.setdefault(evt_name, [])
listeners = self.__get_listeners(evt_name)
lis... | python | def add_listener(self, evt_name, fn):
"""添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。
"""
self._listeners.setdefault(evt_name, [])
listeners = self.__get_listeners(evt_name)
lis... | [
"def",
"add_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
")",
":",
"self",
".",
"_listeners",
".",
"setdefault",
"(",
"evt_name",
",",
"[",
"]",
")",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"listeners",
".",
"append... | 添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。 | [
"添加观察者函数。"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L59-L70 | train |
QunarOPS/qg.core | qg/core/observer.py | Observable.remove_listener | def remove_listener(self, evt_name, fn, remove_all=False):
"""删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
... | python | def remove_listener(self, evt_name, fn, remove_all=False):
"""删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
... | [
"def",
"remove_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
",",
"remove_all",
"=",
"False",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"if",
"not",
"self",
".",
"has_listener",
"(",
"evt_name",
",",
"fn",
")... | 删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
允许一个函数多次注册,多次注册意味着一次时间多次调用。 | [
"删除观察者函数。"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L72-L92 | train |
QunarOPS/qg.core | qg/core/observer.py | Observable.has_listener | def has_listener(self, evt_name, fn):
"""指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
"""
listeners = self.__get_listeners(evt_name)
return fn in listeners | python | def has_listener(self, evt_name, fn):
"""指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
"""
listeners = self.__get_listeners(evt_name)
return fn in listeners | [
"def",
"has_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"return",
"fn",
"in",
"listeners"
] | 指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数 | [
"指定listener是否存在"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L94-L101 | train |
QunarOPS/qg.core | qg/core/observer.py | Observable.fire_event | def fire_event(self, evt_name, *args, **kwargs):
"""触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数
"""
listeners = self.__get_listeners(evt_name)
evt = self.generate_event(evt_name)
for listener in listeners:
lis... | python | def fire_event(self, evt_name, *args, **kwargs):
"""触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数
"""
listeners = self.__get_listeners(evt_name)
evt = self.generate_event(evt_name)
for listener in listeners:
lis... | [
"def",
"fire_event",
"(",
"self",
",",
"evt_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"evt",
"=",
"self",
".",
"generate_event",
"(",
"evt_name",
")",
"for",
"lis... | 触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数 | [
"触发事件"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L118-L128 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | create_server_ec2 | def create_server_ec2(connection,
region,
disk_name,
disk_size,
ami,
key_pair,
instance_type,
tags={},
security_groups=None,
... | python | def create_server_ec2(connection,
region,
disk_name,
disk_size,
ami,
key_pair,
instance_type,
tags={},
security_groups=None,
... | [
"def",
"create_server_ec2",
"(",
"connection",
",",
"region",
",",
"disk_name",
",",
"disk_size",
",",
"ami",
",",
"key_pair",
",",
"instance_type",
",",
"tags",
"=",
"{",
"}",
",",
"security_groups",
"=",
"None",
",",
"delete_on_termination",
"=",
"True",
"... | Creates EC2 Instance | [
"Creates",
"EC2",
"Instance"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L54-L115 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | destroy_ebs_volume | def destroy_ebs_volume(connection, region, volume_id, log=False):
""" destroys an ebs volume """
if ebs_volume_exists(connection, region, volume_id):
if log:
log_yellow('destroying EBS volume ...')
try:
connection.delete_volume(volume_id)
except:
# ou... | python | def destroy_ebs_volume(connection, region, volume_id, log=False):
""" destroys an ebs volume """
if ebs_volume_exists(connection, region, volume_id):
if log:
log_yellow('destroying EBS volume ...')
try:
connection.delete_volume(volume_id)
except:
# ou... | [
"def",
"destroy_ebs_volume",
"(",
"connection",
",",
"region",
",",
"volume_id",
",",
"log",
"=",
"False",
")",
":",
"if",
"ebs_volume_exists",
"(",
"connection",
",",
"region",
",",
"volume_id",
")",
":",
"if",
"log",
":",
"log_yellow",
"(",
"'destroying EB... | destroys an ebs volume | [
"destroys",
"an",
"ebs",
"volume"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L118-L133 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | destroy_ec2 | def destroy_ec2(connection, region, instance_id, log=False):
""" terminates the instance """
data = get_ec2_info(connection=connection,
instance_id=instance_id,
region=region)
instance = connection.terminate_instances(instance_ids=[data['id']])[0]
if log... | python | def destroy_ec2(connection, region, instance_id, log=False):
""" terminates the instance """
data = get_ec2_info(connection=connection,
instance_id=instance_id,
region=region)
instance = connection.terminate_instances(instance_ids=[data['id']])[0]
if log... | [
"def",
"destroy_ec2",
"(",
"connection",
",",
"region",
",",
"instance_id",
",",
"log",
"=",
"False",
")",
":",
"data",
"=",
"get_ec2_info",
"(",
"connection",
"=",
"connection",
",",
"instance_id",
"=",
"instance_id",
",",
"region",
"=",
"region",
")",
"i... | terminates the instance | [
"terminates",
"the",
"instance"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L136-L153 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | down_ec2 | def down_ec2(connection, instance_id, region, log=False):
""" shutdown of an existing EC2 instance """
# get the instance_id from the state file, and stop the instance
instance = connection.stop_instances(instance_ids=instance_id)[0]
while instance.state != "stopped":
if log:
log_yel... | python | def down_ec2(connection, instance_id, region, log=False):
""" shutdown of an existing EC2 instance """
# get the instance_id from the state file, and stop the instance
instance = connection.stop_instances(instance_ids=instance_id)[0]
while instance.state != "stopped":
if log:
log_yel... | [
"def",
"down_ec2",
"(",
"connection",
",",
"instance_id",
",",
"region",
",",
"log",
"=",
"False",
")",
":",
"# get the instance_id from the state file, and stop the instance",
"instance",
"=",
"connection",
".",
"stop_instances",
"(",
"instance_ids",
"=",
"instance_id"... | shutdown of an existing EC2 instance | [
"shutdown",
"of",
"an",
"existing",
"EC2",
"instance"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L156-L166 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | ebs_volume_exists | def ebs_volume_exists(connection, region, volume_id):
""" finds out if a ebs volume exists """
for vol in connection.get_all_volumes():
if vol.id == volume_id:
return True
return False | python | def ebs_volume_exists(connection, region, volume_id):
""" finds out if a ebs volume exists """
for vol in connection.get_all_volumes():
if vol.id == volume_id:
return True
return False | [
"def",
"ebs_volume_exists",
"(",
"connection",
",",
"region",
",",
"volume_id",
")",
":",
"for",
"vol",
"in",
"connection",
".",
"get_all_volumes",
"(",
")",
":",
"if",
"vol",
".",
"id",
"==",
"volume_id",
":",
"return",
"True",
"return",
"False"
] | finds out if a ebs volume exists | [
"finds",
"out",
"if",
"a",
"ebs",
"volume",
"exists"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L169-L174 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | get_ec2_info | def get_ec2_info(connection,
instance_id,
region,
username=None):
""" queries EC2 for details about a particular instance_id
"""
instance = connection.get_only_instances(
filters={'instance_id': instance_id}
)[0]
data = instance.__dict_... | python | def get_ec2_info(connection,
instance_id,
region,
username=None):
""" queries EC2 for details about a particular instance_id
"""
instance = connection.get_only_instances(
filters={'instance_id': instance_id}
)[0]
data = instance.__dict_... | [
"def",
"get_ec2_info",
"(",
"connection",
",",
"instance_id",
",",
"region",
",",
"username",
"=",
"None",
")",
":",
"instance",
"=",
"connection",
".",
"get_only_instances",
"(",
"filters",
"=",
"{",
"'instance_id'",
":",
"instance_id",
"}",
")",
"[",
"0",
... | queries EC2 for details about a particular instance_id | [
"queries",
"EC2",
"for",
"details",
"about",
"a",
"particular",
"instance_id"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L181-L202 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/ec2.py | up_ec2 | def up_ec2(connection,
region,
instance_id,
wait_for_ssh_available=True,
log=False,
timeout=600):
""" boots an existing ec2_instance """
# boot the ec2 instance
instance = connection.start_instances(instance_ids=instance_id)[0]
instance.update()
... | python | def up_ec2(connection,
region,
instance_id,
wait_for_ssh_available=True,
log=False,
timeout=600):
""" boots an existing ec2_instance """
# boot the ec2 instance
instance = connection.start_instances(instance_ids=instance_id)[0]
instance.update()
... | [
"def",
"up_ec2",
"(",
"connection",
",",
"region",
",",
"instance_id",
",",
"wait_for_ssh_available",
"=",
"True",
",",
"log",
"=",
"False",
",",
"timeout",
"=",
"600",
")",
":",
"# boot the ec2 instance",
"instance",
"=",
"connection",
".",
"start_instances",
... | boots an existing ec2_instance | [
"boots",
"an",
"existing",
"ec2_instance"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L205-L226 | train |
tsnaomi/finnsyll | finnsyll/prev/v03.py | apply_T4 | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
for i, v in enumerate(WORD):
# i % 2 != 0 prevents this rule from applying to first, third, etc.
... | python | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
for i, v in enumerate(WORD):
# i % 2 != 0 prevents this rule from applying to first, third, etc.
... | [
"def",
"apply_T4",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"WORD",
")",
":",
"# i % 2 != 0 prevents this rule from applying to first, third, etc.",
"# syllables, which receive stress (W... | An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa]. | [
"An",
"agglutination",
"diphthong",
"that",
"ends",
"in",
"/",
"u",
"y",
"/",
"usually",
"contains",
"a",
"syllable",
"boundary",
"when",
"-",
"C#",
"or",
"-",
"CCV",
"follow",
"e",
".",
"g",
".",
"[",
"lau",
".",
"ka",
".",
"us",
"]",
"[",
"va",
... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v03.py#L137-L159 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | seqs_from_file | def seqs_from_file(filename, exit_on_err=False, return_qual=False):
"""Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which... | python | def seqs_from_file(filename, exit_on_err=False, return_qual=False):
"""Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which... | [
"def",
"seqs_from_file",
"(",
"filename",
",",
"exit_on_err",
"=",
"False",
",",
"return_qual",
"=",
"False",
")",
":",
"# VALIDATE INPUT",
"if",
"not",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"msg",
"=",
"'Filename has to be a string.'",
"if",
"e... | Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which contain a path to the input file
Supported Formats:
fasta, fastq... | [
"Extract",
"sequences",
"from",
"a",
"file",
"Name",
":",
"seqs_from_file",
"Author",
"(",
"s",
")",
":",
"Martin",
"C",
"F",
"Thomsen",
"Date",
":",
"18",
"Jul",
"2013",
"Description",
":",
"Iterator",
"which",
"extract",
"sequence",
"data",
"from",
"the"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L223-L318 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | open_ | def open_(filename, mode=None, compresslevel=9):
"""Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
... | python | def open_(filename, mode=None, compresslevel=9):
"""Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
... | [
"def",
"open_",
"(",
"filename",
",",
"mode",
"=",
"None",
",",
"compresslevel",
"=",
"9",
")",
":",
"if",
"filename",
"[",
"-",
"3",
":",
"]",
"==",
"'.gz'",
":",
"if",
"mode",
"is",
"None",
":",
"mode",
"=",
"'rt'",
"return",
"closing",
"(",
"g... | Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
>>> import gzip
>>> from contextlib import cl... | [
"Switch",
"for",
"both",
"open",
"()",
"and",
"gzip",
".",
"open",
"()",
".",
"Determines",
"if",
"the",
"file",
"is",
"normal",
"or",
"gzipped",
"by",
"looking",
"at",
"the",
"file",
"extension",
".",
"The",
"filename",
"argument",
"is",
"required",
";"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L321-L340 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | load_json | def load_json(json_object):
''' Load json from file or file name '''
content = None
if isinstance(json_object, str) and os.path.exists(json_object):
with open_(json_object) as f:
try:
content = json.load(f)
except Exception as e:
debug.log("Warning: Content of '%... | python | def load_json(json_object):
''' Load json from file or file name '''
content = None
if isinstance(json_object, str) and os.path.exists(json_object):
with open_(json_object) as f:
try:
content = json.load(f)
except Exception as e:
debug.log("Warning: Content of '%... | [
"def",
"load_json",
"(",
"json_object",
")",
":",
"content",
"=",
"None",
"if",
"isinstance",
"(",
"json_object",
",",
"str",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"json_object",
")",
":",
"with",
"open_",
"(",
"json_object",
")",
"as",
"f... | Load json from file or file name | [
"Load",
"json",
"from",
"file",
"or",
"file",
"name"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L342-L358 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | sort2groups | def sort2groups(array, gpat=['_R1','_R2']):
""" Sort an array of strings to groups by patterns """
groups = [REGroup(gp) for gp in gpat]
unmatched = []
for item in array:
matched = False
for m in groups:
if m.match(item):
matched = True
break
if not matched... | python | def sort2groups(array, gpat=['_R1','_R2']):
""" Sort an array of strings to groups by patterns """
groups = [REGroup(gp) for gp in gpat]
unmatched = []
for item in array:
matched = False
for m in groups:
if m.match(item):
matched = True
break
if not matched... | [
"def",
"sort2groups",
"(",
"array",
",",
"gpat",
"=",
"[",
"'_R1'",
",",
"'_R2'",
"]",
")",
":",
"groups",
"=",
"[",
"REGroup",
"(",
"gp",
")",
"for",
"gp",
"in",
"gpat",
"]",
"unmatched",
"=",
"[",
"]",
"for",
"item",
"in",
"array",
":",
"matche... | Sort an array of strings to groups by patterns | [
"Sort",
"an",
"array",
"of",
"strings",
"to",
"groups",
"by",
"patterns"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L360-L371 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | sort_and_distribute | def sort_and_distribute(array, splits=2):
""" Sort an array of strings to groups by alphabetically continuous
distribution
"""
if not isinstance(array, (list,tuple)): raise TypeError("array must be a list")
if not isinstance(splits, int): raise TypeError("splits must be an integer")
remaining = so... | python | def sort_and_distribute(array, splits=2):
""" Sort an array of strings to groups by alphabetically continuous
distribution
"""
if not isinstance(array, (list,tuple)): raise TypeError("array must be a list")
if not isinstance(splits, int): raise TypeError("splits must be an integer")
remaining = so... | [
"def",
"sort_and_distribute",
"(",
"array",
",",
"splits",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"array",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"array must be a list\"",
")",
"if",
"not",
"isinstance",
... | Sort an array of strings to groups by alphabetically continuous
distribution | [
"Sort",
"an",
"array",
"of",
"strings",
"to",
"groups",
"by",
"alphabetically",
"continuous",
"distribution"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L373-L388 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | mkpath | def mkpath(filepath, permissions=0o777):
""" This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775")
"""
# Converting string of octal to integer, if string is given.
if isinstance(permissions, str):
... | python | def mkpath(filepath, permissions=0o777):
""" This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775")
"""
# Converting string of octal to integer, if string is given.
if isinstance(permissions, str):
... | [
"def",
"mkpath",
"(",
"filepath",
",",
"permissions",
"=",
"0o777",
")",
":",
"# Converting string of octal to integer, if string is given.",
"if",
"isinstance",
"(",
"permissions",
",",
"str",
")",
":",
"permissions",
"=",
"sum",
"(",
"[",
"int",
"(",
"x",
")",... | This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775") | [
"This",
"function",
"executes",
"a",
"mkdir",
"command",
"for",
"filepath",
"and",
"with",
"permissions",
"(",
"octal",
"number",
"with",
"leading",
"0",
"or",
"string",
"only",
")",
"#",
"eg",
".",
"mkpath",
"(",
"path",
"/",
"to",
"/",
"file",
"0o775",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L390-L405 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | create_zip_dir | def create_zip_dir(zipfile_path, *file_list):
""" This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array
"""
try:
if isinstance(file_list, (list, tuple)): #unfolding list of list or tuple
if len(file_... | python | def create_zip_dir(zipfile_path, *file_list):
""" This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array
"""
try:
if isinstance(file_list, (list, tuple)): #unfolding list of list or tuple
if len(file_... | [
"def",
"create_zip_dir",
"(",
"zipfile_path",
",",
"*",
"file_list",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"file_list",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"#unfolding list of list or tuple",
"if",
"len",
"(",
"file_list",
")",
"==",
"1... | This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array | [
"This",
"function",
"creates",
"a",
"zipfile",
"located",
"in",
"zipFilePath",
"with",
"the",
"files",
"in",
"the",
"file",
"list",
"#",
"fileList",
"can",
"be",
"both",
"a",
"comma",
"separated",
"list",
"or",
"an",
"array"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L407-L431 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | file_zipper | def file_zipper(root_dir):
""" This function will zip the files created in the runroot directory and
subdirectories """
# FINDING AND ZIPPING UNZIPPED FILES
for root, dirs, files in os.walk(root_dir, topdown=False):
if root != "":
if root[-1] != '/': root += '/'
for current_file in f... | python | def file_zipper(root_dir):
""" This function will zip the files created in the runroot directory and
subdirectories """
# FINDING AND ZIPPING UNZIPPED FILES
for root, dirs, files in os.walk(root_dir, topdown=False):
if root != "":
if root[-1] != '/': root += '/'
for current_file in f... | [
"def",
"file_zipper",
"(",
"root_dir",
")",
":",
"# FINDING AND ZIPPING UNZIPPED FILES",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root_dir",
",",
"topdown",
"=",
"False",
")",
":",
"if",
"root",
"!=",
"\"\"",
":",
"if",
"r... | This function will zip the files created in the runroot directory and
subdirectories | [
"This",
"function",
"will",
"zip",
"the",
"files",
"created",
"in",
"the",
"runroot",
"directory",
"and",
"subdirectories"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L433-L469 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | file_unzipper | def file_unzipper(directory):
""" This function will unzip all files in the runroot directory and
subdirectories
"""
debug.log("Unzipping directory (%s)..."%directory)
#FINDING AND UNZIPPING ZIPPED FILES
for root, dirs, files in os.walk(directory, topdown=False):
if root != "":
orig_dir... | python | def file_unzipper(directory):
""" This function will unzip all files in the runroot directory and
subdirectories
"""
debug.log("Unzipping directory (%s)..."%directory)
#FINDING AND UNZIPPING ZIPPED FILES
for root, dirs, files in os.walk(directory, topdown=False):
if root != "":
orig_dir... | [
"def",
"file_unzipper",
"(",
"directory",
")",
":",
"debug",
".",
"log",
"(",
"\"Unzipping directory (%s)...\"",
"%",
"directory",
")",
"#FINDING AND UNZIPPING ZIPPED FILES",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"directory",
",... | This function will unzip all files in the runroot directory and
subdirectories | [
"This",
"function",
"will",
"unzip",
"all",
"files",
"in",
"the",
"runroot",
"directory",
"and",
"subdirectories"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L471-L484 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | move_file | def move_file(src, dst):
""" this function will simply move the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
... | python | def move_file(src, dst):
""" this function will simply move the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
... | [
"def",
"move_file",
"(",
"src",
",",
"dst",
")",
":",
"# Sanity checkpoint",
"src",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"src",
")",
"dst",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"dst",
")",
"if... | this function will simply move the file from the source path to the dest
path given as input | [
"this",
"function",
"will",
"simply",
"move",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L486-L532 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | copy_file | def copy_file(src, dst, ignore=None):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', ds... | python | def copy_file(src, dst, ignore=None):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', ds... | [
"def",
"copy_file",
"(",
"src",
",",
"dst",
",",
"ignore",
"=",
"None",
")",
":",
"# Sanity checkpoint",
"src",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"src",
")",
"dst",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
... | this function will simply copy the file from the source path to the dest
path given as input | [
"this",
"function",
"will",
"simply",
"copy",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L534-L574 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | copy_dir | def copy_dir(src, dst):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
try:
debug.log("copy dir from "+ src, "to "+ dst)
shutil.copytree(src, dst)
except Exception as e:
debug.log("Error: happened while copying!\n%s\n"%e) | python | def copy_dir(src, dst):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
try:
debug.log("copy dir from "+ src, "to "+ dst)
shutil.copytree(src, dst)
except Exception as e:
debug.log("Error: happened while copying!\n%s\n"%e) | [
"def",
"copy_dir",
"(",
"src",
",",
"dst",
")",
":",
"try",
":",
"debug",
".",
"log",
"(",
"\"copy dir from \"",
"+",
"src",
",",
"\"to \"",
"+",
"dst",
")",
"shutil",
".",
"copytree",
"(",
"src",
",",
"dst",
")",
"except",
"Exception",
"as",
"e",
... | this function will simply copy the file from the source path to the dest
path given as input | [
"this",
"function",
"will",
"simply",
"copy",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L576-L584 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.print_out | def print_out(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stdout, True, True, *lst) | python | def print_out(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stdout, True, True, *lst) | [
"def",
"print_out",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stdout",
",",
"True",
",",
"True",
",",
"*",
"lst",
")"
] | Print list of strings to the predefined stdout. | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"stdout",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L43-L45 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.print_err | def print_err(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stderr, False, True, *lst) | python | def print_err(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stderr, False, True, *lst) | [
"def",
"print_err",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stderr",
",",
"False",
",",
"True",
",",
"*",
"lst",
")"
] | Print list of strings to the predefined stdout. | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"stdout",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L46-L48 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.print2file | def print2file(self, logfile, print2screen, addLineFeed, *lst):
""" This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings
"""
if addLineFeed:
linefeed = '\n'
else: linefeed = ''
i... | python | def print2file(self, logfile, print2screen, addLineFeed, *lst):
""" This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings
"""
if addLineFeed:
linefeed = '\n'
else: linefeed = ''
i... | [
"def",
"print2file",
"(",
"self",
",",
"logfile",
",",
"print2screen",
",",
"addLineFeed",
",",
"*",
"lst",
")",
":",
"if",
"addLineFeed",
":",
"linefeed",
"=",
"'\\n'",
"else",
":",
"linefeed",
"=",
"''",
"if",
"print2screen",
":",
"print",
"(",
"linefe... | This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings | [
"This",
"function",
"prints",
"to",
"the",
"screen",
"and",
"logs",
"to",
"a",
"file",
"all",
"the",
"strings",
"given",
".",
"#",
"print2screen",
"eg",
".",
"True",
"*",
"lst",
"is",
"a",
"commaseparated",
"list",
"of",
"strings"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L49-L69 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.log | def log(self, *lst):
""" Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found
"""
self.print2file(self.logfile, self.debug, True, *lst)
if 'Error' in '\n'.join([str(x) for x in lst]):
self.caught_error = '\n'.join(... | python | def log(self, *lst):
""" Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found
"""
self.print2file(self.logfile, self.debug, True, *lst)
if 'Error' in '\n'.join([str(x) for x in lst]):
self.caught_error = '\n'.join(... | [
"def",
"log",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"logfile",
",",
"self",
".",
"debug",
",",
"True",
",",
"*",
"lst",
")",
"if",
"'Error'",
"in",
"'\\n'",
".",
"join",
"(",
"[",
"str",
"(",
"x",
... | Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"logfile",
"if",
"debug",
"is",
"set",
".",
"and",
"sets",
"the",
"caught_error",
"message",
"if",
"an",
"error",
"is",
"found"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L70-L76 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.log_no_newline | def log_no_newline(self, msg):
""" print the message to the predefined log file without newline """
self.print2file(self.logfile, False, False, msg) | python | def log_no_newline(self, msg):
""" print the message to the predefined log file without newline """
self.print2file(self.logfile, False, False, msg) | [
"def",
"log_no_newline",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"logfile",
",",
"False",
",",
"False",
",",
"msg",
")"
] | print the message to the predefined log file without newline | [
"print",
"the",
"message",
"to",
"the",
"predefined",
"log",
"file",
"without",
"newline"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L77-L79 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Debug.graceful_exit | def graceful_exit(self, msg):
""" This function Tries to update the MSQL database before exiting. """
# Print stored errors to stderr
if self.caught_error:
self.print2file(self.stderr, False, False, self.caught_error)
# Kill process with error message
self.log(msg)
sys.exit(... | python | def graceful_exit(self, msg):
""" This function Tries to update the MSQL database before exiting. """
# Print stored errors to stderr
if self.caught_error:
self.print2file(self.stderr, False, False, self.caught_error)
# Kill process with error message
self.log(msg)
sys.exit(... | [
"def",
"graceful_exit",
"(",
"self",
",",
"msg",
")",
":",
"# Print stored errors to stderr",
"if",
"self",
".",
"caught_error",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stderr",
",",
"False",
",",
"False",
",",
"self",
".",
"caught_error",
")",
... | This function Tries to update the MSQL database before exiting. | [
"This",
"function",
"Tries",
"to",
"update",
"the",
"MSQL",
"database",
"before",
"exiting",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L80-L87 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | adv_dict.get_tree | def get_tree(self, list_of_keys):
""" gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key... | python | def get_tree(self, list_of_keys):
""" gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key... | [
"def",
"get_tree",
"(",
"self",
",",
"list_of_keys",
")",
":",
"cur_obj",
"=",
"self",
"for",
"key",
"in",
"list_of_keys",
":",
"cur_obj",
"=",
"cur_obj",
".",
"get",
"(",
"key",
")",
"if",
"not",
"cur_obj",
":",
"break",
"return",
"cur_obj"
] | gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key2'])
'value' | [
"gettree",
"will",
"extract",
"the",
"value",
"from",
"a",
"nested",
"tree",
"INPUT",
"list_of_keys",
":",
"a",
"list",
"of",
"keys",
"ie",
".",
"[",
"key1",
"key2",
"]",
"USAGE",
">>>",
"#",
"Access",
"the",
"value",
"for",
"key2",
"within",
"the",
"n... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L93-L107 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | adv_dict.invert | def invert(self):
''' Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'],... | python | def invert(self):
''' Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'],... | [
"def",
"invert",
"(",
"self",
")",
":",
"inv_map",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"acceptable_v_instance",
"=",
"isinstance",
"(... | Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'], 3: ['A'], 4: ['B', 'C']} | [
"Return",
"inverse",
"mapping",
"of",
"dictionary",
"with",
"sorted",
"values",
".",
"USAGE",
">>>",
"#",
"Switch",
"the",
"keys",
"and",
"values",
">>>",
"adv_dict",
"(",
"{",
"...",
"A",
":",
"[",
"1",
"2",
"3",
"]",
"...",
"B",
":",
"[",
"4",
"2... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L108-L134 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Reg.sub | def sub(self, replace, string, count=0):
""" returns new string where the matching cases (limited by the count) in
the string is replaced. """
return self.re.sub(replace, string, count) | python | def sub(self, replace, string, count=0):
""" returns new string where the matching cases (limited by the count) in
the string is replaced. """
return self.re.sub(replace, string, count) | [
"def",
"sub",
"(",
"self",
",",
"replace",
",",
"string",
",",
"count",
"=",
"0",
")",
":",
"return",
"self",
".",
"re",
".",
"sub",
"(",
"replace",
",",
"string",
",",
"count",
")"
] | returns new string where the matching cases (limited by the count) in
the string is replaced. | [
"returns",
"new",
"string",
"where",
"the",
"matching",
"cases",
"(",
"limited",
"by",
"the",
"count",
")",
"in",
"the",
"string",
"is",
"replaced",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L186-L189 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | Reg.match | def match(self, s):
""" Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. """
self.matches = self.re.search(s)
return self.matches | python | def match(self, s):
""" Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. """
self.matches = self.re.search(s)
return self.matches | [
"def",
"match",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"matches",
"=",
"self",
".",
"re",
".",
"search",
"(",
"s",
")",
"return",
"self",
".",
"matches"
] | Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. | [
"Matches",
"the",
"string",
"to",
"the",
"stored",
"regular",
"expression",
"and",
"stores",
"all",
"groups",
"in",
"mathches",
".",
"Returns",
"False",
"on",
"negative",
"match",
"."
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L193-L197 | train |
OLC-Bioinformatics/sipprverse | cgecore/utility.py | REGroup.match | def match(self, s):
""" Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list
"""
if self.re.match(s):
self.list.append(s)
return True
else: return False | python | def match(self, s):
""" Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list
"""
if self.re.match(s):
self.list.append(s)
return True
else: return False | [
"def",
"match",
"(",
"self",
",",
"s",
")",
":",
"if",
"self",
".",
"re",
".",
"match",
"(",
"s",
")",
":",
"self",
".",
"list",
".",
"append",
"(",
"s",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list | [
"Matching",
"the",
"pattern",
"to",
"the",
"input",
"string",
"returns",
"True",
"/",
"False",
"and",
"saves",
"the",
"matched",
"string",
"in",
"the",
"internal",
"list"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L213-L220 | train |
OLC-Bioinformatics/sipprverse | MASHsippr/mash.py | Mash.reporter | def reporter(self):
"""
Create the MASH report
"""
logging.info('Creating {} report'.format(self.analysistype))
make_path(self.reportpath)
header = 'Strain,ReferenceGenus,ReferenceFile,ReferenceGenomeMashDistance,Pvalue,NumMatchingHashes\n'
data = ''
for s... | python | def reporter(self):
"""
Create the MASH report
"""
logging.info('Creating {} report'.format(self.analysistype))
make_path(self.reportpath)
header = 'Strain,ReferenceGenus,ReferenceFile,ReferenceGenomeMashDistance,Pvalue,NumMatchingHashes\n'
data = ''
for s... | [
"def",
"reporter",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"header",
"=",
"'Strain,ReferenceGenus,ReferenceFile,Refer... | Create the MASH report | [
"Create",
"the",
"MASH",
"report"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/MASHsippr/mash.py#L214-L236 | train |
pymacaron/pymacaron-core | pymacaron_core/utils.py | get_function | def get_function(pkgpath):
"""Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages)
"""
# Extract the module and function name from pkgpath
elems = pkgpath.split('.')
if len(elems) <= 1:
ra... | python | def get_function(pkgpath):
"""Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages)
"""
# Extract the module and function name from pkgpath
elems = pkgpath.split('.')
if len(elems) <= 1:
ra... | [
"def",
"get_function",
"(",
"pkgpath",
")",
":",
"# Extract the module and function name from pkgpath",
"elems",
"=",
"pkgpath",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"elems",
")",
"<=",
"1",
":",
"raise",
"PyMacaronCoreException",
"(",
"\"Path %s is to... | Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages) | [
"Take",
"a",
"full",
"path",
"to",
"a",
"python",
"method",
"or",
"class",
"for",
"example",
"mypkg",
".",
"subpkg",
".",
"method",
"and",
"return",
"the",
"method",
"or",
"class",
"(",
"after",
"importing",
"the",
"required",
"packages",
")"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/utils.py#L5-L24 | train |
OLC-Bioinformatics/sipprverse | gdcs/gdcs.py | GDCS.runner | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
se... | python | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
se... | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
",",
"self",
".",
"starttime",
")",
"# Create the objects to be used in the analyses",
"objects",
"=",
"Objectprep",
"(... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/gdcs/gdcs.py#L15-L29 | train |
tsnaomi/finnsyll | finnsyll/prev/v06.py | syllabify | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
word = split(word) # detect any non-delimited compounds
compound = True if re.search(r'-| |\.', word) else False
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll... | python | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
word = split(word) # detect any non-delimited compounds
compound = True if re.search(r'-| |\.', word) else False
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"word",
"=",
"split",
"(",
"word",
")",
"# detect any non-delimited compounds",
"compound",
"=",
"True",
"if",
"re",
".",
"search",
"(",
"r'-| |\\.'",
",",
"word",
")",
"else",
"False",
"syllabify",
"=",
"_syllabify... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v06.py#L148-L173 | train |
jorbas/GADDAG | gaddag/node.py | Node.edges | def edges(self):
"""
Return the edge characters of this node.
"""
edge_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_edges(self.gdg, self.node, edge_str)
return [char for char in edge_str.value.decode("ascii")] | python | def edges(self):
"""
Return the edge characters of this node.
"""
edge_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_edges(self.gdg, self.node, edge_str)
return [char for char in edge_str.value.decode("ascii")] | [
"def",
"edges",
"(",
"self",
")",
":",
"edge_str",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"MAX_CHARS",
")",
"cgaddag",
".",
"gdg_edges",
"(",
"self",
".",
"gdg",
",",
"self",
".",
"node",
",",
"edge_str",
")",
"return",
"[",
"char",
"for",
"c... | Return the edge characters of this node. | [
"Return",
"the",
"edge",
"characters",
"of",
"this",
"node",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/node.py#L64-L72 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.