repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
SmartTeleMax/iktomi | iktomi/utils/system.py | doublefork | def doublefork(pidfile, logfile, cwd, umask): # pragma: nocover
'''Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files... | python | def doublefork(pidfile, logfile, cwd, umask): # pragma: nocover
'''Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files... | [
"def",
"doublefork",
"(",
"pidfile",
",",
"logfile",
",",
"cwd",
",",
"umask",
")",
":",
"# pragma: nocover",
"try",
":",
"if",
"os",
".",
"fork",
"(",
")",
":",
"os",
".",
"_exit",
"(",
"os",
".",
"EX_OK",
")",
"except",
"OSError",
"as",
"e",
":",... | Daemonize current process.
After first fork we return to the shell and removing our self from
controling terminal via `setsid`.
After second fork we are not session leader any more and cant get
controlling terminal when opening files. | [
"Daemonize",
"current",
"process",
".",
"After",
"first",
"fork",
"we",
"return",
"to",
"the",
"shell",
"and",
"removing",
"our",
"self",
"from",
"controling",
"terminal",
"via",
"setsid",
".",
"After",
"second",
"fork",
"we",
"are",
"not",
"session",
"leade... | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/system.py#L49-L82 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/repositoryconfigurations_api.py | RepositoryconfigurationsApi.match | def match(self, search, **kwargs):
"""
Searches for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. Only exact matches are returned.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP requ... | python | def match(self, search, **kwargs):
"""
Searches for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. Only exact matches are returned.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP requ... | [
"def",
"match",
"(",
"self",
",",
"search",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"match_with_http_info",
"(",
"sear... | Searches for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. Only exact matches are returned.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be ... | [
"Searches",
"for",
"Repository",
"Configurations",
"based",
"on",
"internal",
"or",
"external",
"url",
"ignoring",
"the",
"protocol",
"and",
"\\",
".",
"git",
"\\",
"suffix",
".",
"Only",
"exact",
"matches",
"are",
"returned",
".",
"This",
"method",
"makes",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/repositoryconfigurations_api.py#L366-L393 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/repositoryconfigurations_api.py | RepositoryconfigurationsApi.search | def search(self, search, **kwargs):
"""
Search for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. The matching is done using LIKE.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP reque... | python | def search(self, search, **kwargs):
"""
Search for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. The matching is done using LIKE.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP reque... | [
"def",
"search",
"(",
"self",
",",
"search",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"search_with_http_info",
"(",
"se... | Search for Repository Configurations based on internal or external url, ignoring the protocol and \".git\" suffix. The matching is done using LIKE.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be in... | [
"Search",
"for",
"Repository",
"Configurations",
"based",
"on",
"internal",
"or",
"external",
"url",
"ignoring",
"the",
"protocol",
"and",
"\\",
".",
"git",
"\\",
"suffix",
".",
"The",
"matching",
"is",
"done",
"using",
"LIKE",
".",
"This",
"method",
"makes"... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/repositoryconfigurations_api.py#L484-L511 |
project-ncl/pnc-cli | pnc_cli/makemead.py | make_mead | def make_mead(config=None, run_build=False, environment=1, suffix="", product_name=None, product_version=None,
look_up_only="",clean_group=False):
"""
Create Build group based on Make-Mead configuration file
:param config: Make Mead config name
:return:
"""
ret=make_mead_impl(confi... | python | def make_mead(config=None, run_build=False, environment=1, suffix="", product_name=None, product_version=None,
look_up_only="",clean_group=False):
"""
Create Build group based on Make-Mead configuration file
:param config: Make Mead config name
:return:
"""
ret=make_mead_impl(confi... | [
"def",
"make_mead",
"(",
"config",
"=",
"None",
",",
"run_build",
"=",
"False",
",",
"environment",
"=",
"1",
",",
"suffix",
"=",
"\"\"",
",",
"product_name",
"=",
"None",
",",
"product_version",
"=",
"None",
",",
"look_up_only",
"=",
"\"\"",
",",
"clean... | Create Build group based on Make-Mead configuration file
:param config: Make Mead config name
:return: | [
"Create",
"Build",
"group",
"based",
"on",
"Make",
"-",
"Mead",
"configuration",
"file",
":",
"param",
"config",
":",
"Make",
"Mead",
"config",
"name",
":",
"return",
":"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/makemead.py#L35-L45 |
CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions.partition | def partition(self, id_):
"""Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
... | python | def partition(self, id_):
"""Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
... | [
"def",
"partition",
"(",
"self",
",",
"id_",
")",
":",
"from",
".",
".",
"orm",
"import",
"Partition",
"as",
"OrmPartition",
"from",
"sqlalchemy",
"import",
"or_",
"from",
".",
".",
"identity",
"import",
"PartialPartitionName",
"if",
"isinstance",
"(",
"id_"... | Get a partition by the id number.
Arguments:
id_ -- a partition id value
Returns:
A partitions.Partition object
Throws:
a Sqlalchemy exception if the partition either does not exist or
is not unique
Because this method works on the bund... | [
"Get",
"a",
"partition",
"by",
"the",
"id",
"number",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L45-L96 |
CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions._find_orm | def _find_orm(self, pnq):
"""Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted.
"""
# import sqlalchemy.orm.exc
from ambry.orm import Partition as OrmPartition # , Table
from sqlalchemy.orm import... | python | def _find_orm(self, pnq):
"""Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted.
"""
# import sqlalchemy.orm.exc
from ambry.orm import Partition as OrmPartition # , Table
from sqlalchemy.orm import... | [
"def",
"_find_orm",
"(",
"self",
",",
"pnq",
")",
":",
"# import sqlalchemy.orm.exc",
"from",
"ambry",
".",
"orm",
"import",
"Partition",
"as",
"OrmPartition",
"# , Table",
"from",
"sqlalchemy",
".",
"orm",
"import",
"joinedload",
"# , joinedload_all",
"assert",
"... | Return a Partition object from the database based on a PartitionId.
An ORM object is returned, so changes can be persisted. | [
"Return",
"a",
"Partition",
"object",
"from",
"the",
"database",
"based",
"on",
"a",
"PartitionId",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L98-L159 |
CivicSpleen/ambry | ambry/bundle/partitions.py | Partitions.new_db_from_pandas | def new_db_from_pandas(self, frame, table=None, data=None, load=True, **kwargs):
"""Create a new db partition from a pandas data frame.
If the table does not exist, it will be created
"""
from ..orm import Column
# from dbexceptions import ConfigurationError
# Create ... | python | def new_db_from_pandas(self, frame, table=None, data=None, load=True, **kwargs):
"""Create a new db partition from a pandas data frame.
If the table does not exist, it will be created
"""
from ..orm import Column
# from dbexceptions import ConfigurationError
# Create ... | [
"def",
"new_db_from_pandas",
"(",
"self",
",",
"frame",
",",
"table",
"=",
"None",
",",
"data",
"=",
"None",
",",
"load",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
".",
"orm",
"import",
"Column",
"# from dbexceptions import Configuration... | Create a new db partition from a pandas data frame.
If the table does not exist, it will be created | [
"Create",
"a",
"new",
"db",
"partition",
"from",
"a",
"pandas",
"data",
"frame",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/partitions.py#L212-L252 |
project-ncl/pnc-cli | pnc_cli/projects.py | update_project | def update_project(id, **kwargs):
"""
Update an existing Project with new information
"""
content = update_project_raw(id, **kwargs)
if content:
return utils.format_json(content) | python | def update_project(id, **kwargs):
"""
Update an existing Project with new information
"""
content = update_project_raw(id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_project",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_project_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update an existing Project with new information | [
"Update",
"an",
"existing",
"Project",
"with",
"new",
"information"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L44-L50 |
project-ncl/pnc-cli | pnc_cli/projects.py | get_project | def get_project(id=None, name=None):
"""
Get a specific Project by ID or name
"""
content = get_project_raw(id, name)
if content:
return utils.format_json(content) | python | def get_project(id=None, name=None):
"""
Get a specific Project by ID or name
"""
content = get_project_raw(id, name)
if content:
return utils.format_json(content) | [
"def",
"get_project",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"content",
"=",
"get_project_raw",
"(",
"id",
",",
"name",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Get a specific Project by ID or name | [
"Get",
"a",
"specific",
"Project",
"by",
"ID",
"or",
"name"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L69-L75 |
project-ncl/pnc-cli | pnc_cli/projects.py | delete_project | def delete_project(id=None, name=None):
"""
Delete a Project by ID or name.
"""
content = delete_project_raw(id, name)
if content:
return utils.format_json(content) | python | def delete_project(id=None, name=None):
"""
Delete a Project by ID or name.
"""
content = delete_project_raw(id, name)
if content:
return utils.format_json(content) | [
"def",
"delete_project",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"content",
"=",
"delete_project_raw",
"(",
"id",
",",
"name",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Delete a Project by ID or name. | [
"Delete",
"a",
"Project",
"by",
"ID",
"or",
"name",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L85-L91 |
project-ncl/pnc-cli | pnc_cli/projects.py | list_projects | def list_projects(page_size=200, page_index=0, sort="", q=""):
"""
List all Projects
"""
content = list_projects_raw(page_size=page_size, page_index=page_index, sort=sort, q=q)
if content:
return utils.format_json_list(content) | python | def list_projects(page_size=200, page_index=0, sort="", q=""):
"""
List all Projects
"""
content = list_projects_raw(page_size=page_size, page_index=page_index, sort=sort, q=q)
if content:
return utils.format_json_list(content) | [
"def",
"list_projects",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_projects_raw",
"(",
"page_size",
"=",
"page_size",
",",
"page_index",
"=",
"page_index",
"... | List all Projects | [
"List",
"all",
"Projects"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/projects.py#L104-L110 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.cancel | def cancel(self, build_record_id, **kwargs):
"""
Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callb... | python | def cancel(self, build_record_id, **kwargs):
"""
Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callb... | [
"def",
"cancel",
"(",
"self",
",",
"build_record_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"cancel_with_http_info",
"... | Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
... | [
"Build",
"record",
"push",
"results",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be",
"invoked",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L42-L67 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.get | def get(self, build_record_id, **kwargs):
"""
Get Build Record Push Result by Id..
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> de... | python | def get(self, build_record_id, **kwargs):
"""
Get Build Record Push Result by Id..
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> de... | [
"def",
"get",
"(",
"self",
",",
"build_record_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_with_http_info",
"(",
... | Get Build Record Push Result by Id..
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response... | [
"Get",
"Build",
"Record",
"Push",
"Result",
"by",
"Id",
"..",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to"... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L152-L176 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.push | def push(self, **kwargs):
"""
Push build record results to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_functio... | python | def push(self, **kwargs):
"""
Push build record results to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_functio... | [
"def",
"push",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"push_with_http_info",
"(",
"*",
"*",
"kwargs",
... | Push build record results to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
... | [
"Push",
"build",
"record",
"results",
"to",
"Brew",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L258-L282 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.push_0 | def push_0(self, build_record_id, **kwargs):
"""
Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callb... | python | def push_0(self, build_record_id, **kwargs):
"""
Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callb... | [
"def",
"push_0",
"(",
"self",
",",
"build_record_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"push_0_with_http_info",
"... | Build record push results.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
... | [
"Build",
"record",
"push",
"results",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be",
"invoked",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L361-L386 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.push_record_set | def push_record_set(self, **kwargs):
"""
Push build config set record to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def ca... | python | def push_record_set(self, **kwargs):
"""
Push build config set record to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def ca... | [
"def",
"push_record_set",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"push_record_set_with_http_info",
"(",
"*",... | Push build config set record to Brew.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(respons... | [
"Push",
"build",
"config",
"set",
"record",
"to",
"Brew",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L471-L495 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildrecordpush_api.py | BuildrecordpushApi.status | def status(self, build_record_id, **kwargs):
"""
Latest push result of BuildRecord.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> d... | python | def status(self, build_record_id, **kwargs):
"""
Latest push result of BuildRecord.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> d... | [
"def",
"status",
"(",
"self",
",",
"build_record_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"status_with_http_info",
"... | Latest push result of BuildRecord.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
... | [
"Latest",
"push",
"result",
"of",
"BuildRecord",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildrecordpush_api.py#L574-L598 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.set_handler | def set_handler(self, handler):
""" Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin}
"""
if self.handler is not None:
raise Exception('Attempted to overwrite BaseSession handler... | python | def set_handler(self, handler):
""" Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin}
"""
if self.handler is not None:
raise Exception('Attempted to overwrite BaseSession handler... | [
"def",
"set_handler",
"(",
"self",
",",
"handler",
")",
":",
"if",
"self",
".",
"handler",
"is",
"not",
"None",
":",
"raise",
"Exception",
"(",
"'Attempted to overwrite BaseSession handler'",
")",
"self",
".",
"handler",
"=",
"handler",
"self",
".",
"transport... | Set transport handler
@param handler: Handler, should derive from the
C{sockjs.cyclone.transports.base.BaseTransportMixin} | [
"Set",
"transport",
"handler"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L48-L64 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.verify_state | def verify_state(self):
""" Verify if session was not yet opened. If it is, open it and call
connection's C{connectionMade} """
if self.state == SESSION_STATE.CONNECTING:
self.state = SESSION_STATE.OPEN
self.conn.connectionMade(self.conn_info) | python | def verify_state(self):
""" Verify if session was not yet opened. If it is, open it and call
connection's C{connectionMade} """
if self.state == SESSION_STATE.CONNECTING:
self.state = SESSION_STATE.OPEN
self.conn.connectionMade(self.conn_info) | [
"def",
"verify_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CONNECTING",
":",
"self",
".",
"state",
"=",
"SESSION_STATE",
".",
"OPEN",
"self",
".",
"conn",
".",
"connectionMade",
"(",
"self",
".",
"conn_info",
"... | Verify if session was not yet opened. If it is, open it and call
connection's C{connectionMade} | [
"Verify",
"if",
"session",
"was",
"not",
"yet",
"opened",
".",
"If",
"it",
"is",
"open",
"it",
"and",
"call",
"connection",
"s",
"C",
"{",
"connectionMade",
"}"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L66-L72 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.close | def close(self, code=3000, message='Go away!'):
""" Close session or endpoint connection.
@param code: Closing code
@param message: Close message
"""
if self.state != SESSION_STATE.CLOSED:
try:
self.conn.connectionLost()
except Exception ... | python | def close(self, code=3000, message='Go away!'):
""" Close session or endpoint connection.
@param code: Closing code
@param message: Close message
"""
if self.state != SESSION_STATE.CLOSED:
try:
self.conn.connectionLost()
except Exception ... | [
"def",
"close",
"(",
"self",
",",
"code",
"=",
"3000",
",",
"message",
"=",
"'Go away!'",
")",
":",
"if",
"self",
".",
"state",
"!=",
"SESSION_STATE",
".",
"CLOSED",
":",
"try",
":",
"self",
".",
"conn",
".",
"connectionLost",
"(",
")",
"except",
"Ex... | Close session or endpoint connection.
@param code: Closing code
@param message: Close message | [
"Close",
"session",
"or",
"endpoint",
"connection",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L85-L106 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.delayed_close | def delayed_close(self):
""" Delayed close - won't close immediately, but on the next reactor
loop. """
self.state = SESSION_STATE.CLOSING
reactor.callLater(0, self.close) | python | def delayed_close(self):
""" Delayed close - won't close immediately, but on the next reactor
loop. """
self.state = SESSION_STATE.CLOSING
reactor.callLater(0, self.close) | [
"def",
"delayed_close",
"(",
"self",
")",
":",
"self",
".",
"state",
"=",
"SESSION_STATE",
".",
"CLOSING",
"reactor",
".",
"callLater",
"(",
"0",
",",
"self",
".",
"close",
")"
] | Delayed close - won't close immediately, but on the next reactor
loop. | [
"Delayed",
"close",
"-",
"won",
"t",
"close",
"immediately",
"but",
"on",
"the",
"next",
"reactor",
"loop",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L108-L112 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | BaseSession.is_closed | def is_closed(self):
""" Check if session was closed. """
return (self.state == SESSION_STATE.CLOSED
or self.state == SESSION_STATE.CLOSING) | python | def is_closed(self):
""" Check if session was closed. """
return (self.state == SESSION_STATE.CLOSED
or self.state == SESSION_STATE.CLOSING) | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CLOSED",
"or",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CLOSING",
")"
] | Check if session was closed. | [
"Check",
"if",
"session",
"was",
"closed",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L129-L132 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | SessionMixin._random_key | def _random_key(self):
""" Return random session key """
hashstr = '%s%s' % (random.random(), self.time_module.time())
return hashlib.md5(hashstr).hexdigest() | python | def _random_key(self):
""" Return random session key """
hashstr = '%s%s' % (random.random(), self.time_module.time())
return hashlib.md5(hashstr).hexdigest() | [
"def",
"_random_key",
"(",
"self",
")",
":",
"hashstr",
"=",
"'%s%s'",
"%",
"(",
"random",
".",
"random",
"(",
")",
",",
"self",
".",
"time_module",
".",
"time",
"(",
")",
")",
"return",
"hashlib",
".",
"md5",
"(",
"hashstr",
")",
".",
"hexdigest",
... | Return random session key | [
"Return",
"random",
"session",
"key"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L192-L195 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | SessionMixin.promote | def promote(self):
""" Mark object as alive, so it won't be collected during next
run of the garbage collector.
"""
if self.expiry is not None:
self.promoted = self.time_module.time() + self.expiry | python | def promote(self):
""" Mark object as alive, so it won't be collected during next
run of the garbage collector.
"""
if self.expiry is not None:
self.promoted = self.time_module.time() + self.expiry | [
"def",
"promote",
"(",
"self",
")",
":",
"if",
"self",
".",
"expiry",
"is",
"not",
"None",
":",
"self",
".",
"promoted",
"=",
"self",
".",
"time_module",
".",
"time",
"(",
")",
"+",
"self",
".",
"expiry"
] | Mark object as alive, so it won't be collected during next
run of the garbage collector. | [
"Mark",
"object",
"as",
"alive",
"so",
"it",
"won",
"t",
"be",
"collected",
"during",
"next",
"run",
"of",
"the",
"garbage",
"collector",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L201-L206 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.set_handler | def set_handler(self, handler, start_heartbeat=True):
""" Set active handler for the session
@param handler: Associate active cyclone handler with the session
@param start_heartbeat: Should session start heartbeat immediately
"""
# Check if session already has associated handle... | python | def set_handler(self, handler, start_heartbeat=True):
""" Set active handler for the session
@param handler: Associate active cyclone handler with the session
@param start_heartbeat: Should session start heartbeat immediately
"""
# Check if session already has associated handle... | [
"def",
"set_handler",
"(",
"self",
",",
"handler",
",",
"start_heartbeat",
"=",
"True",
")",
":",
"# Check if session already has associated handler",
"if",
"self",
".",
"handler",
"is",
"not",
"None",
":",
"handler",
".",
"send_pack",
"(",
"proto",
".",
"discon... | Set active handler for the session
@param handler: Associate active cyclone handler with the session
@param start_heartbeat: Should session start heartbeat immediately | [
"Set",
"active",
"handler",
"for",
"the",
"session"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L268-L308 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.verify_state | def verify_state(self):
""" Verify if session was not yet opened. If it is, open it and call
connections C{connectionMade} """
# If we're in CONNECTING state - send 'o' message to the client
if self.state == SESSION_STATE.CONNECTING:
self.handler.send_pack(proto.CONNECT)
... | python | def verify_state(self):
""" Verify if session was not yet opened. If it is, open it and call
connections C{connectionMade} """
# If we're in CONNECTING state - send 'o' message to the client
if self.state == SESSION_STATE.CONNECTING:
self.handler.send_pack(proto.CONNECT)
... | [
"def",
"verify_state",
"(",
"self",
")",
":",
"# If we're in CONNECTING state - send 'o' message to the client",
"if",
"self",
".",
"state",
"==",
"SESSION_STATE",
".",
"CONNECTING",
":",
"self",
".",
"handler",
".",
"send_pack",
"(",
"proto",
".",
"CONNECT",
")",
... | Verify if session was not yet opened. If it is, open it and call
connections C{connectionMade} | [
"Verify",
"if",
"session",
"was",
"not",
"yet",
"opened",
".",
"If",
"it",
"is",
"open",
"it",
"and",
"call",
"connections",
"C",
"{",
"connectionMade",
"}"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L310-L318 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.send_message | def send_message(self, msg, stats=True):
""" Send or queue outgoing message
@param msg: Message to send
@param stats: If set to True, will update statistics after operation
completes
"""
self.send_jsonified(proto.json_encode(msg), stats) | python | def send_message(self, msg, stats=True):
""" Send or queue outgoing message
@param msg: Message to send
@param stats: If set to True, will update statistics after operation
completes
"""
self.send_jsonified(proto.json_encode(msg), stats) | [
"def",
"send_message",
"(",
"self",
",",
"msg",
",",
"stats",
"=",
"True",
")",
":",
"self",
".",
"send_jsonified",
"(",
"proto",
".",
"json_encode",
"(",
"msg",
")",
",",
"stats",
")"
] | Send or queue outgoing message
@param msg: Message to send
@param stats: If set to True, will update statistics after operation
completes | [
"Send",
"or",
"queue",
"outgoing",
"message"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L330-L338 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.send_jsonified | def send_jsonified(self, msg, stats=True):
""" Send JSON-encoded message
@param msg: JSON encoded string to send
@param stats: If set to True, will update statistics after operation
completes
"""
assert isinstance(msg, basestring), 'Can only send strings'
... | python | def send_jsonified(self, msg, stats=True):
""" Send JSON-encoded message
@param msg: JSON encoded string to send
@param stats: If set to True, will update statistics after operation
completes
"""
assert isinstance(msg, basestring), 'Can only send strings'
... | [
"def",
"send_jsonified",
"(",
"self",
",",
"msg",
",",
"stats",
"=",
"True",
")",
":",
"assert",
"isinstance",
"(",
"msg",
",",
"basestring",
")",
",",
"'Can only send strings'",
"if",
"isinstance",
"(",
"msg",
",",
"unicode",
")",
":",
"msg",
"=",
"msg"... | Send JSON-encoded message
@param msg: JSON encoded string to send
@param stats: If set to True, will update statistics after operation
completes | [
"Send",
"JSON",
"-",
"encoded",
"message"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L340-L367 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.flush | def flush(self):
""" Flush message queue if there's an active connection running """
self._pending_flush = False
if self.handler is None:
return
if self.send_queue.is_empty():
return
self.handler.send_pack('a[%s]' % self.send_queue.get())
self.s... | python | def flush(self):
""" Flush message queue if there's an active connection running """
self._pending_flush = False
if self.handler is None:
return
if self.send_queue.is_empty():
return
self.handler.send_pack('a[%s]' % self.send_queue.get())
self.s... | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"_pending_flush",
"=",
"False",
"if",
"self",
".",
"handler",
"is",
"None",
":",
"return",
"if",
"self",
".",
"send_queue",
".",
"is_empty",
"(",
")",
":",
"return",
"self",
".",
"handler",
".",
"se... | Flush message queue if there's an active connection running | [
"Flush",
"message",
"queue",
"if",
"there",
"s",
"an",
"active",
"connection",
"running"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L369-L380 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.close | def close(self, code=3000, message='Go away!'):
""" Close session.
@param code: Closing code
@param message: Closing message
"""
if self.state != SESSION_STATE.CLOSED:
# Notify handler
if self.handler is not None:
self.handler.send_pack(p... | python | def close(self, code=3000, message='Go away!'):
""" Close session.
@param code: Closing code
@param message: Closing message
"""
if self.state != SESSION_STATE.CLOSED:
# Notify handler
if self.handler is not None:
self.handler.send_pack(p... | [
"def",
"close",
"(",
"self",
",",
"code",
"=",
"3000",
",",
"message",
"=",
"'Go away!'",
")",
":",
"if",
"self",
".",
"state",
"!=",
"SESSION_STATE",
".",
"CLOSED",
":",
"# Notify handler",
"if",
"self",
".",
"handler",
"is",
"not",
"None",
":",
"self... | Close session.
@param code: Closing code
@param message: Closing message | [
"Close",
"session",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L382-L394 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.start_heartbeat | def start_heartbeat(self):
""" Reset hearbeat timer """
self.stop_heartbeat()
self._heartbeat_timer = task.LoopingCall(self._heartbeat)
self._heartbeat_timer.start(self._heartbeat_interval, False) | python | def start_heartbeat(self):
""" Reset hearbeat timer """
self.stop_heartbeat()
self._heartbeat_timer = task.LoopingCall(self._heartbeat)
self._heartbeat_timer.start(self._heartbeat_interval, False) | [
"def",
"start_heartbeat",
"(",
"self",
")",
":",
"self",
".",
"stop_heartbeat",
"(",
")",
"self",
".",
"_heartbeat_timer",
"=",
"task",
".",
"LoopingCall",
"(",
"self",
".",
"_heartbeat",
")",
"self",
".",
"_heartbeat_timer",
".",
"start",
"(",
"self",
"."... | Reset hearbeat timer | [
"Reset",
"hearbeat",
"timer"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L397-L402 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/session.py | Session.messagesReceived | def messagesReceived(self, msg_list):
""" Handle incoming messages
@param msg_list: Message list to process
"""
self.stats.packReceived(len(msg_list))
for msg in msg_list:
self.conn.messageReceived(msg) | python | def messagesReceived(self, msg_list):
""" Handle incoming messages
@param msg_list: Message list to process
"""
self.stats.packReceived(len(msg_list))
for msg in msg_list:
self.conn.messageReceived(msg) | [
"def",
"messagesReceived",
"(",
"self",
",",
"msg_list",
")",
":",
"self",
".",
"stats",
".",
"packReceived",
"(",
"len",
"(",
"msg_list",
")",
")",
"for",
"msg",
"in",
"msg_list",
":",
"self",
".",
"conn",
".",
"messageReceived",
"(",
"msg",
")"
] | Handle incoming messages
@param msg_list: Message list to process | [
"Handle",
"incoming",
"messages"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L422-L430 |
CivicSpleen/ambry | ambry/valuetype/census/__init__.py | CensusStateGeoid.parser | def parser(cls, v):
"""Ensure that the upstream parser gets two digits. """
return geoid.census.State.parse(str(v).zfill(2)) | python | def parser(cls, v):
"""Ensure that the upstream parser gets two digits. """
return geoid.census.State.parse(str(v).zfill(2)) | [
"def",
"parser",
"(",
"cls",
",",
"v",
")",
":",
"return",
"geoid",
".",
"census",
".",
"State",
".",
"parse",
"(",
"str",
"(",
"v",
")",
".",
"zfill",
"(",
"2",
")",
")"
] | Ensure that the upstream parser gets two digits. | [
"Ensure",
"that",
"the",
"upstream",
"parser",
"gets",
"two",
"digits",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/census/__init__.py#L97-L99 |
project-ncl/pnc-cli | pnc_cli/tools/config_utils.py | ConfigReader.get_dependency_structure | def get_dependency_structure(self, artifact=None, include_dependencies=False):
"""
Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's... | python | def get_dependency_structure(self, artifact=None, include_dependencies=False):
"""
Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's... | [
"def",
"get_dependency_structure",
"(",
"self",
",",
"artifact",
"=",
"None",
",",
"include_dependencies",
"=",
"False",
")",
":",
"artifacts",
"=",
"[",
"]",
"dependencies_dict",
"=",
"{",
"}",
"if",
"artifact",
":",
"if",
"isinstance",
"(",
"artifact",
","... | Reads dependency structure. If an artifact is passed in you get only its dependencies otherwise the complete
structure is returned.
:param artifact: an artifact task or artifact name if only an artifact's deps are needed
:param include_dependencies: flag to include also dependencies in returned... | [
"Reads",
"dependency",
"structure",
".",
"If",
"an",
"artifact",
"is",
"passed",
"in",
"you",
"get",
"only",
"its",
"dependencies",
"otherwise",
"the",
"complete",
"structure",
"is",
"returned",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/config_utils.py#L149-L176 |
project-ncl/pnc-cli | pnc_cli/tools/config_utils.py | ConfigReader._do_read_config | def _do_read_config(self, config_file, pommanipext):
"""Reads config for a single job defined by section."""
parser = InterpolationConfigParser()
dataset = parser.read(config_file)
if config_file not in dataset:
raise IOError("Config file %s not found." % config_file)
... | python | def _do_read_config(self, config_file, pommanipext):
"""Reads config for a single job defined by section."""
parser = InterpolationConfigParser()
dataset = parser.read(config_file)
if config_file not in dataset:
raise IOError("Config file %s not found." % config_file)
... | [
"def",
"_do_read_config",
"(",
"self",
",",
"config_file",
",",
"pommanipext",
")",
":",
"parser",
"=",
"InterpolationConfigParser",
"(",
")",
"dataset",
"=",
"parser",
".",
"read",
"(",
"config_file",
")",
"if",
"config_file",
"not",
"in",
"dataset",
":",
"... | Reads config for a single job defined by section. | [
"Reads",
"config",
"for",
"a",
"single",
"job",
"defined",
"by",
"section",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/config_utils.py#L360-L445 |
CivicSpleen/ambry | ambry/valuetype/types.py | transform_generator | def transform_generator(fn):
"""A decorator that marks transform pipes that should be called to create the real transform"""
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
fn.__dict__['is_transform_generator'] = True
return fn | python | def transform_generator(fn):
"""A decorator that marks transform pipes that should be called to create the real transform"""
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
fn.__dict__['is_transform_generator'] = True
return fn | [
"def",
"transform_generator",
"(",
"fn",
")",
":",
"if",
"six",
".",
"PY2",
":",
"fn",
".",
"func_dict",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"else",
":",
"# py3",
"fn",
".",
"__dict__",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"ret... | A decorator that marks transform pipes that should be called to create the real transform | [
"A",
"decorator",
"that",
"marks",
"transform",
"pipes",
"that",
"should",
"be",
"called",
"to",
"create",
"the",
"real",
"transform"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L19-L26 |
CivicSpleen/ambry | ambry/valuetype/types.py | is_transform_generator | def is_transform_generator(fn):
"""Return true of the function has been marked with @transform_generator"""
try:
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
return fn.__dict__.get('is_transform_generator', False)
except AttributeE... | python | def is_transform_generator(fn):
"""Return true of the function has been marked with @transform_generator"""
try:
if six.PY2:
fn.func_dict['is_transform_generator'] = True
else:
# py3
return fn.__dict__.get('is_transform_generator', False)
except AttributeE... | [
"def",
"is_transform_generator",
"(",
"fn",
")",
":",
"try",
":",
"if",
"six",
".",
"PY2",
":",
"fn",
".",
"func_dict",
"[",
"'is_transform_generator'",
"]",
"=",
"True",
"else",
":",
"# py3",
"return",
"fn",
".",
"__dict__",
".",
"get",
"(",
"'is_transf... | Return true of the function has been marked with @transform_generator | [
"Return",
"true",
"of",
"the",
"function",
"has",
"been",
"marked",
"with"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L29-L38 |
CivicSpleen/ambry | ambry/valuetype/types.py | nullify | def nullify(v):
"""Convert empty strings and strings with only spaces to None values. """
if isinstance(v, six.string_types):
v = v.strip()
if v is None or v == '':
return None
else:
return v | python | def nullify(v):
"""Convert empty strings and strings with only spaces to None values. """
if isinstance(v, six.string_types):
v = v.strip()
if v is None or v == '':
return None
else:
return v | [
"def",
"nullify",
"(",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"six",
".",
"string_types",
")",
":",
"v",
"=",
"v",
".",
"strip",
"(",
")",
"if",
"v",
"is",
"None",
"or",
"v",
"==",
"''",
":",
"return",
"None",
"else",
":",
"return",
... | Convert empty strings and strings with only spaces to None values. | [
"Convert",
"empty",
"strings",
"and",
"strings",
"with",
"only",
"spaces",
"to",
"None",
"values",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L45-L54 |
CivicSpleen/ambry | ambry/valuetype/types.py | clean_float | def clean_float(v):
"""Remove commas from a float"""
if v is None or not str(v).strip():
return None
return float(str(v).replace(',', '')) | python | def clean_float(v):
"""Remove commas from a float"""
if v is None or not str(v).strip():
return None
return float(str(v).replace(',', '')) | [
"def",
"clean_float",
"(",
"v",
")",
":",
"if",
"v",
"is",
"None",
"or",
"not",
"str",
"(",
"v",
")",
".",
"strip",
"(",
")",
":",
"return",
"None",
"return",
"float",
"(",
"str",
"(",
"v",
")",
".",
"replace",
"(",
"','",
",",
"''",
")",
")"... | Remove commas from a float | [
"Remove",
"commas",
"from",
"a",
"float"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L57-L63 |
CivicSpleen/ambry | ambry/valuetype/types.py | clean_int | def clean_int(v):
"""Remove commas from a float"""
if v is None or not str(v).strip():
return None
return int(str(v).replace(',', '')) | python | def clean_int(v):
"""Remove commas from a float"""
if v is None or not str(v).strip():
return None
return int(str(v).replace(',', '')) | [
"def",
"clean_int",
"(",
"v",
")",
":",
"if",
"v",
"is",
"None",
"or",
"not",
"str",
"(",
"v",
")",
".",
"strip",
"(",
")",
":",
"return",
"None",
"return",
"int",
"(",
"str",
"(",
"v",
")",
".",
"replace",
"(",
"','",
",",
"''",
")",
")"
] | Remove commas from a float | [
"Remove",
"commas",
"from",
"a",
"float"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L66-L72 |
CivicSpleen/ambry | ambry/valuetype/types.py | parse_int | def parse_int(v, header_d):
"""Parse as an integer, or a subclass of Int."""
v = nullify(v)
if v is None:
return None
try:
# The converson to float allows converting float strings to ints.
# The conversion int('2.134') will fail.
return int(round(float(v), 0))
exce... | python | def parse_int(v, header_d):
"""Parse as an integer, or a subclass of Int."""
v = nullify(v)
if v is None:
return None
try:
# The converson to float allows converting float strings to ints.
# The conversion int('2.134') will fail.
return int(round(float(v), 0))
exce... | [
"def",
"parse_int",
"(",
"v",
",",
"header_d",
")",
":",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"# The converson to float allows converting float strings to ints.",
"# The conversion int('2.134') will fail.",
... | Parse as an integer, or a subclass of Int. | [
"Parse",
"as",
"an",
"integer",
"or",
"a",
"subclass",
"of",
"Int",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L127-L140 |
CivicSpleen/ambry | ambry/valuetype/types.py | _parse_text | def _parse_text(v, header_d):
""" Parses unicode.
Note:
unicode types for py2 and str types for py3.
"""
v = nullify(v)
if v is None:
return None
try:
return six.text_type(v).strip()
except Exception as e:
raise CastingError(six.text_type, header_d, v, st... | python | def _parse_text(v, header_d):
""" Parses unicode.
Note:
unicode types for py2 and str types for py3.
"""
v = nullify(v)
if v is None:
return None
try:
return six.text_type(v).strip()
except Exception as e:
raise CastingError(six.text_type, header_d, v, st... | [
"def",
"_parse_text",
"(",
"v",
",",
"header_d",
")",
":",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"six",
".",
"text_type",
"(",
"v",
")",
".",
"strip",
"(",
")",
"except",
"Except... | Parses unicode.
Note:
unicode types for py2 and str types for py3. | [
"Parses",
"unicode",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L338-L354 |
CivicSpleen/ambry | ambry/valuetype/types.py | _parse_binary | def _parse_binary(v, header_d):
""" Parses binary string.
Note:
<str> for py2 and <binary> for py3.
"""
# This is often a no-op, but it ocassionally converts numbers into strings
v = nullify(v)
if v is None:
return None
if six.PY2:
try:
return six.bi... | python | def _parse_binary(v, header_d):
""" Parses binary string.
Note:
<str> for py2 and <binary> for py3.
"""
# This is often a no-op, but it ocassionally converts numbers into strings
v = nullify(v)
if v is None:
return None
if six.PY2:
try:
return six.bi... | [
"def",
"_parse_binary",
"(",
"v",
",",
"header_d",
")",
":",
"# This is often a no-op, but it ocassionally converts numbers into strings",
"v",
"=",
"nullify",
"(",
"v",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"if",
"six",
".",
"PY2",
":",
"try",
... | Parses binary string.
Note:
<str> for py2 and <binary> for py3. | [
"Parses",
"binary",
"string",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/types.py#L357-L382 |
twisted/epsilon | epsilon/juice.py | parseJuiceHeaders | def parseJuiceHeaders(lines):
"""
Create a JuiceBox from a list of header lines.
@param lines: a list of lines.
"""
b = JuiceBox()
bodylen = 0
key = None
for L in lines:
if L[0] == ' ':
# continuation
assert key is not None
b[key] += '\r\n'+L[... | python | def parseJuiceHeaders(lines):
"""
Create a JuiceBox from a list of header lines.
@param lines: a list of lines.
"""
b = JuiceBox()
bodylen = 0
key = None
for L in lines:
if L[0] == ' ':
# continuation
assert key is not None
b[key] += '\r\n'+L[... | [
"def",
"parseJuiceHeaders",
"(",
"lines",
")",
":",
"b",
"=",
"JuiceBox",
"(",
")",
"bodylen",
"=",
"0",
"key",
"=",
"None",
"for",
"L",
"in",
"lines",
":",
"if",
"L",
"[",
"0",
"]",
"==",
"' '",
":",
"# continuation",
"assert",
"key",
"is",
"not",... | Create a JuiceBox from a list of header lines.
@param lines: a list of lines. | [
"Create",
"a",
"JuiceBox",
"from",
"a",
"list",
"of",
"header",
"lines",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L283-L304 |
twisted/epsilon | epsilon/juice.py | DispatchMixin.lookupFunction | def lookupFunction(self, proto, name, namespace):
"""Return a callable to invoke when executing the named command.
"""
# Try to find a method to be invoked in a transaction first
# Otherwise fallback to a "regular" method
fName = self.autoDispatchPrefix + name
fObj = geta... | python | def lookupFunction(self, proto, name, namespace):
"""Return a callable to invoke when executing the named command.
"""
# Try to find a method to be invoked in a transaction first
# Otherwise fallback to a "regular" method
fName = self.autoDispatchPrefix + name
fObj = geta... | [
"def",
"lookupFunction",
"(",
"self",
",",
"proto",
",",
"name",
",",
"namespace",
")",
":",
"# Try to find a method to be invoked in a transaction first",
"# Otherwise fallback to a \"regular\" method",
"fName",
"=",
"self",
".",
"autoDispatchPrefix",
"+",
"name",
"fObj",
... | Return a callable to invoke when executing the named command. | [
"Return",
"a",
"callable",
"to",
"invoke",
"when",
"executing",
"the",
"named",
"command",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L246-L262 |
twisted/epsilon | epsilon/juice.py | JuiceParserBase.sendBoxCommand | def sendBoxCommand(self, command, box, requiresAnswer=True):
"""
Send a command across the wire with the given C{juice.Box}.
Returns a Deferred which fires with the response C{juice.Box} when it
is received, or fails with a C{juice.RemoteJuiceError} if an error is
received.
... | python | def sendBoxCommand(self, command, box, requiresAnswer=True):
"""
Send a command across the wire with the given C{juice.Box}.
Returns a Deferred which fires with the response C{juice.Box} when it
is received, or fails with a C{juice.RemoteJuiceError} if an error is
received.
... | [
"def",
"sendBoxCommand",
"(",
"self",
",",
"command",
",",
"box",
",",
"requiresAnswer",
"=",
"True",
")",
":",
"if",
"self",
".",
"_outstandingRequests",
"is",
"None",
":",
"return",
"fail",
"(",
"CONNECTION_LOST",
")",
"box",
"[",
"COMMAND",
"]",
"=",
... | Send a command across the wire with the given C{juice.Box}.
Returns a Deferred which fires with the response C{juice.Box} when it
is received, or fails with a C{juice.RemoteJuiceError} if an error is
received.
If the Deferred fails and the error is not handled by the caller of
... | [
"Send",
"a",
"command",
"across",
"the",
"wire",
"with",
"the",
"given",
"C",
"{",
"juice",
".",
"Box",
"}",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L386-L407 |
twisted/epsilon | epsilon/juice.py | Juice._switchTo | def _switchTo(self, newProto, clientFactory=None):
""" Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand.
"""
assert self.innerProtocol is Non... | python | def _switchTo(self, newProto, clientFactory=None):
""" Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand.
"""
assert self.innerProtocol is Non... | [
"def",
"_switchTo",
"(",
"self",
",",
"newProto",
",",
"clientFactory",
"=",
"None",
")",
":",
"assert",
"self",
".",
"innerProtocol",
"is",
"None",
",",
"\"Protocol can only be safely switched once.\"",
"self",
".",
"setRawMode",
"(",
")",
"self",
".",
"innerPr... | Switch this Juice instance to a new protocol. You need to do this
'simultaneously' on both ends of a connection; the easiest way to do
this is to use a subclass of ProtocolSwitchCommand. | [
"Switch",
"this",
"Juice",
"instance",
"to",
"a",
"new",
"protocol",
".",
"You",
"need",
"to",
"do",
"this",
"simultaneously",
"on",
"both",
"ends",
"of",
"a",
"connection",
";",
"the",
"easiest",
"way",
"to",
"do",
"this",
"is",
"to",
"use",
"a",
"sub... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L784-L794 |
twisted/epsilon | epsilon/juice.py | Juice.sendPacket | def sendPacket(self, completeBox):
"""
Send a juice.Box to my peer.
Note: transport.write is never called outside of this method.
"""
assert not self.__locked, "You cannot send juice packets when a connection is locked"
if self._startingTLSBuffer is not None:
... | python | def sendPacket(self, completeBox):
"""
Send a juice.Box to my peer.
Note: transport.write is never called outside of this method.
"""
assert not self.__locked, "You cannot send juice packets when a connection is locked"
if self._startingTLSBuffer is not None:
... | [
"def",
"sendPacket",
"(",
"self",
",",
"completeBox",
")",
":",
"assert",
"not",
"self",
".",
"__locked",
",",
"\"You cannot send juice packets when a connection is locked\"",
"if",
"self",
".",
"_startingTLSBuffer",
"is",
"not",
"None",
":",
"self",
".",
"_starting... | Send a juice.Box to my peer.
Note: transport.write is never called outside of this method. | [
"Send",
"a",
"juice",
".",
"Box",
"to",
"my",
"peer",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/juice.py#L805-L818 |
CivicSpleen/ambry | ambry/orm/plot.py | Plot.dataframe | def dataframe(self, filtered_dims={}, unstack=False, df_class=None, add_code=False):
"""
Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measur... | python | def dataframe(self, filtered_dims={}, unstack=False, df_class=None, add_code=False):
"""
Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measur... | [
"def",
"dataframe",
"(",
"self",
",",
"filtered_dims",
"=",
"{",
"}",
",",
"unstack",
"=",
"False",
",",
"df_class",
"=",
"None",
",",
"add_code",
"=",
"False",
")",
":",
"measure",
"=",
"self",
".",
"table",
".",
"column",
"(",
"measure",
")",
"p_di... | Yield rows in a reduced format, with one dimension as an index, one measure column per
secondary dimension, and all other dimensions filtered.
:param measure: The column names of one or more measures
:param p_dim: The primary dimension. This will be the index of the dataframe.
:param s... | [
"Yield",
"rows",
"in",
"a",
"reduced",
"format",
"with",
"one",
"dimension",
"as",
"an",
"index",
"one",
"measure",
"column",
"per",
"secondary",
"dimension",
"and",
"all",
"other",
"dimensions",
"filtered",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/plot.py#L52-L160 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/buildconfigsetrecords_api.py | BuildconfigsetrecordsApi.get_dependency_graph_for_set | def get_dependency_graph_for_set(self, id, **kwargs):
"""
Gets dependency graph for a Build Group Record (running and completed).
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invo... | python | def get_dependency_graph_for_set(self, id, **kwargs):
"""
Gets dependency graph for a Build Group Record (running and completed).
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invo... | [
"def",
"get_dependency_graph_for_set",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_dependency_gra... | Gets dependency graph for a Build Group Record (running and completed).
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(respons... | [
"Gets",
"dependency",
"graph",
"for",
"a",
"Build",
"Group",
"Record",
"(",
"running",
"and",
"completed",
")",
".",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request"... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildconfigsetrecords_api.py#L385-L409 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex.search | def search(self, search_phrase, limit=None):
""" Finds datasets by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to return. None means without limit.
Returns:
list of DatasetSearchResult instances.
"""
... | python | def search(self, search_phrase, limit=None):
""" Finds datasets by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to return. None means without limit.
Returns:
list of DatasetSearchResult instances.
"""
... | [
"def",
"search",
"(",
"self",
",",
"search_phrase",
",",
"limit",
"=",
"None",
")",
":",
"# SQLite FTS can't find terms with `-`, therefore all hyphens were replaced with underscore",
"# before save. Now to get appropriate result we need to replace all hyphens in the search phrase.",
"# ... | Finds datasets by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to return. None means without limit.
Returns:
list of DatasetSearchResult instances. | [
"Finds",
"datasets",
"by",
"search",
"phrase",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L104-L142 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex._as_document | def _as_document(self, dataset):
""" Converts dataset to document indexed by to FTS index.
Args:
dataset (orm.Dataset): dataset to convert.
Returns:
dict with structure matches to BaseDatasetIndex._schema.
"""
assert isinstance(dataset, Dataset)
... | python | def _as_document(self, dataset):
""" Converts dataset to document indexed by to FTS index.
Args:
dataset (orm.Dataset): dataset to convert.
Returns:
dict with structure matches to BaseDatasetIndex._schema.
"""
assert isinstance(dataset, Dataset)
... | [
"def",
"_as_document",
"(",
"self",
",",
"dataset",
")",
":",
"assert",
"isinstance",
"(",
"dataset",
",",
"Dataset",
")",
"doc",
"=",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"_as_document",
"(",
"dataset",
")",
"# SQLite FTS can't f... | Converts dataset to document indexed by to FTS index.
Args:
dataset (orm.Dataset): dataset to convert.
Returns:
dict with structure matches to BaseDatasetIndex._schema. | [
"Converts",
"dataset",
"to",
"document",
"indexed",
"by",
"to",
"FTS",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L165-L184 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex._index_document | def _index_document(self, document, force=False):
""" Adds document to the index. """
query = text("""
INSERT INTO dataset_index(vid, title, keywords, doc)
VALUES(:vid, :title, :keywords, :doc);
""")
self.backend.library.database.connection.execute(query, **docume... | python | def _index_document(self, document, force=False):
""" Adds document to the index. """
query = text("""
INSERT INTO dataset_index(vid, title, keywords, doc)
VALUES(:vid, :title, :keywords, :doc);
""")
self.backend.library.database.connection.execute(query, **docume... | [
"def",
"_index_document",
"(",
"self",
",",
"document",
",",
"force",
"=",
"False",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n INSERT INTO dataset_index(vid, title, keywords, doc)\n VALUES(:vid, :title, :keywords, :doc);\n \"\"\"",
")",
"self",
... | Adds document to the index. | [
"Adds",
"document",
"to",
"the",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L186-L192 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex._delete | def _delete(self, vid=None):
""" Deletes given dataset from index.
Args:
vid (str): dataset vid.
"""
query = text("""
DELETE FROM dataset_index
WHERE vid = :vid;
""")
self.backend.library.database.connection.execute(query, vid=vid) | python | def _delete(self, vid=None):
""" Deletes given dataset from index.
Args:
vid (str): dataset vid.
"""
query = text("""
DELETE FROM dataset_index
WHERE vid = :vid;
""")
self.backend.library.database.connection.execute(query, vid=vid) | [
"def",
"_delete",
"(",
"self",
",",
"vid",
"=",
"None",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n DELETE FROM dataset_index\n WHERE vid = :vid;\n \"\"\"",
")",
"self",
".",
"backend",
".",
"library",
".",
"database",
".",
"connection"... | Deletes given dataset from index.
Args:
vid (str): dataset vid. | [
"Deletes",
"given",
"dataset",
"from",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L201-L212 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex.is_indexed | def is_indexed(self, dataset):
""" Returns True if dataset is already indexed. Otherwise returns False. """
query = text("""
SELECT vid
FROM dataset_index
WHERE vid = :vid;
""")
result = self.backend.library.database.connection.execute(query, vid=datas... | python | def is_indexed(self, dataset):
""" Returns True if dataset is already indexed. Otherwise returns False. """
query = text("""
SELECT vid
FROM dataset_index
WHERE vid = :vid;
""")
result = self.backend.library.database.connection.execute(query, vid=datas... | [
"def",
"is_indexed",
"(",
"self",
",",
"dataset",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT vid\n FROM dataset_index\n WHERE vid = :vid;\n \"\"\"",
")",
"result",
"=",
"self",
".",
"backend",
".",
"library",
".",
"databa... | Returns True if dataset is already indexed. Otherwise returns False. | [
"Returns",
"True",
"if",
"dataset",
"is",
"already",
"indexed",
".",
"Otherwise",
"returns",
"False",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L214-L222 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | DatasetSQLiteIndex.all | def all(self):
""" Returns list with all indexed datasets. """
datasets = []
query = text("""
SELECT vid
FROM dataset_index;""")
for result in self.backend.library.database.connection.execute(query):
res = DatasetSearchResult()
res.vid = ... | python | def all(self):
""" Returns list with all indexed datasets. """
datasets = []
query = text("""
SELECT vid
FROM dataset_index;""")
for result in self.backend.library.database.connection.execute(query):
res = DatasetSearchResult()
res.vid = ... | [
"def",
"all",
"(",
"self",
")",
":",
"datasets",
"=",
"[",
"]",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT vid\n FROM dataset_index;\"\"\"",
")",
"for",
"result",
"in",
"self",
".",
"backend",
".",
"library",
".",
"database",
".",
"connect... | Returns list with all indexed datasets. | [
"Returns",
"list",
"with",
"all",
"indexed",
"datasets",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L224-L237 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.list_documents | def list_documents(self, limit=None):
""" Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document.
"""
limit_str = ''
if limit:
... | python | def list_documents(self, limit=None):
""" Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document.
"""
limit_str = ''
if limit:
... | [
"def",
"list_documents",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"limit_str",
"=",
"''",
"if",
"limit",
":",
"try",
":",
"limit_str",
"=",
"'LIMIT {}'",
".",
"format",
"(",
"int",
"(",
"limit",
")",
")",
"except",
"(",
"TypeError",
",",
"Va... | Generates vids of all indexed identifiers.
Args:
limit (int, optional): If not empty, the maximum number of results to return
Generates:
str: vid of the document. | [
"Generates",
"vids",
"of",
"all",
"indexed",
"identifiers",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L289-L308 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.reset | def reset(self):
""" Drops index table. """
query = """
DROP TABLE identifier_index;
"""
self.backend.library.database.connection.execute(query) | python | def reset(self):
""" Drops index table. """
query = """
DROP TABLE identifier_index;
"""
self.backend.library.database.connection.execute(query) | [
"def",
"reset",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n DROP TABLE identifier_index;\n \"\"\"",
"self",
".",
"backend",
".",
"library",
".",
"database",
".",
"connection",
".",
"execute",
"(",
"query",
")"
] | Drops index table. | [
"Drops",
"index",
"table",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L318-L323 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex._delete | def _delete(self, identifier=None):
""" Deletes given identifier from index.
Args:
identifier (str): identifier of the document to delete.
"""
query = text("""
DELETE FROM identifier_index
WHERE identifier = :identifier;
""")
self.bac... | python | def _delete(self, identifier=None):
""" Deletes given identifier from index.
Args:
identifier (str): identifier of the document to delete.
"""
query = text("""
DELETE FROM identifier_index
WHERE identifier = :identifier;
""")
self.bac... | [
"def",
"_delete",
"(",
"self",
",",
"identifier",
"=",
"None",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n DELETE FROM identifier_index\n WHERE identifier = :identifier;\n \"\"\"",
")",
"self",
".",
"backend",
".",
"library",
".",
"database... | Deletes given identifier from index.
Args:
identifier (str): identifier of the document to delete. | [
"Deletes",
"given",
"identifier",
"from",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L325-L336 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.is_indexed | def is_indexed(self, identifier):
""" Returns True if identifier is already indexed. Otherwise returns False. """
query = text("""
SELECT identifier
FROM identifier_index
WHERE identifier = :identifier;
""")
result = self.backend.library.database.conne... | python | def is_indexed(self, identifier):
""" Returns True if identifier is already indexed. Otherwise returns False. """
query = text("""
SELECT identifier
FROM identifier_index
WHERE identifier = :identifier;
""")
result = self.backend.library.database.conne... | [
"def",
"is_indexed",
"(",
"self",
",",
"identifier",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT identifier\n FROM identifier_index\n WHERE identifier = :identifier;\n \"\"\"",
")",
"result",
"=",
"self",
".",
"backend",
".",
... | Returns True if identifier is already indexed. Otherwise returns False. | [
"Returns",
"True",
"if",
"identifier",
"is",
"already",
"indexed",
".",
"Otherwise",
"returns",
"False",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L338-L346 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | IdentifierSQLiteIndex.all | def all(self):
""" Returns list with all indexed identifiers. """
identifiers = []
query = text("""
SELECT identifier, type, name
FROM identifier_index;""")
for result in self.backend.library.database.connection.execute(query):
vid, type_, name = res... | python | def all(self):
""" Returns list with all indexed identifiers. """
identifiers = []
query = text("""
SELECT identifier, type, name
FROM identifier_index;""")
for result in self.backend.library.database.connection.execute(query):
vid, type_, name = res... | [
"def",
"all",
"(",
"self",
")",
":",
"identifiers",
"=",
"[",
"]",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT identifier, type, name\n FROM identifier_index;\"\"\"",
")",
"for",
"result",
"in",
"self",
".",
"backend",
".",
"library",
".",
"dat... | Returns list with all indexed identifiers. | [
"Returns",
"list",
"with",
"all",
"indexed",
"identifiers",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L348-L361 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | PartitionSQLiteIndex.search | def search(self, search_phrase, limit=None):
""" Finds partitions by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to generate. None means without limit.
Generates:
PartitionSearchResult instances.
"""
... | python | def search(self, search_phrase, limit=None):
""" Finds partitions by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to generate. None means without limit.
Generates:
PartitionSearchResult instances.
"""
... | [
"def",
"search",
"(",
"self",
",",
"search_phrase",
",",
"limit",
"=",
"None",
")",
":",
"# SQLite FTS can't find terms with `-`, therefore all hyphens replaced with underscore before save.",
"# Now to make proper query we need to replace all hyphens in the search phrase.",
"# See http:/... | Finds partitions by search phrase.
Args:
search_phrase (str or unicode):
limit (int, optional): how many results to generate. None means without limit.
Generates:
PartitionSearchResult instances. | [
"Finds",
"partitions",
"by",
"search",
"phrase",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L385-L427 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | PartitionSQLiteIndex._as_document | def _as_document(self, partition):
""" Converts partition to document indexed by to FTS index.
Args:
partition (orm.Partition): partition to convert.
Returns:
dict with structure matches to BasePartitionIndex._schema.
"""
doc = super(self.__class__, sel... | python | def _as_document(self, partition):
""" Converts partition to document indexed by to FTS index.
Args:
partition (orm.Partition): partition to convert.
Returns:
dict with structure matches to BasePartitionIndex._schema.
"""
doc = super(self.__class__, sel... | [
"def",
"_as_document",
"(",
"self",
",",
"partition",
")",
":",
"doc",
"=",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"_as_document",
"(",
"partition",
")",
"# SQLite FTS can't find terms with `-`, replace it with underscore here and while searching... | Converts partition to document indexed by to FTS index.
Args:
partition (orm.Partition): partition to convert.
Returns:
dict with structure matches to BasePartitionIndex._schema. | [
"Converts",
"partition",
"to",
"document",
"indexed",
"by",
"to",
"FTS",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L451-L471 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | PartitionSQLiteIndex._make_query_from_terms | def _make_query_from_terms(self, terms):
""" Creates a query for partition from decomposed search terms.
Args:
terms (dict or unicode or string):
Returns:
tuple of (str, dict): First element is str with FTS query, second is parameters of the query.
"""
... | python | def _make_query_from_terms(self, terms):
""" Creates a query for partition from decomposed search terms.
Args:
terms (dict or unicode or string):
Returns:
tuple of (str, dict): First element is str with FTS query, second is parameters of the query.
"""
... | [
"def",
"_make_query_from_terms",
"(",
"self",
",",
"terms",
")",
":",
"match_query",
"=",
"''",
"expanded_terms",
"=",
"self",
".",
"_expand_terms",
"(",
"terms",
")",
"if",
"expanded_terms",
"[",
"'doc'",
"]",
":",
"match_query",
"=",
"self",
".",
"backend"... | Creates a query for partition from decomposed search terms.
Args:
terms (dict or unicode or string):
Returns:
tuple of (str, dict): First element is str with FTS query, second is parameters of the query. | [
"Creates",
"a",
"query",
"for",
"partition",
"from",
"decomposed",
"search",
"terms",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L473-L512 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | PartitionSQLiteIndex._index_document | def _index_document(self, document, force=False):
""" Adds parition document to the index. """
from ambry.util import int_maybe
time_coverage = document.pop('time_coverage', [])
from_year = None
to_year = None
if time_coverage:
from_year = int_maybe(time_cover... | python | def _index_document(self, document, force=False):
""" Adds parition document to the index. """
from ambry.util import int_maybe
time_coverage = document.pop('time_coverage', [])
from_year = None
to_year = None
if time_coverage:
from_year = int_maybe(time_cover... | [
"def",
"_index_document",
"(",
"self",
",",
"document",
",",
"force",
"=",
"False",
")",
":",
"from",
"ambry",
".",
"util",
"import",
"int_maybe",
"time_coverage",
"=",
"document",
".",
"pop",
"(",
"'time_coverage'",
",",
"[",
"]",
")",
"from_year",
"=",
... | Adds parition document to the index. | [
"Adds",
"parition",
"document",
"to",
"the",
"index",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L514-L528 |
CivicSpleen/ambry | ambry/library/search_backends/sqlite_backend.py | PartitionSQLiteIndex.all | def all(self):
""" Returns list with vids of all indexed partitions. """
partitions = []
query = text("""
SELECT dataset_vid, vid
FROM partition_index;""")
for result in self.backend.library.database.connection.execute(query):
dataset_vid, vid = resu... | python | def all(self):
""" Returns list with vids of all indexed partitions. """
partitions = []
query = text("""
SELECT dataset_vid, vid
FROM partition_index;""")
for result in self.backend.library.database.connection.execute(query):
dataset_vid, vid = resu... | [
"def",
"all",
"(",
"self",
")",
":",
"partitions",
"=",
"[",
"]",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT dataset_vid, vid\n FROM partition_index;\"\"\"",
")",
"for",
"result",
"in",
"self",
".",
"backend",
".",
"library",
".",
"database",
... | Returns list with vids of all indexed partitions. | [
"Returns",
"list",
"with",
"vids",
"of",
"all",
"indexed",
"partitions",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/sqlite_backend.py#L560-L571 |
kurtraschke/pyRFC3339 | pyrfc3339/utils.py | timedelta_seconds | def timedelta_seconds(td):
'''
Return the offset stored by a :class:`datetime.timedelta` object as an
integer number of seconds. Microseconds, if present, are rounded to
the nearest second.
Delegates to
:meth:`timedelta.total_seconds() <datetime.timedelta.total_seconds()>`
if available.
... | python | def timedelta_seconds(td):
'''
Return the offset stored by a :class:`datetime.timedelta` object as an
integer number of seconds. Microseconds, if present, are rounded to
the nearest second.
Delegates to
:meth:`timedelta.total_seconds() <datetime.timedelta.total_seconds()>`
if available.
... | [
"def",
"timedelta_seconds",
"(",
"td",
")",
":",
"try",
":",
"return",
"int",
"(",
"round",
"(",
"td",
".",
"total_seconds",
"(",
")",
")",
")",
"except",
"AttributeError",
":",
"days",
"=",
"td",
".",
"days",
"seconds",
"=",
"td",
".",
"seconds",
"m... | Return the offset stored by a :class:`datetime.timedelta` object as an
integer number of seconds. Microseconds, if present, are rounded to
the nearest second.
Delegates to
:meth:`timedelta.total_seconds() <datetime.timedelta.total_seconds()>`
if available.
>>> timedelta_seconds(timedelta(hour... | [
"Return",
"the",
"offset",
"stored",
"by",
"a",
":",
"class",
":",
"datetime",
".",
"timedelta",
"object",
"as",
"an",
"integer",
"number",
"of",
"seconds",
".",
"Microseconds",
"if",
"present",
"are",
"rounded",
"to",
"the",
"nearest",
"second",
"."
] | train | https://github.com/kurtraschke/pyRFC3339/blob/e30cc1555adce0ecc7bd65509a2249d47e5a41b4/pyrfc3339/utils.py#L87-L119 |
kurtraschke/pyRFC3339 | pyrfc3339/utils.py | timezone | def timezone(utcoffset):
'''
Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00'
'''
hours, seconds = divmod(abs(utcoffset), 3600)
m... | python | def timezone(utcoffset):
'''
Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00'
'''
hours, seconds = divmod(abs(utcoffset), 3600)
m... | [
"def",
"timezone",
"(",
"utcoffset",
")",
":",
"hours",
",",
"seconds",
"=",
"divmod",
"(",
"abs",
"(",
"utcoffset",
")",
",",
"3600",
")",
"minutes",
"=",
"round",
"(",
"float",
"(",
"seconds",
")",
"/",
"60",
")",
"if",
"utcoffset",
">=",
"0",
":... | Return a string representing the timezone offset.
Remaining seconds are rounded to the nearest minute.
>>> timezone(3600)
'+01:00'
>>> timezone(5400)
'+01:30'
>>> timezone(-28800)
'-08:00' | [
"Return",
"a",
"string",
"representing",
"the",
"timezone",
"offset",
".",
"Remaining",
"seconds",
"are",
"rounded",
"to",
"the",
"nearest",
"minute",
"."
] | train | https://github.com/kurtraschke/pyRFC3339/blob/e30cc1555adce0ecc7bd65509a2249d47e5a41b4/pyrfc3339/utils.py#L122-L143 |
project-ncl/pnc-cli | pnc_cli/common.py | id_exists | def id_exists(api, search_id):
"""
Test if an ID exists within any arbitrary API
:param api: api to search for search_id
:param search_id: id to test for
:return: True if an entity with ID search_id exists, false otherwise
"""
response = utils.checked_api_call(api, 'get_specific', id=search_... | python | def id_exists(api, search_id):
"""
Test if an ID exists within any arbitrary API
:param api: api to search for search_id
:param search_id: id to test for
:return: True if an entity with ID search_id exists, false otherwise
"""
response = utils.checked_api_call(api, 'get_specific', id=search_... | [
"def",
"id_exists",
"(",
"api",
",",
"search_id",
")",
":",
"response",
"=",
"utils",
".",
"checked_api_call",
"(",
"api",
",",
"'get_specific'",
",",
"id",
"=",
"search_id",
")",
"return",
"response",
"is",
"not",
"None"
] | Test if an ID exists within any arbitrary API
:param api: api to search for search_id
:param search_id: id to test for
:return: True if an entity with ID search_id exists, false otherwise | [
"Test",
"if",
"an",
"ID",
"exists",
"within",
"any",
"arbitrary",
"API",
":",
"param",
"api",
":",
"api",
"to",
"search",
"for",
"search_id",
":",
"param",
"search_id",
":",
"id",
"to",
"test",
"for",
":",
"return",
":",
"True",
"if",
"an",
"entity",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/common.py#L19-L27 |
project-ncl/pnc-cli | pnc_cli/common.py | get_id_by_name | def get_id_by_name(api, search_name):
"""
calls 'get_all' on the given API with a search name and returns the ID of the entity retrieved, if any, None otherwise
:param api: api to search
:param search_name: name to test for
:return ID of entity matching search_name, None otherwise
"""
entiti... | python | def get_id_by_name(api, search_name):
"""
calls 'get_all' on the given API with a search name and returns the ID of the entity retrieved, if any, None otherwise
:param api: api to search
:param search_name: name to test for
:return ID of entity matching search_name, None otherwise
"""
entiti... | [
"def",
"get_id_by_name",
"(",
"api",
",",
"search_name",
")",
":",
"entities",
"=",
"api",
".",
"get_all",
"(",
"q",
"=",
"'name=='",
"+",
"\"'\"",
"+",
"search_name",
"+",
"\"'\"",
")",
".",
"content",
"if",
"entities",
":",
"return",
"entities",
"[",
... | calls 'get_all' on the given API with a search name and returns the ID of the entity retrieved, if any, None otherwise
:param api: api to search
:param search_name: name to test for
:return ID of entity matching search_name, None otherwise | [
"calls",
"get_all",
"on",
"the",
"given",
"API",
"with",
"a",
"search",
"name",
"and",
"returns",
"the",
"ID",
"of",
"the",
"entity",
"retrieved",
"if",
"any",
"None",
"otherwise",
":",
"param",
"api",
":",
"api",
"to",
"search",
":",
"param",
"search_na... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/common.py#L30-L40 |
project-ncl/pnc-cli | pnc_cli/common.py | get_entity | def get_entity(api, entity_id):
"""
Generic "getSpecific" call that calls get_specific with the given id
:param api: api to call get_specific on
:param id: id of the entity to retrieve
:return: REST entity
"""
response = utils.checked_api_call(api, 'get_specific', id=entity_id)
if respon... | python | def get_entity(api, entity_id):
"""
Generic "getSpecific" call that calls get_specific with the given id
:param api: api to call get_specific on
:param id: id of the entity to retrieve
:return: REST entity
"""
response = utils.checked_api_call(api, 'get_specific', id=entity_id)
if respon... | [
"def",
"get_entity",
"(",
"api",
",",
"entity_id",
")",
":",
"response",
"=",
"utils",
".",
"checked_api_call",
"(",
"api",
",",
"'get_specific'",
",",
"id",
"=",
"entity_id",
")",
"if",
"response",
":",
"return",
"response",
".",
"content",
"return"
] | Generic "getSpecific" call that calls get_specific with the given id
:param api: api to call get_specific on
:param id: id of the entity to retrieve
:return: REST entity | [
"Generic",
"getSpecific",
"call",
"that",
"calls",
"get_specific",
"with",
"the",
"given",
"id",
":",
"param",
"api",
":",
"api",
"to",
"call",
"get_specific",
"on",
":",
"param",
"id",
":",
"id",
"of",
"the",
"entity",
"to",
"retrieve",
":",
"return",
"... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/common.py#L52-L62 |
CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.build_duration | def build_duration(self):
"""Return the difference between build and build_done states"""
return int(self.state.build_done) - int(self.state.build) | python | def build_duration(self):
"""Return the difference between build and build_done states"""
return int(self.state.build_done) - int(self.state.build) | [
"def",
"build_duration",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"state",
".",
"build_done",
")",
"-",
"int",
"(",
"self",
".",
"state",
".",
"build",
")"
] | Return the difference between build and build_done states | [
"Return",
"the",
"difference",
"between",
"build",
"and",
"build_done",
"states"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L228-L231 |
CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.build_duration_pretty | def build_duration_pretty(self):
"""Return the difference between build and build_done states, in a human readable format"""
from ambry.util import pretty_time
from time import time
if not self.state.building:
return None
built = self.state.built or time()
... | python | def build_duration_pretty(self):
"""Return the difference between build and build_done states, in a human readable format"""
from ambry.util import pretty_time
from time import time
if not self.state.building:
return None
built = self.state.built or time()
... | [
"def",
"build_duration_pretty",
"(",
"self",
")",
":",
"from",
"ambry",
".",
"util",
"import",
"pretty_time",
"from",
"time",
"import",
"time",
"if",
"not",
"self",
".",
"state",
".",
"building",
":",
"return",
"None",
"built",
"=",
"self",
".",
"state",
... | Return the difference between build and build_done states, in a human readable format | [
"Return",
"the",
"difference",
"between",
"build",
"and",
"build_done",
"states",
"in",
"a",
"human",
"readable",
"format"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L234-L247 |
CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.built_datetime | def built_datetime(self):
"""Return the built time as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.build_done)
except TypeError:
# build_done is null
return None | python | def built_datetime(self):
"""Return the built time as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.build_done)
except TypeError:
# build_done is null
return None | [
"def",
"built_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"build_done",
")",
"except",
"TypeError",
":",
"# build_done is null",
"return",
"... | Return the built time as a datetime object | [
"Return",
"the",
"built",
"time",
"as",
"a",
"datetime",
"object"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L250-L257 |
CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.new_datetime | def new_datetime(self):
"""Return the time the bundle was created as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.new)
except TypeError:
return None | python | def new_datetime(self):
"""Return the time the bundle was created as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.new)
except TypeError:
return None | [
"def",
"new_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"new",
")",
"except",
"TypeError",
":",
"return",
"None"
] | Return the time the bundle was created as a datetime object | [
"Return",
"the",
"time",
"the",
"bundle",
"was",
"created",
"as",
"a",
"datetime",
"object"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L260-L267 |
CivicSpleen/ambry | ambry/orm/config.py | BuildConfigGroupAccessor.last_datetime | def last_datetime(self):
"""Return the time of the last operation on the bundle as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.lasttime)
except TypeError:
return None | python | def last_datetime(self):
"""Return the time of the last operation on the bundle as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.lasttime)
except TypeError:
return None | [
"def",
"last_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"lasttime",
")",
"except",
"TypeError",
":",
"return",
"None"
] | Return the time of the last operation on the bundle as a datetime object | [
"Return",
"the",
"time",
"of",
"the",
"last",
"operation",
"on",
"the",
"bundle",
"as",
"a",
"datetime",
"object"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L270-L277 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/sessioncontainer.py | SessionContainer.add | def add(self, session):
""" Add session to the container.
@param session: Session object
"""
self._items[session.session_id] = session
if session.expiry is not None:
self._queue.push(session) | python | def add(self, session):
""" Add session to the container.
@param session: Session object
"""
self._items[session.session_id] = session
if session.expiry is not None:
self._queue.push(session) | [
"def",
"add",
"(",
"self",
",",
"session",
")",
":",
"self",
".",
"_items",
"[",
"session",
".",
"session_id",
"]",
"=",
"session",
"if",
"session",
".",
"expiry",
"is",
"not",
"None",
":",
"self",
".",
"_queue",
".",
"push",
"(",
"session",
")"
] | Add session to the container.
@param session: Session object | [
"Add",
"session",
"to",
"the",
"container",
"."
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/sessioncontainer.py#L12-L20 |
flaviogrossi/sockjs-cyclone | sockjs/cyclone/sessioncontainer.py | SessionContainer.expire | def expire(self, current_time=None):
""" Expire any old entries
@param current_time: Optional time to be used to clean up queue (can be
used in unit tests)
"""
if self._queue.is_empty():
return
if current_time is None:
curren... | python | def expire(self, current_time=None):
""" Expire any old entries
@param current_time: Optional time to be used to clean up queue (can be
used in unit tests)
"""
if self._queue.is_empty():
return
if current_time is None:
curren... | [
"def",
"expire",
"(",
"self",
",",
"current_time",
"=",
"None",
")",
":",
"if",
"self",
".",
"_queue",
".",
"is_empty",
"(",
")",
":",
"return",
"if",
"current_time",
"is",
"None",
":",
"current_time",
"=",
"time",
".",
"time",
"(",
")",
"while",
"no... | Expire any old entries
@param current_time: Optional time to be used to clean up queue (can be
used in unit tests) | [
"Expire",
"any",
"old",
"entries"
] | train | https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/sessioncontainer.py#L44-L86 |
CivicSpleen/ambry | ambry/util/mail.py | send_email | def send_email(recipients, subject, message, attachments=None):
""" Sends email.
Args:
recipients (list of str):
subject (str):
message (str):
attachments (list of str): list containing full paths (txt files only) to attach to email.
"""
if not attachments:
attach... | python | def send_email(recipients, subject, message, attachments=None):
""" Sends email.
Args:
recipients (list of str):
subject (str):
message (str):
attachments (list of str): list containing full paths (txt files only) to attach to email.
"""
if not attachments:
attach... | [
"def",
"send_email",
"(",
"recipients",
",",
"subject",
",",
"message",
",",
"attachments",
"=",
"None",
")",
":",
"if",
"not",
"attachments",
":",
"attachments",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"EMAIL_SETTINGS_FILE",
")",
":"... | Sends email.
Args:
recipients (list of str):
subject (str):
message (str):
attachments (list of str): list containing full paths (txt files only) to attach to email. | [
"Sends",
"email",
".",
"Args",
":",
"recipients",
"(",
"list",
"of",
"str",
")",
":",
"subject",
"(",
"str",
")",
":",
"message",
"(",
"str",
")",
":",
"attachments",
"(",
"list",
"of",
"str",
")",
":",
"list",
"containing",
"full",
"paths",
"(",
"... | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/mail.py#L13-L64 |
project-ncl/pnc-cli | pnc_cli/productversions.py | list_product_versions | def list_product_versions(page_size=200, page_index=0, sort="", q=""):
"""
List all ProductVersions
"""
content = list_product_versions_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | python | def list_product_versions(page_size=200, page_index=0, sort="", q=""):
"""
List all ProductVersions
"""
content = list_product_versions_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | [
"def",
"list_product_versions",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_product_versions_raw",
"(",
"page_size",
",",
"page_index",
",",
"sort",
",",
"q",
... | List all ProductVersions | [
"List",
"all",
"ProductVersions"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L34-L40 |
project-ncl/pnc-cli | pnc_cli/productversions.py | create_product_version | def create_product_version(product_id, version, **kwargs):
"""
Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support c... | python | def create_product_version(product_id, version, **kwargs):
"""
Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support c... | [
"def",
"create_product_version",
"(",
"product_id",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"create_product_version_raw",
"(",
"product_id",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
"if",
"data",
":",
"return",
"utils",
".",
"f... | Create a new ProductVersion.
Each ProductVersion represents a supported product release stream, which includes milestones and releases typically associated with a single major.minor version of a Product.
Follows the Red Hat product support cycle, and typically includes Alpha, Beta, GA, and CP releases with the ... | [
"Create",
"a",
"new",
"ProductVersion",
".",
"Each",
"ProductVersion",
"represents",
"a",
"supported",
"product",
"release",
"stream",
"which",
"includes",
"milestones",
"and",
"releases",
"typically",
"associated",
"with",
"a",
"single",
"major",
".",
"minor",
"v... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L60-L72 |
project-ncl/pnc-cli | pnc_cli/productversions.py | update_product_version | def update_product_version(id, **kwargs):
"""
Update the ProductVersion with ID id with new values.
"""
content = update_product_version_raw(id, **kwargs)
if content:
return utils.format_json(content) | python | def update_product_version(id, **kwargs):
"""
Update the ProductVersion with ID id with new values.
"""
content = update_product_version_raw(id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_product_version",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_product_version_raw",
"(",
"id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update the ProductVersion with ID id with new values. | [
"Update",
"the",
"ProductVersion",
"with",
"ID",
"id",
"with",
"new",
"values",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/productversions.py#L117-L123 |
SmartTeleMax/iktomi | iktomi/forms/widgets.py | Widget.prepare_data | def prepare_data(self):
'''
Method returning data passed to template.
Subclasses can override it.
'''
value = self.get_raw_value()
return dict(widget=self,
field=self.field,
value=value,
readonly=not self.field.w... | python | def prepare_data(self):
'''
Method returning data passed to template.
Subclasses can override it.
'''
value = self.get_raw_value()
return dict(widget=self,
field=self.field,
value=value,
readonly=not self.field.w... | [
"def",
"prepare_data",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"get_raw_value",
"(",
")",
"return",
"dict",
"(",
"widget",
"=",
"self",
",",
"field",
"=",
"self",
".",
"field",
",",
"value",
"=",
"value",
",",
"readonly",
"=",
"not",
"self"... | Method returning data passed to template.
Subclasses can override it. | [
"Method",
"returning",
"data",
"passed",
"to",
"template",
".",
"Subclasses",
"can",
"override",
"it",
"."
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/widgets.py#L52-L61 |
SmartTeleMax/iktomi | iktomi/forms/widgets.py | Widget.render | def render(self):
'''
Renders widget to template
'''
data = self.prepare_data()
if self.field.readable:
return self.env.template.render(self.template, **data)
return '' | python | def render(self):
'''
Renders widget to template
'''
data = self.prepare_data()
if self.field.readable:
return self.env.template.render(self.template, **data)
return '' | [
"def",
"render",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"prepare_data",
"(",
")",
"if",
"self",
".",
"field",
".",
"readable",
":",
"return",
"self",
".",
"env",
".",
"template",
".",
"render",
"(",
"self",
".",
"template",
",",
"*",
"*",... | Renders widget to template | [
"Renders",
"widget",
"to",
"template"
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/widgets.py#L66-L73 |
vovanec/httputil | httputil/request_engines/async.py | AsyncRequestEngine._request | def _request(self, url, *,
method='GET', headers=None, data=None, result_callback=None):
"""Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable obj... | python | def _request(self, url, *,
method='GET', headers=None, data=None, result_callback=None):
"""Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable obj... | [
"def",
"_request",
"(",
"self",
",",
"url",
",",
"*",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"result_callback",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"_prepare_request",
"(",
"url",
",",... | Perform asynchronous request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable object.
:param object -> object result_callback: result callback.
:rtype: dict
:raise: APIError | [
"Perform",
"asynchronous",
"request",
"."
] | train | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/request_engines/async.py#L56-L102 |
vovanec/httputil | httputil/request_engines/async.py | AsyncRequestEngine._prepare_request | def _prepare_request(self, url, method, headers, data):
"""Prepare HTTP request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable object.
:rtype: httpclient.HTTPRequest
"""
... | python | def _prepare_request(self, url, method, headers, data):
"""Prepare HTTP request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable object.
:rtype: httpclient.HTTPRequest
"""
... | [
"def",
"_prepare_request",
"(",
"self",
",",
"url",
",",
"method",
",",
"headers",
",",
"data",
")",
":",
"request",
"=",
"httpclient",
".",
"HTTPRequest",
"(",
"url",
"=",
"url",
",",
"method",
"=",
"method",
",",
"headers",
"=",
"headers",
",",
"body... | Prepare HTTP request.
:param str url: request URL.
:param str method: request method.
:param dict headers: request headers.
:param object data: JSON-encodable object.
:rtype: httpclient.HTTPRequest | [
"Prepare",
"HTTP",
"request",
"."
] | train | https://github.com/vovanec/httputil/blob/0b8dab5a23166cceb7dbc2a1dbc802ab5b311347/httputil/request_engines/async.py#L104-L124 |
acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.iter | def iter(self):
"""
Extract BLAST records and yield C{ReadAlignments} instances.
For each file except the first, check that the BLAST parameters are
compatible with those found (above, in __init__) in the first file.
@return: A generator that yields C{ReadAlignments} instances.... | python | def iter(self):
"""
Extract BLAST records and yield C{ReadAlignments} instances.
For each file except the first, check that the BLAST parameters are
compatible with those found (above, in __init__) in the first file.
@return: A generator that yields C{ReadAlignments} instances.... | [
"def",
"iter",
"(",
"self",
")",
":",
"# Note that self._reader is already initialized (in __init__) for",
"# the first input file. This is less clean than it could be, but it",
"# makes testing easier, since open() is then only called once for",
"# each input file.",
"count",
"=",
"0",
"r... | Extract BLAST records and yield C{ReadAlignments} instances.
For each file except the first, check that the BLAST parameters are
compatible with those found (above, in __init__) in the first file.
@return: A generator that yields C{ReadAlignments} instances. | [
"Extract",
"BLAST",
"records",
"and",
"yield",
"C",
"{",
"ReadAlignments",
"}",
"instances",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L96-L143 |
acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.getSubjectSequence | def getSubjectSequence(self, title):
"""
Obtain information about a subject sequence given its title.
This information is cached in self._subjectTitleToSubject. It can
be obtained from either a) an sqlite database (given via the
sqliteDatabaseFilename argument to __init__), b) t... | python | def getSubjectSequence(self, title):
"""
Obtain information about a subject sequence given its title.
This information is cached in self._subjectTitleToSubject. It can
be obtained from either a) an sqlite database (given via the
sqliteDatabaseFilename argument to __init__), b) t... | [
"def",
"getSubjectSequence",
"(",
"self",
",",
"title",
")",
":",
"if",
"self",
".",
"params",
".",
"application",
"in",
"{",
"'blastp'",
",",
"'blastx'",
"}",
":",
"readClass",
"=",
"AARead",
"else",
":",
"readClass",
"=",
"DNARead",
"if",
"self",
".",
... | Obtain information about a subject sequence given its title.
This information is cached in self._subjectTitleToSubject. It can
be obtained from either a) an sqlite database (given via the
sqliteDatabaseFilename argument to __init__), b) the FASTA that was
originally given to BLAST (via ... | [
"Obtain",
"information",
"about",
"a",
"subject",
"sequence",
"given",
"its",
"title",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L145-L193 |
acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.adjustHspsForPlotting | def adjustHspsForPlotting(self, titleAlignments):
"""
Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}.
"""
# If we're using bit scores, there's nothing to do.
if self.... | python | def adjustHspsForPlotting(self, titleAlignments):
"""
Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}.
"""
# If we're using bit scores, there's nothing to do.
if self.... | [
"def",
"adjustHspsForPlotting",
"(",
"self",
",",
"titleAlignments",
")",
":",
"# If we're using bit scores, there's nothing to do.",
"if",
"self",
".",
"scoreClass",
"is",
"HigherIsBetterScore",
":",
"return",
"# Convert all e-values to high positive values, and keep track of the"... | Our HSPs are about to be plotted. If we are using e-values, these need
to be adjusted.
@param titleAlignments: An instance of L{TitleAlignment}. | [
"Our",
"HSPs",
"are",
"about",
"to",
"be",
"plotted",
".",
"If",
"we",
"are",
"using",
"e",
"-",
"values",
"these",
"need",
"to",
"be",
"adjusted",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L195-L237 |
acorg/dark-matter | dark/blast/alignments.py | BlastReadsAlignments.adjustPlot | def adjustPlot(self, readsAx):
"""
Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot.
"""
# If we're using bit scores, t... | python | def adjustPlot(self, readsAx):
"""
Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot.
"""
# If we're using bit scores, t... | [
"def",
"adjustPlot",
"(",
"self",
",",
"readsAx",
")",
":",
"# If we're using bit scores, there's nothing to do.",
"if",
"self",
".",
"scoreClass",
"is",
"HigherIsBetterScore",
":",
"return",
"if",
"self",
".",
"_zeroEValueFound",
":",
"readsAx",
".",
"axhline",
"("... | Add a horizontal line to the plotted reads if we're plotting e-values
and a zero e-value was found.
@param readsAx: A Matplotlib sub-plot instance, as returned by
matplotlib.pyplot.subplot. | [
"Add",
"a",
"horizontal",
"line",
"to",
"the",
"plotted",
"reads",
"if",
"we",
"re",
"plotting",
"e",
"-",
"values",
"and",
"a",
"zero",
"e",
"-",
"value",
"was",
"found",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/blast/alignments.py#L239-L253 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sum | def sum(self, axis=0, dtype=None):
"""Sum over rows or columns.
Overrides the default `pandas.DataFrame.sum()` function to prevent
temporary in-memory copies.
"""
if axis not in [0, 1, 'index', 'columns']:
raise ValueError('"axis" parameter must be one of 0, ... | python | def sum(self, axis=0, dtype=None):
"""Sum over rows or columns.
Overrides the default `pandas.DataFrame.sum()` function to prevent
temporary in-memory copies.
"""
if axis not in [0, 1, 'index', 'columns']:
raise ValueError('"axis" parameter must be one of 0, ... | [
"def",
"sum",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"axis",
"not",
"in",
"[",
"0",
",",
"1",
",",
"'index'",
",",
"'columns'",
"]",
":",
"raise",
"ValueError",
"(",
"'\"axis\" parameter must be one of 0, 1, \"inde... | Sum over rows or columns.
Overrides the default `pandas.DataFrame.sum()` function to prevent
temporary in-memory copies. | [
"Sum",
"over",
"rows",
"or",
"columns",
".",
"Overrides",
"the",
"default",
"pandas",
".",
"DataFrame",
".",
"sum",
"()",
"function",
"to",
"prevent",
"temporary",
"in",
"-",
"memory",
"copies",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L208-L228 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.get_heatmap | def get_heatmap(self, highlight_genes=None, highlight_samples=None,
highlight_color=None, **kwargs):
"""Generate a heatmap (`ExpHeatmap`) of the matrix.
See :class:`ExpHeatmap` constructor for keyword arguments.
Parameters
----------
highlight_genes : ... | python | def get_heatmap(self, highlight_genes=None, highlight_samples=None,
highlight_color=None, **kwargs):
"""Generate a heatmap (`ExpHeatmap`) of the matrix.
See :class:`ExpHeatmap` constructor for keyword arguments.
Parameters
----------
highlight_genes : ... | [
"def",
"get_heatmap",
"(",
"self",
",",
"highlight_genes",
"=",
"None",
",",
"highlight_samples",
"=",
"None",
",",
"highlight_color",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"visualize",
"import",
"ExpHeatmap",
"from",
".",
"visualize",... | Generate a heatmap (`ExpHeatmap`) of the matrix.
See :class:`ExpHeatmap` constructor for keyword arguments.
Parameters
----------
highlight_genes : list of str
List of genes to highlight
highlight_color : str
Color to use for highlighting
Return... | [
"Generate",
"a",
"heatmap",
"(",
"ExpHeatmap",
")",
"of",
"the",
"matrix",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L240-L292 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.get_figure | def get_figure(self, heatmap_kw=None, **kwargs):
"""Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_k... | python | def get_figure(self, heatmap_kw=None, **kwargs):
"""Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_k... | [
"def",
"get_figure",
"(",
"self",
",",
"heatmap_kw",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"heatmap_kw",
"is",
"not",
"None",
":",
"assert",
"isinstance",
"(",
"heatmap_kw",
",",
"dict",
")",
"if",
"heatmap_kw",
"is",
"None",
":",
"heat... | Generate a plotly figure showing the matrix as a heatmap.
This is a shortcut for ``ExpMatrix.get_heatmap(...).get_figure(...)``.
See :func:`ExpHeatmap.get_figure` for keyword arguments.
Parameters
----------
heatmap_kw : dict or None
If not None, dictionary contain... | [
"Generate",
"a",
"plotly",
"figure",
"showing",
"the",
"matrix",
"as",
"a",
"heatmap",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L295-L319 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sort_genes | def sort_genes(self, stable=True, inplace=False, ascending=True):
"""Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to... | python | def sort_genes(self, stable=True, inplace=False, ascending=True):
"""Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to... | [
"def",
"sort_genes",
"(",
"self",
",",
"stable",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"ascending",
"=",
"True",
")",
":",
"kind",
"=",
"'quicksort'",
"if",
"stable",
":",
"kind",
"=",
"'mergesort'",
"return",
"self",
".",
"sort_index",
"(",
... | Sort the rows of the matrix alphabetically by gene name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to perform the operation in place.[False]
ascending: bool, optional
... | [
"Sort",
"the",
"rows",
"of",
"the",
"matrix",
"alphabetically",
"by",
"gene",
"name",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L322-L342 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sort_samples | def sort_samples(self, stable=True, inplace=False, ascending=True):
"""Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whe... | python | def sort_samples(self, stable=True, inplace=False, ascending=True):
"""Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whe... | [
"def",
"sort_samples",
"(",
"self",
",",
"stable",
"=",
"True",
",",
"inplace",
"=",
"False",
",",
"ascending",
"=",
"True",
")",
":",
"kind",
"=",
"'quicksort'",
"if",
"stable",
":",
"kind",
"=",
"'mergesort'",
"return",
"self",
".",
"sort_index",
"(",
... | Sort the columns of the matrix alphabetically by sample name.
Parameters
----------
stable: bool, optional
Whether to use a stable sorting algorithm. [True]
inplace: bool, optional
Whether to perform the operation in place.[False]
ascending: bool, optiona... | [
"Sort",
"the",
"columns",
"of",
"the",
"matrix",
"alphabetically",
"by",
"sample",
"name",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L344-L365 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.center_genes | def center_genes(self, use_median=False, inplace=False):
"""Center the expression of each gene (row)."""
if use_median:
X = self.X - \
np.tile(np.median(self.X, axis=1), (self.n, 1)).T
else:
X = self.X - \
np.tile(np.mean(self.X, axis=1), (... | python | def center_genes(self, use_median=False, inplace=False):
"""Center the expression of each gene (row)."""
if use_median:
X = self.X - \
np.tile(np.median(self.X, axis=1), (self.n, 1)).T
else:
X = self.X - \
np.tile(np.mean(self.X, axis=1), (... | [
"def",
"center_genes",
"(",
"self",
",",
"use_median",
"=",
"False",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"use_median",
":",
"X",
"=",
"self",
".",
"X",
"-",
"np",
".",
"tile",
"(",
"np",
".",
"median",
"(",
"self",
".",
"X",
",",
"axis"... | Center the expression of each gene (row). | [
"Center",
"the",
"expression",
"of",
"each",
"gene",
"(",
"row",
")",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L367-L382 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.standardize_genes | def standardize_genes(self, inplace=False):
"""Standardize the expression of each gene (row)."""
matrix = self.center_genes(inplace=inplace)
matrix.X[:,:] = matrix.X / \
np.tile(np.std(matrix.X, axis=1, ddof=1), (matrix.n, 1)).T
return matrix | python | def standardize_genes(self, inplace=False):
"""Standardize the expression of each gene (row)."""
matrix = self.center_genes(inplace=inplace)
matrix.X[:,:] = matrix.X / \
np.tile(np.std(matrix.X, axis=1, ddof=1), (matrix.n, 1)).T
return matrix | [
"def",
"standardize_genes",
"(",
"self",
",",
"inplace",
"=",
"False",
")",
":",
"matrix",
"=",
"self",
".",
"center_genes",
"(",
"inplace",
"=",
"inplace",
")",
"matrix",
".",
"X",
"[",
":",
",",
":",
"]",
"=",
"matrix",
".",
"X",
"/",
"np",
".",
... | Standardize the expression of each gene (row). | [
"Standardize",
"the",
"expression",
"of",
"each",
"gene",
"(",
"row",
")",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L384-L389 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.filter_genes | def filter_genes(self, gene_names : Iterable[str], inplace=False):
"""Filter the expression matrix against a _genome (set of genes).
Parameters
----------
gene_names: list of str
The genome to filter the genes against.
inplace: bool, optional
Whether to p... | python | def filter_genes(self, gene_names : Iterable[str], inplace=False):
"""Filter the expression matrix against a _genome (set of genes).
Parameters
----------
gene_names: list of str
The genome to filter the genes against.
inplace: bool, optional
Whether to p... | [
"def",
"filter_genes",
"(",
"self",
",",
"gene_names",
":",
"Iterable",
"[",
"str",
"]",
",",
"inplace",
"=",
"False",
")",
":",
"return",
"self",
".",
"drop",
"(",
"set",
"(",
"self",
".",
"genes",
")",
"-",
"set",
"(",
"gene_names",
")",
",",
"in... | Filter the expression matrix against a _genome (set of genes).
Parameters
----------
gene_names: list of str
The genome to filter the genes against.
inplace: bool, optional
Whether to perform the operation in-place.
Returns
-------
ExpMat... | [
"Filter",
"the",
"expression",
"matrix",
"against",
"a",
"_genome",
"(",
"set",
"of",
"genes",
")",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L391-L408 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.sample_correlations | def sample_correlations(self):
"""Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix.
"""
C = np.corrcoef(self.X.T)
corr_matrix = ExpMatrix(genes=self.samples, samples=self.sa... | python | def sample_correlations(self):
"""Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix.
"""
C = np.corrcoef(self.X.T)
corr_matrix = ExpMatrix(genes=self.samples, samples=self.sa... | [
"def",
"sample_correlations",
"(",
"self",
")",
":",
"C",
"=",
"np",
".",
"corrcoef",
"(",
"self",
".",
"X",
".",
"T",
")",
"corr_matrix",
"=",
"ExpMatrix",
"(",
"genes",
"=",
"self",
".",
"samples",
",",
"samples",
"=",
"self",
".",
"samples",
",",
... | Returns an `ExpMatrix` containing all pairwise sample correlations.
Returns
-------
`ExpMatrix`
The sample correlation matrix. | [
"Returns",
"an",
"ExpMatrix",
"containing",
"all",
"pairwise",
"sample",
"correlations",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L411-L422 |
flo-compbio/genometools | genometools/expression/matrix.py | ExpMatrix.read_tsv | def read_tsv(cls, file_path: str, gene_table: ExpGeneTable = None,
encoding: str = 'UTF-8', sep: str = '\t'):
"""Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGe... | python | def read_tsv(cls, file_path: str, gene_table: ExpGeneTable = None,
encoding: str = 'UTF-8', sep: str = '\t'):
"""Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGe... | [
"def",
"read_tsv",
"(",
"cls",
",",
"file_path",
":",
"str",
",",
"gene_table",
":",
"ExpGeneTable",
"=",
"None",
",",
"encoding",
":",
"str",
"=",
"'UTF-8'",
",",
"sep",
":",
"str",
"=",
"'\\t'",
")",
":",
"# use pd.read_csv to parse the tsv file into a DataF... | Read expression matrix from a tab-delimited text file.
Parameters
----------
file_path: str
The path of the text file.
gene_table: `ExpGeneTable` object, optional
The set of valid genes. If given, the genes in the text file will
be filtered against th... | [
"Read",
"expression",
"matrix",
"from",
"a",
"tab",
"-",
"delimited",
"text",
"file",
"."
] | train | https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/expression/matrix.py#L426-L466 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.