repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/checker.py | IsogeoChecker._check_filter_specific_tag | def _check_filter_specific_tag(self, specific_tag: list):
"""Check if specific_tag parameter is valid.
:param list specific_tag: list of specific tag to check
"""
if isinstance(specific_tag, list):
if len(specific_tag) > 0:
specific_tag = ",".join(specific_ta... | python | def _check_filter_specific_tag(self, specific_tag: list):
"""Check if specific_tag parameter is valid.
:param list specific_tag: list of specific tag to check
"""
if isinstance(specific_tag, list):
if len(specific_tag) > 0:
specific_tag = ",".join(specific_ta... | [
"def",
"_check_filter_specific_tag",
"(",
"self",
",",
"specific_tag",
":",
"list",
")",
":",
"if",
"isinstance",
"(",
"specific_tag",
",",
"list",
")",
":",
"if",
"len",
"(",
"specific_tag",
")",
">",
"0",
":",
"specific_tag",
"=",
"\",\"",
".",
"join",
... | Check if specific_tag parameter is valid.
:param list specific_tag: list of specific tag to check | [
"Check",
"if",
"specific_tag",
"parameter",
"is",
"valid",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/checker.py#L372-L384 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/checker.py | IsogeoChecker._check_filter_includes | def _check_filter_includes(self, includes: list, resource: str = "metadata"):
"""Check if specific_resources parameter is valid.
:param list includes: sub resources to check
:param str resource: resource type to check sub resources.
Must be one of: metadata | keyword.
"""
... | python | def _check_filter_includes(self, includes: list, resource: str = "metadata"):
"""Check if specific_resources parameter is valid.
:param list includes: sub resources to check
:param str resource: resource type to check sub resources.
Must be one of: metadata | keyword.
"""
... | [
"def",
"_check_filter_includes",
"(",
"self",
",",
"includes",
":",
"list",
",",
"resource",
":",
"str",
"=",
"\"metadata\"",
")",
":",
"# check resource parameter",
"if",
"resource",
"==",
"\"metadata\"",
":",
"ref_subresources",
"=",
"_SUBRESOURCES_MD",
"elif",
... | Check if specific_resources parameter is valid.
:param list includes: sub resources to check
:param str resource: resource type to check sub resources.
Must be one of: metadata | keyword. | [
"Check",
"if",
"specific_resources",
"parameter",
"is",
"valid",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/checker.py#L386-L411 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/checker.py | IsogeoChecker._check_subresource | def _check_subresource(self, subresource: str):
"""Check if specific_resources parameter is valid.
:param str resource: subresource to check.
"""
warnings.warn(
"subresource in URL is deprecated." " Use _include mecanism instead.",
DeprecationWarning,
)
... | python | def _check_subresource(self, subresource: str):
"""Check if specific_resources parameter is valid.
:param str resource: subresource to check.
"""
warnings.warn(
"subresource in URL is deprecated." " Use _include mecanism instead.",
DeprecationWarning,
)
... | [
"def",
"_check_subresource",
"(",
"self",
",",
"subresource",
":",
"str",
")",
":",
"warnings",
".",
"warn",
"(",
"\"subresource in URL is deprecated.\"",
"\" Use _include mecanism instead.\"",
",",
"DeprecationWarning",
",",
")",
"l_subresources",
"=",
"(",
"\"conditio... | Check if specific_resources parameter is valid.
:param str resource: subresource to check. | [
"Check",
"if",
"specific_resources",
"parameter",
"is",
"valid",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/checker.py#L413-L460 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/checker.py | IsogeoChecker._convert_md_type | def _convert_md_type(self, type_to_convert: str):
"""Metadata types are not consistent in Isogeo API. A vector dataset is
defined as vector-dataset in query filter but as vectorDataset in
resource (metadata) details.
see: https://github.com/isogeo/isogeo-api-py-minsdk/issues/29
... | python | def _convert_md_type(self, type_to_convert: str):
"""Metadata types are not consistent in Isogeo API. A vector dataset is
defined as vector-dataset in query filter but as vectorDataset in
resource (metadata) details.
see: https://github.com/isogeo/isogeo-api-py-minsdk/issues/29
... | [
"def",
"_convert_md_type",
"(",
"self",
",",
"type_to_convert",
":",
"str",
")",
":",
"if",
"type_to_convert",
"in",
"FILTER_TYPES",
":",
"return",
"FILTER_TYPES",
".",
"get",
"(",
"type_to_convert",
")",
"elif",
"type_to_convert",
"in",
"FILTER_TYPES",
".",
"va... | Metadata types are not consistent in Isogeo API. A vector dataset is
defined as vector-dataset in query filter but as vectorDataset in
resource (metadata) details.
see: https://github.com/isogeo/isogeo-api-py-minsdk/issues/29 | [
"Metadata",
"types",
"are",
"not",
"consistent",
"in",
"Isogeo",
"API",
".",
"A",
"vector",
"dataset",
"is",
"defined",
"as",
"vector",
"-",
"dataset",
"in",
"query",
"filter",
"but",
"as",
"vectorDataset",
"in",
"resource",
"(",
"metadata",
")",
"details",
... | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/checker.py#L462-L476 |
novopl/peltak | src/peltak/commands/version.py | version_cli | def version_cli(ctx, porcelain):
# type: (click.Context, bool) -> None
""" Show project version. Has sub commands.
For this command to work you must specify where the project version is
stored. You can do that with version_file conf variable. peltak supports
multiple ways to store the project versi... | python | def version_cli(ctx, porcelain):
# type: (click.Context, bool) -> None
""" Show project version. Has sub commands.
For this command to work you must specify where the project version is
stored. You can do that with version_file conf variable. peltak supports
multiple ways to store the project versi... | [
"def",
"version_cli",
"(",
"ctx",
",",
"porcelain",
")",
":",
"# type: (click.Context, bool) -> None",
"if",
"ctx",
".",
"invoked_subcommand",
":",
"return",
"from",
"peltak",
".",
"core",
"import",
"log",
"from",
"peltak",
".",
"core",
"import",
"versioning",
"... | Show project version. Has sub commands.
For this command to work you must specify where the project version is
stored. You can do that with version_file conf variable. peltak supports
multiple ways to store the project version. Right now you can store it in a
python file using built-in __version__ vari... | [
"Show",
"project",
"version",
".",
"Has",
"sub",
"commands",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/commands/version.py#L25-L64 |
novopl/peltak | src/peltak/commands/version.py | bump_version | def bump_version(component='patch', exact=None):
# type: (str, str) -> None
""" Bump current project version without committing anything.
No tags are created either.
Examples:
\b
$ peltak version bump patch # Bump patch version component
$ peltak version bump minor... | python | def bump_version(component='patch', exact=None):
# type: (str, str) -> None
""" Bump current project version without committing anything.
No tags are created either.
Examples:
\b
$ peltak version bump patch # Bump patch version component
$ peltak version bump minor... | [
"def",
"bump_version",
"(",
"component",
"=",
"'patch'",
",",
"exact",
"=",
"None",
")",
":",
"# type: (str, str) -> None",
"from",
"peltak",
".",
"core",
"import",
"log",
"from",
"peltak",
".",
"core",
"import",
"versioning",
"old_ver",
",",
"new_ver",
"=",
... | Bump current project version without committing anything.
No tags are created either.
Examples:
\b
$ peltak version bump patch # Bump patch version component
$ peltak version bump minor # Bump minor version component
$ peltak version bump major ... | [
"Bump",
"current",
"project",
"version",
"without",
"committing",
"anything",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/commands/version.py#L76-L99 |
nathankw/pulsarpy | pulsarpy/models.py | Meta.get_logfile_name | def get_logfile_name(tag):
"""
Creates a name for a log file that is meant to be used in a call to
``logging.FileHandler``. The log file name will incldue the path to the log directory given
by the `p.LOG_DIR` constant. The format of the file name is: 'log_$HOST_$TAG.txt', where
... | python | def get_logfile_name(tag):
"""
Creates a name for a log file that is meant to be used in a call to
``logging.FileHandler``. The log file name will incldue the path to the log directory given
by the `p.LOG_DIR` constant. The format of the file name is: 'log_$HOST_$TAG.txt', where
... | [
"def",
"get_logfile_name",
"(",
"tag",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"p",
".",
"LOG_DIR",
")",
":",
"os",
".",
"mkdir",
"(",
"p",
".",
"LOG_DIR",
")",
"filename",
"=",
"\"log_\"",
"+",
"p",
".",
"HOST",
"+",
"\"_\"... | Creates a name for a log file that is meant to be used in a call to
``logging.FileHandler``. The log file name will incldue the path to the log directory given
by the `p.LOG_DIR` constant. The format of the file name is: 'log_$HOST_$TAG.txt', where
$HOST is the hostname part of the URL given by... | [
"Creates",
"a",
"name",
"for",
"a",
"log",
"file",
"that",
"is",
"meant",
"to",
"be",
"used",
"in",
"a",
"call",
"to",
"logging",
".",
"FileHandler",
".",
"The",
"log",
"file",
"name",
"will",
"incldue",
"the",
"path",
"to",
"the",
"log",
"directory",
... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L114-L131 |
nathankw/pulsarpy | pulsarpy/models.py | Model._get | def _get(self, rec_id=None, upstream=None):
"""
Fetches a record by the record's ID or upstream_identifier.
Raises:
`pulsarpy.models.RecordNotFound`: A record could not be found.
"""
if rec_id:
self.record_url = self.__class__.get_record_url(rec_id)
... | python | def _get(self, rec_id=None, upstream=None):
"""
Fetches a record by the record's ID or upstream_identifier.
Raises:
`pulsarpy.models.RecordNotFound`: A record could not be found.
"""
if rec_id:
self.record_url = self.__class__.get_record_url(rec_id)
... | [
"def",
"_get",
"(",
"self",
",",
"rec_id",
"=",
"None",
",",
"upstream",
"=",
"None",
")",
":",
"if",
"rec_id",
":",
"self",
".",
"record_url",
"=",
"self",
".",
"__class__",
".",
"get_record_url",
"(",
"rec_id",
")",
"self",
".",
"debug_logger",
".",
... | Fetches a record by the record's ID or upstream_identifier.
Raises:
`pulsarpy.models.RecordNotFound`: A record could not be found. | [
"Fetches",
"a",
"record",
"by",
"the",
"record",
"s",
"ID",
"or",
"upstream_identifier",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L296-L315 |
nathankw/pulsarpy | pulsarpy/models.py | Model.replace_name_with_id | def replace_name_with_id(cls, name):
"""
Used to replace a foreign key reference using a name with an ID. Works by searching the
record in Pulsar and expects to find exactly one hit. First, will check if the foreign key
reference is an integer value and if so, returns that as it is presu... | python | def replace_name_with_id(cls, name):
"""
Used to replace a foreign key reference using a name with an ID. Works by searching the
record in Pulsar and expects to find exactly one hit. First, will check if the foreign key
reference is an integer value and if so, returns that as it is presu... | [
"def",
"replace_name_with_id",
"(",
"cls",
",",
"name",
")",
":",
"try",
":",
"int",
"(",
"name",
")",
"return",
"name",
"#Already a presumed ID.",
"except",
"ValueError",
":",
"pass",
"#Not an int, so maybe a combination of MODEL_ABBR and Primary Key, i.e. B-8.",
"if",
... | Used to replace a foreign key reference using a name with an ID. Works by searching the
record in Pulsar and expects to find exactly one hit. First, will check if the foreign key
reference is an integer value and if so, returns that as it is presumed to be the foreign key.
Raises:
`... | [
"Used",
"to",
"replace",
"a",
"foreign",
"key",
"reference",
"using",
"a",
"name",
"with",
"an",
"ID",
".",
"Works",
"by",
"searching",
"the",
"record",
"in",
"Pulsar",
"and",
"expects",
"to",
"find",
"exactly",
"one",
"hit",
".",
"First",
"will",
"check... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L330-L354 |
nathankw/pulsarpy | pulsarpy/models.py | Model.add_model_name_to_payload | def add_model_name_to_payload(cls, payload):
"""
Checks whether the model name in question is in the payload. If not, the entire payload
is set as a value of a key by the name of the model. This method is useful when some
server-side Rails API calls expect the parameters to include the ... | python | def add_model_name_to_payload(cls, payload):
"""
Checks whether the model name in question is in the payload. If not, the entire payload
is set as a value of a key by the name of the model. This method is useful when some
server-side Rails API calls expect the parameters to include the ... | [
"def",
"add_model_name_to_payload",
"(",
"cls",
",",
"payload",
")",
":",
"if",
"not",
"cls",
".",
"MODEL_NAME",
"in",
"payload",
":",
"payload",
"=",
"{",
"cls",
".",
"MODEL_NAME",
":",
"payload",
"}",
"return",
"payload"
] | Checks whether the model name in question is in the payload. If not, the entire payload
is set as a value of a key by the name of the model. This method is useful when some
server-side Rails API calls expect the parameters to include the parameterized model name.
For example, server-side endpoi... | [
"Checks",
"whether",
"the",
"model",
"name",
"in",
"question",
"is",
"in",
"the",
"payload",
".",
"If",
"not",
"the",
"entire",
"payload",
"is",
"set",
"as",
"a",
"value",
"of",
"a",
"key",
"by",
"the",
"name",
"of",
"the",
"model",
".",
"This",
"met... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L358-L381 |
nathankw/pulsarpy | pulsarpy/models.py | Model.delete | def delete(self):
"""Deletes the record.
"""
res = requests.delete(url=self.record_url, headers=HEADERS, verify=False)
#self.write_response_html_to_file(res,"bob_delete.html")
if res.status_code == 204:
#No content. Can't render json:
return {}
ret... | python | def delete(self):
"""Deletes the record.
"""
res = requests.delete(url=self.record_url, headers=HEADERS, verify=False)
#self.write_response_html_to_file(res,"bob_delete.html")
if res.status_code == 204:
#No content. Can't render json:
return {}
ret... | [
"def",
"delete",
"(",
"self",
")",
":",
"res",
"=",
"requests",
".",
"delete",
"(",
"url",
"=",
"self",
".",
"record_url",
",",
"headers",
"=",
"HEADERS",
",",
"verify",
"=",
"False",
")",
"#self.write_response_html_to_file(res,\"bob_delete.html\")",
"if",
"re... | Deletes the record. | [
"Deletes",
"the",
"record",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L413-L421 |
nathankw/pulsarpy | pulsarpy/models.py | Model.find_by | def find_by(cls, payload, require=False):
"""
Searches the model in question by AND joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a dict. as well. Only the first hit is returned, and there is no ... | python | def find_by(cls, payload, require=False):
"""
Searches the model in question by AND joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a dict. as well. Only the first hit is returned, and there is no ... | [
"def",
"find_by",
"(",
"cls",
",",
"payload",
",",
"require",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"The 'payload' parameter must be provided a dictionary object.\"",
")",
"url",
"... | Searches the model in question by AND joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a dict. as well. Only the first hit is returned, and there is no particular
ordering specified in the server-side API m... | [
"Searches",
"the",
"model",
"in",
"question",
"by",
"AND",
"joining",
"the",
"query",
"parameters",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L424-L463 |
nathankw/pulsarpy | pulsarpy/models.py | Model.find_by_or | def find_by_or(cls, payload):
"""
Searches the model in question by OR joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a string (for the OR operator joining to be specified).
Only the firs... | python | def find_by_or(cls, payload):
"""
Searches the model in question by OR joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a string (for the OR operator joining to be specified).
Only the firs... | [
"def",
"find_by_or",
"(",
"cls",
",",
"payload",
")",
":",
"if",
"not",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"The 'payload' parameter must be provided a dictionary object.\"",
")",
"url",
"=",
"os",
".",
"path",
".",... | Searches the model in question by OR joining the query parameters.
Implements a Railsy way of looking for a record using a method by the same name and passing
in the query as a string (for the OR operator joining to be specified).
Only the first hit is returned, and there is not particular ord... | [
"Searches",
"the",
"model",
"in",
"question",
"by",
"OR",
"joining",
"the",
"query",
"parameters",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L466-L497 |
nathankw/pulsarpy | pulsarpy/models.py | Model.index | def index(cls):
"""Fetches all records.
Returns:
`dict`. The JSON formatted response.
Raises:
`requests.exceptions.HTTPError`: The status code is not ok.
"""
res = requests.get(cls.URL, headers=HEADERS, verify=False)
res.raise_for_status()
... | python | def index(cls):
"""Fetches all records.
Returns:
`dict`. The JSON formatted response.
Raises:
`requests.exceptions.HTTPError`: The status code is not ok.
"""
res = requests.get(cls.URL, headers=HEADERS, verify=False)
res.raise_for_status()
... | [
"def",
"index",
"(",
"cls",
")",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"cls",
".",
"URL",
",",
"headers",
"=",
"HEADERS",
",",
"verify",
"=",
"False",
")",
"res",
".",
"raise_for_status",
"(",
")",
"return",
"res",
".",
"json",
"(",
")"
] | Fetches all records.
Returns:
`dict`. The JSON formatted response.
Raises:
`requests.exceptions.HTTPError`: The status code is not ok. | [
"Fetches",
"all",
"records",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L500-L511 |
nathankw/pulsarpy | pulsarpy/models.py | Model.patch | def patch(self, payload, append_to_arrays=True):
"""
Patches current record and udpates the current instance's 'attrs'
attribute to reflect the new changes.
Args:
payload - hash. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. ... | python | def patch(self, payload, append_to_arrays=True):
"""
Patches current record and udpates the current instance's 'attrs'
attribute to reflect the new changes.
Args:
payload - hash. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. ... | [
"def",
"patch",
"(",
"self",
",",
"payload",
",",
"append_to_arrays",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"The 'payload' parameter must be provided a dictionary object.\"",
")",
"pa... | Patches current record and udpates the current instance's 'attrs'
attribute to reflect the new changes.
Args:
payload - hash. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. The JSON formatted response.
Raises:
`requests.e... | [
"Patches",
"current",
"record",
"and",
"udpates",
"the",
"current",
"instance",
"s",
"attrs",
"attribute",
"to",
"reflect",
"the",
"new",
"changes",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L513-L545 |
nathankw/pulsarpy | pulsarpy/models.py | Model.set_id_in_fkeys | def set_id_in_fkeys(cls, payload):
"""
Looks for any keys in the payload that end with either _id or _ids, signaling a foreign
key field. For each foreign key field, checks whether the value is using the name of the
record or the actual primary ID of the record (which may include the mod... | python | def set_id_in_fkeys(cls, payload):
"""
Looks for any keys in the payload that end with either _id or _ids, signaling a foreign
key field. For each foreign key field, checks whether the value is using the name of the
record or the actual primary ID of the record (which may include the mod... | [
"def",
"set_id_in_fkeys",
"(",
"cls",
",",
"payload",
")",
":",
"for",
"key",
"in",
"payload",
":",
"val",
"=",
"payload",
"[",
"key",
"]",
"if",
"not",
"val",
":",
"continue",
"if",
"key",
".",
"endswith",
"(",
"\"_id\"",
")",
":",
"model",
"=",
"... | Looks for any keys in the payload that end with either _id or _ids, signaling a foreign
key field. For each foreign key field, checks whether the value is using the name of the
record or the actual primary ID of the record (which may include the model abbreviation, i.e.
B-1). If the former case,... | [
"Looks",
"for",
"any",
"keys",
"in",
"the",
"payload",
"that",
"end",
"with",
"either",
"_id",
"or",
"_ids",
"signaling",
"a",
"foreign",
"key",
"field",
".",
"For",
"each",
"foreign",
"key",
"field",
"checks",
"whether",
"the",
"value",
"is",
"using",
"... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L548-L577 |
nathankw/pulsarpy | pulsarpy/models.py | Model.post | def post(cls, payload):
"""Posts the data to the specified record.
Args:
payload: `dict`. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. The JSON formatted response.
Raises:
`Requests.exceptions.HTTPError`: The status cod... | python | def post(cls, payload):
"""Posts the data to the specified record.
Args:
payload: `dict`. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. The JSON formatted response.
Raises:
`Requests.exceptions.HTTPError`: The status cod... | [
"def",
"post",
"(",
"cls",
",",
"payload",
")",
":",
"if",
"not",
"isinstance",
"(",
"payload",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"The 'payload' parameter must be provided a dictionary object.\"",
")",
"payload",
"=",
"cls",
".",
"set_id_in_fkey... | Posts the data to the specified record.
Args:
payload: `dict`. This will be JSON-formatted prior to sending the request.
Returns:
`dict`. The JSON formatted response.
Raises:
`Requests.exceptions.HTTPError`: The status code is not ok.
`RecordNot... | [
"Posts",
"the",
"data",
"to",
"the",
"specified",
"record",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L585-L619 |
nathankw/pulsarpy | pulsarpy/models.py | Model.log_error | def log_error(cls, msg):
"""
Logs the provided error message to both the error logger and the debug logger logging
instances.
Args:
msg: `str`. The error message to log.
"""
cls.error_logger.error(msg)
cls.debug_logger.debug(msg) | python | def log_error(cls, msg):
"""
Logs the provided error message to both the error logger and the debug logger logging
instances.
Args:
msg: `str`. The error message to log.
"""
cls.error_logger.error(msg)
cls.debug_logger.debug(msg) | [
"def",
"log_error",
"(",
"cls",
",",
"msg",
")",
":",
"cls",
".",
"error_logger",
".",
"error",
"(",
"msg",
")",
"cls",
".",
"debug_logger",
".",
"debug",
"(",
"msg",
")"
] | Logs the provided error message to both the error logger and the debug logger logging
instances.
Args:
msg: `str`. The error message to log. | [
"Logs",
"the",
"provided",
"error",
"message",
"to",
"both",
"the",
"error",
"logger",
"and",
"the",
"debug",
"logger",
"logging",
"instances",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L622-L631 |
nathankw/pulsarpy | pulsarpy/models.py | Model.write_response_html_to_file | def write_response_html_to_file(response,filename):
"""
An aid in troubleshooting internal application errors, i.e. <Response [500]>, to be mainly
beneficial when developing the server-side API. This method will write the response HTML
for viewing the error details in the browesr.
... | python | def write_response_html_to_file(response,filename):
"""
An aid in troubleshooting internal application errors, i.e. <Response [500]>, to be mainly
beneficial when developing the server-side API. This method will write the response HTML
for viewing the error details in the browesr.
... | [
"def",
"write_response_html_to_file",
"(",
"response",
",",
"filename",
")",
":",
"fout",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"if",
"not",
"str",
"(",
"response",
".",
"status_code",
")",
".",
"startswith",
"(",
"\"2\"",
")",
":",
"Model",
"."... | An aid in troubleshooting internal application errors, i.e. <Response [500]>, to be mainly
beneficial when developing the server-side API. This method will write the response HTML
for viewing the error details in the browesr.
Args:
response: `requests.models.Response` instance.
... | [
"An",
"aid",
"in",
"troubleshooting",
"internal",
"application",
"errors",
"i",
".",
"e",
".",
"<Response",
"[",
"500",
"]",
">",
"to",
"be",
"mainly",
"beneficial",
"when",
"developing",
"the",
"server",
"-",
"side",
"API",
".",
"This",
"method",
"will",
... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L634-L648 |
nathankw/pulsarpy | pulsarpy/models.py | Biosample.parent_ids | def parent_ids(self):
"""
Returns an array of parent Biosample IDs. If the current Biosample has a part_of relationship,
the Biosampled referenced there will be returned. Otherwise, if the current Biosample was
generated from a pool of Biosamples (pooled_from_biosample_ids), then those w... | python | def parent_ids(self):
"""
Returns an array of parent Biosample IDs. If the current Biosample has a part_of relationship,
the Biosampled referenced there will be returned. Otherwise, if the current Biosample was
generated from a pool of Biosamples (pooled_from_biosample_ids), then those w... | [
"def",
"parent_ids",
"(",
"self",
")",
":",
"action",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"record_url",
",",
"\"parent_ids\"",
")",
"res",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"action",
",",
"headers",
"=",
"HEADERS",
",",... | Returns an array of parent Biosample IDs. If the current Biosample has a part_of relationship,
the Biosampled referenced there will be returned. Otherwise, if the current Biosample was
generated from a pool of Biosamples (pooled_from_biosample_ids), then those will be returned.
Otherwise, the re... | [
"Returns",
"an",
"array",
"of",
"parent",
"Biosample",
"IDs",
".",
"If",
"the",
"current",
"Biosample",
"has",
"a",
"part_of",
"relationship",
"the",
"Biosampled",
"referenced",
"there",
"will",
"be",
"returned",
".",
"Otherwise",
"if",
"the",
"current",
"Bios... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L696-L706 |
nathankw/pulsarpy | pulsarpy/models.py | Biosample.find_first_wt_parent | def find_first_wt_parent(self, with_ip=False):
"""
Recursively looks at the part_of parent ancestry line (ignoring pooled_from parents) and returns
a parent Biosample ID if its wild_type attribute is True.
Args:
with_ip: `bool`. True means to restrict the search to the firs... | python | def find_first_wt_parent(self, with_ip=False):
"""
Recursively looks at the part_of parent ancestry line (ignoring pooled_from parents) and returns
a parent Biosample ID if its wild_type attribute is True.
Args:
with_ip: `bool`. True means to restrict the search to the firs... | [
"def",
"find_first_wt_parent",
"(",
"self",
",",
"with_ip",
"=",
"False",
")",
":",
"parent_id",
"=",
"self",
".",
"part_of_id",
"if",
"not",
"parent_id",
":",
"return",
"False",
"parent",
"=",
"Biosample",
"(",
"parent_id",
")",
"if",
"parent",
".",
"wild... | Recursively looks at the part_of parent ancestry line (ignoring pooled_from parents) and returns
a parent Biosample ID if its wild_type attribute is True.
Args:
with_ip: `bool`. True means to restrict the search to the first parental Wild Type that
also has an Immunoblot l... | [
"Recursively",
"looks",
"at",
"the",
"part_of",
"parent",
"ancestry",
"line",
"(",
"ignoring",
"pooled_from",
"parents",
")",
"and",
"returns",
"a",
"parent",
"Biosample",
"ID",
"if",
"its",
"wild_type",
"attribute",
"is",
"True",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L708-L734 |
nathankw/pulsarpy | pulsarpy/models.py | Document.upload | def upload(cls, path, document_type, is_protocol, description=""):
"""
Args:
path: `str`. The path to the document to upload.
document_type: `str`. DocumentType identified by the value of its name attribute.
is_protocol: `bool`.
description: `str`.
... | python | def upload(cls, path, document_type, is_protocol, description=""):
"""
Args:
path: `str`. The path to the document to upload.
document_type: `str`. DocumentType identified by the value of its name attribute.
is_protocol: `bool`.
description: `str`.
... | [
"def",
"upload",
"(",
"cls",
",",
"path",
",",
"document_type",
",",
"is_protocol",
",",
"description",
"=",
"\"\"",
")",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"mime_type",
"=",
"mimetypes",
".",
"guess_type",
"(",
... | Args:
path: `str`. The path to the document to upload.
document_type: `str`. DocumentType identified by the value of its name attribute.
is_protocol: `bool`.
description: `str`. | [
"Args",
":",
"path",
":",
"str",
".",
"The",
"path",
"to",
"the",
"document",
"to",
"upload",
".",
"document_type",
":",
"str",
".",
"DocumentType",
"identified",
"by",
"the",
"value",
"of",
"its",
"name",
"attribute",
".",
"is_protocol",
":",
"bool",
".... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L838-L858 |
nathankw/pulsarpy | pulsarpy/models.py | Library.post | def post(cls, payload):
"""
A wrapper over Model.post() that handles the case where a Library has a PairedBarcode
and the user may have supplied the PairedBarcode in the form of index1-index2, i.e.
GATTTCCA-GGCGTCGA. This isn't the PairedBarcode's record name or a record ID, thus
... | python | def post(cls, payload):
"""
A wrapper over Model.post() that handles the case where a Library has a PairedBarcode
and the user may have supplied the PairedBarcode in the form of index1-index2, i.e.
GATTTCCA-GGCGTCGA. This isn't the PairedBarcode's record name or a record ID, thus
... | [
"def",
"post",
"(",
"cls",
",",
"payload",
")",
":",
"slpk_attr_name",
"=",
"\"sequencing_library_prep_kit_id\"",
"paired_bc_id_attr_name",
"=",
"\"paired_barcode_id\"",
"seq_reg",
"=",
"re",
".",
"compile",
"(",
"\"^[ACGTN]+$\"",
")",
"if",
"paired_bc_id_attr_name",
... | A wrapper over Model.post() that handles the case where a Library has a PairedBarcode
and the user may have supplied the PairedBarcode in the form of index1-index2, i.e.
GATTTCCA-GGCGTCGA. This isn't the PairedBarcode's record name or a record ID, thus
Model.post() won't be able to figure out ... | [
"A",
"wrapper",
"over",
"Model",
".",
"post",
"()",
"that",
"handles",
"the",
"case",
"where",
"a",
"Library",
"has",
"a",
"PairedBarcode",
"and",
"the",
"user",
"may",
"have",
"supplied",
"the",
"PairedBarcode",
"in",
"the",
"form",
"of",
"index1",
"-",
... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L969-L1005 |
nathankw/pulsarpy | pulsarpy/models.py | SequencingRequest.get_library_barcode_sequence_hash | def get_library_barcode_sequence_hash(self, inverse=False):
"""
Calls the SequencingRequest's get_library_barcode_sequence_hash server-side endpoint to
create a hash of the form {LibraryID -> barcode_sequence} for all Libraries on the
SequencingRequest.
Args:
inver... | python | def get_library_barcode_sequence_hash(self, inverse=False):
"""
Calls the SequencingRequest's get_library_barcode_sequence_hash server-side endpoint to
create a hash of the form {LibraryID -> barcode_sequence} for all Libraries on the
SequencingRequest.
Args:
inver... | [
"def",
"get_library_barcode_sequence_hash",
"(",
"self",
",",
"inverse",
"=",
"False",
")",
":",
"action",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"record_url",
",",
"\"get_library_barcode_sequence_hash\"",
")",
"res",
"=",
"requests",
".",
"get... | Calls the SequencingRequest's get_library_barcode_sequence_hash server-side endpoint to
create a hash of the form {LibraryID -> barcode_sequence} for all Libraries on the
SequencingRequest.
Args:
inverse: `bool`. True means to inverse the key and value pairs such that the barcode
... | [
"Calls",
"the",
"SequencingRequest",
"s",
"get_library_barcode_sequence_hash",
"server",
"-",
"side",
"endpoint",
"to",
"create",
"a",
"hash",
"of",
"the",
"form",
"{",
"LibraryID",
"-",
">",
"barcode_sequence",
"}",
"for",
"all",
"Libraries",
"on",
"the",
"Sequ... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L1047-L1074 |
nathankw/pulsarpy | pulsarpy/models.py | SequencingRun.library_sequencing_results | def library_sequencing_results(self):
"""
Generates a dict. where each key is a Library ID on the SequencingRequest and each value
is the associated SequencingResult. Libraries that aren't yet with a SequencingResult are
not inlcuded in the dict.
"""
sres_ids = self.seque... | python | def library_sequencing_results(self):
"""
Generates a dict. where each key is a Library ID on the SequencingRequest and each value
is the associated SequencingResult. Libraries that aren't yet with a SequencingResult are
not inlcuded in the dict.
"""
sres_ids = self.seque... | [
"def",
"library_sequencing_results",
"(",
"self",
")",
":",
"sres_ids",
"=",
"self",
".",
"sequencing_result_ids",
"res",
"=",
"{",
"}",
"for",
"i",
"in",
"sres_ids",
":",
"sres",
"=",
"SequencingResult",
"(",
"i",
")",
"res",
"[",
"sres",
".",
"library_id... | Generates a dict. where each key is a Library ID on the SequencingRequest and each value
is the associated SequencingResult. Libraries that aren't yet with a SequencingResult are
not inlcuded in the dict. | [
"Generates",
"a",
"dict",
".",
"where",
"each",
"key",
"is",
"a",
"Library",
"ID",
"on",
"the",
"SequencingRequest",
"and",
"each",
"value",
"is",
"the",
"associated",
"SequencingResult",
".",
"Libraries",
"that",
"aren",
"t",
"yet",
"with",
"a",
"Sequencing... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L1098-L1109 |
nathankw/pulsarpy | pulsarpy/models.py | User.unarchive_user | def unarchive_user(self, user_id):
"""Unarchives the user with the specified user ID.
Args:
user_id: `int`. The ID of the user to unarchive.
Returns:
`NoneType`: None.
"""
url = self.record_url + "/unarchive"
res = requests.patch(url=url, json={"... | python | def unarchive_user(self, user_id):
"""Unarchives the user with the specified user ID.
Args:
user_id: `int`. The ID of the user to unarchive.
Returns:
`NoneType`: None.
"""
url = self.record_url + "/unarchive"
res = requests.patch(url=url, json={"... | [
"def",
"unarchive_user",
"(",
"self",
",",
"user_id",
")",
":",
"url",
"=",
"self",
".",
"record_url",
"+",
"\"/unarchive\"",
"res",
"=",
"requests",
".",
"patch",
"(",
"url",
"=",
"url",
",",
"json",
"=",
"{",
"\"user_id\"",
":",
"user_id",
"}",
",",
... | Unarchives the user with the specified user ID.
Args:
user_id: `int`. The ID of the user to unarchive.
Returns:
`NoneType`: None. | [
"Unarchives",
"the",
"user",
"with",
"the",
"specified",
"user",
"ID",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L1179-L1191 |
nathankw/pulsarpy | pulsarpy/models.py | User.remove_api_key | def remove_api_key(self):
"""
Removes the user's existing API key, if present, and sets the current instance's 'api_key'
attribute to the empty string.
Returns:
`NoneType`: None.
"""
url = self.record_url + "/remove_api_key"
res = requests.patch(url=u... | python | def remove_api_key(self):
"""
Removes the user's existing API key, if present, and sets the current instance's 'api_key'
attribute to the empty string.
Returns:
`NoneType`: None.
"""
url = self.record_url + "/remove_api_key"
res = requests.patch(url=u... | [
"def",
"remove_api_key",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"record_url",
"+",
"\"/remove_api_key\"",
"res",
"=",
"requests",
".",
"patch",
"(",
"url",
"=",
"url",
",",
"headers",
"=",
"HEADERS",
",",
"verify",
"=",
"False",
")",
"res",
".... | Removes the user's existing API key, if present, and sets the current instance's 'api_key'
attribute to the empty string.
Returns:
`NoneType`: None. | [
"Removes",
"the",
"user",
"s",
"existing",
"API",
"key",
"if",
"present",
"and",
"sets",
"the",
"current",
"instance",
"s",
"api_key",
"attribute",
"to",
"the",
"empty",
"string",
"."
] | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/models.py#L1206-L1217 |
Vital-Fernandez/dazer | bin/lib/ssp_functions/ssp_synthesis_tools.py | ssp_fitter.generate_synthObs | def generate_synthObs(self, bases_wave, bases_flux, basesCoeff, Av_star, z_star, sigma_star, resample_range = None, resample_int = 1):
'''basesWave: Bases wavelength must be at rest'''
nbases = basesCoeff.shape[0]
bases_wave_resam = arange(int(resample_range[0]),... | python | def generate_synthObs(self, bases_wave, bases_flux, basesCoeff, Av_star, z_star, sigma_star, resample_range = None, resample_int = 1):
'''basesWave: Bases wavelength must be at rest'''
nbases = basesCoeff.shape[0]
bases_wave_resam = arange(int(resample_range[0]),... | [
"def",
"generate_synthObs",
"(",
"self",
",",
"bases_wave",
",",
"bases_flux",
",",
"basesCoeff",
",",
"Av_star",
",",
"z_star",
",",
"sigma_star",
",",
"resample_range",
"=",
"None",
",",
"resample_int",
"=",
"1",
")",
":",
"nbases",
"=",
"basesCoeff",
".",... | basesWave: Bases wavelength must be at rest | [
"basesWave",
":",
"Bases",
"wavelength",
"must",
"be",
"at",
"rest"
] | train | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/ssp_functions/ssp_synthesis_tools.py#L683-L728 |
paydunya/paydunya-python | paydunya/__init__.py | Payment._process | def _process(self, resource=None, data={}):
"""Processes the current transaction
Sends an HTTP request to the PAYDUNYA API server
"""
# use object's data if no data is passed
_data = data or self._data
rsc_url = self.get_rsc_endpoint(resource)
if _data:
... | python | def _process(self, resource=None, data={}):
"""Processes the current transaction
Sends an HTTP request to the PAYDUNYA API server
"""
# use object's data if no data is passed
_data = data or self._data
rsc_url = self.get_rsc_endpoint(resource)
if _data:
... | [
"def",
"_process",
"(",
"self",
",",
"resource",
"=",
"None",
",",
"data",
"=",
"{",
"}",
")",
":",
"# use object's data if no data is passed",
"_data",
"=",
"data",
"or",
"self",
".",
"_data",
"rsc_url",
"=",
"self",
".",
"get_rsc_endpoint",
"(",
"resource"... | Processes the current transaction
Sends an HTTP request to the PAYDUNYA API server | [
"Processes",
"the",
"current",
"transaction"
] | train | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/__init__.py#L86-L107 |
paydunya/paydunya-python | paydunya/__init__.py | Payment.add_header | def add_header(self, header):
"""Add a custom HTTP header to the client's request headers"""
if type(header) is dict:
self._headers.update(header)
else:
raise ValueError(
"Dictionary expected, got '%s' instead" % type(header)
) | python | def add_header(self, header):
"""Add a custom HTTP header to the client's request headers"""
if type(header) is dict:
self._headers.update(header)
else:
raise ValueError(
"Dictionary expected, got '%s' instead" % type(header)
) | [
"def",
"add_header",
"(",
"self",
",",
"header",
")",
":",
"if",
"type",
"(",
"header",
")",
"is",
"dict",
":",
"self",
".",
"_headers",
".",
"update",
"(",
"header",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Dictionary expected, got '%s' instead\"",
... | Add a custom HTTP header to the client's request headers | [
"Add",
"a",
"custom",
"HTTP",
"header",
"to",
"the",
"client",
"s",
"request",
"headers"
] | train | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/__init__.py#L114-L121 |
novopl/peltak | src/peltak/extra/changelog/commands.py | changelog_cli | def changelog_cli(ctx):
# type: () -> None
""" Generate changelog from commit messages. """
if ctx.invoked_subcommand:
return
from peltak.core import shell
from . import logic
shell.cprint(logic.changelog()) | python | def changelog_cli(ctx):
# type: () -> None
""" Generate changelog from commit messages. """
if ctx.invoked_subcommand:
return
from peltak.core import shell
from . import logic
shell.cprint(logic.changelog()) | [
"def",
"changelog_cli",
"(",
"ctx",
")",
":",
"# type: () -> None",
"if",
"ctx",
".",
"invoked_subcommand",
":",
"return",
"from",
"peltak",
".",
"core",
"import",
"shell",
"from",
".",
"import",
"logic",
"shell",
".",
"cprint",
"(",
"logic",
".",
"changelog... | Generate changelog from commit messages. | [
"Generate",
"changelog",
"from",
"commit",
"messages",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/changelog/commands.py#L24-L32 |
Varkal/chuda | chuda/arguments.py | Argument.convert_to_argument | def convert_to_argument(self):
'''
Convert the Argument object to a tuple use in :meth:`~argparse.ArgumentParser.add_argument` calls on the parser
'''
field_list = [
"action", "nargs", "const", "default", "type",
"choices", "required", "help", "metavar", "des... | python | def convert_to_argument(self):
'''
Convert the Argument object to a tuple use in :meth:`~argparse.ArgumentParser.add_argument` calls on the parser
'''
field_list = [
"action", "nargs", "const", "default", "type",
"choices", "required", "help", "metavar", "des... | [
"def",
"convert_to_argument",
"(",
"self",
")",
":",
"field_list",
"=",
"[",
"\"action\"",
",",
"\"nargs\"",
",",
"\"const\"",
",",
"\"default\"",
",",
"\"type\"",
",",
"\"choices\"",
",",
"\"required\"",
",",
"\"help\"",
",",
"\"metavar\"",
",",
"\"dest\"",
"... | Convert the Argument object to a tuple use in :meth:`~argparse.ArgumentParser.add_argument` calls on the parser | [
"Convert",
"the",
"Argument",
"object",
"to",
"a",
"tuple",
"use",
"in",
":",
"meth",
":",
"~argparse",
".",
"ArgumentParser",
".",
"add_argument",
"calls",
"on",
"the",
"parser"
] | train | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/arguments.py#L52-L67 |
Varkal/chuda | chuda/arguments.py | Option.get_default_name | def get_default_name(self):
'''
Return the default generated name to store value on the parser for this option.
eg. An option *['-s', '--use-ssl']* will generate the *use_ssl* name
Returns:
str: the default name of the option
'''
long_names = [name for name ... | python | def get_default_name(self):
'''
Return the default generated name to store value on the parser for this option.
eg. An option *['-s', '--use-ssl']* will generate the *use_ssl* name
Returns:
str: the default name of the option
'''
long_names = [name for name ... | [
"def",
"get_default_name",
"(",
"self",
")",
":",
"long_names",
"=",
"[",
"name",
"for",
"name",
"in",
"self",
".",
"name",
"if",
"name",
".",
"startswith",
"(",
"\"--\"",
")",
"]",
"short_names",
"=",
"[",
"name",
"for",
"name",
"in",
"self",
".",
"... | Return the default generated name to store value on the parser for this option.
eg. An option *['-s', '--use-ssl']* will generate the *use_ssl* name
Returns:
str: the default name of the option | [
"Return",
"the",
"default",
"generated",
"name",
"to",
"store",
"value",
"on",
"the",
"parser",
"for",
"this",
"option",
"."
] | train | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/arguments.py#L84-L99 |
gpiantoni/bidso | bidso/files.py | file_Core.get_filename | def get_filename(self, base_dir=None, modality=None):
"""Construct filename based on the attributes.
Parameters
----------
base_dir : Path
path of the root directory. If specified, the return value is a Path,
with base_dir / sub-XXX / (ses-XXX /) modality / filen... | python | def get_filename(self, base_dir=None, modality=None):
"""Construct filename based on the attributes.
Parameters
----------
base_dir : Path
path of the root directory. If specified, the return value is a Path,
with base_dir / sub-XXX / (ses-XXX /) modality / filen... | [
"def",
"get_filename",
"(",
"self",
",",
"base_dir",
"=",
"None",
",",
"modality",
"=",
"None",
")",
":",
"filename",
"=",
"'sub-'",
"+",
"self",
".",
"subject",
"if",
"self",
".",
"session",
"is",
"not",
"None",
":",
"filename",
"+=",
"'_ses-'",
"+",
... | Construct filename based on the attributes.
Parameters
----------
base_dir : Path
path of the root directory. If specified, the return value is a Path,
with base_dir / sub-XXX / (ses-XXX /) modality / filename
otherwise the return value is a string.
m... | [
"Construct",
"filename",
"based",
"on",
"the",
"attributes",
"."
] | train | https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/files.py#L37-L87 |
gpiantoni/bidso | bidso/files.py | file_Tsv.get | def get(self, filter_lambda=None, map_lambda=None):
"""Select elements of the TSV, using python filter and map.
Parameters
----------
filter_lambda : function
function to filter the tsv rows (the function needs to return True/False)
map_lambda : function
... | python | def get(self, filter_lambda=None, map_lambda=None):
"""Select elements of the TSV, using python filter and map.
Parameters
----------
filter_lambda : function
function to filter the tsv rows (the function needs to return True/False)
map_lambda : function
... | [
"def",
"get",
"(",
"self",
",",
"filter_lambda",
"=",
"None",
",",
"map_lambda",
"=",
"None",
")",
":",
"if",
"filter_lambda",
"is",
"None",
":",
"filter_lambda",
"=",
"lambda",
"x",
":",
"True",
"if",
"map_lambda",
"is",
"None",
":",
"map_lambda",
"=",
... | Select elements of the TSV, using python filter and map.
Parameters
----------
filter_lambda : function
function to filter the tsv rows (the function needs to return True/False)
map_lambda : function
function to select the tsv columns
Returns
---... | [
"Select",
"elements",
"of",
"the",
"TSV",
"using",
"python",
"filter",
"and",
"map",
"."
] | train | https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/files.py#L95-L125 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.connect | def connect(self, client_id: str = None, client_secret: str = None) -> dict:
"""Authenticate application and get token bearer.
Isogeo API uses oAuth 2.0 protocol (https://tools.ietf.org/html/rfc6749)
see: http://help.isogeo.com/api/fr/authentication/groupsapps.html
:param str client_id... | python | def connect(self, client_id: str = None, client_secret: str = None) -> dict:
"""Authenticate application and get token bearer.
Isogeo API uses oAuth 2.0 protocol (https://tools.ietf.org/html/rfc6749)
see: http://help.isogeo.com/api/fr/authentication/groupsapps.html
:param str client_id... | [
"def",
"connect",
"(",
"self",
",",
"client_id",
":",
"str",
"=",
"None",
",",
"client_secret",
":",
"str",
"=",
"None",
")",
"->",
"dict",
":",
"# instanciated or direct call",
"if",
"not",
"client_id",
"and",
"not",
"client_secret",
":",
"client_id",
"=",
... | Authenticate application and get token bearer.
Isogeo API uses oAuth 2.0 protocol (https://tools.ietf.org/html/rfc6749)
see: http://help.isogeo.com/api/fr/authentication/groupsapps.html
:param str client_id: application oAuth2 identifier
:param str client_secret: application oAuth2 sec... | [
"Authenticate",
"application",
"and",
"get",
"token",
"bearer",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L177-L234 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo._check_bearer_validity | def _check_bearer_validity(decorated_func):
"""Check API Bearer token validity.
Isogeo ID delivers authentication bearers which are valid during
a certain time. So this decorator checks the validity of the token
comparing with actual datetime (UTC) and renews it if necessary.
Se... | python | def _check_bearer_validity(decorated_func):
"""Check API Bearer token validity.
Isogeo ID delivers authentication bearers which are valid during
a certain time. So this decorator checks the validity of the token
comparing with actual datetime (UTC) and renews it if necessary.
Se... | [
"def",
"_check_bearer_validity",
"(",
"decorated_func",
")",
":",
"@",
"wraps",
"(",
"decorated_func",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# compare token expiration date and ask for a new one if it's expired",
"... | Check API Bearer token validity.
Isogeo ID delivers authentication bearers which are valid during
a certain time. So this decorator checks the validity of the token
comparing with actual datetime (UTC) and renews it if necessary.
See: http://tools.ietf.org/html/rfc6750#section-2
... | [
"Check",
"API",
"Bearer",
"token",
"validity",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L246-L270 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.search | def search(
self,
token: dict = None,
query: str = "",
bbox: list = None,
poly: str = None,
georel: str = None,
order_by: str = "_created",
order_dir: str = "desc",
page_size: int = 100,
offset: int = 0,
share: str = None,
s... | python | def search(
self,
token: dict = None,
query: str = "",
bbox: list = None,
poly: str = None,
georel: str = None,
order_by: str = "_created",
order_dir: str = "desc",
page_size: int = 100,
offset: int = 0,
share: str = None,
s... | [
"def",
"search",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"query",
":",
"str",
"=",
"\"\"",
",",
"bbox",
":",
"list",
"=",
"None",
",",
"poly",
":",
"str",
"=",
"None",
",",
"georel",
":",
"str",
"=",
"None",
",",
"order_by",
"... | Search within the resources shared to the application.
It's the main method to use.
:param str token: API auth token - DEPRECATED: token is now automatically included
:param str query: search terms and semantic filters. Equivalent of
**q** parameter in Isogeo API. It could be a simple... | [
"Search",
"within",
"the",
"resources",
"shared",
"to",
"the",
"application",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L274-L450 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.resource | def resource(
self,
token: dict = None,
id_resource: str = None,
subresource=None,
include: list = [],
prot: str = "https",
) -> dict:
"""Get complete or partial metadata about one specific resource.
:param str token: API auth token
:param str... | python | def resource(
self,
token: dict = None,
id_resource: str = None,
subresource=None,
include: list = [],
prot: str = "https",
) -> dict:
"""Get complete or partial metadata about one specific resource.
:param str token: API auth token
:param str... | [
"def",
"resource",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"id_resource",
":",
"str",
"=",
"None",
",",
"subresource",
"=",
"None",
",",
"include",
":",
"list",
"=",
"[",
"]",
",",
"prot",
":",
"str",
"=",
"\"https\"",
",",
")",
... | Get complete or partial metadata about one specific resource.
:param str token: API auth token
:param str id_resource: metadata UUID to get
:param list include: subresources that should be included.
Must be a list of strings. Available values: 'isogeo.SUBRESOURCES'
:param str p... | [
"Get",
"complete",
"or",
"partial",
"metadata",
"about",
"one",
"specific",
"resource",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L453-L494 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.shares | def shares(self, token: dict = None, prot: str = "https") -> dict:
"""Get information about shares which feed the application.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# passing auth paramete... | python | def shares(self, token: dict = None, prot: str = "https") -> dict:
"""Get information about shares which feed the application.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# passing auth paramete... | [
"def",
"shares",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# passing auth parameter",
"shares_url",
"=",
"\"{}://v1.{}.isogeo.com/shares/\"",
".",
"format",
"(",
"prot",
",",
"sel... | Get information about shares which feed the application.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"information",
"about",
"shares",
"which",
"feed",
"the",
"application",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L498-L515 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.share | def share(
self,
share_id: str,
token: dict = None,
augment: bool = False,
prot: str = "https",
) -> dict:
"""Get information about a specific share and its applications.
:param str token: API auth token
:param str share_id: share UUID
:param ... | python | def share(
self,
share_id: str,
token: dict = None,
augment: bool = False,
prot: str = "https",
) -> dict:
"""Get information about a specific share and its applications.
:param str token: API auth token
:param str share_id: share UUID
:param ... | [
"def",
"share",
"(",
"self",
",",
"share_id",
":",
"str",
",",
"token",
":",
"dict",
"=",
"None",
",",
"augment",
":",
"bool",
"=",
"False",
",",
"prot",
":",
"str",
"=",
"\"https\"",
",",
")",
"->",
"dict",
":",
"# passing auth parameter",
"share_url"... | Get information about a specific share and its applications.
:param str token: API auth token
:param str share_id: share UUID
:param bool augment: option to improve API response by adding
some tags on the fly.
:param str prot: https [DEFAULT] or http
(use it only for d... | [
"Get",
"information",
"about",
"a",
"specific",
"share",
"and",
"its",
"applications",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L518-L555 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.licenses | def licenses(
self, token: dict = None, owner_id: str = None, prot: str = "https"
) -> dict:
"""Get information about licenses owned by a specific workgroup.
:param str token: API auth token
:param str owner_id: workgroup UUID
:param str prot: https [DEFAULT] or http
... | python | def licenses(
self, token: dict = None, owner_id: str = None, prot: str = "https"
) -> dict:
"""Get information about licenses owned by a specific workgroup.
:param str token: API auth token
:param str owner_id: workgroup UUID
:param str prot: https [DEFAULT] or http
... | [
"def",
"licenses",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"owner_id",
":",
"str",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# handling request parameters",
"payload",
"=",
"{",
"\"gid\"",
":",
"... | Get information about licenses owned by a specific workgroup.
:param str token: API auth token
:param str owner_id: workgroup UUID
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"information",
"about",
"licenses",
"owned",
"by",
"a",
"specific",
"workgroup",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L559-L590 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.license | def license(self, license_id: str, token: dict = None, prot: str = "https") -> dict:
"""Get details about a specific license.
:param str token: API auth token
:param str license_id: license UUID
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
... | python | def license(self, license_id: str, token: dict = None, prot: str = "https") -> dict:
"""Get details about a specific license.
:param str token: API auth token
:param str license_id: license UUID
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
... | [
"def",
"license",
"(",
"self",
",",
"license_id",
":",
"str",
",",
"token",
":",
"dict",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# handling request parameters",
"payload",
"=",
"{",
"\"lid\"",
":",
"license_id",
"... | Get details about a specific license.
:param str token: API auth token
:param str license_id: license UUID
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"details",
"about",
"a",
"specific",
"license",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L593-L620 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.thesauri | def thesauri(self, token: dict = None, prot: str = "https") -> dict:
"""Get list of available thesauri.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# passing auth parameter
thez_url = "{... | python | def thesauri(self, token: dict = None, prot: str = "https") -> dict:
"""Get list of available thesauri.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# passing auth parameter
thez_url = "{... | [
"def",
"thesauri",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# passing auth parameter",
"thez_url",
"=",
"\"{}://v1.{}.isogeo.com/thesauri\"",
".",
"format",
"(",
"prot",
",",
"se... | Get list of available thesauri.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"list",
"of",
"available",
"thesauri",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L625-L642 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.thesaurus | def thesaurus(
self,
token: dict = None,
thez_id: str = "1616597fbc4348c8b11ef9d59cf594c8",
prot: str = "https",
) -> dict:
"""Get a thesaurus.
:param str token: API auth token
:param str thez_id: thesaurus UUID
:param str prot: https [DEFAULT] or htt... | python | def thesaurus(
self,
token: dict = None,
thez_id: str = "1616597fbc4348c8b11ef9d59cf594c8",
prot: str = "https",
) -> dict:
"""Get a thesaurus.
:param str token: API auth token
:param str thez_id: thesaurus UUID
:param str prot: https [DEFAULT] or htt... | [
"def",
"thesaurus",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"thez_id",
":",
"str",
"=",
"\"1616597fbc4348c8b11ef9d59cf594c8\"",
",",
"prot",
":",
"str",
"=",
"\"https\"",
",",
")",
"->",
"dict",
":",
"# handling request parameters",
"payload"... | Get a thesaurus.
:param str token: API auth token
:param str thez_id: thesaurus UUID
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"a",
"thesaurus",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L645-L677 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.keywords | def keywords(
self,
token: dict = None,
thez_id: str = "1616597fbc4348c8b11ef9d59cf594c8",
query: str = "",
offset: int = 0,
order_by: str = "text",
order_dir: str = "desc",
page_size: int = 20,
specific_md: list = [],
specific_tag: list = ... | python | def keywords(
self,
token: dict = None,
thez_id: str = "1616597fbc4348c8b11ef9d59cf594c8",
query: str = "",
offset: int = 0,
order_by: str = "text",
order_dir: str = "desc",
page_size: int = 20,
specific_md: list = [],
specific_tag: list = ... | [
"def",
"keywords",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"thez_id",
":",
"str",
"=",
"\"1616597fbc4348c8b11ef9d59cf594c8\"",
",",
"query",
":",
"str",
"=",
"\"\"",
",",
"offset",
":",
"int",
"=",
"0",
",",
"order_by",
":",
"str",
"=... | Search for keywords within a specific thesaurus.
:param str token: API auth token
:param str thez_id: thesaurus UUID
:param str query: search terms
:param int offset: pagination start
:param str order_by: sort criteria. Available values :
- count.group,
... | [
"Search",
"for",
"keywords",
"within",
"a",
"specific",
"thesaurus",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L680-L746 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.dl_hosted | def dl_hosted(
self,
token: dict = None,
resource_link: dict = None,
encode_clean: bool = 1,
proxy_url: str = None,
prot: str = "https",
) -> tuple:
"""Download hosted resource.
:param str token: API auth token
:param dict resource_link: link ... | python | def dl_hosted(
self,
token: dict = None,
resource_link: dict = None,
encode_clean: bool = 1,
proxy_url: str = None,
prot: str = "https",
) -> tuple:
"""Download hosted resource.
:param str token: API auth token
:param dict resource_link: link ... | [
"def",
"dl_hosted",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"resource_link",
":",
"dict",
"=",
"None",
",",
"encode_clean",
":",
"bool",
"=",
"1",
",",
"proxy_url",
":",
"str",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",... | Download hosted resource.
:param str token: API auth token
:param dict resource_link: link dictionary
:param bool encode_clean: option to ensure a clean filename and avoid OS errors
:param str proxy_url: proxy to use to download
:param str prot: https [DEFAULT] or http
... | [
"Download",
"hosted",
"resource",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L750-L843 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.xml19139 | def xml19139(
self,
token: dict = None,
id_resource: str = None,
proxy_url=None,
prot: str = "https",
):
"""Get resource exported into XML ISO 19139.
:param str token: API auth token
:param str id_resource: metadata UUID to export
:param str p... | python | def xml19139(
self,
token: dict = None,
id_resource: str = None,
proxy_url=None,
prot: str = "https",
):
"""Get resource exported into XML ISO 19139.
:param str token: API auth token
:param str id_resource: metadata UUID to export
:param str p... | [
"def",
"xml19139",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"id_resource",
":",
"str",
"=",
"None",
",",
"proxy_url",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
",",
")",
":",
"# check metadata UUID",
"if",
"not",
"checker... | Get resource exported into XML ISO 19139.
:param str token: API auth token
:param str id_resource: metadata UUID to export
:param str proxy_url: proxy to use to download
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"resource",
"exported",
"into",
"XML",
"ISO",
"19139",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L846-L884 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.add_tags_shares | def add_tags_shares(self, tags: dict = dict()):
"""Add shares list to the tags attributes in search results.
:param dict tags: tags dictionary from a search request
"""
# check if shares_id have already been retrieved or not
if not hasattr(self, "shares_id"):
shares ... | python | def add_tags_shares(self, tags: dict = dict()):
"""Add shares list to the tags attributes in search results.
:param dict tags: tags dictionary from a search request
"""
# check if shares_id have already been retrieved or not
if not hasattr(self, "shares_id"):
shares ... | [
"def",
"add_tags_shares",
"(",
"self",
",",
"tags",
":",
"dict",
"=",
"dict",
"(",
")",
")",
":",
"# check if shares_id have already been retrieved or not",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"shares_id\"",
")",
":",
"shares",
"=",
"self",
".",
"share... | Add shares list to the tags attributes in search results.
:param dict tags: tags dictionary from a search request | [
"Add",
"shares",
"list",
"to",
"the",
"tags",
"attributes",
"in",
"search",
"results",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L887-L901 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.get_app_properties | def get_app_properties(self, token: dict = None, prot: str = "https"):
"""Get information about the application declared on Isogeo.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# check if app pro... | python | def get_app_properties(self, token: dict = None, prot: str = "https"):
"""Get information about the application declared on Isogeo.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# check if app pro... | [
"def",
"get_app_properties",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
":",
"# check if app properties have already been retrieved or not",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"app_properties\"",
"... | Get information about the application declared on Isogeo.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"information",
"about",
"the",
"application",
"declared",
"on",
"Isogeo",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L904-L927 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.get_directives | def get_directives(self, token: dict = None, prot: str = "https") -> dict:
"""Get environment directives which represent INSPIRE limitations.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# search... | python | def get_directives(self, token: dict = None, prot: str = "https") -> dict:
"""Get environment directives which represent INSPIRE limitations.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs).
"""
# search... | [
"def",
"get_directives",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# search request",
"req_url",
"=",
"\"{}://v1.{}.isogeo.com/directives\"",
".",
"format",
"(",
"prot",
",",
"sel... | Get environment directives which represent INSPIRE limitations.
:param str token: API auth token
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"environment",
"directives",
"which",
"represent",
"INSPIRE",
"limitations",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L951-L969 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.get_coordinate_systems | def get_coordinate_systems(
self, token: dict = None, srs_code: str = None, prot: str = "https"
) -> dict:
"""Get available coordinate systems in Isogeo API.
:param str token: API auth token
:param str srs_code: code of a specific coordinate system
:param str prot: https [DE... | python | def get_coordinate_systems(
self, token: dict = None, srs_code: str = None, prot: str = "https"
) -> dict:
"""Get available coordinate systems in Isogeo API.
:param str token: API auth token
:param str srs_code: code of a specific coordinate system
:param str prot: https [DE... | [
"def",
"get_coordinate_systems",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"srs_code",
":",
"str",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# if specific format",
"if",
"isinstance",
"(",
"srs_code",
... | Get available coordinate systems in Isogeo API.
:param str token: API auth token
:param str srs_code: code of a specific coordinate system
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"available",
"coordinate",
"systems",
"in",
"Isogeo",
"API",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L972-L1001 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/isogeo_sdk.py | Isogeo.get_formats | def get_formats(
self, token: dict = None, format_code: str = None, prot: str = "https"
) -> dict:
"""Get formats.
:param str token: API auth token
:param str format_code: code of a specific format
:param str prot: https [DEFAULT] or http
(use it only for dev and tr... | python | def get_formats(
self, token: dict = None, format_code: str = None, prot: str = "https"
) -> dict:
"""Get formats.
:param str token: API auth token
:param str format_code: code of a specific format
:param str prot: https [DEFAULT] or http
(use it only for dev and tr... | [
"def",
"get_formats",
"(",
"self",
",",
"token",
":",
"dict",
"=",
"None",
",",
"format_code",
":",
"str",
"=",
"None",
",",
"prot",
":",
"str",
"=",
"\"https\"",
")",
"->",
"dict",
":",
"# if specific format",
"if",
"isinstance",
"(",
"format_code",
","... | Get formats.
:param str token: API auth token
:param str format_code: code of a specific format
:param str prot: https [DEFAULT] or http
(use it only for dev and tracking needs). | [
"Get",
"formats",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/isogeo_sdk.py#L1004-L1033 |
kajala/django-jutil | jutil/parse.py | parse_bool | def parse_bool(v, default=None, exceptions: bool=True) -> bool:
"""
Parses boolean value
:param v: Input string
:param default: Default value if exceptions=False
:param exceptions: Raise exception on error or not
:return: bool
"""
if isinstance(v, bool):
return v
s = str(v).l... | python | def parse_bool(v, default=None, exceptions: bool=True) -> bool:
"""
Parses boolean value
:param v: Input string
:param default: Default value if exceptions=False
:param exceptions: Raise exception on error or not
:return: bool
"""
if isinstance(v, bool):
return v
s = str(v).l... | [
"def",
"parse_bool",
"(",
"v",
",",
"default",
"=",
"None",
",",
"exceptions",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"v",
",",
"bool",
")",
":",
"return",
"v",
"s",
"=",
"str",
"(",
"v",
")",
".",
"lower",
"... | Parses boolean value
:param v: Input string
:param default: Default value if exceptions=False
:param exceptions: Raise exception on error or not
:return: bool | [
"Parses",
"boolean",
"value",
":",
"param",
"v",
":",
"Input",
"string",
":",
"param",
"default",
":",
"Default",
"value",
"if",
"exceptions",
"=",
"False",
":",
"param",
"exceptions",
":",
"Raise",
"exception",
"on",
"error",
"or",
"not",
":",
"return",
... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/parse.py#L22-L40 |
kajala/django-jutil | jutil/parse.py | parse_datetime | def parse_datetime(v, default=None, tz=None, exceptions: bool=True) -> datetime:
"""
Parses datetime
:param v: Input string
:param default: Default value if exceptions=False
:param tz: Default pytz timezone or None if utc
:param exceptions: Raise exception on error or not
:return: datetime
... | python | def parse_datetime(v, default=None, tz=None, exceptions: bool=True) -> datetime:
"""
Parses datetime
:param v: Input string
:param default: Default value if exceptions=False
:param tz: Default pytz timezone or None if utc
:param exceptions: Raise exception on error or not
:return: datetime
... | [
"def",
"parse_datetime",
"(",
"v",
",",
"default",
"=",
"None",
",",
"tz",
"=",
"None",
",",
"exceptions",
":",
"bool",
"=",
"True",
")",
"->",
"datetime",
":",
"try",
":",
"t",
"=",
"dateutil_parse",
"(",
"v",
",",
"default",
"=",
"datetime",
"(",
... | Parses datetime
:param v: Input string
:param default: Default value if exceptions=False
:param tz: Default pytz timezone or None if utc
:param exceptions: Raise exception on error or not
:return: datetime | [
"Parses",
"datetime",
":",
"param",
"v",
":",
"Input",
"string",
":",
"param",
"default",
":",
"Default",
"value",
"if",
"exceptions",
"=",
"False",
":",
"param",
"tz",
":",
"Default",
"pytz",
"timezone",
"or",
"None",
"if",
"utc",
":",
"param",
"excepti... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/parse.py#L43-L60 |
InformaticsMatters/pipelines-utils | src/python/pipelines_utils/TypedColumnReader.py | convert_boolean | def convert_boolean(string_value):
"""Converts a string to a boolean (see CONVERTERS).
There is a converter function for each column type.
Boolean strings are independent of case. Values interpreted as True
are: "yes", "true", "on", "1". values interpreted as False are
"no", "false", "off", "0". An... | python | def convert_boolean(string_value):
"""Converts a string to a boolean (see CONVERTERS).
There is a converter function for each column type.
Boolean strings are independent of case. Values interpreted as True
are: "yes", "true", "on", "1". values interpreted as False are
"no", "false", "off", "0". An... | [
"def",
"convert_boolean",
"(",
"string_value",
")",
":",
"lean_string_value",
"=",
"string_value",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"if",
"lean_string_value",
"in",
"[",
"'yes'",
",",
"'true'",
",",
"'on'",
",",
"'1'",
"]",
":",
"return",
... | Converts a string to a boolean (see CONVERTERS).
There is a converter function for each column type.
Boolean strings are independent of case. Values interpreted as True
are: "yes", "true", "on", "1". values interpreted as False are
"no", "false", "off", "0". Any other value will result in a ValueError.... | [
"Converts",
"a",
"string",
"to",
"a",
"boolean",
"(",
"see",
"CONVERTERS",
")",
".",
"There",
"is",
"a",
"converter",
"function",
"for",
"each",
"column",
"type",
"."
] | train | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/TypedColumnReader.py#L68-L88 |
InformaticsMatters/pipelines-utils | src/python/pipelines_utils/TypedColumnReader.py | TypedColumnReader._handle_hdr | def _handle_hdr(self, hdr):
"""Given the file header line (or one provided when the object
is instantiated) this method populates the ``self._converters`` array,
a list of type converters indexed by the column name.
:param hdr: The header line.
:raises: ContentError for any for... | python | def _handle_hdr(self, hdr):
"""Given the file header line (or one provided when the object
is instantiated) this method populates the ``self._converters`` array,
a list of type converters indexed by the column name.
:param hdr: The header line.
:raises: ContentError for any for... | [
"def",
"_handle_hdr",
"(",
"self",
",",
"hdr",
")",
":",
"column_number",
"=",
"1",
"for",
"cell",
"in",
"hdr",
":",
"cell_parts",
"=",
"cell",
".",
"split",
"(",
"self",
".",
"_type_sep",
")",
"if",
"len",
"(",
"cell_parts",
")",
"not",
"in",
"[",
... | Given the file header line (or one provided when the object
is instantiated) this method populates the ``self._converters`` array,
a list of type converters indexed by the column name.
:param hdr: The header line.
:raises: ContentError for any formatting problems
:raises: Unkno... | [
"Given",
"the",
"file",
"header",
"line",
"(",
"or",
"one",
"provided",
"when",
"the",
"object",
"is",
"instantiated",
")",
"this",
"method",
"populates",
"the",
"self",
".",
"_converters",
"array",
"a",
"list",
"of",
"type",
"converters",
"indexed",
"by",
... | train | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/TypedColumnReader.py#L259-L293 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/samples/udata_client_datagouvfr.py | DataGouvFr.search_datasets | def search_datasets(
self,
license=None,
format=None,
query=None,
featured=None,
owner=None,
organization=None,
badge=None,
reuses=None,
page_size=20,
x_fields=None,
):
"""Search datasets within uData portal."""
... | python | def search_datasets(
self,
license=None,
format=None,
query=None,
featured=None,
owner=None,
organization=None,
badge=None,
reuses=None,
page_size=20,
x_fields=None,
):
"""Search datasets within uData portal."""
... | [
"def",
"search_datasets",
"(",
"self",
",",
"license",
"=",
"None",
",",
"format",
"=",
"None",
",",
"query",
"=",
"None",
",",
"featured",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"organization",
"=",
"None",
",",
"badge",
"=",
"None",
",",
"reu... | Search datasets within uData portal. | [
"Search",
"datasets",
"within",
"uData",
"portal",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/samples/udata_client_datagouvfr.py#L79-L112 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/samples/udata_client_datagouvfr.py | DataGouvFr.get_filters_values | def get_filters_values(self):
"""Get different filters values as dicts."""
# DATASETS --
# badges
self._DST_BADGES = requests.get(self.base_url + "datasets/badges/").json()
# licences
self._DST_LICENSES = {
l.get("id"): l.get("title")
for l in requ... | python | def get_filters_values(self):
"""Get different filters values as dicts."""
# DATASETS --
# badges
self._DST_BADGES = requests.get(self.base_url + "datasets/badges/").json()
# licences
self._DST_LICENSES = {
l.get("id"): l.get("title")
for l in requ... | [
"def",
"get_filters_values",
"(",
"self",
")",
":",
"# DATASETS --",
"# badges",
"self",
".",
"_DST_BADGES",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"base_url",
"+",
"\"datasets/badges/\"",
")",
".",
"json",
"(",
")",
"# licences",
"self",
".",
"_DST_... | Get different filters values as dicts. | [
"Get",
"different",
"filters",
"values",
"as",
"dicts",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/samples/udata_client_datagouvfr.py#L115-L167 |
novopl/peltak | src/peltak_appengine/logic.py | deploy | def deploy(app_id, version, promote, quiet):
# type: (str, str, bool, bool) -> None
""" Deploy the app to AppEngine.
Args:
app_id (str):
AppEngine App ID. Overrides config value app_id if given.
version (str):
AppEngine project version. Overrides config values if giv... | python | def deploy(app_id, version, promote, quiet):
# type: (str, str, bool, bool) -> None
""" Deploy the app to AppEngine.
Args:
app_id (str):
AppEngine App ID. Overrides config value app_id if given.
version (str):
AppEngine project version. Overrides config values if giv... | [
"def",
"deploy",
"(",
"app_id",
",",
"version",
",",
"promote",
",",
"quiet",
")",
":",
"# type: (str, str, bool, bool) -> None",
"gae_app",
"=",
"GaeApp",
".",
"for_branch",
"(",
"git",
".",
"current_branch",
"(",
")",
".",
"name",
")",
"if",
"gae_app",
"is... | Deploy the app to AppEngine.
Args:
app_id (str):
AppEngine App ID. Overrides config value app_id if given.
version (str):
AppEngine project version. Overrides config values if given.
promote (bool):
If set to **True** promote the current remote app versio... | [
"Deploy",
"the",
"app",
"to",
"AppEngine",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_appengine/logic.py#L41-L73 |
novopl/peltak | src/peltak_appengine/logic.py | devserver | def devserver(port, admin_port, clear):
# type: (int, int, bool) -> None
""" Run devserver.
Args:
port (int):
Port on which the app will be served.
admin_port (int):
Port on which the admin interface is served.
clear (bool):
If set to **True**, cl... | python | def devserver(port, admin_port, clear):
# type: (int, int, bool) -> None
""" Run devserver.
Args:
port (int):
Port on which the app will be served.
admin_port (int):
Port on which the admin interface is served.
clear (bool):
If set to **True**, cl... | [
"def",
"devserver",
"(",
"port",
",",
"admin_port",
",",
"clear",
")",
":",
"# type: (int, int, bool) -> None",
"admin_port",
"=",
"admin_port",
"or",
"(",
"port",
"+",
"1",
")",
"args",
"=",
"[",
"'--port={}'",
".",
"format",
"(",
"port",
")",
",",
"'--ad... | Run devserver.
Args:
port (int):
Port on which the app will be served.
admin_port (int):
Port on which the admin interface is served.
clear (bool):
If set to **True**, clear the datastore on startup. | [
"Run",
"devserver",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_appengine/logic.py#L77-L100 |
novopl/peltak | src/peltak_appengine/logic.py | setup_ci | def setup_ci():
# type: () -> None
""" Setup AppEngine SDK on CircleCI """
gcloud_path = shell.run('which gcloud', capture=True).stdout.strip()
sdk_path = normpath(join(gcloud_path, '../../platform/google_appengine'))
gcloud_cmd = gcloud_path + ' --quiet'
if not exists(sdk_path):
log.in... | python | def setup_ci():
# type: () -> None
""" Setup AppEngine SDK on CircleCI """
gcloud_path = shell.run('which gcloud', capture=True).stdout.strip()
sdk_path = normpath(join(gcloud_path, '../../platform/google_appengine'))
gcloud_cmd = gcloud_path + ' --quiet'
if not exists(sdk_path):
log.in... | [
"def",
"setup_ci",
"(",
")",
":",
"# type: () -> None",
"gcloud_path",
"=",
"shell",
".",
"run",
"(",
"'which gcloud'",
",",
"capture",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"sdk_path",
"=",
"normpath",
"(",
"join",
"(",
"gcloud_path",
... | Setup AppEngine SDK on CircleCI | [
"Setup",
"AppEngine",
"SDK",
"on",
"CircleCI"
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_appengine/logic.py#L104-L124 |
novopl/peltak | src/peltak/core/util.py | mark_experimental | def mark_experimental(fn):
# type: (FunctionType) -> FunctionType
""" Mark function as experimental.
Args:
fn (FunctionType):
The command function to decorate.
"""
@wraps(fn)
def wrapper(*args, **kw): # pylint: disable=missing-docstring
from peltak.core import shel... | python | def mark_experimental(fn):
# type: (FunctionType) -> FunctionType
""" Mark function as experimental.
Args:
fn (FunctionType):
The command function to decorate.
"""
@wraps(fn)
def wrapper(*args, **kw): # pylint: disable=missing-docstring
from peltak.core import shel... | [
"def",
"mark_experimental",
"(",
"fn",
")",
":",
"# type: (FunctionType) -> FunctionType",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# pylint: disable=missing-docstring",
"from",
"peltak",
".",
"core",
"i... | Mark function as experimental.
Args:
fn (FunctionType):
The command function to decorate. | [
"Mark",
"function",
"as",
"experimental",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/util.py#L74-L93 |
novopl/peltak | src/peltak/core/util.py | mark_deprecated | def mark_deprecated(replaced_by):
# type: (Text) -> FunctionType
""" Mark command as deprecated.
Args:
replaced_by (str):
The command that deprecated this command and should be used instead.
"""
def decorator(fn): # pylint: disable=missing-docstring
@wraps(fn)
... | python | def mark_deprecated(replaced_by):
# type: (Text) -> FunctionType
""" Mark command as deprecated.
Args:
replaced_by (str):
The command that deprecated this command and should be used instead.
"""
def decorator(fn): # pylint: disable=missing-docstring
@wraps(fn)
... | [
"def",
"mark_deprecated",
"(",
"replaced_by",
")",
":",
"# type: (Text) -> FunctionType",
"def",
"decorator",
"(",
"fn",
")",
":",
"# pylint: disable=missing-docstring",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")"... | Mark command as deprecated.
Args:
replaced_by (str):
The command that deprecated this command and should be used instead. | [
"Mark",
"command",
"as",
"deprecated",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/util.py#L96-L117 |
novopl/peltak | src/peltak/core/util.py | in_batches | def in_batches(iterable, batch_size):
# type: (Iterable[Any]) -> Generator[List[Any]]
""" Split the given iterable into batches.
Args:
iterable (Iterable[Any]):
The iterable you want to split into batches.
batch_size (int):
The size of each bach. The last batch will ... | python | def in_batches(iterable, batch_size):
# type: (Iterable[Any]) -> Generator[List[Any]]
""" Split the given iterable into batches.
Args:
iterable (Iterable[Any]):
The iterable you want to split into batches.
batch_size (int):
The size of each bach. The last batch will ... | [
"def",
"in_batches",
"(",
"iterable",
",",
"batch_size",
")",
":",
"# type: (Iterable[Any]) -> Generator[List[Any]]",
"items",
"=",
"list",
"(",
"iterable",
")",
"size",
"=",
"len",
"(",
"items",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size",
",",
... | Split the given iterable into batches.
Args:
iterable (Iterable[Any]):
The iterable you want to split into batches.
batch_size (int):
The size of each bach. The last batch will be probably smaller (if
the number of elements cannot be equally divided.
Returns... | [
"Split",
"the",
"given",
"iterable",
"into",
"batches",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/util.py#L186-L217 |
novopl/peltak | src/peltak/core/util.py | yaml_dump | def yaml_dump(data, stream=None):
# type: (YamlData, Optional[TextIO]) -> Text
""" Dump data to a YAML string/file.
Args:
data (YamlData):
The data to serialize as YAML.
stream (TextIO):
The file-like object to save to. If given, this function will write
... | python | def yaml_dump(data, stream=None):
# type: (YamlData, Optional[TextIO]) -> Text
""" Dump data to a YAML string/file.
Args:
data (YamlData):
The data to serialize as YAML.
stream (TextIO):
The file-like object to save to. If given, this function will write
... | [
"def",
"yaml_dump",
"(",
"data",
",",
"stream",
"=",
"None",
")",
":",
"# type: (YamlData, Optional[TextIO]) -> Text",
"return",
"yaml",
".",
"dump",
"(",
"data",
",",
"stream",
"=",
"stream",
",",
"Dumper",
"=",
"Dumper",
",",
"default_flow_style",
"=",
"Fals... | Dump data to a YAML string/file.
Args:
data (YamlData):
The data to serialize as YAML.
stream (TextIO):
The file-like object to save to. If given, this function will write
the resulting YAML to that stream.
Returns:
str: The YAML string. | [
"Dump",
"data",
"to",
"a",
"YAML",
"string",
"/",
"file",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/util.py#L233-L252 |
novopl/peltak | src/peltak/core/util.py | cached_result.clear | def clear(cls, fn):
# type: (FunctionType) -> None
""" Clear result cache on the given function.
If the function has no cached result, this call will do nothing.
Args:
fn (FunctionType):
The function whose cache should be cleared.
"""
if hasa... | python | def clear(cls, fn):
# type: (FunctionType) -> None
""" Clear result cache on the given function.
If the function has no cached result, this call will do nothing.
Args:
fn (FunctionType):
The function whose cache should be cleared.
"""
if hasa... | [
"def",
"clear",
"(",
"cls",
",",
"fn",
")",
":",
"# type: (FunctionType) -> None",
"if",
"hasattr",
"(",
"fn",
",",
"cls",
".",
"CACHE_VAR",
")",
":",
"delattr",
"(",
"fn",
",",
"cls",
".",
"CACHE_VAR",
")"
] | Clear result cache on the given function.
If the function has no cached result, this call will do nothing.
Args:
fn (FunctionType):
The function whose cache should be cleared. | [
"Clear",
"result",
"cache",
"on",
"the",
"given",
"function",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/util.py#L172-L183 |
novopl/peltak | src/peltak/extra/gitflow/logic/task.py | start | def start(name):
# type: (str) -> None
""" Start working on a new feature by branching off develop.
This will create a new branch off develop called feature/<name>.
Args:
name (str):
The name of the new feature.
"""
branch = git.current_branch(refresh=True)
task_branch ... | python | def start(name):
# type: (str) -> None
""" Start working on a new feature by branching off develop.
This will create a new branch off develop called feature/<name>.
Args:
name (str):
The name of the new feature.
"""
branch = git.current_branch(refresh=True)
task_branch ... | [
"def",
"start",
"(",
"name",
")",
":",
"# type: (str) -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"task_branch",
"=",
"'task/'",
"+",
"common",
".",
"to_branch_name",
"(",
"name",
")",
"if",
"branch",
".",
"type... | Start working on a new feature by branching off develop.
This will create a new branch off develop called feature/<name>.
Args:
name (str):
The name of the new feature. | [
"Start",
"working",
"on",
"a",
"new",
"feature",
"by",
"branching",
"off",
"develop",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/task.py#L33-L51 |
novopl/peltak | src/peltak/extra/gitflow/logic/task.py | update | def update():
# type: () -> None
""" Update the feature with updates committed to develop.
This will merge current develop into the current branch.
"""
branch = git.current_branch(refresh=True)
base_branch = common.get_base_branch()
common.assert_branch_type('task')
common.git_checkout... | python | def update():
# type: () -> None
""" Update the feature with updates committed to develop.
This will merge current develop into the current branch.
"""
branch = git.current_branch(refresh=True)
base_branch = common.get_base_branch()
common.assert_branch_type('task')
common.git_checkout... | [
"def",
"update",
"(",
")",
":",
"# type: () -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"base_branch",
"=",
"common",
".",
"get_base_branch",
"(",
")",
"common",
".",
"assert_branch_type",
"(",
"'task'",
")",
"com... | Update the feature with updates committed to develop.
This will merge current develop into the current branch. | [
"Update",
"the",
"feature",
"with",
"updates",
"committed",
"to",
"develop",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/task.py#L54-L67 |
novopl/peltak | src/peltak/extra/gitflow/logic/task.py | finish | def finish():
# type: () -> None
""" Merge current feature branch into develop. """
pretend = context.get('pretend', False)
if not pretend and (git.staged() or git.unstaged()):
log.err(
"You have uncommitted changes in your repo!\n"
"You need to stash them before you mer... | python | def finish():
# type: () -> None
""" Merge current feature branch into develop. """
pretend = context.get('pretend', False)
if not pretend and (git.staged() or git.unstaged()):
log.err(
"You have uncommitted changes in your repo!\n"
"You need to stash them before you mer... | [
"def",
"finish",
"(",
")",
":",
"# type: () -> None",
"pretend",
"=",
"context",
".",
"get",
"(",
"'pretend'",
",",
"False",
")",
"if",
"not",
"pretend",
"and",
"(",
"git",
".",
"staged",
"(",
")",
"or",
"git",
".",
"unstaged",
"(",
")",
")",
":",
... | Merge current feature branch into develop. | [
"Merge",
"current",
"feature",
"branch",
"into",
"develop",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/task.py#L83-L114 |
novopl/peltak | src/peltak/extra/gitflow/logic/task.py | merged | def merged():
# type: () -> None
""" Cleanup a remotely merged branch. """
base_branch = common.get_base_branch()
branch = git.current_branch(refresh=True)
common.assert_branch_type('task')
# Pull feature branch with the merged task
common.git_checkout(base_branch)
common.git_pull(base... | python | def merged():
# type: () -> None
""" Cleanup a remotely merged branch. """
base_branch = common.get_base_branch()
branch = git.current_branch(refresh=True)
common.assert_branch_type('task')
# Pull feature branch with the merged task
common.git_checkout(base_branch)
common.git_pull(base... | [
"def",
"merged",
"(",
")",
":",
"# type: () -> None",
"base_branch",
"=",
"common",
".",
"get_base_branch",
"(",
")",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"common",
".",
"assert_branch_type",
"(",
"'task'",
")",
"# P... | Cleanup a remotely merged branch. | [
"Cleanup",
"a",
"remotely",
"merged",
"branch",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/task.py#L117-L133 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | mutagen_call | def mutagen_call(action, path, func, *args, **kwargs):
"""Call a Mutagen function with appropriate error handling.
`action` is a string describing what the function is trying to do,
and `path` is the relevant filename. The rest of the arguments
describe the callable to invoke.
We require at least ... | python | def mutagen_call(action, path, func, *args, **kwargs):
"""Call a Mutagen function with appropriate error handling.
`action` is a string describing what the function is trying to do,
and `path` is the relevant filename. The rest of the arguments
describe the callable to invoke.
We require at least ... | [
"def",
"mutagen_call",
"(",
"action",
",",
"path",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"mutagen",
".",
"MutagenError",
"as",
"exc"... | Call a Mutagen function with appropriate error handling.
`action` is a string describing what the function is trying to do,
and `path` is the relevant filename. The rest of the arguments
describe the callable to invoke.
We require at least Mutagen 1.33, where `IOError` is *never* used,
neither for... | [
"Call",
"a",
"Mutagen",
"function",
"with",
"appropriate",
"error",
"handling",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L117-L139 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | _safe_cast | def _safe_cast(out_type, val):
"""Try to covert val to out_type but never raise an exception. If
the value can't be converted, then a sensible default value is
returned. out_type should be bool, int, or unicode; otherwise, the
value is just passed through.
"""
if val is None:
return None... | python | def _safe_cast(out_type, val):
"""Try to covert val to out_type but never raise an exception. If
the value can't be converted, then a sensible default value is
returned. out_type should be bool, int, or unicode; otherwise, the
value is just passed through.
"""
if val is None:
return None... | [
"def",
"_safe_cast",
"(",
"out_type",
",",
"val",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"None",
"if",
"out_type",
"==",
"int",
":",
"if",
"isinstance",
"(",
"val",
",",
"int",
")",
"or",
"isinstance",
"(",
"val",
",",
"float",
")",
":... | Try to covert val to out_type but never raise an exception. If
the value can't be converted, then a sensible default value is
returned. out_type should be bool, int, or unicode; otherwise, the
value is just passed through. | [
"Try",
"to",
"covert",
"val",
"to",
"out_type",
"but",
"never",
"raise",
"an",
"exception",
".",
"If",
"the",
"value",
"can",
"t",
"be",
"converted",
"then",
"a",
"sensible",
"default",
"value",
"is",
"returned",
".",
"out_type",
"should",
"be",
"bool",
... | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L144-L199 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | _unpack_asf_image | def _unpack_asf_image(data):
"""Unpack image data from a WM/Picture tag. Return a tuple
containing the MIME type, the raw image data, a type indicator, and
the image's description.
This function is treated as "untrusted" and could throw all manner
of exceptions (out-of-bounds, etc.). We should clea... | python | def _unpack_asf_image(data):
"""Unpack image data from a WM/Picture tag. Return a tuple
containing the MIME type, the raw image data, a type indicator, and
the image's description.
This function is treated as "untrusted" and could throw all manner
of exceptions (out-of-bounds, etc.). We should clea... | [
"def",
"_unpack_asf_image",
"(",
"data",
")",
":",
"type",
",",
"size",
"=",
"struct",
".",
"unpack_from",
"(",
"'<bi'",
",",
"data",
")",
"pos",
"=",
"5",
"mime",
"=",
"b''",
"while",
"data",
"[",
"pos",
":",
"pos",
"+",
"2",
"]",
"!=",
"b'\\x00\\... | Unpack image data from a WM/Picture tag. Return a tuple
containing the MIME type, the raw image data, a type indicator, and
the image's description.
This function is treated as "untrusted" and could throw all manner
of exceptions (out-of-bounds, etc.). We should clean this up
sometime so that the f... | [
"Unpack",
"image",
"data",
"from",
"a",
"WM",
"/",
"Picture",
"tag",
".",
"Return",
"a",
"tuple",
"containing",
"the",
"MIME",
"type",
"the",
"raw",
"image",
"data",
"a",
"type",
"indicator",
"and",
"the",
"image",
"s",
"description",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L204-L227 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | _pack_asf_image | def _pack_asf_image(mime, data, type=3, description=""):
"""Pack image data for a WM/Picture tag.
"""
tag_data = struct.pack('<bi', type, len(data))
tag_data += mime.encode("utf-16-le") + b'\x00\x00'
tag_data += description.encode("utf-16-le") + b'\x00\x00'
tag_data += data
return tag_data | python | def _pack_asf_image(mime, data, type=3, description=""):
"""Pack image data for a WM/Picture tag.
"""
tag_data = struct.pack('<bi', type, len(data))
tag_data += mime.encode("utf-16-le") + b'\x00\x00'
tag_data += description.encode("utf-16-le") + b'\x00\x00'
tag_data += data
return tag_data | [
"def",
"_pack_asf_image",
"(",
"mime",
",",
"data",
",",
"type",
"=",
"3",
",",
"description",
"=",
"\"\"",
")",
":",
"tag_data",
"=",
"struct",
".",
"pack",
"(",
"'<bi'",
",",
"type",
",",
"len",
"(",
"data",
")",
")",
"tag_data",
"+=",
"mime",
".... | Pack image data for a WM/Picture tag. | [
"Pack",
"image",
"data",
"for",
"a",
"WM",
"/",
"Picture",
"tag",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L230-L237 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | _sc_decode | def _sc_decode(soundcheck):
"""Convert a Sound Check bytestring value to a (gain, peak) tuple as
used by ReplayGain.
"""
# We decode binary data. If one of the formats gives us a text
# string, interpret it as UTF-8.
if isinstance(soundcheck, six.text_type):
soundcheck = soundcheck.encod... | python | def _sc_decode(soundcheck):
"""Convert a Sound Check bytestring value to a (gain, peak) tuple as
used by ReplayGain.
"""
# We decode binary data. If one of the formats gives us a text
# string, interpret it as UTF-8.
if isinstance(soundcheck, six.text_type):
soundcheck = soundcheck.encod... | [
"def",
"_sc_decode",
"(",
"soundcheck",
")",
":",
"# We decode binary data. If one of the formats gives us a text",
"# string, interpret it as UTF-8.",
"if",
"isinstance",
"(",
"soundcheck",
",",
"six",
".",
"text_type",
")",
":",
"soundcheck",
"=",
"soundcheck",
".",
"en... | Convert a Sound Check bytestring value to a (gain, peak) tuple as
used by ReplayGain. | [
"Convert",
"a",
"Sound",
"Check",
"bytestring",
"value",
"to",
"a",
"(",
"gain",
"peak",
")",
"tuple",
"as",
"used",
"by",
"ReplayGain",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L242-L280 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | _sc_encode | def _sc_encode(gain, peak):
"""Encode ReplayGain gain/peak values as a Sound Check string.
"""
# SoundCheck stores the peak value as the actual value of the
# sample, rather than the percentage of full scale that RG uses, so
# we do a simple conversion assuming 16 bit samples.
peak *= 32768.0
... | python | def _sc_encode(gain, peak):
"""Encode ReplayGain gain/peak values as a Sound Check string.
"""
# SoundCheck stores the peak value as the actual value of the
# sample, rather than the percentage of full scale that RG uses, so
# we do a simple conversion assuming 16 bit samples.
peak *= 32768.0
... | [
"def",
"_sc_encode",
"(",
"gain",
",",
"peak",
")",
":",
"# SoundCheck stores the peak value as the actual value of the",
"# sample, rather than the percentage of full scale that RG uses, so",
"# we do a simple conversion assuming 16 bit samples.",
"peak",
"*=",
"32768.0",
"# SoundCheck ... | Encode ReplayGain gain/peak values as a Sound Check string. | [
"Encode",
"ReplayGain",
"gain",
"/",
"peak",
"values",
"as",
"a",
"Sound",
"Check",
"string",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L283-L304 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | image_mime_type | def image_mime_type(data):
"""Return the MIME type of the image data (a bytestring).
"""
# This checks for a jpeg file with only the magic bytes (unrecognized by
# imghdr.what). imghdr.what returns none for that type of file, so
# _wider_test_jpeg is run in that case. It still returns None if it did... | python | def image_mime_type(data):
"""Return the MIME type of the image data (a bytestring).
"""
# This checks for a jpeg file with only the magic bytes (unrecognized by
# imghdr.what). imghdr.what returns none for that type of file, so
# _wider_test_jpeg is run in that case. It still returns None if it did... | [
"def",
"image_mime_type",
"(",
"data",
")",
":",
"# This checks for a jpeg file with only the magic bytes (unrecognized by",
"# imghdr.what). imghdr.what returns none for that type of file, so",
"# _wider_test_jpeg is run in that case. It still returns None if it didn't",
"# match such a jpeg file... | Return the MIME type of the image data (a bytestring). | [
"Return",
"the",
"MIME",
"type",
"of",
"the",
"image",
"data",
"(",
"a",
"bytestring",
")",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L329-L348 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | StorageStyle.deserialize | def deserialize(self, mutagen_value):
"""Given a raw value stored on a Mutagen object, decode and
return the represented value.
"""
if self.suffix and isinstance(mutagen_value, six.text_type) \
and mutagen_value.endswith(self.suffix):
return mutagen_value[:-len(sel... | python | def deserialize(self, mutagen_value):
"""Given a raw value stored on a Mutagen object, decode and
return the represented value.
"""
if self.suffix and isinstance(mutagen_value, six.text_type) \
and mutagen_value.endswith(self.suffix):
return mutagen_value[:-len(sel... | [
"def",
"deserialize",
"(",
"self",
",",
"mutagen_value",
")",
":",
"if",
"self",
".",
"suffix",
"and",
"isinstance",
"(",
"mutagen_value",
",",
"six",
".",
"text_type",
")",
"and",
"mutagen_value",
".",
"endswith",
"(",
"self",
".",
"suffix",
")",
":",
"... | Given a raw value stored on a Mutagen object, decode and
return the represented value. | [
"Given",
"a",
"raw",
"value",
"stored",
"on",
"a",
"Mutagen",
"object",
"decode",
"and",
"return",
"the",
"represented",
"value",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L494-L502 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | StorageStyle.set | def set(self, mutagen_file, value):
"""Assign the value for the field using this style.
"""
self.store(mutagen_file, self.serialize(value)) | python | def set(self, mutagen_file, value):
"""Assign the value for the field using this style.
"""
self.store(mutagen_file, self.serialize(value)) | [
"def",
"set",
"(",
"self",
",",
"mutagen_file",
",",
"value",
")",
":",
"self",
".",
"store",
"(",
"mutagen_file",
",",
"self",
".",
"serialize",
"(",
"value",
")",
")"
] | Assign the value for the field using this style. | [
"Assign",
"the",
"value",
"for",
"the",
"field",
"using",
"this",
"style",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L506-L509 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | StorageStyle.serialize | def serialize(self, value):
"""Convert the external Python value to a type that is suitable for
storing in a Mutagen file object.
"""
if isinstance(value, float) and self.as_type is six.text_type:
value = u'{0:.{1}f}'.format(value, self.float_places)
value = self.... | python | def serialize(self, value):
"""Convert the external Python value to a type that is suitable for
storing in a Mutagen file object.
"""
if isinstance(value, float) and self.as_type is six.text_type:
value = u'{0:.{1}f}'.format(value, self.float_places)
value = self.... | [
"def",
"serialize",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"float",
")",
"and",
"self",
".",
"as_type",
"is",
"six",
".",
"text_type",
":",
"value",
"=",
"u'{0:.{1}f}'",
".",
"format",
"(",
"value",
",",
"self",
"... | Convert the external Python value to a type that is suitable for
storing in a Mutagen file object. | [
"Convert",
"the",
"external",
"Python",
"value",
"to",
"a",
"type",
"that",
"is",
"suitable",
"for",
"storing",
"in",
"a",
"Mutagen",
"file",
"object",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L516-L537 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | ListStorageStyle.get_list | def get_list(self, mutagen_file):
"""Get a list of all values for the field using this style.
"""
return [self.deserialize(item) for item in self.fetch(mutagen_file)] | python | def get_list(self, mutagen_file):
"""Get a list of all values for the field using this style.
"""
return [self.deserialize(item) for item in self.fetch(mutagen_file)] | [
"def",
"get_list",
"(",
"self",
",",
"mutagen_file",
")",
":",
"return",
"[",
"self",
".",
"deserialize",
"(",
"item",
")",
"for",
"item",
"in",
"self",
".",
"fetch",
"(",
"mutagen_file",
")",
"]"
] | Get a list of all values for the field using this style. | [
"Get",
"a",
"list",
"of",
"all",
"values",
"for",
"the",
"field",
"using",
"this",
"style",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L569-L572 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | ListStorageStyle.set_list | def set_list(self, mutagen_file, values):
"""Set all values for the field using this style. `values`
should be an iterable.
"""
self.store(mutagen_file, [self.serialize(value) for value in values]) | python | def set_list(self, mutagen_file, values):
"""Set all values for the field using this style. `values`
should be an iterable.
"""
self.store(mutagen_file, [self.serialize(value) for value in values]) | [
"def",
"set_list",
"(",
"self",
",",
"mutagen_file",
",",
"values",
")",
":",
"self",
".",
"store",
"(",
"mutagen_file",
",",
"[",
"self",
".",
"serialize",
"(",
"value",
")",
"for",
"value",
"in",
"values",
"]",
")"
] | Set all values for the field using this style. `values`
should be an iterable. | [
"Set",
"all",
"values",
"for",
"the",
"field",
"using",
"this",
"style",
".",
"values",
"should",
"be",
"an",
"iterable",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L588-L592 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MP3ImageStorageStyle.deserialize | def deserialize(self, apic_frame):
"""Convert APIC frame into Image."""
return Image(data=apic_frame.data, desc=apic_frame.desc,
type=apic_frame.type) | python | def deserialize(self, apic_frame):
"""Convert APIC frame into Image."""
return Image(data=apic_frame.data, desc=apic_frame.desc,
type=apic_frame.type) | [
"def",
"deserialize",
"(",
"self",
",",
"apic_frame",
")",
":",
"return",
"Image",
"(",
"data",
"=",
"apic_frame",
".",
"data",
",",
"desc",
"=",
"apic_frame",
".",
"desc",
",",
"type",
"=",
"apic_frame",
".",
"type",
")"
] | Convert APIC frame into Image. | [
"Convert",
"APIC",
"frame",
"into",
"Image",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L933-L936 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MP3ImageStorageStyle.serialize | def serialize(self, image):
"""Return an APIC frame populated with data from ``image``.
"""
assert isinstance(image, Image)
frame = mutagen.id3.Frames[self.key]()
frame.data = image.data
frame.mime = image.mime_type
frame.desc = image.desc or u''
# For co... | python | def serialize(self, image):
"""Return an APIC frame populated with data from ``image``.
"""
assert isinstance(image, Image)
frame = mutagen.id3.Frames[self.key]()
frame.data = image.data
frame.mime = image.mime_type
frame.desc = image.desc or u''
# For co... | [
"def",
"serialize",
"(",
"self",
",",
"image",
")",
":",
"assert",
"isinstance",
"(",
"image",
",",
"Image",
")",
"frame",
"=",
"mutagen",
".",
"id3",
".",
"Frames",
"[",
"self",
".",
"key",
"]",
"(",
")",
"frame",
".",
"data",
"=",
"image",
".",
... | Return an APIC frame populated with data from ``image``. | [
"Return",
"an",
"APIC",
"frame",
"populated",
"with",
"data",
"from",
"image",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L947-L966 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | VorbisImageStorageStyle.serialize | def serialize(self, image):
"""Turn a Image into a base64 encoded FLAC picture block.
"""
pic = mutagen.flac.Picture()
pic.data = image.data
pic.type = image.type_index
pic.mime = image.mime_type
pic.desc = image.desc or u''
# Encoding with base64 returns... | python | def serialize(self, image):
"""Turn a Image into a base64 encoded FLAC picture block.
"""
pic = mutagen.flac.Picture()
pic.data = image.data
pic.type = image.type_index
pic.mime = image.mime_type
pic.desc = image.desc or u''
# Encoding with base64 returns... | [
"def",
"serialize",
"(",
"self",
",",
"image",
")",
":",
"pic",
"=",
"mutagen",
".",
"flac",
".",
"Picture",
"(",
")",
"pic",
".",
"data",
"=",
"image",
".",
"data",
"pic",
".",
"type",
"=",
"image",
".",
"type_index",
"pic",
".",
"mime",
"=",
"i... | Turn a Image into a base64 encoded FLAC picture block. | [
"Turn",
"a",
"Image",
"into",
"a",
"base64",
"encoded",
"FLAC",
"picture",
"block",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1036-L1048 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | FlacImageStorageStyle.store | def store(self, mutagen_file, pictures):
"""``pictures`` is a list of mutagen.flac.Picture instances.
"""
mutagen_file.clear_pictures()
for pic in pictures:
mutagen_file.add_picture(pic) | python | def store(self, mutagen_file, pictures):
"""``pictures`` is a list of mutagen.flac.Picture instances.
"""
mutagen_file.clear_pictures()
for pic in pictures:
mutagen_file.add_picture(pic) | [
"def",
"store",
"(",
"self",
",",
"mutagen_file",
",",
"pictures",
")",
":",
"mutagen_file",
".",
"clear_pictures",
"(",
")",
"for",
"pic",
"in",
"pictures",
":",
"mutagen_file",
".",
"add_picture",
"(",
"pic",
")"
] | ``pictures`` is a list of mutagen.flac.Picture instances. | [
"pictures",
"is",
"a",
"list",
"of",
"mutagen",
".",
"flac",
".",
"Picture",
"instances",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1066-L1071 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | FlacImageStorageStyle.serialize | def serialize(self, image):
"""Turn a Image into a mutagen.flac.Picture.
"""
pic = mutagen.flac.Picture()
pic.data = image.data
pic.type = image.type_index
pic.mime = image.mime_type
pic.desc = image.desc or u''
return pic | python | def serialize(self, image):
"""Turn a Image into a mutagen.flac.Picture.
"""
pic = mutagen.flac.Picture()
pic.data = image.data
pic.type = image.type_index
pic.mime = image.mime_type
pic.desc = image.desc or u''
return pic | [
"def",
"serialize",
"(",
"self",
",",
"image",
")",
":",
"pic",
"=",
"mutagen",
".",
"flac",
".",
"Picture",
"(",
")",
"pic",
".",
"data",
"=",
"image",
".",
"data",
"pic",
".",
"type",
"=",
"image",
".",
"type_index",
"pic",
".",
"mime",
"=",
"i... | Turn a Image into a mutagen.flac.Picture. | [
"Turn",
"a",
"Image",
"into",
"a",
"mutagen",
".",
"flac",
".",
"Picture",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1073-L1081 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | APEv2ImageStorageStyle.delete | def delete(self, mutagen_file):
"""Remove all images from the file.
"""
for cover_tag in self.TAG_NAMES.values():
try:
del mutagen_file[cover_tag]
except KeyError:
pass | python | def delete(self, mutagen_file):
"""Remove all images from the file.
"""
for cover_tag in self.TAG_NAMES.values():
try:
del mutagen_file[cover_tag]
except KeyError:
pass | [
"def",
"delete",
"(",
"self",
",",
"mutagen_file",
")",
":",
"for",
"cover_tag",
"in",
"self",
".",
"TAG_NAMES",
".",
"values",
"(",
")",
":",
"try",
":",
"del",
"mutagen_file",
"[",
"cover_tag",
"]",
"except",
"KeyError",
":",
"pass"
] | Remove all images from the file. | [
"Remove",
"all",
"images",
"from",
"the",
"file",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1150-L1157 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaField.styles | def styles(self, mutagen_file):
"""Yields the list of storage styles of this field that can
handle the MediaFile's format.
"""
for style in self._styles:
if mutagen_file.__class__.__name__ in style.formats:
yield style | python | def styles(self, mutagen_file):
"""Yields the list of storage styles of this field that can
handle the MediaFile's format.
"""
for style in self._styles:
if mutagen_file.__class__.__name__ in style.formats:
yield style | [
"def",
"styles",
"(",
"self",
",",
"mutagen_file",
")",
":",
"for",
"style",
"in",
"self",
".",
"_styles",
":",
"if",
"mutagen_file",
".",
"__class__",
".",
"__name__",
"in",
"style",
".",
"formats",
":",
"yield",
"style"
] | Yields the list of storage styles of this field that can
handle the MediaFile's format. | [
"Yields",
"the",
"list",
"of",
"storage",
"styles",
"of",
"this",
"field",
"that",
"can",
"handle",
"the",
"MediaFile",
"s",
"format",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1183-L1189 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaField._none_value | def _none_value(self):
"""Get an appropriate "null" value for this field's type. This
is used internally when setting the field to None.
"""
if self.out_type == int:
return 0
elif self.out_type == float:
return 0.0
elif self.out_type == bool:
... | python | def _none_value(self):
"""Get an appropriate "null" value for this field's type. This
is used internally when setting the field to None.
"""
if self.out_type == int:
return 0
elif self.out_type == float:
return 0.0
elif self.out_type == bool:
... | [
"def",
"_none_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"out_type",
"==",
"int",
":",
"return",
"0",
"elif",
"self",
".",
"out_type",
"==",
"float",
":",
"return",
"0.0",
"elif",
"self",
".",
"out_type",
"==",
"bool",
":",
"return",
"False",
... | Get an appropriate "null" value for this field's type. This
is used internally when setting the field to None. | [
"Get",
"an",
"appropriate",
"null",
"value",
"for",
"this",
"field",
"s",
"type",
".",
"This",
"is",
"used",
"internally",
"when",
"setting",
"the",
"field",
"to",
"None",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1209-L1220 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | DateField._get_date_tuple | def _get_date_tuple(self, mediafile):
"""Get a 3-item sequence representing the date consisting of a
year, month, and day number. Each number is either an integer or
None.
"""
# Get the underlying data and split on hyphens and slashes.
datestring = super(DateField, self).... | python | def _get_date_tuple(self, mediafile):
"""Get a 3-item sequence representing the date consisting of a
year, month, and day number. Each number is either an integer or
None.
"""
# Get the underlying data and split on hyphens and slashes.
datestring = super(DateField, self).... | [
"def",
"_get_date_tuple",
"(",
"self",
",",
"mediafile",
")",
":",
"# Get the underlying data and split on hyphens and slashes.",
"datestring",
"=",
"super",
"(",
"DateField",
",",
"self",
")",
".",
"__get__",
"(",
"mediafile",
",",
"None",
")",
"if",
"isinstance",
... | Get a 3-item sequence representing the date consisting of a
year, month, and day number. Each number is either an integer or
None. | [
"Get",
"a",
"3",
"-",
"item",
"sequence",
"representing",
"the",
"date",
"consisting",
"of",
"a",
"year",
"month",
"and",
"day",
"number",
".",
"Each",
"number",
"is",
"either",
"an",
"integer",
"or",
"None",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1293-L1323 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | DateField._set_date_tuple | def _set_date_tuple(self, mediafile, year, month=None, day=None):
"""Set the value of the field given a year, month, and day
number. Each number can be an integer or None to indicate an
unset component.
"""
if year is None:
self.__delete__(mediafile)
retur... | python | def _set_date_tuple(self, mediafile, year, month=None, day=None):
"""Set the value of the field given a year, month, and day
number. Each number can be an integer or None to indicate an
unset component.
"""
if year is None:
self.__delete__(mediafile)
retur... | [
"def",
"_set_date_tuple",
"(",
"self",
",",
"mediafile",
",",
"year",
",",
"month",
"=",
"None",
",",
"day",
"=",
"None",
")",
":",
"if",
"year",
"is",
"None",
":",
"self",
".",
"__delete__",
"(",
"mediafile",
")",
"return",
"date",
"=",
"[",
"u'{0:0... | Set the value of the field given a year, month, and day
number. Each number can be an integer or None to indicate an
unset component. | [
"Set",
"the",
"value",
"of",
"the",
"field",
"given",
"a",
"year",
"month",
"and",
"day",
"number",
".",
"Each",
"number",
"can",
"be",
"an",
"integer",
"or",
"None",
"to",
"indicate",
"an",
"unset",
"component",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1325-L1343 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.save | def save(self):
"""Write the object's tags back to the file. May
throw `UnreadableFileError`.
"""
# Possibly save the tags to ID3v2.3.
kwargs = {}
if self.id3v23:
id3 = self.mgfile
if hasattr(id3, 'tags'):
# In case this is an MP3 o... | python | def save(self):
"""Write the object's tags back to the file. May
throw `UnreadableFileError`.
"""
# Possibly save the tags to ID3v2.3.
kwargs = {}
if self.id3v23:
id3 = self.mgfile
if hasattr(id3, 'tags'):
# In case this is an MP3 o... | [
"def",
"save",
"(",
"self",
")",
":",
"# Possibly save the tags to ID3v2.3.",
"kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"id3v23",
":",
"id3",
"=",
"self",
".",
"mgfile",
"if",
"hasattr",
"(",
"id3",
",",
"'tags'",
")",
":",
"# In case this is an MP3 object... | Write the object's tags back to the file. May
throw `UnreadableFileError`. | [
"Write",
"the",
"object",
"s",
"tags",
"back",
"to",
"the",
"file",
".",
"May",
"throw",
"UnreadableFileError",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1492-L1506 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.fields | def fields(cls):
"""Get the names of all writable properties that reflect
metadata tags (i.e., those that are instances of
:class:`MediaField`).
"""
for property, descriptor in cls.__dict__.items():
if isinstance(descriptor, MediaField):
if isinstance(... | python | def fields(cls):
"""Get the names of all writable properties that reflect
metadata tags (i.e., those that are instances of
:class:`MediaField`).
"""
for property, descriptor in cls.__dict__.items():
if isinstance(descriptor, MediaField):
if isinstance(... | [
"def",
"fields",
"(",
"cls",
")",
":",
"for",
"property",
",",
"descriptor",
"in",
"cls",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"descriptor",
",",
"MediaField",
")",
":",
"if",
"isinstance",
"(",
"property",
",",
"bytes... | Get the names of all writable properties that reflect
metadata tags (i.e., those that are instances of
:class:`MediaField`). | [
"Get",
"the",
"names",
"of",
"all",
"writable",
"properties",
"that",
"reflect",
"metadata",
"tags",
"(",
"i",
".",
"e",
".",
"those",
"that",
"are",
"instances",
"of",
":",
"class",
":",
"MediaField",
")",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1517-L1529 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile._field_sort_name | def _field_sort_name(cls, name):
"""Get a sort key for a field name that determines the order
fields should be written in.
Fields names are kept unchanged, unless they are instances of
:class:`DateItemField`, in which case `year`, `month`, and `day`
are replaced by `date0`, `dat... | python | def _field_sort_name(cls, name):
"""Get a sort key for a field name that determines the order
fields should be written in.
Fields names are kept unchanged, unless they are instances of
:class:`DateItemField`, in which case `year`, `month`, and `day`
are replaced by `date0`, `dat... | [
"def",
"_field_sort_name",
"(",
"cls",
",",
"name",
")",
":",
"if",
"isinstance",
"(",
"cls",
".",
"__dict__",
"[",
"name",
"]",
",",
"DateItemField",
")",
":",
"name",
"=",
"re",
".",
"sub",
"(",
"'year'",
",",
"'date0'",
",",
"name",
")",
"name",
... | Get a sort key for a field name that determines the order
fields should be written in.
Fields names are kept unchanged, unless they are instances of
:class:`DateItemField`, in which case `year`, `month`, and `day`
are replaced by `date0`, `date1`, and `date2`, respectively, to
m... | [
"Get",
"a",
"sort",
"key",
"for",
"a",
"field",
"name",
"that",
"determines",
"the",
"order",
"fields",
"should",
"be",
"written",
"in",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1532-L1545 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.sorted_fields | def sorted_fields(cls):
"""Get the names of all writable metadata fields, sorted in the
order that they should be written.
This is a lexicographic order, except for instances of
:class:`DateItemField`, which are sorted in year-month-day
order.
"""
for property in... | python | def sorted_fields(cls):
"""Get the names of all writable metadata fields, sorted in the
order that they should be written.
This is a lexicographic order, except for instances of
:class:`DateItemField`, which are sorted in year-month-day
order.
"""
for property in... | [
"def",
"sorted_fields",
"(",
"cls",
")",
":",
"for",
"property",
"in",
"sorted",
"(",
"cls",
".",
"fields",
"(",
")",
",",
"key",
"=",
"cls",
".",
"_field_sort_name",
")",
":",
"yield",
"property"
] | Get the names of all writable metadata fields, sorted in the
order that they should be written.
This is a lexicographic order, except for instances of
:class:`DateItemField`, which are sorted in year-month-day
order. | [
"Get",
"the",
"names",
"of",
"all",
"writable",
"metadata",
"fields",
"sorted",
"in",
"the",
"order",
"that",
"they",
"should",
"be",
"written",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1548-L1557 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.add_field | def add_field(cls, name, descriptor):
"""Add a field to store custom tags.
:param name: the name of the property the field is accessed
through. It must not already exist on this class.
:param descriptor: an instance of :class:`MediaField`.
"""
if not isinst... | python | def add_field(cls, name, descriptor):
"""Add a field to store custom tags.
:param name: the name of the property the field is accessed
through. It must not already exist on this class.
:param descriptor: an instance of :class:`MediaField`.
"""
if not isinst... | [
"def",
"add_field",
"(",
"cls",
",",
"name",
",",
"descriptor",
")",
":",
"if",
"not",
"isinstance",
"(",
"descriptor",
",",
"MediaField",
")",
":",
"raise",
"ValueError",
"(",
"u'{0} must be an instance of MediaField'",
".",
"format",
"(",
"descriptor",
")",
... | Add a field to store custom tags.
:param name: the name of the property the field is accessed
through. It must not already exist on this class.
:param descriptor: an instance of :class:`MediaField`. | [
"Add",
"a",
"field",
"to",
"store",
"custom",
"tags",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1571-L1585 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.update | def update(self, dict):
"""Set all field values from a dictionary.
For any key in `dict` that is also a field to store tags the
method retrieves the corresponding value from `dict` and updates
the `MediaFile`. If a key has the value `None`, the
corresponding property is deleted ... | python | def update(self, dict):
"""Set all field values from a dictionary.
For any key in `dict` that is also a field to store tags the
method retrieves the corresponding value from `dict` and updates
the `MediaFile`. If a key has the value `None`, the
corresponding property is deleted ... | [
"def",
"update",
"(",
"self",
",",
"dict",
")",
":",
"for",
"field",
"in",
"self",
".",
"sorted_fields",
"(",
")",
":",
"if",
"field",
"in",
"dict",
":",
"if",
"dict",
"[",
"field",
"]",
"is",
"None",
":",
"delattr",
"(",
"self",
",",
"field",
")... | Set all field values from a dictionary.
For any key in `dict` that is also a field to store tags the
method retrieves the corresponding value from `dict` and updates
the `MediaFile`. If a key has the value `None`, the
corresponding property is deleted from the `MediaFile`. | [
"Set",
"all",
"field",
"values",
"from",
"a",
"dictionary",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L1587-L1600 |
Josef-Friedrich/phrydy | phrydy/mediafile.py | MediaFile.samplerate | def samplerate(self):
"""The audio's sample rate (an int)."""
if hasattr(self.mgfile.info, 'sample_rate'):
return self.mgfile.info.sample_rate
elif self.type == 'opus':
# Opus is always 48kHz internally.
return 48000
return 0 | python | def samplerate(self):
"""The audio's sample rate (an int)."""
if hasattr(self.mgfile.info, 'sample_rate'):
return self.mgfile.info.sample_rate
elif self.type == 'opus':
# Opus is always 48kHz internally.
return 48000
return 0 | [
"def",
"samplerate",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"mgfile",
".",
"info",
",",
"'sample_rate'",
")",
":",
"return",
"self",
".",
"mgfile",
".",
"info",
".",
"sample_rate",
"elif",
"self",
".",
"type",
"==",
"'opus'",
":",
... | The audio's sample rate (an int). | [
"The",
"audio",
"s",
"sample",
"rate",
"(",
"an",
"int",
")",
"."
] | train | https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/mediafile.py#L2162-L2169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.