partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Organization.get_datasets | Get list of datasets in organization
Args:
query (str): Restrict datasets returned to this query (in Solr format). Defaults to '*:*'.
**kwargs: See below
sort (string): Sorting of the search results. Defaults to 'relevance asc, metadata_modified desc'.
rows (int)... | src/hdx/data/organization.py | def get_datasets(self, query='*:*', **kwargs):
# type: (str, Any) -> List[hdx.data.dataset.Dataset]
"""Get list of datasets in organization
Args:
query (str): Restrict datasets returned to this query (in Solr format). Defaults to '*:*'.
**kwargs: See below
so... | def get_datasets(self, query='*:*', **kwargs):
# type: (str, Any) -> List[hdx.data.dataset.Dataset]
"""Get list of datasets in organization
Args:
query (str): Restrict datasets returned to this query (in Solr format). Defaults to '*:*'.
**kwargs: See below
so... | [
"Get",
"list",
"of",
"datasets",
"in",
"organization"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/organization.py#L210-L231 | [
"def",
"get_datasets",
"(",
"self",
",",
"query",
"=",
"'*:*'",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, Any) -> List[hdx.data.dataset.Dataset]",
"return",
"hdx",
".",
"data",
".",
"dataset",
".",
"Dataset",
".",
"search_in_hdx",
"(",
"query",
"=",
"q... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Organization.get_all_organization_names | Get all organization names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
sort (str): Sort the search results according to field name and sort-order. Allowed fields are ‘name’, ‘package_count’ an... | src/hdx/data/organization.py | def get_all_organization_names(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List[str]
"""Get all organization names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
... | def get_all_organization_names(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List[str]
"""Get all organization names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
... | [
"Get",
"all",
"organization",
"names",
"in",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/organization.py#L234-L253 | [
"def",
"get_all_organization_names",
"(",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[Configuration], Any) -> List[str]",
"organization",
"=",
"Organization",
"(",
"configuration",
"=",
"configuration",
")",
"organization",
"[",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._read_from_hdx | Makes a read call to HDX passing in given parameter.
Args:
object_type (str): Description of HDX object type (for messages)
value (str): Value of HDX field
fieldname (str): HDX field name. Defaults to id.
action (Optional[str]): Replacement CKAN action url to use... | src/hdx/data/hdxobject.py | def _read_from_hdx(self, object_type, value, fieldname='id',
action=None, **kwargs):
# type: (str, str, str, Optional[str], Any) -> Tuple[bool, Union[Dict, str]]
"""Makes a read call to HDX passing in given parameter.
Args:
object_type (str): Description of HD... | def _read_from_hdx(self, object_type, value, fieldname='id',
action=None, **kwargs):
# type: (str, str, str, Optional[str], Any) -> Tuple[bool, Union[Dict, str]]
"""Makes a read call to HDX passing in given parameter.
Args:
object_type (str): Description of HD... | [
"Makes",
"a",
"read",
"call",
"to",
"HDX",
"passing",
"in",
"given",
"parameter",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L95-L122 | [
"def",
"_read_from_hdx",
"(",
"self",
",",
"object_type",
",",
"value",
",",
"fieldname",
"=",
"'id'",
",",
"action",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, str, str, Optional[str], Any) -> Tuple[bool, Union[Dict, str]]",
"if",
"not",
"fieldn... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._load_from_hdx | Helper method to load the HDX object given by identifier from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field (str): HDX object identifier
Returns:
bool: True if loaded, False if not | src/hdx/data/hdxobject.py | def _load_from_hdx(self, object_type, id_field):
# type: (str, str) -> bool
"""Helper method to load the HDX object given by identifier from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field (str): HDX object identifier
Returns:... | def _load_from_hdx(self, object_type, id_field):
# type: (str, str) -> bool
"""Helper method to load the HDX object given by identifier from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field (str): HDX object identifier
Returns:... | [
"Helper",
"method",
"to",
"load",
"the",
"HDX",
"object",
"given",
"by",
"identifier",
"from",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L124-L141 | [
"def",
"_load_from_hdx",
"(",
"self",
",",
"object_type",
",",
"id_field",
")",
":",
"# type: (str, str) -> bool",
"success",
",",
"result",
"=",
"self",
".",
"_read_from_hdx",
"(",
"object_type",
",",
"id_field",
")",
"if",
"success",
":",
"self",
".",
"old_d... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._check_load_existing_object | Check metadata exists and contains HDX object identifier, and if so load HDX object
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
operation (str): Operation to report if error. Defau... | src/hdx/data/hdxobject.py | def _check_load_existing_object(self, object_type, id_field_name, operation='update'):
# type: (str, str, str) -> None
"""Check metadata exists and contains HDX object identifier, and if so load HDX object
Args:
object_type (str): Description of HDX object type (for messages)
... | def _check_load_existing_object(self, object_type, id_field_name, operation='update'):
# type: (str, str, str) -> None
"""Check metadata exists and contains HDX object identifier, and if so load HDX object
Args:
object_type (str): Description of HDX object type (for messages)
... | [
"Check",
"metadata",
"exists",
"and",
"contains",
"HDX",
"object",
"identifier",
"and",
"if",
"so",
"load",
"HDX",
"object"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L165-L179 | [
"def",
"_check_load_existing_object",
"(",
"self",
",",
"object_type",
",",
"id_field_name",
",",
"operation",
"=",
"'update'",
")",
":",
"# type: (str, str, str) -> None",
"self",
".",
"_check_existing_object",
"(",
"object_type",
",",
"id_field_name",
")",
"if",
"no... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._check_required_fields | Helper method to check that metadata for HDX object is complete
Args:
ignore_fields (List[str]): Any fields to ignore in the check
Returns:
None | src/hdx/data/hdxobject.py | def _check_required_fields(self, object_type, ignore_fields):
# type: (str, List[str]) -> None
"""Helper method to check that metadata for HDX object is complete
Args:
ignore_fields (List[str]): Any fields to ignore in the check
Returns:
None
"""
... | def _check_required_fields(self, object_type, ignore_fields):
# type: (str, List[str]) -> None
"""Helper method to check that metadata for HDX object is complete
Args:
ignore_fields (List[str]): Any fields to ignore in the check
Returns:
None
"""
... | [
"Helper",
"method",
"to",
"check",
"that",
"metadata",
"for",
"HDX",
"object",
"is",
"complete"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L195-L207 | [
"def",
"_check_required_fields",
"(",
"self",
",",
"object_type",
",",
"ignore_fields",
")",
":",
"# type: (str, List[str]) -> None",
"for",
"field",
"in",
"self",
".",
"configuration",
"[",
"object_type",
"]",
"[",
"'required_fields'",
"]",
":",
"if",
"field",
"n... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._merge_hdx_update | Helper method to check if HDX object exists and update it
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
file_to_upload (Optional[str]): File to upload to HDX
**kwargs: Se... | src/hdx/data/hdxobject.py | def _merge_hdx_update(self, object_type, id_field_name, file_to_upload=None, **kwargs):
# type: (str, str, Optional[str], Any) -> None
"""Helper method to check if HDX object exists and update it
Args:
object_type (str): Description of HDX object type (for messages)
id_f... | def _merge_hdx_update(self, object_type, id_field_name, file_to_upload=None, **kwargs):
# type: (str, str, Optional[str], Any) -> None
"""Helper method to check if HDX object exists and update it
Args:
object_type (str): Description of HDX object type (for messages)
id_f... | [
"Helper",
"method",
"to",
"check",
"if",
"HDX",
"object",
"exists",
"and",
"update",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L209-L231 | [
"def",
"_merge_hdx_update",
"(",
"self",
",",
"object_type",
",",
"id_field_name",
",",
"file_to_upload",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, str, Optional[str], Any) -> None",
"merge_two_dictionaries",
"(",
"self",
".",
"data",
",",
"self... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._update_in_hdx | Helper method to check if HDX object exists in HDX and if so, update it
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
file_to_upload (Optional[str]): File to upload to HDX
... | src/hdx/data/hdxobject.py | def _update_in_hdx(self, object_type, id_field_name, file_to_upload=None, **kwargs):
# type: (str, str, Optional[str], Any) -> None
"""Helper method to check if HDX object exists in HDX and if so, update it
Args:
object_type (str): Description of HDX object type (for messages)
... | def _update_in_hdx(self, object_type, id_field_name, file_to_upload=None, **kwargs):
# type: (str, str, Optional[str], Any) -> None
"""Helper method to check if HDX object exists in HDX and if so, update it
Args:
object_type (str): Description of HDX object type (for messages)
... | [
"Helper",
"method",
"to",
"check",
"if",
"HDX",
"object",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L243-L262 | [
"def",
"_update_in_hdx",
"(",
"self",
",",
"object_type",
",",
"id_field_name",
",",
"file_to_upload",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, str, Optional[str], Any) -> None",
"self",
".",
"_check_load_existing_object",
"(",
"object_type",
","... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._write_to_hdx | Creates or updates an HDX object in HDX and return HDX object metadata dict
Args:
action (str): Action to perform eg. 'create', 'update'
data (Dict): Data to write to HDX
id_field_name (str): Name of field containing HDX object identifier or None
file_to_upload (... | src/hdx/data/hdxobject.py | def _write_to_hdx(self, action, data, id_field_name, file_to_upload=None):
# type: (str, Dict, str, Optional[str]) -> Dict
"""Creates or updates an HDX object in HDX and return HDX object metadata dict
Args:
action (str): Action to perform eg. 'create', 'update'
data (Di... | def _write_to_hdx(self, action, data, id_field_name, file_to_upload=None):
# type: (str, Dict, str, Optional[str]) -> Dict
"""Creates or updates an HDX object in HDX and return HDX object metadata dict
Args:
action (str): Action to perform eg. 'create', 'update'
data (Di... | [
"Creates",
"or",
"updates",
"an",
"HDX",
"object",
"in",
"HDX",
"and",
"return",
"HDX",
"object",
"metadata",
"dict"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L264-L289 | [
"def",
"_write_to_hdx",
"(",
"self",
",",
"action",
",",
"data",
",",
"id_field_name",
",",
"file_to_upload",
"=",
"None",
")",
":",
"# type: (str, Dict, str, Optional[str]) -> Dict",
"file",
"=",
"None",
"try",
":",
"if",
"file_to_upload",
":",
"file",
"=",
"op... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._save_to_hdx | Creates or updates an HDX object in HDX, saving current data and replacing with returned HDX object data
from HDX
Args:
action (str): Action to perform: 'create' or 'update'
id_field_name (str): Name of field containing HDX object identifier
file_to_upload (Optional[... | src/hdx/data/hdxobject.py | def _save_to_hdx(self, action, id_field_name, file_to_upload=None):
# type: (str, str, Optional[str]) -> None
"""Creates or updates an HDX object in HDX, saving current data and replacing with returned HDX object data
from HDX
Args:
action (str): Action to perform: 'create' ... | def _save_to_hdx(self, action, id_field_name, file_to_upload=None):
# type: (str, str, Optional[str]) -> None
"""Creates or updates an HDX object in HDX, saving current data and replacing with returned HDX object data
from HDX
Args:
action (str): Action to perform: 'create' ... | [
"Creates",
"or",
"updates",
"an",
"HDX",
"object",
"in",
"HDX",
"saving",
"current",
"data",
"and",
"replacing",
"with",
"returned",
"HDX",
"object",
"data",
"from",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L291-L306 | [
"def",
"_save_to_hdx",
"(",
"self",
",",
"action",
",",
"id_field_name",
",",
"file_to_upload",
"=",
"None",
")",
":",
"# type: (str, str, Optional[str]) -> None",
"result",
"=",
"self",
".",
"_write_to_hdx",
"(",
"action",
",",
"self",
".",
"data",
",",
"id_fie... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._create_in_hdx | Helper method to check if resource exists in HDX and if so, update it, otherwise create it
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
name_field_name (str): Name of field contain... | src/hdx/data/hdxobject.py | def _create_in_hdx(self, object_type, id_field_name, name_field_name,
file_to_upload=None):
# type: (str, str, str, Optional[str]) -> None
"""Helper method to check if resource exists in HDX and if so, update it, otherwise create it
Args:
object_type (str): D... | def _create_in_hdx(self, object_type, id_field_name, name_field_name,
file_to_upload=None):
# type: (str, str, str, Optional[str]) -> None
"""Helper method to check if resource exists in HDX and if so, update it, otherwise create it
Args:
object_type (str): D... | [
"Helper",
"method",
"to",
"check",
"if",
"resource",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L318-L338 | [
"def",
"_create_in_hdx",
"(",
"self",
",",
"object_type",
",",
"id_field_name",
",",
"name_field_name",
",",
"file_to_upload",
"=",
"None",
")",
":",
"# type: (str, str, str, Optional[str]) -> None",
"self",
".",
"check_required_fields",
"(",
")",
"if",
"id_field_name",... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._delete_from_hdx | Helper method to deletes a resource from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
Returns:
None | src/hdx/data/hdxobject.py | def _delete_from_hdx(self, object_type, id_field_name):
# type: (str, str) -> None
"""Helper method to deletes a resource from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
... | def _delete_from_hdx(self, object_type, id_field_name):
# type: (str, str) -> None
"""Helper method to deletes a resource from HDX
Args:
object_type (str): Description of HDX object type (for messages)
id_field_name (str): Name of field containing HDX object identifier
... | [
"Helper",
"method",
"to",
"deletes",
"a",
"resource",
"from",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L350-L363 | [
"def",
"_delete_from_hdx",
"(",
"self",
",",
"object_type",
",",
"id_field_name",
")",
":",
"# type: (str, str) -> None",
"if",
"id_field_name",
"not",
"in",
"self",
".",
"data",
":",
"raise",
"HDXError",
"(",
"'No %s field (mandatory) in %s!'",
"%",
"(",
"id_field_... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._addupdate_hdxobject | Helper function to add a new HDX object to a supplied list of HDX objects or update existing metadata if the object
already exists in the list
Args:
hdxobjects (List[T <= HDXObject]): list of HDX objects to which to add new objects or update existing ones
id_field (str): Field o... | src/hdx/data/hdxobject.py | def _addupdate_hdxobject(self, hdxobjects, id_field, new_hdxobject):
# type: (List[HDXObjectUpperBound], str, HDXObjectUpperBound) -> HDXObjectUpperBound
"""Helper function to add a new HDX object to a supplied list of HDX objects or update existing metadata if the object
already exists in the l... | def _addupdate_hdxobject(self, hdxobjects, id_field, new_hdxobject):
# type: (List[HDXObjectUpperBound], str, HDXObjectUpperBound) -> HDXObjectUpperBound
"""Helper function to add a new HDX object to a supplied list of HDX objects or update existing metadata if the object
already exists in the l... | [
"Helper",
"function",
"to",
"add",
"a",
"new",
"HDX",
"object",
"to",
"a",
"supplied",
"list",
"of",
"HDX",
"objects",
"or",
"update",
"existing",
"metadata",
"if",
"the",
"object",
"already",
"exists",
"in",
"the",
"list"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L365-L383 | [
"def",
"_addupdate_hdxobject",
"(",
"self",
",",
"hdxobjects",
",",
"id_field",
",",
"new_hdxobject",
")",
":",
"# type: (List[HDXObjectUpperBound], str, HDXObjectUpperBound) -> HDXObjectUpperBound",
"for",
"hdxobject",
"in",
"hdxobjects",
":",
"if",
"hdxobject",
"[",
"id_f... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._remove_hdxobject | Remove an HDX object from a list within the parent HDX object
Args:
objlist (List[Union[T <= HDXObject,Dict]]): list of HDX objects
obj (Union[T <= HDXObject,Dict,str]): Either an id or hdx object metadata either from an HDX object or a dictionary
matchon (str): Field to mat... | src/hdx/data/hdxobject.py | def _remove_hdxobject(self, objlist, obj, matchon='id', delete=False):
# type: (List[Union[HDXObjectUpperBound,Dict]], Union[HDXObjectUpperBound,Dict,str], str, bool) -> bool
"""Remove an HDX object from a list within the parent HDX object
Args:
objlist (List[Union[T <= HDXObject,Di... | def _remove_hdxobject(self, objlist, obj, matchon='id', delete=False):
# type: (List[Union[HDXObjectUpperBound,Dict]], Union[HDXObjectUpperBound,Dict,str], str, bool) -> bool
"""Remove an HDX object from a list within the parent HDX object
Args:
objlist (List[Union[T <= HDXObject,Di... | [
"Remove",
"an",
"HDX",
"object",
"from",
"a",
"list",
"within",
"the",
"parent",
"HDX",
"object"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L385-L415 | [
"def",
"_remove_hdxobject",
"(",
"self",
",",
"objlist",
",",
"obj",
",",
"matchon",
"=",
"'id'",
",",
"delete",
"=",
"False",
")",
":",
"# type: (List[Union[HDXObjectUpperBound,Dict]], Union[HDXObjectUpperBound,Dict,str], str, bool) -> bool",
"if",
"objlist",
"is",
"None... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._convert_hdxobjects | Helper function to convert supplied list of HDX objects to a list of dict
Args:
hdxobjects (List[T <= HDXObject]): List of HDX objects to convert
Returns:
List[Dict]: List of HDX objects converted to simple dictionaries | src/hdx/data/hdxobject.py | def _convert_hdxobjects(self, hdxobjects):
# type: (List[HDXObjectUpperBound]) -> List[HDXObjectUpperBound]
"""Helper function to convert supplied list of HDX objects to a list of dict
Args:
hdxobjects (List[T <= HDXObject]): List of HDX objects to convert
Returns:
... | def _convert_hdxobjects(self, hdxobjects):
# type: (List[HDXObjectUpperBound]) -> List[HDXObjectUpperBound]
"""Helper function to convert supplied list of HDX objects to a list of dict
Args:
hdxobjects (List[T <= HDXObject]): List of HDX objects to convert
Returns:
... | [
"Helper",
"function",
"to",
"convert",
"supplied",
"list",
"of",
"HDX",
"objects",
"to",
"a",
"list",
"of",
"dict"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L417-L430 | [
"def",
"_convert_hdxobjects",
"(",
"self",
",",
"hdxobjects",
")",
":",
"# type: (List[HDXObjectUpperBound]) -> List[HDXObjectUpperBound]",
"newhdxobjects",
"=",
"list",
"(",
")",
"for",
"hdxobject",
"in",
"hdxobjects",
":",
"newhdxobjects",
".",
"append",
"(",
"hdxobje... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._copy_hdxobjects | Helper function to make a deep copy of a supplied list of HDX objects
Args:
hdxobjects (List[T <= HDXObject]): list of HDX objects to copy
hdxobjectclass (type): Type of the HDX Objects to be copied
attribute_to_copy (Optional[str]): An attribute to copy over from the HDX ob... | src/hdx/data/hdxobject.py | def _copy_hdxobjects(self, hdxobjects, hdxobjectclass, attribute_to_copy=None):
# type: (List[HDXObjectUpperBound], type, Optional[str]) -> List[HDXObjectUpperBound]
"""Helper function to make a deep copy of a supplied list of HDX objects
Args:
hdxobjects (List[T <= HDXObject]): lis... | def _copy_hdxobjects(self, hdxobjects, hdxobjectclass, attribute_to_copy=None):
# type: (List[HDXObjectUpperBound], type, Optional[str]) -> List[HDXObjectUpperBound]
"""Helper function to make a deep copy of a supplied list of HDX objects
Args:
hdxobjects (List[T <= HDXObject]): lis... | [
"Helper",
"function",
"to",
"make",
"a",
"deep",
"copy",
"of",
"a",
"supplied",
"list",
"of",
"HDX",
"objects"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L432-L452 | [
"def",
"_copy_hdxobjects",
"(",
"self",
",",
"hdxobjects",
",",
"hdxobjectclass",
",",
"attribute_to_copy",
"=",
"None",
")",
":",
"# type: (List[HDXObjectUpperBound], type, Optional[str]) -> List[HDXObjectUpperBound]",
"newhdxobjects",
"=",
"list",
"(",
")",
"for",
"hdxobj... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._separate_hdxobjects | Helper function to take a list of HDX objects contained in the internal dictionary and add them to a
supplied list of HDX objects or update existing metadata if any objects already exist in the list. The list in
the internal dictionary is then deleted.
Args:
hdxobjects (List[T <= HD... | src/hdx/data/hdxobject.py | def _separate_hdxobjects(self, hdxobjects, hdxobjects_name, id_field, hdxobjectclass):
# type: (List[HDXObjectUpperBound], str, str, type) -> None
"""Helper function to take a list of HDX objects contained in the internal dictionary and add them to a
supplied list of HDX objects or update existi... | def _separate_hdxobjects(self, hdxobjects, hdxobjects_name, id_field, hdxobjectclass):
# type: (List[HDXObjectUpperBound], str, str, type) -> None
"""Helper function to take a list of HDX objects contained in the internal dictionary and add them to a
supplied list of HDX objects or update existi... | [
"Helper",
"function",
"to",
"take",
"a",
"list",
"of",
"HDX",
"objects",
"contained",
"in",
"the",
"internal",
"dictionary",
"and",
"add",
"them",
"to",
"a",
"supplied",
"list",
"of",
"HDX",
"objects",
"or",
"update",
"existing",
"metadata",
"if",
"any",
"... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L454-L483 | [
"def",
"_separate_hdxobjects",
"(",
"self",
",",
"hdxobjects",
",",
"hdxobjects_name",
",",
"id_field",
",",
"hdxobjectclass",
")",
":",
"# type: (List[HDXObjectUpperBound], str, str, type) -> None",
"new_hdxobjects",
"=",
"self",
".",
"data",
".",
"get",
"(",
"hdxobjec... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._get_tags | Return the dataset's list of tags
Returns:
List[str]: list of tags or [] if there are none | src/hdx/data/hdxobject.py | def _get_tags(self):
# type: () -> List[str]
"""Return the dataset's list of tags
Returns:
List[str]: list of tags or [] if there are none
"""
tags = self.data.get('tags', None)
if not tags:
return list()
return [x['name'] for x in tags] | def _get_tags(self):
# type: () -> List[str]
"""Return the dataset's list of tags
Returns:
List[str]: list of tags or [] if there are none
"""
tags = self.data.get('tags', None)
if not tags:
return list()
return [x['name'] for x in tags] | [
"Return",
"the",
"dataset",
"s",
"list",
"of",
"tags"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L485-L495 | [
"def",
"_get_tags",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"tags",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'tags'",
",",
"None",
")",
"if",
"not",
"tags",
":",
"return",
"list",
"(",
")",
"return",
"[",
"x",
"[",
"'name'",
"]",
"for",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._add_tag | Add a tag
Args:
tag (str): Tag to add
Returns:
bool: True if tag added or False if tag already present | src/hdx/data/hdxobject.py | def _add_tag(self, tag):
# type: (str) -> bool
"""Add a tag
Args:
tag (str): Tag to add
Returns:
bool: True if tag added or False if tag already present
"""
tags = self.data.get('tags', None)
if tags:
if tag in [x['name'] for ... | def _add_tag(self, tag):
# type: (str) -> bool
"""Add a tag
Args:
tag (str): Tag to add
Returns:
bool: True if tag added or False if tag already present
"""
tags = self.data.get('tags', None)
if tags:
if tag in [x['name'] for ... | [
"Add",
"a",
"tag"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L497-L515 | [
"def",
"_add_tag",
"(",
"self",
",",
"tag",
")",
":",
"# type: (str) -> bool",
"tags",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'tags'",
",",
"None",
")",
"if",
"tags",
":",
"if",
"tag",
"in",
"[",
"x",
"[",
"'name'",
"]",
"for",
"x",
"in",
"t... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._add_tags | Add a list of tag
Args:
tags (List[str]): list of tags to add
Returns:
bool: True if all tags added or False if any already present. | src/hdx/data/hdxobject.py | def _add_tags(self, tags):
# type: (List[str]) -> bool
"""Add a list of tag
Args:
tags (List[str]): list of tags to add
Returns:
bool: True if all tags added or False if any already present.
"""
alltagsadded = True
for tag in tags:
... | def _add_tags(self, tags):
# type: (List[str]) -> bool
"""Add a list of tag
Args:
tags (List[str]): list of tags to add
Returns:
bool: True if all tags added or False if any already present.
"""
alltagsadded = True
for tag in tags:
... | [
"Add",
"a",
"list",
"of",
"tag"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L517-L531 | [
"def",
"_add_tags",
"(",
"self",
",",
"tags",
")",
":",
"# type: (List[str]) -> bool",
"alltagsadded",
"=",
"True",
"for",
"tag",
"in",
"tags",
":",
"if",
"not",
"self",
".",
"_add_tag",
"(",
"tag",
")",
":",
"alltagsadded",
"=",
"False",
"return",
"alltag... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._get_stringlist_from_commastring | Return list of strings from comma separated list
Args:
field (str): Field containing comma separated list
Returns:
List[str]: List of strings | src/hdx/data/hdxobject.py | def _get_stringlist_from_commastring(self, field):
# type: (str) -> List[str]
"""Return list of strings from comma separated list
Args:
field (str): Field containing comma separated list
Returns:
List[str]: List of strings
"""
strings = self.data... | def _get_stringlist_from_commastring(self, field):
# type: (str) -> List[str]
"""Return list of strings from comma separated list
Args:
field (str): Field containing comma separated list
Returns:
List[str]: List of strings
"""
strings = self.data... | [
"Return",
"list",
"of",
"strings",
"from",
"comma",
"separated",
"list"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L533-L547 | [
"def",
"_get_stringlist_from_commastring",
"(",
"self",
",",
"field",
")",
":",
"# type: (str) -> List[str]",
"strings",
"=",
"self",
".",
"data",
".",
"get",
"(",
"field",
")",
"if",
"strings",
":",
"return",
"strings",
".",
"split",
"(",
"','",
")",
"else"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._add_string_to_commastring | Add a string to a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to add
Returns:
bool: True if string added or False if string already present | src/hdx/data/hdxobject.py | def _add_string_to_commastring(self, field, string):
# type: (str, str) -> bool
"""Add a string to a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to add
Returns:
bool: True if string ad... | def _add_string_to_commastring(self, field, string):
# type: (str, str) -> bool
"""Add a string to a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to add
Returns:
bool: True if string ad... | [
"Add",
"a",
"string",
"to",
"a",
"comma",
"separated",
"list",
"of",
"strings"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L549-L566 | [
"def",
"_add_string_to_commastring",
"(",
"self",
",",
"field",
",",
"string",
")",
":",
"# type: (str, str) -> bool",
"if",
"string",
"in",
"self",
".",
"_get_stringlist_from_commastring",
"(",
"field",
")",
":",
"return",
"False",
"strings",
"=",
"'%s,%s'",
"%",... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._add_strings_to_commastring | Add a list of strings to a comma separated list of strings
Args:
field (str): Field containing comma separated list
strings (List[str]): list of strings to add
Returns:
bool: True if all strings added or False if any already present. | src/hdx/data/hdxobject.py | def _add_strings_to_commastring(self, field, strings):
# type: (str, List[str]) -> bool
"""Add a list of strings to a comma separated list of strings
Args:
field (str): Field containing comma separated list
strings (List[str]): list of strings to add
Returns:
... | def _add_strings_to_commastring(self, field, strings):
# type: (str, List[str]) -> bool
"""Add a list of strings to a comma separated list of strings
Args:
field (str): Field containing comma separated list
strings (List[str]): list of strings to add
Returns:
... | [
"Add",
"a",
"list",
"of",
"strings",
"to",
"a",
"comma",
"separated",
"list",
"of",
"strings"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L568-L583 | [
"def",
"_add_strings_to_commastring",
"(",
"self",
",",
"field",
",",
"strings",
")",
":",
"# type: (str, List[str]) -> bool",
"allstringsadded",
"=",
"True",
"for",
"string",
"in",
"strings",
":",
"if",
"not",
"self",
".",
"_add_string_to_commastring",
"(",
"field"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | HDXObject._remove_string_from_commastring | Remove a string from a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to remove
Returns:
bool: True if string removed or False if not | src/hdx/data/hdxobject.py | def _remove_string_from_commastring(self, field, string):
# type: (str, str) -> bool
"""Remove a string from a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to remove
Returns:
bool: True... | def _remove_string_from_commastring(self, field, string):
# type: (str, str) -> bool
"""Remove a string from a comma separated list of strings
Args:
field (str): Field containing comma separated list
string (str): String to remove
Returns:
bool: True... | [
"Remove",
"a",
"string",
"from",
"a",
"comma",
"separated",
"list",
"of",
"strings"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/hdxobject.py#L585-L600 | [
"def",
"_remove_string_from_commastring",
"(",
"self",
",",
"field",
",",
"string",
")",
":",
"# type: (str, str) -> bool",
"commastring",
"=",
"self",
".",
"data",
".",
"get",
"(",
"field",
",",
"''",
")",
"if",
"string",
"in",
"commastring",
":",
"self",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.read_from_hdx | Reads the resource given by identifier from HDX and returns Resource object
Args:
identifier (str): Identifier of resource
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
Optional[Resource]: Resource object if s... | src/hdx/data/resource.py | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Resource']
"""Reads the resource given by identifier from HDX and returns Resource object
Args:
identifier (str): Identifier of resource
configuration (Optional[Configu... | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Resource']
"""Reads the resource given by identifier from HDX and returns Resource object
Args:
identifier (str): Identifier of resource
configuration (Optional[Configu... | [
"Reads",
"the",
"resource",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"Resource",
"object"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L83-L101 | [
"def",
"read_from_hdx",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> Optional['Resource']",
"if",
"is_valid_uuid",
"(",
"identifier",
")",
"is",
"False",
":",
"raise",
"HDXError",
"(",
"'%s is not a valid resou... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.set_file_to_upload | Delete any existing url and set the file uploaded to the local path provided
Args:
file_to_upload (str): Local path to file to upload
Returns:
None | src/hdx/data/resource.py | def set_file_to_upload(self, file_to_upload):
# type: (str) -> None
"""Delete any existing url and set the file uploaded to the local path provided
Args:
file_to_upload (str): Local path to file to upload
Returns:
None
"""
if 'url' in self.data:
... | def set_file_to_upload(self, file_to_upload):
# type: (str) -> None
"""Delete any existing url and set the file uploaded to the local path provided
Args:
file_to_upload (str): Local path to file to upload
Returns:
None
"""
if 'url' in self.data:
... | [
"Delete",
"any",
"existing",
"url",
"and",
"set",
"the",
"file",
"uploaded",
"to",
"the",
"local",
"path",
"provided"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L133-L145 | [
"def",
"set_file_to_upload",
"(",
"self",
",",
"file_to_upload",
")",
":",
"# type: (str) -> None",
"if",
"'url'",
"in",
"self",
".",
"data",
":",
"del",
"self",
".",
"data",
"[",
"'url'",
"]",
"self",
".",
"file_to_upload",
"=",
"file_to_upload"
] | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.check_url_filetoupload | Check if url or file to upload provided for resource and add resource_type and url_type if not supplied
Returns:
None | src/hdx/data/resource.py | def check_url_filetoupload(self):
# type: () -> None
"""Check if url or file to upload provided for resource and add resource_type and url_type if not supplied
Returns:
None
"""
if self.file_to_upload is None:
if 'url' in self.data:
if 're... | def check_url_filetoupload(self):
# type: () -> None
"""Check if url or file to upload provided for resource and add resource_type and url_type if not supplied
Returns:
None
"""
if self.file_to_upload is None:
if 'url' in self.data:
if 're... | [
"Check",
"if",
"url",
"or",
"file",
"to",
"upload",
"provided",
"for",
"resource",
"and",
"add",
"resource_type",
"and",
"url_type",
"if",
"not",
"supplied"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L147-L171 | [
"def",
"check_url_filetoupload",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"self",
".",
"file_to_upload",
"is",
"None",
":",
"if",
"'url'",
"in",
"self",
".",
"data",
":",
"if",
"'resource_type'",
"not",
"in",
"self",
".",
"data",
":",
"self",
"."... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.update_in_hdx | Check if resource exists in HDX and if so, update it
Args:
**kwargs: See below
operation (string): Operation to perform eg. patch. Defaults to update.
Returns:
None | src/hdx/data/resource.py | def update_in_hdx(self, **kwargs):
# type: (Any) -> None
"""Check if resource exists in HDX and if so, update it
Args:
**kwargs: See below
operation (string): Operation to perform eg. patch. Defaults to update.
Returns:
None
"""
self.... | def update_in_hdx(self, **kwargs):
# type: (Any) -> None
"""Check if resource exists in HDX and if so, update it
Args:
**kwargs: See below
operation (string): Operation to perform eg. patch. Defaults to update.
Returns:
None
"""
self.... | [
"Check",
"if",
"resource",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L187-L201 | [
"def",
"update_in_hdx",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Any) -> None",
"self",
".",
"_check_load_existing_object",
"(",
"'resource'",
",",
"'id'",
")",
"if",
"self",
".",
"file_to_upload",
"and",
"'url'",
"in",
"self",
".",
"data",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_in_hdx | Check if resource exists in HDX and if so, update it, otherwise create it
Returns:
None | src/hdx/data/resource.py | def create_in_hdx(self):
# type: () -> None
"""Check if resource exists in HDX and if so, update it, otherwise create it
Returns:
None
"""
self.check_required_fields()
id = self.data.get('id')
if id and self._load_from_hdx('resource', id):
... | def create_in_hdx(self):
# type: () -> None
"""Check if resource exists in HDX and if so, update it, otherwise create it
Returns:
None
"""
self.check_required_fields()
id = self.data.get('id')
if id and self._load_from_hdx('resource', id):
... | [
"Check",
"if",
"resource",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L203-L218 | [
"def",
"create_in_hdx",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"check_required_fields",
"(",
")",
"id",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'id'",
")",
"if",
"id",
"and",
"self",
".",
"_load_from_hdx",
"(",
"'resource'",
",",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.get_dataset | Return dataset containing this resource
Returns:
hdx.data.dataset.Dataset: Dataset containing this resource | src/hdx/data/resource.py | def get_dataset(self):
# type: () -> hdx.data.dataset.Dataset
"""Return dataset containing this resource
Returns:
hdx.data.dataset.Dataset: Dataset containing this resource
"""
package_id = self.data.get('package_id')
if package_id is None:
raise ... | def get_dataset(self):
# type: () -> hdx.data.dataset.Dataset
"""Return dataset containing this resource
Returns:
hdx.data.dataset.Dataset: Dataset containing this resource
"""
package_id = self.data.get('package_id')
if package_id is None:
raise ... | [
"Return",
"dataset",
"containing",
"this",
"resource"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L229-L239 | [
"def",
"get_dataset",
"(",
"self",
")",
":",
"# type: () -> hdx.data.dataset.Dataset",
"package_id",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'package_id'",
")",
"if",
"package_id",
"is",
"None",
":",
"raise",
"HDXError",
"(",
"'Resource has no package id!'",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.search_in_hdx | Searches for resources in HDX. NOTE: Does not search dataset metadata!
Args:
query (str): Query
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
order_by (str): A field on the Resource model that or... | src/hdx/data/resource.py | def search_in_hdx(query, configuration=None, **kwargs):
# type: (str, Optional[Configuration], Any) -> List['Resource']
"""Searches for resources in HDX. NOTE: Does not search dataset metadata!
Args:
query (str): Query
configuration (Optional[Configuration]): HDX configu... | def search_in_hdx(query, configuration=None, **kwargs):
# type: (str, Optional[Configuration], Any) -> List['Resource']
"""Searches for resources in HDX. NOTE: Does not search dataset metadata!
Args:
query (str): Query
configuration (Optional[Configuration]): HDX configu... | [
"Searches",
"for",
"resources",
"in",
"HDX",
".",
"NOTE",
":",
"Does",
"not",
"search",
"dataset",
"metadata!"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L242-L268 | [
"def",
"search_in_hdx",
"(",
"query",
",",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, Optional[Configuration], Any) -> List['Resource']",
"resources",
"=",
"[",
"]",
"resource",
"=",
"Resource",
"(",
"configuration",
"=",
"config... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.download | Download resource store to provided folder or temporary folder if no folder supplied
Args:
folder (Optional[str]): Folder to download resource to. Defaults to None.
Returns:
Tuple[str, str]: (URL downloaded, Path to downloaded file) | src/hdx/data/resource.py | def download(self, folder=None):
# type: (Optional[str]) -> Tuple[str, str]
"""Download resource store to provided folder or temporary folder if no folder supplied
Args:
folder (Optional[str]): Folder to download resource to. Defaults to None.
Returns:
Tuple[str... | def download(self, folder=None):
# type: (Optional[str]) -> Tuple[str, str]
"""Download resource store to provided folder or temporary folder if no folder supplied
Args:
folder (Optional[str]): Folder to download resource to. Defaults to None.
Returns:
Tuple[str... | [
"Download",
"resource",
"store",
"to",
"provided",
"folder",
"or",
"temporary",
"folder",
"if",
"no",
"folder",
"supplied"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L270-L292 | [
"def",
"download",
"(",
"self",
",",
"folder",
"=",
"None",
")",
":",
"# type: (Optional[str]) -> Tuple[str, str]",
"# Download the resource",
"url",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'url'",
",",
"None",
")",
"if",
"not",
"url",
":",
"raise",
"HDX... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.get_all_resource_ids_in_datastore | Get list of resources that have a datastore returning their ids.
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
List[str]: List of resource ids that are in the datastore | src/hdx/data/resource.py | def get_all_resource_ids_in_datastore(configuration=None):
# type: (Optional[Configuration]) -> List[str]
"""Get list of resources that have a datastore returning their ids.
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
... | def get_all_resource_ids_in_datastore(configuration=None):
# type: (Optional[Configuration]) -> List[str]
"""Get list of resources that have a datastore returning their ids.
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
... | [
"Get",
"list",
"of",
"resources",
"that",
"have",
"a",
"datastore",
"returning",
"their",
"ids",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L295-L314 | [
"def",
"get_all_resource_ids_in_datastore",
"(",
"configuration",
"=",
"None",
")",
":",
"# type: (Optional[Configuration]) -> List[str]",
"resource",
"=",
"Resource",
"(",
"configuration",
"=",
"configuration",
")",
"success",
",",
"result",
"=",
"resource",
".",
"_rea... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.has_datastore | Check if the resource has a datastore.
Returns:
bool: Whether the resource has a datastore or not | src/hdx/data/resource.py | def has_datastore(self):
# type: () -> bool
"""Check if the resource has a datastore.
Returns:
bool: Whether the resource has a datastore or not
"""
success, result = self._read_from_hdx('datastore', self.data['id'], 'resource_id',
... | def has_datastore(self):
# type: () -> bool
"""Check if the resource has a datastore.
Returns:
bool: Whether the resource has a datastore or not
"""
success, result = self._read_from_hdx('datastore', self.data['id'], 'resource_id',
... | [
"Check",
"if",
"the",
"resource",
"has",
"a",
"datastore",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L316-L330 | [
"def",
"has_datastore",
"(",
"self",
")",
":",
"# type: () -> bool",
"success",
",",
"result",
"=",
"self",
".",
"_read_from_hdx",
"(",
"'datastore'",
",",
"self",
".",
"data",
"[",
"'id'",
"]",
",",
"'resource_id'",
",",
"self",
".",
"actions",
"(",
")",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.delete_datastore | Delete a resource from the HDX datastore
Returns:
None | src/hdx/data/resource.py | def delete_datastore(self):
# type: () -> None
"""Delete a resource from the HDX datastore
Returns:
None
"""
success, result = self._read_from_hdx('datastore', self.data['id'], 'resource_id',
self.actions()['datastore_del... | def delete_datastore(self):
# type: () -> None
"""Delete a resource from the HDX datastore
Returns:
None
"""
success, result = self._read_from_hdx('datastore', self.data['id'], 'resource_id',
self.actions()['datastore_del... | [
"Delete",
"a",
"resource",
"from",
"the",
"HDX",
"datastore"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L332-L343 | [
"def",
"delete_datastore",
"(",
"self",
")",
":",
"# type: () -> None",
"success",
",",
"result",
"=",
"self",
".",
"_read_from_hdx",
"(",
"'datastore'",
",",
"self",
".",
"data",
"[",
"'id'",
"]",
",",
"'resource_id'",
",",
"self",
".",
"actions",
"(",
")... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_datastore | For tabular data, create a resource in the HDX datastore which enables data preview in HDX. If no schema is provided
all fields are assumed to be text. If path is not supplied, the file is first downloaded from HDX.
Args:
schema (List[Dict]): List of fields and types of form {'id': 'FIELD',... | src/hdx/data/resource.py | def create_datastore(self, schema=None, primary_key=None,
delete_first=0, path=None):
# type: (Optional[List[Dict]], Optional[str], int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX. If no schema is provided... | def create_datastore(self, schema=None, primary_key=None,
delete_first=0, path=None):
# type: (Optional[List[Dict]], Optional[str], int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX. If no schema is provided... | [
"For",
"tabular",
"data",
"create",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
".",
"If",
"no",
"schema",
"is",
"provided",
"all",
"fields",
"are",
"assumed",
"to",
"be",
"text",
".",
"If",
"path... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L345-L418 | [
"def",
"create_datastore",
"(",
"self",
",",
"schema",
"=",
"None",
",",
"primary_key",
"=",
"None",
",",
"delete_first",
"=",
"0",
",",
"path",
"=",
"None",
")",
":",
"# type: (Optional[List[Dict]], Optional[str], int, Optional[str]) -> None",
"if",
"delete_first",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_datastore_from_dict_schema | For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a dictionary
containing a list of fields and types of form {'id': 'FIELD', 'type': 'TYPE'} and optionally a primary key.
If path is not supplied, the file is first downloaded from HDX.
Args:
... | src/hdx/data/resource.py | def create_datastore_from_dict_schema(self, data, delete_first=0, path=None):
# type: (dict, int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a dictionary
containing a list of fields and types of form {'id': 'FIELD', '... | def create_datastore_from_dict_schema(self, data, delete_first=0, path=None):
# type: (dict, int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a dictionary
containing a list of fields and types of form {'id': 'FIELD', '... | [
"For",
"tabular",
"data",
"create",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
"from",
"a",
"dictionary",
"containing",
"a",
"list",
"of",
"fields",
"and",
"types",
"of",
"form",
"{",
"id",
":",
... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L420-L436 | [
"def",
"create_datastore_from_dict_schema",
"(",
"self",
",",
"data",
",",
"delete_first",
"=",
"0",
",",
"path",
"=",
"None",
")",
":",
"# type: (dict, int, Optional[str]) -> None",
"schema",
"=",
"data",
"[",
"'schema'",
"]",
"primary_key",
"=",
"data",
".",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_datastore_from_yaml_schema | For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a YAML file
containing a list of fields and types of form {'id': 'FIELD', 'type': 'TYPE'} and optionally a primary key.
If path is not supplied, the file is first downloaded from HDX.
Args:
... | src/hdx/data/resource.py | def create_datastore_from_yaml_schema(self, yaml_path, delete_first=0,
path=None):
# type: (str, Optional[int], Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a YAML file
containi... | def create_datastore_from_yaml_schema(self, yaml_path, delete_first=0,
path=None):
# type: (str, Optional[int], Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a YAML file
containi... | [
"For",
"tabular",
"data",
"create",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
"from",
"a",
"YAML",
"file",
"containing",
"a",
"list",
"of",
"fields",
"and",
"types",
"of",
"form",
"{",
"id",
":"... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L438-L454 | [
"def",
"create_datastore_from_yaml_schema",
"(",
"self",
",",
"yaml_path",
",",
"delete_first",
"=",
"0",
",",
"path",
"=",
"None",
")",
":",
"# type: (str, Optional[int], Optional[str]) -> None",
"data",
"=",
"load_yaml",
"(",
"yaml_path",
")",
"self",
".",
"create... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_datastore_from_json_schema | For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a JSON file
containing a list of fields and types of form {'id': 'FIELD', 'type': 'TYPE'} and optionally a primary key.
If path is not supplied, the file is first downloaded from HDX.
Args:
... | src/hdx/data/resource.py | def create_datastore_from_json_schema(self, json_path, delete_first=0, path=None):
# type: (str, int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a JSON file
containing a list of fields and types of form {'id': 'FIELD'... | def create_datastore_from_json_schema(self, json_path, delete_first=0, path=None):
# type: (str, int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX from a JSON file
containing a list of fields and types of form {'id': 'FIELD'... | [
"For",
"tabular",
"data",
"create",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
"from",
"a",
"JSON",
"file",
"containing",
"a",
"list",
"of",
"fields",
"and",
"types",
"of",
"form",
"{",
"id",
":"... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L456-L471 | [
"def",
"create_datastore_from_json_schema",
"(",
"self",
",",
"json_path",
",",
"delete_first",
"=",
"0",
",",
"path",
"=",
"None",
")",
":",
"# type: (str, int, Optional[str]) -> None",
"data",
"=",
"load_json",
"(",
"json_path",
")",
"self",
".",
"create_datastore... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.create_datastore_for_topline | For tabular data, create a resource in the HDX datastore which enables data preview in HDX using the built in
YAML definition for a topline. If path is not supplied, the file is first downloaded from HDX.
Args:
delete_first (int): Delete datastore before creation. 0 = No, 1 = Yes, 2 = If no... | src/hdx/data/resource.py | def create_datastore_for_topline(self, delete_first=0, path=None):
# type: (int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX using the built in
YAML definition for a topline. If path is not supplied, the file is first downl... | def create_datastore_for_topline(self, delete_first=0, path=None):
# type: (int, Optional[str]) -> None
"""For tabular data, create a resource in the HDX datastore which enables data preview in HDX using the built in
YAML definition for a topline. If path is not supplied, the file is first downl... | [
"For",
"tabular",
"data",
"create",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
"using",
"the",
"built",
"in",
"YAML",
"definition",
"for",
"a",
"topline",
".",
"If",
"path",
"is",
"not",
"supplied"... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L473-L486 | [
"def",
"create_datastore_for_topline",
"(",
"self",
",",
"delete_first",
"=",
"0",
",",
"path",
"=",
"None",
")",
":",
"# type: (int, Optional[str]) -> None",
"data",
"=",
"load_yaml",
"(",
"script_dir_plus_file",
"(",
"join",
"(",
"'..'",
",",
"'hdx_datasource_topl... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.update_datastore | For tabular data, update a resource in the HDX datastore which enables data preview in HDX. If no schema is provided
all fields are assumed to be text. If path is not supplied, the file is first downloaded from HDX.
Args:
schema (List[Dict]): List of fields and types of form {'id': 'FIELD',... | src/hdx/data/resource.py | def update_datastore(self, schema=None, primary_key=None,
path=None):
# type: (Optional[List[Dict]], Optional[str], Optional[str]) -> None
"""For tabular data, update a resource in the HDX datastore which enables data preview in HDX. If no schema is provided
all fields a... | def update_datastore(self, schema=None, primary_key=None,
path=None):
# type: (Optional[List[Dict]], Optional[str], Optional[str]) -> None
"""For tabular data, update a resource in the HDX datastore which enables data preview in HDX. If no schema is provided
all fields a... | [
"For",
"tabular",
"data",
"update",
"a",
"resource",
"in",
"the",
"HDX",
"datastore",
"which",
"enables",
"data",
"preview",
"in",
"HDX",
".",
"If",
"no",
"schema",
"is",
"provided",
"all",
"fields",
"are",
"assumed",
"to",
"be",
"text",
".",
"If",
"path... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L488-L502 | [
"def",
"update_datastore",
"(",
"self",
",",
"schema",
"=",
"None",
",",
"primary_key",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"# type: (Optional[List[Dict]], Optional[str], Optional[str]) -> None",
"self",
".",
"create_datastore",
"(",
"schema",
",",
"pri... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource._get_resource_view | Get resource view id
Args:
resource_view (Union[ResourceView,Dict]): ResourceView metadata from a ResourceView object or dictionary
Returns:
ResourceView: ResourceView object | src/hdx/data/resource.py | def _get_resource_view(self, resource_view):
# type: (Union[ResourceView,Dict]) -> ResourceView
"""Get resource view id
Args:
resource_view (Union[ResourceView,Dict]): ResourceView metadata from a ResourceView object or dictionary
Returns:
ResourceView: Resource... | def _get_resource_view(self, resource_view):
# type: (Union[ResourceView,Dict]) -> ResourceView
"""Get resource view id
Args:
resource_view (Union[ResourceView,Dict]): ResourceView metadata from a ResourceView object or dictionary
Returns:
ResourceView: Resource... | [
"Get",
"resource",
"view",
"id"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L571-L585 | [
"def",
"_get_resource_view",
"(",
"self",
",",
"resource_view",
")",
":",
"# type: (Union[ResourceView,Dict]) -> ResourceView",
"if",
"isinstance",
"(",
"resource_view",
",",
"dict",
")",
":",
"resource_view",
"=",
"ResourceView",
"(",
"resource_view",
",",
"configurati... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.add_update_resource_views | Add new or update existing resource views in resource with new metadata.
Args:
resource_views (List[Union[ResourceView,Dict]]): A list of resource views metadata from ResourceView objects or dictionaries
Returns:
None | src/hdx/data/resource.py | def add_update_resource_views(self, resource_views):
# type: (List[Union[ResourceView,Dict]]) -> None
"""Add new or update existing resource views in resource with new metadata.
Args:
resource_views (List[Union[ResourceView,Dict]]): A list of resource views metadata from ResourceVie... | def add_update_resource_views(self, resource_views):
# type: (List[Union[ResourceView,Dict]]) -> None
"""Add new or update existing resource views in resource with new metadata.
Args:
resource_views (List[Union[ResourceView,Dict]]): A list of resource views metadata from ResourceVie... | [
"Add",
"new",
"or",
"update",
"existing",
"resource",
"views",
"in",
"resource",
"with",
"new",
"metadata",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L601-L614 | [
"def",
"add_update_resource_views",
"(",
"self",
",",
"resource_views",
")",
":",
"# type: (List[Union[ResourceView,Dict]]) -> None",
"if",
"not",
"isinstance",
"(",
"resource_views",
",",
"list",
")",
":",
"raise",
"HDXError",
"(",
"'ResourceViews should be a list!'",
")... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.reorder_resource_views | Order resource views in resource.
Args:
resource_views (List[Union[ResourceView,Dict,str]]): A list of either resource view ids or resource views metadata from ResourceView objects or dictionaries
Returns:
None | src/hdx/data/resource.py | def reorder_resource_views(self, resource_views):
# type: (List[Union[ResourceView,Dict,str]]) -> None
"""Order resource views in resource.
Args:
resource_views (List[Union[ResourceView,Dict,str]]): A list of either resource view ids or resource views metadata from ResourceView obje... | def reorder_resource_views(self, resource_views):
# type: (List[Union[ResourceView,Dict,str]]) -> None
"""Order resource views in resource.
Args:
resource_views (List[Union[ResourceView,Dict,str]]): A list of either resource view ids or resource views metadata from ResourceView obje... | [
"Order",
"resource",
"views",
"in",
"resource",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L616-L638 | [
"def",
"reorder_resource_views",
"(",
"self",
",",
"resource_views",
")",
":",
"# type: (List[Union[ResourceView,Dict,str]]) -> None",
"if",
"not",
"isinstance",
"(",
"resource_views",
",",
"list",
")",
":",
"raise",
"HDXError",
"(",
"'ResourceViews should be a list!'",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Resource.delete_resource_view | Delete a resource view from the resource and HDX
Args:
resource_view (Union[ResourceView,Dict,str]): Either a resource view id or resource view metadata either from a ResourceView object or a dictionary
Returns:
None | src/hdx/data/resource.py | def delete_resource_view(self, resource_view):
# type: (Union[ResourceView,Dict,str]) -> None
"""Delete a resource view from the resource and HDX
Args:
resource_view (Union[ResourceView,Dict,str]): Either a resource view id or resource view metadata either from a ResourceView object... | def delete_resource_view(self, resource_view):
# type: (Union[ResourceView,Dict,str]) -> None
"""Delete a resource view from the resource and HDX
Args:
resource_view (Union[ResourceView,Dict,str]): Either a resource view id or resource view metadata either from a ResourceView object... | [
"Delete",
"a",
"resource",
"view",
"from",
"the",
"resource",
"and",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource.py#L640-L666 | [
"def",
"delete_resource_view",
"(",
"self",
",",
"resource_view",
")",
":",
"# type: (Union[ResourceView,Dict,str]) -> None",
"if",
"isinstance",
"(",
"resource_view",
",",
"str",
")",
":",
"if",
"is_valid_uuid",
"(",
"resource_view",
")",
"is",
"False",
":",
"raise... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | parse_for_simple_stems | Parses the output stem lines to produce a list with possible stems
for each word in the output.
:param skip_empty: set True to skip lines without stems (default is False)
:returns: a list of tuples, each containing an original text word and
a list of stems for the given word | pymorfologik/output_parser.py | def parse_for_simple_stems(output, skip_empty=False, skip_same_stems=True):
"""
Parses the output stem lines to produce a list with possible stems
for each word in the output.
:param skip_empty: set True to skip lines without stems (default is False)
:returns: a list of tuples, each containing an o... | def parse_for_simple_stems(output, skip_empty=False, skip_same_stems=True):
"""
Parses the output stem lines to produce a list with possible stems
for each word in the output.
:param skip_empty: set True to skip lines without stems (default is False)
:returns: a list of tuples, each containing an o... | [
"Parses",
"the",
"output",
"stem",
"lines",
"to",
"produce",
"a",
"list",
"with",
"possible",
"stems",
"for",
"each",
"word",
"in",
"the",
"output",
"."
] | dmirecki/pyMorfologik | python | https://github.com/dmirecki/pyMorfologik/blob/e4d93a82e8b4c7a108f01e0456fbeb8024df0259/pymorfologik/output_parser.py#L19-L49 | [
"def",
"parse_for_simple_stems",
"(",
"output",
",",
"skip_empty",
"=",
"False",
",",
"skip_same_stems",
"=",
"True",
")",
":",
"lines_with_stems",
"=",
"_get_lines_with_stems",
"(",
"output",
")",
"stems",
"=",
"list",
"(",
")",
"last_word",
"=",
"None",
"for... | e4d93a82e8b4c7a108f01e0456fbeb8024df0259 |
train | StructureValuesClassFactory._CreateClassTemplate | Creates the class template.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
str: class template. | dtfabric/runtime/runtime.py | def _CreateClassTemplate(cls, data_type_definition):
"""Creates the class template.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
str: class template.
"""
type_name = data_type_definition.name
type_description = data_type_definition.description or... | def _CreateClassTemplate(cls, data_type_definition):
"""Creates the class template.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
str: class template.
"""
type_name = data_type_definition.name
type_description = data_type_definition.description or... | [
"Creates",
"the",
"class",
"template",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/runtime.py#L45-L106 | [
"def",
"_CreateClassTemplate",
"(",
"cls",
",",
"data_type_definition",
")",
":",
"type_name",
"=",
"data_type_definition",
".",
"name",
"type_description",
"=",
"data_type_definition",
".",
"description",
"or",
"type_name",
"while",
"type_description",
".",
"endswith",... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | StructureValuesClassFactory._IsIdentifier | Checks if a string contains an identifier.
Args:
string (str): string to check.
Returns:
bool: True if the string contains an identifier, False otherwise. | dtfabric/runtime/runtime.py | def _IsIdentifier(cls, string):
"""Checks if a string contains an identifier.
Args:
string (str): string to check.
Returns:
bool: True if the string contains an identifier, False otherwise.
"""
return (
string and not string[0].isdigit() and
all(character.isalnum() or c... | def _IsIdentifier(cls, string):
"""Checks if a string contains an identifier.
Args:
string (str): string to check.
Returns:
bool: True if the string contains an identifier, False otherwise.
"""
return (
string and not string[0].isdigit() and
all(character.isalnum() or c... | [
"Checks",
"if",
"a",
"string",
"contains",
"an",
"identifier",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/runtime.py#L109-L120 | [
"def",
"_IsIdentifier",
"(",
"cls",
",",
"string",
")",
":",
"return",
"(",
"string",
"and",
"not",
"string",
"[",
"0",
"]",
".",
"isdigit",
"(",
")",
"and",
"all",
"(",
"character",
".",
"isalnum",
"(",
")",
"or",
"character",
"==",
"'_'",
"for",
... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | StructureValuesClassFactory._ValidateDataTypeDefinition | Validates the data type definition.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
ValueError: if the data type definition is not considered valid. | dtfabric/runtime/runtime.py | def _ValidateDataTypeDefinition(cls, data_type_definition):
"""Validates the data type definition.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
ValueError: if the data type definition is not considered valid.
"""
if not cls._IsIdentifier(data_type_defi... | def _ValidateDataTypeDefinition(cls, data_type_definition):
"""Validates the data type definition.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
ValueError: if the data type definition is not considered valid.
"""
if not cls._IsIdentifier(data_type_defi... | [
"Validates",
"the",
"data",
"type",
"definition",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/runtime.py#L123-L169 | [
"def",
"_ValidateDataTypeDefinition",
"(",
"cls",
",",
"data_type_definition",
")",
":",
"if",
"not",
"cls",
".",
"_IsIdentifier",
"(",
"data_type_definition",
".",
"name",
")",
":",
"raise",
"ValueError",
"(",
"'Data type definition name: {0!s} not a valid identifier'",
... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | StructureValuesClassFactory.CreateClass | Creates a new structure values class.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
class: structure values class. | dtfabric/runtime/runtime.py | def CreateClass(cls, data_type_definition):
"""Creates a new structure values class.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
class: structure values class.
"""
cls._ValidateDataTypeDefinition(data_type_definition)
class_definition = cls._Cre... | def CreateClass(cls, data_type_definition):
"""Creates a new structure values class.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
class: structure values class.
"""
cls._ValidateDataTypeDefinition(data_type_definition)
class_definition = cls._Cre... | [
"Creates",
"a",
"new",
"structure",
"values",
"class",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/runtime.py#L172-L197 | [
"def",
"CreateClass",
"(",
"cls",
",",
"data_type_definition",
")",
":",
"cls",
".",
"_ValidateDataTypeDefinition",
"(",
"data_type_definition",
")",
"class_definition",
"=",
"cls",
".",
"_CreateClassTemplate",
"(",
"data_type_definition",
")",
"namespace",
"=",
"{",
... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | DataTypeDefinitionsRegistry.DeregisterDefinition | Deregisters a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
KeyError: if a data type definition is not set for the corresponding
name. | dtfabric/registry.py | def DeregisterDefinition(self, data_type_definition):
"""Deregisters a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
KeyError: if a data type definition is not s... | def DeregisterDefinition(self, data_type_definition):
"""Deregisters a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Raises:
KeyError: if a data type definition is not s... | [
"Deregisters",
"a",
"data",
"type",
"definition",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/registry.py#L19-L36 | [
"def",
"DeregisterDefinition",
"(",
"self",
",",
"data_type_definition",
")",
":",
"name",
"=",
"data_type_definition",
".",
"name",
".",
"lower",
"(",
")",
"if",
"name",
"not",
"in",
"self",
".",
"_definitions",
":",
"raise",
"KeyError",
"(",
"'Definition not... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | DataTypeDefinitionsRegistry.GetDefinitionByName | Retrieves a specific data type definition by name.
Args:
name (str): name of the data type definition.
Returns:
DataTypeDefinition: data type definition or None if not available. | dtfabric/registry.py | def GetDefinitionByName(self, name):
"""Retrieves a specific data type definition by name.
Args:
name (str): name of the data type definition.
Returns:
DataTypeDefinition: data type definition or None if not available.
"""
lookup_name = name.lower()
if lookup_name not in self._defi... | def GetDefinitionByName(self, name):
"""Retrieves a specific data type definition by name.
Args:
name (str): name of the data type definition.
Returns:
DataTypeDefinition: data type definition or None if not available.
"""
lookup_name = name.lower()
if lookup_name not in self._defi... | [
"Retrieves",
"a",
"specific",
"data",
"type",
"definition",
"by",
"name",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/registry.py#L38-L51 | [
"def",
"GetDefinitionByName",
"(",
"self",
",",
"name",
")",
":",
"lookup_name",
"=",
"name",
".",
"lower",
"(",
")",
"if",
"lookup_name",
"not",
"in",
"self",
".",
"_definitions",
":",
"lookup_name",
"=",
"self",
".",
"_aliases",
".",
"get",
"(",
"name"... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | DataTypeDefinitionsRegistry.RegisterDefinition | Registers a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definitions.
Raises:
KeyError: if data type definition is already set for the corresponding
name. | dtfabric/registry.py | def RegisterDefinition(self, data_type_definition):
"""Registers a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definitions.
Raises:
KeyError: if data type definition is already se... | def RegisterDefinition(self, data_type_definition):
"""Registers a data type definition.
The data type definitions are identified based on their lower case name.
Args:
data_type_definition (DataTypeDefinition): data type definitions.
Raises:
KeyError: if data type definition is already se... | [
"Registers",
"a",
"data",
"type",
"definition",
"."
] | libyal/dtfabric | python | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/registry.py#L61-L92 | [
"def",
"RegisterDefinition",
"(",
"self",
",",
"data_type_definition",
")",
":",
"name_lower",
"=",
"data_type_definition",
".",
"name",
".",
"lower",
"(",
")",
"if",
"name_lower",
"in",
"self",
".",
"_definitions",
":",
"raise",
"KeyError",
"(",
"'Definition al... | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 |
train | LintConfig.apply_on_csv_string | Splits a given string by comma, trims whitespace on the resulting strings and applies a given ```func``` to
each item. | pymarkdownlint/config.py | def apply_on_csv_string(rules_str, func):
""" Splits a given string by comma, trims whitespace on the resulting strings and applies a given ```func``` to
each item. """
splitted = rules_str.split(",")
for str in splitted:
func(str.strip()) | def apply_on_csv_string(rules_str, func):
""" Splits a given string by comma, trims whitespace on the resulting strings and applies a given ```func``` to
each item. """
splitted = rules_str.split(",")
for str in splitted:
func(str.strip()) | [
"Splits",
"a",
"given",
"string",
"by",
"comma",
"trims",
"whitespace",
"on",
"the",
"resulting",
"strings",
"and",
"applies",
"a",
"given",
"func",
"to",
"each",
"item",
"."
] | jorisroovers/pymarkdownlint | python | https://github.com/jorisroovers/pymarkdownlint/blob/c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65/pymarkdownlint/config.py#L41-L46 | [
"def",
"apply_on_csv_string",
"(",
"rules_str",
",",
"func",
")",
":",
"splitted",
"=",
"rules_str",
".",
"split",
"(",
"\",\"",
")",
"for",
"str",
"in",
"splitted",
":",
"func",
"(",
"str",
".",
"strip",
"(",
")",
")"
] | c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65 |
train | placeFavicon | Gets Favicon-URL for the Model.
Template Syntax:
{% placeFavicon %} | favicon/templatetags/favtags.py | def placeFavicon(context):
"""
Gets Favicon-URL for the Model.
Template Syntax:
{% placeFavicon %}
"""
fav = Favicon.objects.filter(isFavicon=True).first()
if not fav:
return mark_safe('<!-- no favicon -->')
html = ''
for rel in config:
for size in sorted(confi... | def placeFavicon(context):
"""
Gets Favicon-URL for the Model.
Template Syntax:
{% placeFavicon %}
"""
fav = Favicon.objects.filter(isFavicon=True).first()
if not fav:
return mark_safe('<!-- no favicon -->')
html = ''
for rel in config:
for size in sorted(confi... | [
"Gets",
"Favicon",
"-",
"URL",
"for",
"the",
"Model",
"."
] | arteria/django-favicon-plus | python | https://github.com/arteria/django-favicon-plus/blob/eb0e58c421507dffe49f739ecd11d477f83d2204/favicon/templatetags/favtags.py#L10-L33 | [
"def",
"placeFavicon",
"(",
"context",
")",
":",
"fav",
"=",
"Favicon",
".",
"objects",
".",
"filter",
"(",
"isFavicon",
"=",
"True",
")",
".",
"first",
"(",
")",
"if",
"not",
"fav",
":",
"return",
"mark_safe",
"(",
"'<!-- no favicon -->'",
")",
"html",
... | eb0e58c421507dffe49f739ecd11d477f83d2204 |
train | set_default_theme | Set default theme name based in config file. | cdk/__init__.py | def set_default_theme(theme):
"""
Set default theme name based in config file.
"""
pref_init() # make sure config files exist
parser = cp.ConfigParser()
parser.read(PREFS_FILE)
# Do we need to create a section?
if not parser.has_section("theme"):
parser.add_section("theme")
... | def set_default_theme(theme):
"""
Set default theme name based in config file.
"""
pref_init() # make sure config files exist
parser = cp.ConfigParser()
parser.read(PREFS_FILE)
# Do we need to create a section?
if not parser.has_section("theme"):
parser.add_section("theme")
... | [
"Set",
"default",
"theme",
"name",
"based",
"in",
"config",
"file",
"."
] | twitter/cdk | python | https://github.com/twitter/cdk/blob/f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02/cdk/__init__.py#L65-L80 | [
"def",
"set_default_theme",
"(",
"theme",
")",
":",
"pref_init",
"(",
")",
"# make sure config files exist",
"parser",
"=",
"cp",
".",
"ConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"PREFS_FILE",
")",
"# Do we need to create a section?",
"if",
"not",
"parse... | f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02 |
train | pick_theme | Return theme name based on manual input, prefs file, or default to "plain". | cdk/__init__.py | def pick_theme(manual):
"""
Return theme name based on manual input, prefs file, or default to "plain".
"""
if manual:
return manual
pref_init()
parser = cp.ConfigParser()
parser.read(PREFS_FILE)
try:
theme = parser.get("theme", "default")
except (cp.NoSectionError, c... | def pick_theme(manual):
"""
Return theme name based on manual input, prefs file, or default to "plain".
"""
if manual:
return manual
pref_init()
parser = cp.ConfigParser()
parser.read(PREFS_FILE)
try:
theme = parser.get("theme", "default")
except (cp.NoSectionError, c... | [
"Return",
"theme",
"name",
"based",
"on",
"manual",
"input",
"prefs",
"file",
"or",
"default",
"to",
"plain",
"."
] | twitter/cdk | python | https://github.com/twitter/cdk/blob/f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02/cdk/__init__.py#L83-L96 | [
"def",
"pick_theme",
"(",
"manual",
")",
":",
"if",
"manual",
":",
"return",
"manual",
"pref_init",
"(",
")",
"parser",
"=",
"cp",
".",
"ConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"PREFS_FILE",
")",
"try",
":",
"theme",
"=",
"parser",
".",
... | f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02 |
train | pref_init | Can be called without penalty. Create ~/.cdk dir if it doesn't
exist. Copy the default pref file if it doesn't exist. | cdk/__init__.py | def pref_init():
"""Can be called without penalty. Create ~/.cdk dir if it doesn't
exist. Copy the default pref file if it doesn't exist."""
# make sure we have a ~/.cdk dir
if not isdir(PREFS_DIR):
mkdir(PREFS_DIR)
# make sure we have a default prefs file
if not isfile(PREFS_FILE):
... | def pref_init():
"""Can be called without penalty. Create ~/.cdk dir if it doesn't
exist. Copy the default pref file if it doesn't exist."""
# make sure we have a ~/.cdk dir
if not isdir(PREFS_DIR):
mkdir(PREFS_DIR)
# make sure we have a default prefs file
if not isfile(PREFS_FILE):
... | [
"Can",
"be",
"called",
"without",
"penalty",
".",
"Create",
"~",
"/",
".",
"cdk",
"dir",
"if",
"it",
"doesn",
"t",
"exist",
".",
"Copy",
"the",
"default",
"pref",
"file",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | twitter/cdk | python | https://github.com/twitter/cdk/blob/f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02/cdk/__init__.py#L99-L108 | [
"def",
"pref_init",
"(",
")",
":",
"# make sure we have a ~/.cdk dir",
"if",
"not",
"isdir",
"(",
"PREFS_DIR",
")",
":",
"mkdir",
"(",
"PREFS_DIR",
")",
"# make sure we have a default prefs file",
"if",
"not",
"isfile",
"(",
"PREFS_FILE",
")",
":",
"copy",
"(",
... | f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02 |
train | install_theme | Pass a path to a theme file which will be extracted to the themes directory. | cdk/__init__.py | def install_theme(path_to_theme):
"""
Pass a path to a theme file which will be extracted to the themes directory.
"""
pref_init()
# cp the file
filename = basename(path_to_theme)
dest = join(THEMES_DIR, filename)
copy(path_to_theme, dest)
# unzip
zf = zipfile.ZipFile(dest)
#... | def install_theme(path_to_theme):
"""
Pass a path to a theme file which will be extracted to the themes directory.
"""
pref_init()
# cp the file
filename = basename(path_to_theme)
dest = join(THEMES_DIR, filename)
copy(path_to_theme, dest)
# unzip
zf = zipfile.ZipFile(dest)
#... | [
"Pass",
"a",
"path",
"to",
"a",
"theme",
"file",
"which",
"will",
"be",
"extracted",
"to",
"the",
"themes",
"directory",
"."
] | twitter/cdk | python | https://github.com/twitter/cdk/blob/f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02/cdk/__init__.py#L111-L126 | [
"def",
"install_theme",
"(",
"path_to_theme",
")",
":",
"pref_init",
"(",
")",
"# cp the file",
"filename",
"=",
"basename",
"(",
"path_to_theme",
")",
"dest",
"=",
"join",
"(",
"THEMES_DIR",
",",
"filename",
")",
"copy",
"(",
"path_to_theme",
",",
"dest",
"... | f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02 |
train | main | Entry point for choosing what subcommand to run. Really should be using asciidocapi | cdk/__init__.py | def main():
"""
Entry point for choosing what subcommand to run. Really should be using asciidocapi
"""
# Try parsing command line args and flags with docopt
args = docopt(__doc__, version="cdk")
# Am I going to need validation? No Schema for the moment...
if args['FILE']:
out = outp... | def main():
"""
Entry point for choosing what subcommand to run. Really should be using asciidocapi
"""
# Try parsing command line args and flags with docopt
args = docopt(__doc__, version="cdk")
# Am I going to need validation? No Schema for the moment...
if args['FILE']:
out = outp... | [
"Entry",
"point",
"for",
"choosing",
"what",
"subcommand",
"to",
"run",
".",
"Really",
"should",
"be",
"using",
"asciidocapi"
] | twitter/cdk | python | https://github.com/twitter/cdk/blob/f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02/cdk/__init__.py#L215-L257 | [
"def",
"main",
"(",
")",
":",
"# Try parsing command line args and flags with docopt",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"\"cdk\"",
")",
"# Am I going to need validation? No Schema for the moment...",
"if",
"args",
"[",
"'FILE'",
"]",
":",
"out... | f4e97337e2dd9d582efdfe1c70bdf01ff79a9b02 |
train | Dataset.separate_resources | Move contents of resources key in internal dictionary into self.resources
Returns:
None | src/hdx/data/dataset.py | def separate_resources(self):
# type: () -> None
"""Move contents of resources key in internal dictionary into self.resources
Returns:
None
"""
self._separate_hdxobjects(self.resources, 'resources', 'name', hdx.data.resource.Resource) | def separate_resources(self):
# type: () -> None
"""Move contents of resources key in internal dictionary into self.resources
Returns:
None
"""
self._separate_hdxobjects(self.resources, 'resources', 'name', hdx.data.resource.Resource) | [
"Move",
"contents",
"of",
"resources",
"key",
"in",
"internal",
"dictionary",
"into",
"self",
".",
"resources"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L127-L134 | [
"def",
"separate_resources",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"_separate_hdxobjects",
"(",
"self",
".",
"resources",
",",
"'resources'",
",",
"'name'",
",",
"hdx",
".",
"data",
".",
"resource",
".",
"Resource",
")"
] | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._get_resource_from_obj | Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resource metadata from a Resource object or a dictionary
Returns:
hdx.data.resource.Resource: Resource object | src/hdx/data/dataset.py | def _get_resource_from_obj(self, resource):
# type: (Union[hdx.data.resource.Resource,Dict,str]) -> hdx.data.resource.Resource
"""Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resou... | def _get_resource_from_obj(self, resource):
# type: (Union[hdx.data.resource.Resource,Dict,str]) -> hdx.data.resource.Resource
"""Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resou... | [
"Add",
"new",
"or",
"update",
"existing",
"resource",
"in",
"dataset",
"with",
"new",
"metadata"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L146-L164 | [
"def",
"_get_resource_from_obj",
"(",
"self",
",",
"resource",
")",
":",
"# type: (Union[hdx.data.resource.Resource,Dict,str]) -> hdx.data.resource.Resource",
"if",
"isinstance",
"(",
"resource",
",",
"str",
")",
":",
"if",
"is_valid_uuid",
"(",
"resource",
")",
"is",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_update_resource | Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resource metadata from a Resource object or a dictionary
ignore_datasetid (bool): Whether to ignore dataset id in the resource
Ret... | src/hdx/data/dataset.py | def add_update_resource(self, resource, ignore_datasetid=False):
# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> None
"""Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or ... | def add_update_resource(self, resource, ignore_datasetid=False):
# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> None
"""Add new or update existing resource in dataset with new metadata
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or ... | [
"Add",
"new",
"or",
"update",
"existing",
"resource",
"in",
"dataset",
"with",
"new",
"metadata"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L166-L184 | [
"def",
"add_update_resource",
"(",
"self",
",",
"resource",
",",
"ignore_datasetid",
"=",
"False",
")",
":",
"# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> None",
"resource",
"=",
"self",
".",
"_get_resource_from_obj",
"(",
"resource",
")",
"if",
"'package... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_update_resources | Add new or update existing resources with new metadata to the dataset
Args:
resources (List[Union[hdx.data.resource.Resource,Dict,str]]): A list of either resource ids or resources metadata from either Resource objects or dictionaries
ignore_datasetid (bool): Whether to ignore dataset i... | src/hdx/data/dataset.py | def add_update_resources(self, resources, ignore_datasetid=False):
# type: (List[Union[hdx.data.resource.Resource,Dict,str]], bool) -> None
"""Add new or update existing resources with new metadata to the dataset
Args:
resources (List[Union[hdx.data.resource.Resource,Dict,str]]): A ... | def add_update_resources(self, resources, ignore_datasetid=False):
# type: (List[Union[hdx.data.resource.Resource,Dict,str]], bool) -> None
"""Add new or update existing resources with new metadata to the dataset
Args:
resources (List[Union[hdx.data.resource.Resource,Dict,str]]): A ... | [
"Add",
"new",
"or",
"update",
"existing",
"resources",
"with",
"new",
"metadata",
"to",
"the",
"dataset"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L186-L200 | [
"def",
"add_update_resources",
"(",
"self",
",",
"resources",
",",
"ignore_datasetid",
"=",
"False",
")",
":",
"# type: (List[Union[hdx.data.resource.Resource,Dict,str]], bool) -> None",
"if",
"not",
"isinstance",
"(",
"resources",
",",
"list",
")",
":",
"raise",
"HDXEr... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.delete_resource | Delete a resource from the dataset and also from HDX by default
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resource metadata from a Resource object or a dictionary
delete (bool): Whetehr to delete the resource from HDX (not just the dataset). Defa... | src/hdx/data/dataset.py | def delete_resource(self, resource, delete=True):
# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> bool
"""Delete a resource from the dataset and also from HDX by default
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resource metadat... | def delete_resource(self, resource, delete=True):
# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> bool
"""Delete a resource from the dataset and also from HDX by default
Args:
resource (Union[hdx.data.resource.Resource,Dict,str]): Either resource id or resource metadat... | [
"Delete",
"a",
"resource",
"from",
"the",
"dataset",
"and",
"also",
"from",
"HDX",
"by",
"default"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L202-L216 | [
"def",
"delete_resource",
"(",
"self",
",",
"resource",
",",
"delete",
"=",
"True",
")",
":",
"# type: (Union[hdx.data.resource.Resource,Dict,str], bool) -> bool",
"if",
"isinstance",
"(",
"resource",
",",
"str",
")",
":",
"if",
"is_valid_uuid",
"(",
"resource",
")"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.reorder_resources | Reorder resources in dataset according to provided list.
If only some resource ids are supplied then these are
assumed to be first and the other resources will stay in
their original order.
Args:
resource_ids (List[str]): List of resource ids
hxl_update (bool): W... | src/hdx/data/dataset.py | def reorder_resources(self, resource_ids, hxl_update=True):
# type: (List[str], bool) -> None
"""Reorder resources in dataset according to provided list.
If only some resource ids are supplied then these are
assumed to be first and the other resources will stay in
their original ... | def reorder_resources(self, resource_ids, hxl_update=True):
# type: (List[str], bool) -> None
"""Reorder resources in dataset according to provided list.
If only some resource ids are supplied then these are
assumed to be first and the other resources will stay in
their original ... | [
"Reorder",
"resources",
"in",
"dataset",
"according",
"to",
"provided",
"list",
".",
"If",
"only",
"some",
"resource",
"ids",
"are",
"supplied",
"then",
"these",
"are",
"assumed",
"to",
"be",
"first",
"and",
"the",
"other",
"resources",
"will",
"stay",
"in",... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L239-L260 | [
"def",
"reorder_resources",
"(",
"self",
",",
"resource_ids",
",",
"hxl_update",
"=",
"True",
")",
":",
"# type: (List[str], bool) -> None",
"dataset_id",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"dataset_id",
":",
"raise",
"HDXErro... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.update_from_yaml | Update dataset metadata with static metadata from YAML file
Args:
path (str): Path to YAML dataset metadata. Defaults to config/hdx_dataset_static.yml.
Returns:
None | src/hdx/data/dataset.py | def update_from_yaml(self, path=join('config', 'hdx_dataset_static.yml')):
# type: (str) -> None
"""Update dataset metadata with static metadata from YAML file
Args:
path (str): Path to YAML dataset metadata. Defaults to config/hdx_dataset_static.yml.
Returns:
N... | def update_from_yaml(self, path=join('config', 'hdx_dataset_static.yml')):
# type: (str) -> None
"""Update dataset metadata with static metadata from YAML file
Args:
path (str): Path to YAML dataset metadata. Defaults to config/hdx_dataset_static.yml.
Returns:
N... | [
"Update",
"dataset",
"metadata",
"with",
"static",
"metadata",
"from",
"YAML",
"file"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L262-L273 | [
"def",
"update_from_yaml",
"(",
"self",
",",
"path",
"=",
"join",
"(",
"'config'",
",",
"'hdx_dataset_static.yml'",
")",
")",
":",
"# type: (str) -> None",
"super",
"(",
"Dataset",
",",
"self",
")",
".",
"update_from_yaml",
"(",
"path",
")",
"self",
".",
"se... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.update_from_json | Update dataset metadata with static metadata from JSON file
Args:
path (str): Path to JSON dataset metadata. Defaults to config/hdx_dataset_static.json.
Returns:
None | src/hdx/data/dataset.py | def update_from_json(self, path=join('config', 'hdx_dataset_static.json')):
# type: (str) -> None
"""Update dataset metadata with static metadata from JSON file
Args:
path (str): Path to JSON dataset metadata. Defaults to config/hdx_dataset_static.json.
Returns:
... | def update_from_json(self, path=join('config', 'hdx_dataset_static.json')):
# type: (str) -> None
"""Update dataset metadata with static metadata from JSON file
Args:
path (str): Path to JSON dataset metadata. Defaults to config/hdx_dataset_static.json.
Returns:
... | [
"Update",
"dataset",
"metadata",
"with",
"static",
"metadata",
"from",
"JSON",
"file"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L275-L286 | [
"def",
"update_from_json",
"(",
"self",
",",
"path",
"=",
"join",
"(",
"'config'",
",",
"'hdx_dataset_static.json'",
")",
")",
":",
"# type: (str) -> None",
"super",
"(",
"Dataset",
",",
"self",
")",
".",
"update_from_json",
"(",
"path",
")",
"self",
".",
"s... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.read_from_hdx | Reads the dataset given by identifier from HDX and returns Dataset object
Args:
identifier (str): Identifier of dataset
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
Optional[Dataset]: Dataset object if succes... | src/hdx/data/dataset.py | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Dataset']
"""Reads the dataset given by identifier from HDX and returns Dataset object
Args:
identifier (str): Identifier of dataset
configuration (Optional[Configurati... | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Dataset']
"""Reads the dataset given by identifier from HDX and returns Dataset object
Args:
identifier (str): Identifier of dataset
configuration (Optional[Configurati... | [
"Reads",
"the",
"dataset",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"Dataset",
"object"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L289-L305 | [
"def",
"read_from_hdx",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> Optional['Dataset']",
"dataset",
"=",
"Dataset",
"(",
"configuration",
"=",
"configuration",
")",
"result",
"=",
"dataset",
".",
"_dataset_... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._dataset_create_resources | Creates resource objects in dataset | src/hdx/data/dataset.py | def _dataset_create_resources(self):
# type: () -> None
"""Creates resource objects in dataset
"""
if 'resources' in self.data:
self.old_data['resources'] = self._copy_hdxobjects(self.resources, hdx.data.resource.Resource, 'file_to_upload')
self.init_resources()
... | def _dataset_create_resources(self):
# type: () -> None
"""Creates resource objects in dataset
"""
if 'resources' in self.data:
self.old_data['resources'] = self._copy_hdxobjects(self.resources, hdx.data.resource.Resource, 'file_to_upload')
self.init_resources()
... | [
"Creates",
"resource",
"objects",
"in",
"dataset"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L307-L315 | [
"def",
"_dataset_create_resources",
"(",
"self",
")",
":",
"# type: () -> None",
"if",
"'resources'",
"in",
"self",
".",
"data",
":",
"self",
".",
"old_data",
"[",
"'resources'",
"]",
"=",
"self",
".",
"_copy_hdxobjects",
"(",
"self",
".",
"resources",
",",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._dataset_load_from_hdx | Loads the dataset given by either id or name from HDX
Args:
id_or_name (str): Either id or name of dataset
Returns:
bool: True if loaded, False if not | src/hdx/data/dataset.py | def _dataset_load_from_hdx(self, id_or_name):
# type: (str) -> bool
"""Loads the dataset given by either id or name from HDX
Args:
id_or_name (str): Either id or name of dataset
Returns:
bool: True if loaded, False if not
"""
if not self._load_f... | def _dataset_load_from_hdx(self, id_or_name):
# type: (str) -> bool
"""Loads the dataset given by either id or name from HDX
Args:
id_or_name (str): Either id or name of dataset
Returns:
bool: True if loaded, False if not
"""
if not self._load_f... | [
"Loads",
"the",
"dataset",
"given",
"by",
"either",
"id",
"or",
"name",
"from",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L317-L331 | [
"def",
"_dataset_load_from_hdx",
"(",
"self",
",",
"id_or_name",
")",
":",
"# type: (str) -> bool",
"if",
"not",
"self",
".",
"_load_from_hdx",
"(",
"'dataset'",
",",
"id_or_name",
")",
":",
"return",
"False",
"self",
".",
"_dataset_create_resources",
"(",
")",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.check_required_fields | Check that metadata for dataset and its resources is complete. The parameter ignore_fields
should be set if required to any fields that should be ignored for the particular operation.
Args:
ignore_fields (List[str]): Fields to ignore. Default is [].
allow_no_resources (bool): Wh... | src/hdx/data/dataset.py | def check_required_fields(self, ignore_fields=list(), allow_no_resources=False):
# type: (List[str], bool) -> None
"""Check that metadata for dataset and its resources is complete. The parameter ignore_fields
should be set if required to any fields that should be ignored for the particular opera... | def check_required_fields(self, ignore_fields=list(), allow_no_resources=False):
# type: (List[str], bool) -> None
"""Check that metadata for dataset and its resources is complete. The parameter ignore_fields
should be set if required to any fields that should be ignored for the particular opera... | [
"Check",
"that",
"metadata",
"for",
"dataset",
"and",
"its",
"resources",
"is",
"complete",
".",
"The",
"parameter",
"ignore_fields",
"should",
"be",
"set",
"if",
"required",
"to",
"any",
"fields",
"that",
"should",
"be",
"ignored",
"for",
"the",
"particular",... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L333-L353 | [
"def",
"check_required_fields",
"(",
"self",
",",
"ignore_fields",
"=",
"list",
"(",
")",
",",
"allow_no_resources",
"=",
"False",
")",
":",
"# type: (List[str], bool) -> None",
"if",
"self",
".",
"is_requestable",
"(",
")",
":",
"self",
".",
"_check_required_fiel... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._dataset_merge_filestore_resource | Helper method to merge updated resource from dataset into HDX resource read from HDX including filestore.
Args:
resource (hdx.data.Resource): Resource read from HDX
updated_resource (hdx.data.Resource): Updated resource from dataset
filestore_resources (List[hdx.data.Resourc... | src/hdx/data/dataset.py | def _dataset_merge_filestore_resource(self, resource, updated_resource, filestore_resources, ignore_fields):
# type: (hdx.data.Resource, hdx.data.Resource, List[hdx.data.Resource], List[str]) -> None
"""Helper method to merge updated resource from dataset into HDX resource read from HDX including filest... | def _dataset_merge_filestore_resource(self, resource, updated_resource, filestore_resources, ignore_fields):
# type: (hdx.data.Resource, hdx.data.Resource, List[hdx.data.Resource], List[str]) -> None
"""Helper method to merge updated resource from dataset into HDX resource read from HDX including filest... | [
"Helper",
"method",
"to",
"merge",
"updated",
"resource",
"from",
"dataset",
"into",
"HDX",
"resource",
"read",
"from",
"HDX",
"including",
"filestore",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L355-L374 | [
"def",
"_dataset_merge_filestore_resource",
"(",
"self",
",",
"resource",
",",
"updated_resource",
",",
"filestore_resources",
",",
"ignore_fields",
")",
":",
"# type: (hdx.data.Resource, hdx.data.Resource, List[hdx.data.Resource], List[str]) -> None",
"if",
"updated_resource",
"."... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._dataset_merge_filestore_newresource | Helper method to add new resource from dataset including filestore.
Args:
new_resource (hdx.data.Resource): New resource from dataset
ignore_fields (List[str]): List of fields to ignore when checking resource
filestore_resources (List[hdx.data.Resource]): List of resources t... | src/hdx/data/dataset.py | def _dataset_merge_filestore_newresource(self, new_resource, ignore_fields, filestore_resources):
# type: (hdx.data.Resource, List[str], List[hdx.data.Resource]) -> None
"""Helper method to add new resource from dataset including filestore.
Args:
new_resource (hdx.data.Resource): Ne... | def _dataset_merge_filestore_newresource(self, new_resource, ignore_fields, filestore_resources):
# type: (hdx.data.Resource, List[str], List[hdx.data.Resource]) -> None
"""Helper method to add new resource from dataset including filestore.
Args:
new_resource (hdx.data.Resource): Ne... | [
"Helper",
"method",
"to",
"add",
"new",
"resource",
"from",
"dataset",
"including",
"filestore",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L376-L392 | [
"def",
"_dataset_merge_filestore_newresource",
"(",
"self",
",",
"new_resource",
",",
"ignore_fields",
",",
"filestore_resources",
")",
":",
"# type: (hdx.data.Resource, List[str], List[hdx.data.Resource]) -> None",
"new_resource",
".",
"check_required_fields",
"(",
"ignore_fields"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._add_filestore_resources | Helper method to create files in filestore by updating resources.
Args:
filestore_resources (List[hdx.data.Resource]): List of resources that use filestore (to be appended to)
create_default_views (bool): Whether to call package_create_default_resource_views.
hxl_update (boo... | src/hdx/data/dataset.py | def _add_filestore_resources(self, filestore_resources, create_default_views, hxl_update):
# type: (List[hdx.data.Resource], bool, bool) -> None
"""Helper method to create files in filestore by updating resources.
Args:
filestore_resources (List[hdx.data.Resource]): List of resource... | def _add_filestore_resources(self, filestore_resources, create_default_views, hxl_update):
# type: (List[hdx.data.Resource], bool, bool) -> None
"""Helper method to create files in filestore by updating resources.
Args:
filestore_resources (List[hdx.data.Resource]): List of resource... | [
"Helper",
"method",
"to",
"create",
"files",
"in",
"filestore",
"by",
"updating",
"resources",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L394-L419 | [
"def",
"_add_filestore_resources",
"(",
"self",
",",
"filestore_resources",
",",
"create_default_views",
",",
"hxl_update",
")",
":",
"# type: (List[hdx.data.Resource], bool, bool) -> None",
"for",
"resource",
"in",
"filestore_resources",
":",
"for",
"created_resource",
"in",... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._dataset_merge_hdx_update | Helper method to check if dataset or its resources exist and update them
Args:
update_resources (bool): Whether to update resources
update_resources_by_name (bool): Compare resource names rather than position in list
remove_additional_resources (bool): Remove additional reso... | src/hdx/data/dataset.py | def _dataset_merge_hdx_update(self, update_resources, update_resources_by_name,
remove_additional_resources, create_default_views, hxl_update):
# type: (bool, bool, bool, bool, bool) -> None
"""Helper method to check if dataset or its resources exist and update them
... | def _dataset_merge_hdx_update(self, update_resources, update_resources_by_name,
remove_additional_resources, create_default_views, hxl_update):
# type: (bool, bool, bool, bool, bool) -> None
"""Helper method to check if dataset or its resources exist and update them
... | [
"Helper",
"method",
"to",
"check",
"if",
"dataset",
"or",
"its",
"resources",
"exist",
"and",
"update",
"them"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L421-L498 | [
"def",
"_dataset_merge_hdx_update",
"(",
"self",
",",
"update_resources",
",",
"update_resources_by_name",
",",
"remove_additional_resources",
",",
"create_default_views",
",",
"hxl_update",
")",
":",
"# type: (bool, bool, bool, bool, bool) -> None",
"# 'old_data' here is the data ... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.update_in_hdx | Check if dataset exists in HDX and if so, update it
Args:
update_resources (bool): Whether to update resources. Defaults to True.
update_resources_by_name (bool): Compare resource names rather than position in list. Defaults to True.
remove_additional_resources (bool): Remov... | src/hdx/data/dataset.py | def update_in_hdx(self, update_resources=True, update_resources_by_name=True,
remove_additional_resources=False, create_default_views=True, hxl_update=True):
# type: (bool, bool, bool, bool, bool) -> None
"""Check if dataset exists in HDX and if so, update it
Args:
... | def update_in_hdx(self, update_resources=True, update_resources_by_name=True,
remove_additional_resources=False, create_default_views=True, hxl_update=True):
# type: (bool, bool, bool, bool, bool) -> None
"""Check if dataset exists in HDX and if so, update it
Args:
... | [
"Check",
"if",
"dataset",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L500-L530 | [
"def",
"update_in_hdx",
"(",
"self",
",",
"update_resources",
"=",
"True",
",",
"update_resources_by_name",
"=",
"True",
",",
"remove_additional_resources",
"=",
"False",
",",
"create_default_views",
"=",
"True",
",",
"hxl_update",
"=",
"True",
")",
":",
"# type: ... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.create_in_hdx | Check if dataset exists in HDX and if so, update it, otherwise create it
Args:
allow_no_resources (bool): Whether to allow no resources. Defaults to False.
update_resources (bool): Whether to update resources (if updating). Defaults to True.
update_resources_by_name (bool): ... | src/hdx/data/dataset.py | def create_in_hdx(self, allow_no_resources=False, update_resources=True, update_resources_by_name=True,
remove_additional_resources=False, create_default_views=True, hxl_update=True):
# type: (bool, bool, bool, bool, bool, bool) -> None
"""Check if dataset exists in HDX and if so, ... | def create_in_hdx(self, allow_no_resources=False, update_resources=True, update_resources_by_name=True,
remove_additional_resources=False, create_default_views=True, hxl_update=True):
# type: (bool, bool, bool, bool, bool, bool) -> None
"""Check if dataset exists in HDX and if so, ... | [
"Check",
"if",
"dataset",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"it"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L532-L577 | [
"def",
"create_in_hdx",
"(",
"self",
",",
"allow_no_resources",
"=",
"False",
",",
"update_resources",
"=",
"True",
",",
"update_resources_by_name",
"=",
"True",
",",
"remove_additional_resources",
"=",
"False",
",",
"create_default_views",
"=",
"True",
",",
"hxl_up... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.search_in_hdx | Searches for datasets in HDX
Args:
query (Optional[str]): Query (in Solr format). Defaults to '*:*'.
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
page_size (int): Size of page to return. Defaults to 1000.
**kwargs:... | src/hdx/data/dataset.py | def search_in_hdx(cls, query='*:*', configuration=None, page_size=1000, **kwargs):
# type: (Optional[str], Optional[Configuration], int, Any) -> List['Dataset']
"""Searches for datasets in HDX
Args:
query (Optional[str]): Query (in Solr format). Defaults to '*:*'.
config... | def search_in_hdx(cls, query='*:*', configuration=None, page_size=1000, **kwargs):
# type: (Optional[str], Optional[Configuration], int, Any) -> List['Dataset']
"""Searches for datasets in HDX
Args:
query (Optional[str]): Query (in Solr format). Defaults to '*:*'.
config... | [
"Searches",
"for",
"datasets",
"in",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L598-L665 | [
"def",
"search_in_hdx",
"(",
"cls",
",",
"query",
"=",
"'*:*'",
",",
"configuration",
"=",
"None",
",",
"page_size",
"=",
"1000",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[str], Optional[Configuration], int, Any) -> List['Dataset']",
"dataset",
"=",
"Dat... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_all_dataset_names | Get all dataset names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
limit (int): Number of rows to return. Defaults to all dataset names.
offset (int): Offset in the complete result ... | src/hdx/data/dataset.py | def get_all_dataset_names(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List[str]
"""Get all dataset names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
... | def get_all_dataset_names(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List[str]
"""Get all dataset names in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
... | [
"Get",
"all",
"dataset",
"names",
"in",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L668-L683 | [
"def",
"get_all_dataset_names",
"(",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[Configuration], Any) -> List[str]",
"dataset",
"=",
"Dataset",
"(",
"configuration",
"=",
"configuration",
")",
"dataset",
"[",
"'id'",
"]",
"=",... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_all_datasets | Get all datasets in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
page_size (int): Size of page to return. Defaults to 1000.
check_duplicates (bool): Whether to check for duplicate datasets. Defaults to True.
... | src/hdx/data/dataset.py | def get_all_datasets(cls, configuration=None, page_size=1000, check_duplicates=True, **kwargs):
# type: (Optional[Configuration], int, bool, Any) -> List['Dataset']
"""Get all datasets in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global config... | def get_all_datasets(cls, configuration=None, page_size=1000, check_duplicates=True, **kwargs):
# type: (Optional[Configuration], int, bool, Any) -> List['Dataset']
"""Get all datasets in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global config... | [
"Get",
"all",
"datasets",
"in",
"HDX"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L686-L750 | [
"def",
"get_all_datasets",
"(",
"cls",
",",
"configuration",
"=",
"None",
",",
"page_size",
"=",
"1000",
",",
"check_duplicates",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[Configuration], int, bool, Any) -> List['Dataset']",
"dataset",
"=",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_all_resources | Get all resources from a list of datasets (such as returned by search)
Args:
datasets (List[Dataset]): list of datasets
Returns:
List[hdx.data.resource.Resource]: list of resources within those datasets | src/hdx/data/dataset.py | def get_all_resources(datasets):
# type: (List['Dataset']) -> List[hdx.data.resource.Resource]
"""Get all resources from a list of datasets (such as returned by search)
Args:
datasets (List[Dataset]): list of datasets
Returns:
List[hdx.data.resource.Resource]: l... | def get_all_resources(datasets):
# type: (List['Dataset']) -> List[hdx.data.resource.Resource]
"""Get all resources from a list of datasets (such as returned by search)
Args:
datasets (List[Dataset]): list of datasets
Returns:
List[hdx.data.resource.Resource]: l... | [
"Get",
"all",
"resources",
"from",
"a",
"list",
"of",
"datasets",
"(",
"such",
"as",
"returned",
"by",
"search",
")"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L753-L767 | [
"def",
"get_all_resources",
"(",
"datasets",
")",
":",
"# type: (List['Dataset']) -> List[hdx.data.resource.Resource]",
"resources",
"=",
"[",
"]",
"for",
"dataset",
"in",
"datasets",
":",
"for",
"resource",
"in",
"dataset",
".",
"get_resources",
"(",
")",
":",
"res... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_dataset_date_as_datetime | Get dataset date as datetime.datetime object. For range returns start date.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set | src/hdx/data/dataset.py | def get_dataset_date_as_datetime(self):
# type: () -> Optional[datetime]
"""Get dataset date as datetime.datetime object. For range returns start date.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set
"""
dataset_date = ... | def get_dataset_date_as_datetime(self):
# type: () -> Optional[datetime]
"""Get dataset date as datetime.datetime object. For range returns start date.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set
"""
dataset_date = ... | [
"Get",
"dataset",
"date",
"as",
"datetime",
".",
"datetime",
"object",
".",
"For",
"range",
"returns",
"start",
"date",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L785-L798 | [
"def",
"get_dataset_date_as_datetime",
"(",
"self",
")",
":",
"# type: () -> Optional[datetime]",
"dataset_date",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'dataset_date'",
",",
"None",
")",
"if",
"dataset_date",
":",
"if",
"'-'",
"in",
"dataset_date",
":",
"d... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_dataset_end_date_as_datetime | Get dataset end date as datetime.datetime object.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set | src/hdx/data/dataset.py | def get_dataset_end_date_as_datetime(self):
# type: () -> Optional[datetime]
"""Get dataset end date as datetime.datetime object.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set
"""
dataset_date = self.data.get('dataset... | def get_dataset_end_date_as_datetime(self):
# type: () -> Optional[datetime]
"""Get dataset end date as datetime.datetime object.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set
"""
dataset_date = self.data.get('dataset... | [
"Get",
"dataset",
"end",
"date",
"as",
"datetime",
".",
"datetime",
"object",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L800-L812 | [
"def",
"get_dataset_end_date_as_datetime",
"(",
"self",
")",
":",
"# type: () -> Optional[datetime]",
"dataset_date",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'dataset_date'",
",",
"None",
")",
"if",
"dataset_date",
":",
"if",
"'-'",
"in",
"dataset_date",
":",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._get_formatted_date | Get supplied dataset date as string in specified format.
If no format is supplied, an ISO 8601 string is returned.
Args:
dataset_date (Optional[datetime.datetime]): dataset date in datetime.datetime format
date_format (Optional[str]): Date format. None is taken to be ISO 8601.... | src/hdx/data/dataset.py | def _get_formatted_date(dataset_date, date_format=None):
# type: (Optional[datetime], Optional[str]) -> Optional[str]
"""Get supplied dataset date as string in specified format.
If no format is supplied, an ISO 8601 string is returned.
Args:
dataset_date (Optional[datetime.... | def _get_formatted_date(dataset_date, date_format=None):
# type: (Optional[datetime], Optional[str]) -> Optional[str]
"""Get supplied dataset date as string in specified format.
If no format is supplied, an ISO 8601 string is returned.
Args:
dataset_date (Optional[datetime.... | [
"Get",
"supplied",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L815-L833 | [
"def",
"_get_formatted_date",
"(",
"dataset_date",
",",
"date_format",
"=",
"None",
")",
":",
"# type: (Optional[datetime], Optional[str]) -> Optional[str]",
"if",
"dataset_date",
":",
"if",
"date_format",
":",
"return",
"dataset_date",
".",
"strftime",
"(",
"date_format"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_dataset_date | Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. None is taken to be ISO 8601. Defaults to None.
Returns:
Optional[str]: Dataset date s... | src/hdx/data/dataset.py | def get_dataset_date(self, date_format=None):
# type: (Optional[str]) -> Optional[str]
"""Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. N... | def get_dataset_date(self, date_format=None):
# type: (Optional[str]) -> Optional[str]
"""Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. N... | [
"Get",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"For",
"range",
"returns",
"start",
"date",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L835-L847 | [
"def",
"get_dataset_date",
"(",
"self",
",",
"date_format",
"=",
"None",
")",
":",
"# type: (Optional[str]) -> Optional[str]",
"dataset_date",
"=",
"self",
".",
"get_dataset_date_as_datetime",
"(",
")",
"return",
"self",
".",
"_get_formatted_date",
"(",
"dataset_date",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_dataset_end_date | Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date format. None is taken to be ISO 8601. Defaults to None.
Returns:
Optional[str]: Dataset date s... | src/hdx/data/dataset.py | def get_dataset_end_date(self, date_format=None):
# type: (Optional[str]) -> Optional[str]
"""Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date forma... | def get_dataset_end_date(self, date_format=None):
# type: (Optional[str]) -> Optional[str]
"""Get dataset date as string in specified format. For range returns start date.
If no format is supplied, an ISO 8601 string is returned.
Args:
date_format (Optional[str]): Date forma... | [
"Get",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"For",
"range",
"returns",
"start",
"date",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L849-L861 | [
"def",
"get_dataset_end_date",
"(",
"self",
",",
"date_format",
"=",
"None",
")",
":",
"# type: (Optional[str]) -> Optional[str]",
"dataset_date",
"=",
"self",
".",
"get_dataset_end_date_as_datetime",
"(",
")",
"return",
"self",
".",
"_get_formatted_date",
"(",
"dataset... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.set_dataset_date_from_datetime | Set dataset date from datetime.datetime object
Args:
dataset_date (datetime.datetime): Dataset date
dataset_end_date (Optional[datetime.datetime]): Dataset end date
Returns:
None | src/hdx/data/dataset.py | def set_dataset_date_from_datetime(self, dataset_date, dataset_end_date=None):
# type: (datetime, Optional[datetime]) -> None
"""Set dataset date from datetime.datetime object
Args:
dataset_date (datetime.datetime): Dataset date
dataset_end_date (Optional[datetime.dateti... | def set_dataset_date_from_datetime(self, dataset_date, dataset_end_date=None):
# type: (datetime, Optional[datetime]) -> None
"""Set dataset date from datetime.datetime object
Args:
dataset_date (datetime.datetime): Dataset date
dataset_end_date (Optional[datetime.dateti... | [
"Set",
"dataset",
"date",
"from",
"datetime",
".",
"datetime",
"object"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L863-L879 | [
"def",
"set_dataset_date_from_datetime",
"(",
"self",
",",
"dataset_date",
",",
"dataset_end_date",
"=",
"None",
")",
":",
"# type: (datetime, Optional[datetime]) -> None",
"start_date",
"=",
"dataset_date",
".",
"strftime",
"(",
"'%m/%d/%Y'",
")",
"if",
"dataset_end_date... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset._parse_date | Parse dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
Args:
dataset_date (str): Dataset date string
date_format (Optional[str]): Date format. If None is given, will attempt to guess... | src/hdx/data/dataset.py | def _parse_date(dataset_date, date_format):
# type: (str, Optional[str]) -> datetime
"""Parse dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
Args:
dataset_date (str): Dataset d... | def _parse_date(dataset_date, date_format):
# type: (str, Optional[str]) -> datetime
"""Parse dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
Args:
dataset_date (str): Dataset d... | [
"Parse",
"dataset",
"date",
"from",
"string",
"using",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"the",
"function",
"will",
"guess",
".",
"For",
"unambiguous",
"formats",
"this",
"should",
"be",
"fine",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L882-L903 | [
"def",
"_parse_date",
"(",
"dataset_date",
",",
"date_format",
")",
":",
"# type: (str, Optional[str]) -> datetime",
"if",
"date_format",
"is",
"None",
":",
"try",
":",
"return",
"parser",
".",
"parse",
"(",
"dataset_date",
")",
"except",
"(",
"ValueError",
",",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.set_dataset_date | Set dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
Args:
dataset_date (str): Dataset date string
dataset_end_date (Optional[str]): Dataset end date string
date_format (... | src/hdx/data/dataset.py | def set_dataset_date(self, dataset_date, dataset_end_date=None, date_format=None):
# type: (str, Optional[str], Optional[str]) -> None
"""Set dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
... | def set_dataset_date(self, dataset_date, dataset_end_date=None, date_format=None):
# type: (str, Optional[str], Optional[str]) -> None
"""Set dataset date from string using specified format. If no format is supplied, the function will guess.
For unambiguous formats, this should be fine.
... | [
"Set",
"dataset",
"date",
"from",
"string",
"using",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"the",
"function",
"will",
"guess",
".",
"For",
"unambiguous",
"formats",
"this",
"should",
"be",
"fine",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L905-L923 | [
"def",
"set_dataset_date",
"(",
"self",
",",
"dataset_date",
",",
"dataset_end_date",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"# type: (str, Optional[str], Optional[str]) -> None",
"parsed_date",
"=",
"self",
".",
"_parse_date",
"(",
"dataset_date",
",... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.set_dataset_year_range | Set dataset date as a range from year or start and end year.
Args:
dataset_year (Union[str, int]): Dataset year given as string or int
dataset_end_year (Optional[Union[str, int]]): Dataset end year given as string or int
Returns:
None | src/hdx/data/dataset.py | def set_dataset_year_range(self, dataset_year, dataset_end_year=None):
# type: (Union[str, int], Optional[Union[str, int]]) -> None
"""Set dataset date as a range from year or start and end year.
Args:
dataset_year (Union[str, int]): Dataset year given as string or int
d... | def set_dataset_year_range(self, dataset_year, dataset_end_year=None):
# type: (Union[str, int], Optional[Union[str, int]]) -> None
"""Set dataset date as a range from year or start and end year.
Args:
dataset_year (Union[str, int]): Dataset year given as string or int
d... | [
"Set",
"dataset",
"date",
"as",
"a",
"range",
"from",
"year",
"or",
"start",
"and",
"end",
"year",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L925-L950 | [
"def",
"set_dataset_year_range",
"(",
"self",
",",
"dataset_year",
",",
"dataset_end_year",
"=",
"None",
")",
":",
"# type: (Union[str, int], Optional[Union[str, int]]) -> None",
"if",
"isinstance",
"(",
"dataset_year",
",",
"int",
")",
":",
"dataset_date",
"=",
"'01/01... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_expected_update_frequency | Get expected update frequency (in textual rather than numeric form)
Returns:
Optional[str]: Update frequency in textual form or None if the update frequency doesn't exist or is blank. | src/hdx/data/dataset.py | def get_expected_update_frequency(self):
# type: () -> Optional[str]
"""Get expected update frequency (in textual rather than numeric form)
Returns:
Optional[str]: Update frequency in textual form or None if the update frequency doesn't exist or is blank.
"""
days = ... | def get_expected_update_frequency(self):
# type: () -> Optional[str]
"""Get expected update frequency (in textual rather than numeric form)
Returns:
Optional[str]: Update frequency in textual form or None if the update frequency doesn't exist or is blank.
"""
days = ... | [
"Get",
"expected",
"update",
"frequency",
"(",
"in",
"textual",
"rather",
"than",
"numeric",
"form",
")"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L966-L977 | [
"def",
"get_expected_update_frequency",
"(",
"self",
")",
":",
"# type: () -> Optional[str]",
"days",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'data_update_frequency'",
",",
"None",
")",
"if",
"days",
":",
"return",
"Dataset",
".",
"transform_update_frequency",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.set_expected_update_frequency | Set expected update frequency
Args:
update_frequency (str): Update frequency
Returns:
None | src/hdx/data/dataset.py | def set_expected_update_frequency(self, update_frequency):
# type: (str) -> None
"""Set expected update frequency
Args:
update_frequency (str): Update frequency
Returns:
None
"""
try:
int(update_frequency)
except ValueError:
... | def set_expected_update_frequency(self, update_frequency):
# type: (str) -> None
"""Set expected update frequency
Args:
update_frequency (str): Update frequency
Returns:
None
"""
try:
int(update_frequency)
except ValueError:
... | [
"Set",
"expected",
"update",
"frequency"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L979-L995 | [
"def",
"set_expected_update_frequency",
"(",
"self",
",",
"update_frequency",
")",
":",
"# type: (str) -> None",
"try",
":",
"int",
"(",
"update_frequency",
")",
"except",
"ValueError",
":",
"update_frequency",
"=",
"Dataset",
".",
"transform_update_frequency",
"(",
"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.remove_tag | Remove a tag
Args:
tag (str): Tag to remove
Returns:
bool: True if tag removed or False if not | src/hdx/data/dataset.py | def remove_tag(self, tag):
# type: (str) -> bool
"""Remove a tag
Args:
tag (str): Tag to remove
Returns:
bool: True if tag removed or False if not
"""
return self._remove_hdxobject(self.data.get('tags'), tag, matchon='name') | def remove_tag(self, tag):
# type: (str) -> bool
"""Remove a tag
Args:
tag (str): Tag to remove
Returns:
bool: True if tag removed or False if not
"""
return self._remove_hdxobject(self.data.get('tags'), tag, matchon='name') | [
"Remove",
"a",
"tag"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1030-L1040 | [
"def",
"remove_tag",
"(",
"self",
",",
"tag",
")",
":",
"# type: (str) -> bool",
"return",
"self",
".",
"_remove_hdxobject",
"(",
"self",
".",
"data",
".",
"get",
"(",
"'tags'",
")",
",",
"tag",
",",
"matchon",
"=",
"'name'",
")"
] | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.get_location | Return the dataset's location
Args:
locations (Optional[List[str]]): Valid locations list. Defaults to list downloaded from HDX.
Returns:
List[str]: list of locations or [] if there are none | src/hdx/data/dataset.py | def get_location(self, locations=None):
# type: (Optional[List[str]]) -> List[str]
"""Return the dataset's location
Args:
locations (Optional[List[str]]): Valid locations list. Defaults to list downloaded from HDX.
Returns:
List[str]: list of locations or [] if ... | def get_location(self, locations=None):
# type: (Optional[List[str]]) -> List[str]
"""Return the dataset's location
Args:
locations (Optional[List[str]]): Valid locations list. Defaults to list downloaded from HDX.
Returns:
List[str]: list of locations or [] if ... | [
"Return",
"the",
"dataset",
"s",
"location"
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1066-L1080 | [
"def",
"get_location",
"(",
"self",
",",
"locations",
"=",
"None",
")",
":",
"# type: (Optional[List[str]]) -> List[str]",
"countries",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'groups'",
",",
"None",
")",
"if",
"not",
"countries",
":",
"return",
"list",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_country_location | Add a country. If an iso 3 code is not provided, value is parsed and if it is a valid country name,
converted to an iso 3 code. If the country is already added, it is ignored.
Args:
country (str): Country to add
exact (bool): True for exact matching or False to allow fuzzy match... | src/hdx/data/dataset.py | def add_country_location(self, country, exact=True, locations=None, use_live=True):
# type: (str, bool, Optional[List[str]], bool) -> bool
"""Add a country. If an iso 3 code is not provided, value is parsed and if it is a valid country name,
converted to an iso 3 code. If the country is already ... | def add_country_location(self, country, exact=True, locations=None, use_live=True):
# type: (str, bool, Optional[List[str]], bool) -> bool
"""Add a country. If an iso 3 code is not provided, value is parsed and if it is a valid country name,
converted to an iso 3 code. If the country is already ... | [
"Add",
"a",
"country",
".",
"If",
"an",
"iso",
"3",
"code",
"is",
"not",
"provided",
"value",
"is",
"parsed",
"and",
"if",
"it",
"is",
"a",
"valid",
"country",
"name",
"converted",
"to",
"an",
"iso",
"3",
"code",
".",
"If",
"the",
"country",
"is",
... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1082-L1102 | [
"def",
"add_country_location",
"(",
"self",
",",
"country",
",",
"exact",
"=",
"True",
",",
"locations",
"=",
"None",
",",
"use_live",
"=",
"True",
")",
":",
"# type: (str, bool, Optional[List[str]], bool) -> bool",
"iso3",
",",
"match",
"=",
"Country",
".",
"ge... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_country_locations | Add a list of countries. If iso 3 codes are not provided, values are parsed and where they are valid country
names, converted to iso 3 codes. If any country is already added, it is ignored.
Args:
countries (List[str]): list of countries to add
locations (Optional[List[str]]): Va... | src/hdx/data/dataset.py | def add_country_locations(self, countries, locations=None, use_live=True):
# type: (List[str], Optional[List[str]], bool) -> bool
"""Add a list of countries. If iso 3 codes are not provided, values are parsed and where they are valid country
names, converted to iso 3 codes. If any country is alr... | def add_country_locations(self, countries, locations=None, use_live=True):
# type: (List[str], Optional[List[str]], bool) -> bool
"""Add a list of countries. If iso 3 codes are not provided, values are parsed and where they are valid country
names, converted to iso 3 codes. If any country is alr... | [
"Add",
"a",
"list",
"of",
"countries",
".",
"If",
"iso",
"3",
"codes",
"are",
"not",
"provided",
"values",
"are",
"parsed",
"and",
"where",
"they",
"are",
"valid",
"country",
"names",
"converted",
"to",
"iso",
"3",
"codes",
".",
"If",
"any",
"country",
... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1104-L1121 | [
"def",
"add_country_locations",
"(",
"self",
",",
"countries",
",",
"locations",
"=",
"None",
",",
"use_live",
"=",
"True",
")",
":",
"# type: (List[str], Optional[List[str]], bool) -> bool",
"allcountriesadded",
"=",
"True",
"for",
"country",
"in",
"countries",
":",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_region_location | Add all countries in a region. If a 3 digit UNStats M49 region code is not provided, value is parsed as a
region name. If any country is already added, it is ignored.
Args:
region (str): M49 region, intermediate region or subregion to add
locations (Optional[List[str]]): Valid l... | src/hdx/data/dataset.py | def add_region_location(self, region, locations=None, use_live=True):
# type: (str, Optional[List[str]], bool) -> bool
"""Add all countries in a region. If a 3 digit UNStats M49 region code is not provided, value is parsed as a
region name. If any country is already added, it is ignored.
... | def add_region_location(self, region, locations=None, use_live=True):
# type: (str, Optional[List[str]], bool) -> bool
"""Add all countries in a region. If a 3 digit UNStats M49 region code is not provided, value is parsed as a
region name. If any country is already added, it is ignored.
... | [
"Add",
"all",
"countries",
"in",
"a",
"region",
".",
"If",
"a",
"3",
"digit",
"UNStats",
"M49",
"region",
"code",
"is",
"not",
"provided",
"value",
"is",
"parsed",
"as",
"a",
"region",
"name",
".",
"If",
"any",
"country",
"is",
"already",
"added",
"it"... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1123-L1137 | [
"def",
"add_region_location",
"(",
"self",
",",
"region",
",",
"locations",
"=",
"None",
",",
"use_live",
"=",
"True",
")",
":",
"# type: (str, Optional[List[str]], bool) -> bool",
"return",
"self",
".",
"add_country_locations",
"(",
"Country",
".",
"get_countries_in_... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.add_other_location | Add a location which is not a country or region. Value is parsed and compared to existing locations in
HDX. If the location is already added, it is ignored.
Args:
location (str): Location to add
exact (bool): True for exact matching or False to allow fuzzy matching. Defaults to ... | src/hdx/data/dataset.py | def add_other_location(self, location, exact=True, alterror=None, locations=None):
# type: (str, bool, Optional[str], Optional[List[str]]) -> bool
"""Add a location which is not a country or region. Value is parsed and compared to existing locations in
HDX. If the location is already added, it i... | def add_other_location(self, location, exact=True, alterror=None, locations=None):
# type: (str, bool, Optional[str], Optional[List[str]]) -> bool
"""Add a location which is not a country or region. Value is parsed and compared to existing locations in
HDX. If the location is already added, it i... | [
"Add",
"a",
"location",
"which",
"is",
"not",
"a",
"country",
"or",
"region",
".",
"Value",
"is",
"parsed",
"and",
"compared",
"to",
"existing",
"locations",
"in",
"HDX",
".",
"If",
"the",
"location",
"is",
"already",
"added",
"it",
"is",
"ignored",
"."
... | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1139-L1169 | [
"def",
"add_other_location",
"(",
"self",
",",
"location",
",",
"exact",
"=",
"True",
",",
"alterror",
"=",
"None",
",",
"locations",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[str], Optional[List[str]]) -> bool",
"hdx_code",
",",
"match",
"=",
"Locations"... | 212440f54f73805826a16db77dbcb6033b18a313 |
train | Dataset.remove_location | Remove a location. If the location is already added, it is ignored.
Args:
location (str): Location to remove
Returns:
bool: True if location removed or False if not | src/hdx/data/dataset.py | def remove_location(self, location):
# type: (str) -> bool
"""Remove a location. If the location is already added, it is ignored.
Args:
location (str): Location to remove
Returns:
bool: True if location removed or False if not
"""
res = self._rem... | def remove_location(self, location):
# type: (str) -> bool
"""Remove a location. If the location is already added, it is ignored.
Args:
location (str): Location to remove
Returns:
bool: True if location removed or False if not
"""
res = self._rem... | [
"Remove",
"a",
"location",
".",
"If",
"the",
"location",
"is",
"already",
"added",
"it",
"is",
"ignored",
"."
] | OCHA-DAP/hdx-python-api | python | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1171-L1186 | [
"def",
"remove_location",
"(",
"self",
",",
"location",
")",
":",
"# type: (str) -> bool",
"res",
"=",
"self",
".",
"_remove_hdxobject",
"(",
"self",
".",
"data",
".",
"get",
"(",
"'groups'",
")",
",",
"location",
",",
"matchon",
"=",
"'name'",
")",
"if",
... | 212440f54f73805826a16db77dbcb6033b18a313 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.