repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.update_in_hdx | 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:
... | python | 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: ... | 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... | [
"Check",
"if",
"dataset",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L500-L530 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.create_in_hdx | 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, ... | python | 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_up... | 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): ... | [
"Check",
"if",
"dataset",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"it"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L532-L577 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.search_in_hdx | 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... | python | 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']",
"dataset",
"=",
"Dat... | 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:... | [
"Searches",
"for",
"datasets",
"in",
"HDX"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L598-L665 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_all_dataset_names | 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
... | python | 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]",
"dataset",
"=",
"Dataset",
"(",
"configuration",
"=",
"configuration",
")",
"dataset",
"[",
"'id'",
"]",
"=",... | 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 ... | [
"Get",
"all",
"dataset",
"names",
"in",
"HDX"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L668-L683 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_all_datasets | 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... | python | 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']",
"dataset",
"=",
... | 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.
... | [
"Get",
"all",
"datasets",
"in",
"HDX"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L686-L750 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_all_resources | 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... | python | 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]",
"resources",
"=",
"[",
"]",
"for",
"dataset",
"in",
"datasets",
":",
"for",
"resource",
"in",
"dataset",
".",
"get_resources",
"(",
")",
":",
"res... | 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 | [
"Get",
"all",
"resources",
"from",
"a",
"list",
"of",
"datasets",
"(",
"such",
"as",
"returned",
"by",
"search",
")"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L753-L767 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_dataset_date_as_datetime | 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 = ... | python | 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]",
"dataset_date",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'dataset_date'",
",",
"None",
")",
"if",
"dataset_date",
":",
"if",
"'-'",
"in",
"dataset_date",
":",
"d... | 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 | [
"Get",
"dataset",
"date",
"as",
"datetime",
".",
"datetime",
"object",
".",
"For",
"range",
"returns",
"start",
"date",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L785-L798 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_dataset_end_date_as_datetime | 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... | python | 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]",
"dataset_date",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'dataset_date'",
",",
"None",
")",
"if",
"dataset_date",
":",
"if",
"'-'",
"in",
"dataset_date",
":",
... | Get dataset end date as datetime.datetime object.
Returns:
Optional[datetime.datetime]: Dataset date in datetime object or None if no date is set | [
"Get",
"dataset",
"end",
"date",
"as",
"datetime",
".",
"datetime",
"object",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L800-L812 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset._get_formatted_date | 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.... | python | 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]",
"if",
"dataset_date",
":",
"if",
"date_format",
":",
"return",
"dataset_date",
".",
"strftime",
"(",
"date_format"... | 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.... | [
"Get",
"supplied",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L815-L833 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_dataset_date | 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... | python | 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]",
"dataset_date",
"=",
"self",
".",
"get_dataset_date_as_datetime",
"(",
")",
"return",
"self",
".",
"_get_formatted_date",
"(",
"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... | [
"Get",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"For",
"range",
"returns",
"start",
"date",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L835-L847 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_dataset_end_date | 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... | python | 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]",
"dataset_date",
"=",
"self",
".",
"get_dataset_end_date_as_datetime",
"(",
")",
"return",
"self",
".",
"_get_formatted_date",
"(",
"dataset... | 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... | [
"Get",
"dataset",
"date",
"as",
"string",
"in",
"specified",
"format",
".",
"For",
"range",
"returns",
"start",
"date",
".",
"If",
"no",
"format",
"is",
"supplied",
"an",
"ISO",
"8601",
"string",
"is",
"returned",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L849-L861 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_dataset_date_from_datetime | 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... | python | 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",
"start_date",
"=",
"dataset_date",
".",
"strftime",
"(",
"'%m/%d/%Y'",
")",
"if",
"dataset_end_date... | 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 | [
"Set",
"dataset",
"date",
"from",
"datetime",
".",
"datetime",
"object"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L863-L879 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset._parse_date | 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... | python | 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",
"if",
"date_format",
"is",
"None",
":",
"try",
":",
"return",
"parser",
".",
"parse",
"(",
"dataset_date",
")",
"except",
"(",
"ValueError",
",",
... | 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... | [
"Parse",
"dataset",
"date",
"from",
"string",
"using",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"the",
"function",
"will",
"guess",
".",
"For",
"unambiguous",
"formats",
"this",
"should",
"be",
"fine",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L882-L903 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_dataset_date | 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.
... | python | 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",
"parsed_date",
"=",
"self",
".",
"_parse_date",
"(",
"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 (... | [
"Set",
"dataset",
"date",
"from",
"string",
"using",
"specified",
"format",
".",
"If",
"no",
"format",
"is",
"supplied",
"the",
"function",
"will",
"guess",
".",
"For",
"unambiguous",
"formats",
"this",
"should",
"be",
"fine",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L905-L923 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_dataset_year_range | 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... | python | 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",
"if",
"isinstance",
"(",
"dataset_year",
",",
"int",
")",
":",
"dataset_date",
"=",
"'01/01... | 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 | [
"Set",
"dataset",
"date",
"as",
"a",
"range",
"from",
"year",
"or",
"start",
"and",
"end",
"year",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L925-L950 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_expected_update_frequency | 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 = ... | python | 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]",
"days",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'data_update_frequency'",
",",
"None",
")",
"if",
"days",
":",
"return",
"Dataset",
".",
"transform_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. | [
"Get",
"expected",
"update",
"frequency",
"(",
"in",
"textual",
"rather",
"than",
"numeric",
"form",
")"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L966-L977 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_expected_update_frequency | 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:
... | python | 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",
"try",
":",
"int",
"(",
"update_frequency",
")",
"except",
"ValueError",
":",
"update_frequency",
"=",
"Dataset",
".",
"transform_update_frequency",
"(",
"... | Set expected update frequency
Args:
update_frequency (str): Update frequency
Returns:
None | [
"Set",
"expected",
"update",
"frequency"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L979-L995 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.remove_tag | 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') | python | 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",
"return",
"self",
".",
"_remove_hdxobject",
"(",
"self",
".",
"data",
".",
"get",
"(",
"'tags'",
")",
",",
"tag",
",",
"matchon",
"=",
"'name'",
")"
] | Remove a tag
Args:
tag (str): Tag to remove
Returns:
bool: True if tag removed or False if not | [
"Remove",
"a",
"tag"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1030-L1040 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_location | 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 ... | python | 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]",
"countries",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'groups'",
",",
"None",
")",
"if",
"not",
"countries",
":",
"return",
"list",
... | 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 | [
"Return",
"the",
"dataset",
"s",
"location"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1066-L1080 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_country_location | 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 ... | python | 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",
"iso3",
",",
"match",
"=",
"Country",
".",
"ge... | 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... | [
"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",
... | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1082-L1102 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_country_locations | 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... | python | 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",
"allcountriesadded",
"=",
"True",
"for",
"country",
"in",
"countries",
":",
... | 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... | [
"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",
... | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1104-L1121 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_region_location | 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.
... | python | 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",
"return",
"self",
".",
"add_country_locations",
"(",
"Country",
".",
"get_countries_in_... | 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... | [
"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"... | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1123-L1137 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_other_location | 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... | python | 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",
"hdx_code",
",",
"match",
"=",
"Locations"... | 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 ... | [
"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",
"."
... | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1139-L1169 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.remove_location | 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... | python | 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",
"res",
"=",
"self",
".",
"_remove_hdxobject",
"(",
"self",
".",
"data",
".",
"get",
"(",
"'groups'",
")",
",",
"location",
",",
"matchon",
"=",
"'name'",
")",
"if",
... | 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 | [
"Remove",
"a",
"location",
".",
"If",
"the",
"location",
"is",
"already",
"added",
"it",
"is",
"ignored",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1171-L1186 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_maintainer | def get_maintainer(self):
# type: () -> hdx.data.user.User
"""Get the dataset's maintainer.
Returns:
User: Dataset's maintainer
"""
return hdx.data.user.User.read_from_hdx(self.data['maintainer'], configuration=self.configuration) | python | def get_maintainer(self):
# type: () -> hdx.data.user.User
"""Get the dataset's maintainer.
Returns:
User: Dataset's maintainer
"""
return hdx.data.user.User.read_from_hdx(self.data['maintainer'], configuration=self.configuration) | [
"def",
"get_maintainer",
"(",
"self",
")",
":",
"# type: () -> hdx.data.user.User",
"return",
"hdx",
".",
"data",
".",
"user",
".",
"User",
".",
"read_from_hdx",
"(",
"self",
".",
"data",
"[",
"'maintainer'",
"]",
",",
"configuration",
"=",
"self",
".",
"con... | Get the dataset's maintainer.
Returns:
User: Dataset's maintainer | [
"Get",
"the",
"dataset",
"s",
"maintainer",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1188-L1195 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_maintainer | def set_maintainer(self, maintainer):
# type: (Union[hdx.data.user.User,Dict,str]) -> None
"""Set the dataset's maintainer.
Args:
maintainer (Union[User,Dict,str]): Either a user id or User metadata from a User object or dictionary.
Returns:
None
"""
... | python | def set_maintainer(self, maintainer):
# type: (Union[hdx.data.user.User,Dict,str]) -> None
"""Set the dataset's maintainer.
Args:
maintainer (Union[User,Dict,str]): Either a user id or User metadata from a User object or dictionary.
Returns:
None
"""
... | [
"def",
"set_maintainer",
"(",
"self",
",",
"maintainer",
")",
":",
"# type: (Union[hdx.data.user.User,Dict,str]) -> None",
"if",
"isinstance",
"(",
"maintainer",
",",
"hdx",
".",
"data",
".",
"user",
".",
"User",
")",
"or",
"isinstance",
"(",
"maintainer",
",",
... | Set the dataset's maintainer.
Args:
maintainer (Union[User,Dict,str]): Either a user id or User metadata from a User object or dictionary.
Returns:
None | [
"Set",
"the",
"dataset",
"s",
"maintainer",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1197-L1214 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_organization | def get_organization(self):
# type: () -> hdx.data.organization.Organization
"""Get the dataset's organization.
Returns:
Organization: Dataset's organization
"""
return hdx.data.organization.Organization.read_from_hdx(self.data['owner_org'], configuration=self.conf... | python | def get_organization(self):
# type: () -> hdx.data.organization.Organization
"""Get the dataset's organization.
Returns:
Organization: Dataset's organization
"""
return hdx.data.organization.Organization.read_from_hdx(self.data['owner_org'], configuration=self.conf... | [
"def",
"get_organization",
"(",
"self",
")",
":",
"# type: () -> hdx.data.organization.Organization",
"return",
"hdx",
".",
"data",
".",
"organization",
".",
"Organization",
".",
"read_from_hdx",
"(",
"self",
".",
"data",
"[",
"'owner_org'",
"]",
",",
"configuration... | Get the dataset's organization.
Returns:
Organization: Dataset's organization | [
"Get",
"the",
"dataset",
"s",
"organization",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1216-L1223 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_organization | def set_organization(self, organization):
# type: (Union[hdx.data.organization.Organization,Dict,str]) -> None
"""Set the dataset's organization.
Args:
organization (Union[Organization,Dict,str]): Either an Organization id or Organization metadata from an Organization object or di... | python | def set_organization(self, organization):
# type: (Union[hdx.data.organization.Organization,Dict,str]) -> None
"""Set the dataset's organization.
Args:
organization (Union[Organization,Dict,str]): Either an Organization id or Organization metadata from an Organization object or di... | [
"def",
"set_organization",
"(",
"self",
",",
"organization",
")",
":",
"# type: (Union[hdx.data.organization.Organization,Dict,str]) -> None",
"if",
"isinstance",
"(",
"organization",
",",
"hdx",
".",
"data",
".",
"organization",
".",
"Organization",
")",
"or",
"isinsta... | Set the dataset's organization.
Args:
organization (Union[Organization,Dict,str]): Either an Organization id or Organization metadata from an Organization object or dictionary.
Returns:
None | [
"Set",
"the",
"dataset",
"s",
"organization",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1225-L1242 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_showcases | def get_showcases(self):
# type: () -> List[hdx.data.showcase.Showcase]
"""Get any showcases the dataset is in
Returns:
List[Showcase]: list of showcases
"""
assoc_result, showcases_dicts = self._read_from_hdx('showcase', self.data['id'], fieldname='package_id',
... | python | def get_showcases(self):
# type: () -> List[hdx.data.showcase.Showcase]
"""Get any showcases the dataset is in
Returns:
List[Showcase]: list of showcases
"""
assoc_result, showcases_dicts = self._read_from_hdx('showcase', self.data['id'], fieldname='package_id',
... | [
"def",
"get_showcases",
"(",
"self",
")",
":",
"# type: () -> List[hdx.data.showcase.Showcase]",
"assoc_result",
",",
"showcases_dicts",
"=",
"self",
".",
"_read_from_hdx",
"(",
"'showcase'",
",",
"self",
".",
"data",
"[",
"'id'",
"]",
",",
"fieldname",
"=",
"'pac... | Get any showcases the dataset is in
Returns:
List[Showcase]: list of showcases | [
"Get",
"any",
"showcases",
"the",
"dataset",
"is",
"in"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1244-L1258 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset._get_dataset_showcase_dict | def _get_dataset_showcase_dict(self, showcase):
# type: (Union[hdx.data.showcase.Showcase, Dict,str]) -> Dict
"""Get dataset showcase dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
... | python | def _get_dataset_showcase_dict(self, showcase):
# type: (Union[hdx.data.showcase.Showcase, Dict,str]) -> Dict
"""Get dataset showcase dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
... | [
"def",
"_get_dataset_showcase_dict",
"(",
"self",
",",
"showcase",
")",
":",
"# type: (Union[hdx.data.showcase.Showcase, Dict,str]) -> Dict",
"if",
"isinstance",
"(",
"showcase",
",",
"hdx",
".",
"data",
".",
"showcase",
".",
"Showcase",
")",
"or",
"isinstance",
"(",
... | Get dataset showcase dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
dict: dataset showcase dict | [
"Get",
"dataset",
"showcase",
"dict"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1260-L1278 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_showcase | def add_showcase(self, showcase, showcases_to_check=None):
# type: (Union[hdx.data.showcase.Showcase,Dict,str], List[hdx.data.showcase.Showcase]) -> bool
"""Add dataset to showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or showcase metadata from a Showcase o... | python | def add_showcase(self, showcase, showcases_to_check=None):
# type: (Union[hdx.data.showcase.Showcase,Dict,str], List[hdx.data.showcase.Showcase]) -> bool
"""Add dataset to showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or showcase metadata from a Showcase o... | [
"def",
"add_showcase",
"(",
"self",
",",
"showcase",
",",
"showcases_to_check",
"=",
"None",
")",
":",
"# type: (Union[hdx.data.showcase.Showcase,Dict,str], List[hdx.data.showcase.Showcase]) -> bool",
"dataset_showcase",
"=",
"self",
".",
"_get_dataset_showcase_dict",
"(",
"sho... | Add dataset to showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or showcase metadata from a Showcase object or dictionary
showcases_to_check (List[Showcase]): list of showcases against which to check existence of showcase. Defaults to showcases containing dataset... | [
"Add",
"dataset",
"to",
"showcase"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1280-L1299 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.add_showcases | def add_showcases(self, showcases, showcases_to_check=None):
# type: (List[Union[hdx.data.showcase.Showcase,Dict,str]], List[hdx.data.showcase.Showcase]) -> bool
"""Add dataset to multiple showcases
Args:
showcases (List[Union[Showcase,Dict,str]]): A list of either showcase ids or s... | python | def add_showcases(self, showcases, showcases_to_check=None):
# type: (List[Union[hdx.data.showcase.Showcase,Dict,str]], List[hdx.data.showcase.Showcase]) -> bool
"""Add dataset to multiple showcases
Args:
showcases (List[Union[Showcase,Dict,str]]): A list of either showcase ids or s... | [
"def",
"add_showcases",
"(",
"self",
",",
"showcases",
",",
"showcases_to_check",
"=",
"None",
")",
":",
"# type: (List[Union[hdx.data.showcase.Showcase,Dict,str]], List[hdx.data.showcase.Showcase]) -> bool",
"if",
"showcases_to_check",
"is",
"None",
":",
"showcases_to_check",
... | Add dataset to multiple showcases
Args:
showcases (List[Union[Showcase,Dict,str]]): A list of either showcase ids or showcase metadata from Showcase objects or dictionaries
showcases_to_check (List[Showcase]): list of showcases against which to check existence of showcase. Defaults to s... | [
"Add",
"dataset",
"to",
"multiple",
"showcases"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1301-L1318 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.remove_showcase | def remove_showcase(self, showcase):
# type: (Union[hdx.data.showcase.Showcase,Dict,str]) -> None
"""Remove dataset from showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id string or showcase metadata from a Showcase object or dictionary
Returns:
... | python | def remove_showcase(self, showcase):
# type: (Union[hdx.data.showcase.Showcase,Dict,str]) -> None
"""Remove dataset from showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id string or showcase metadata from a Showcase object or dictionary
Returns:
... | [
"def",
"remove_showcase",
"(",
"self",
",",
"showcase",
")",
":",
"# type: (Union[hdx.data.showcase.Showcase,Dict,str]) -> None",
"dataset_showcase",
"=",
"self",
".",
"_get_dataset_showcase_dict",
"(",
"showcase",
")",
"showcase",
"=",
"hdx",
".",
"data",
".",
"showcas... | Remove dataset from showcase
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id string or showcase metadata from a Showcase object or dictionary
Returns:
None | [
"Remove",
"dataset",
"from",
"showcase"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1320-L1332 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_requestable | def set_requestable(self, requestable=True):
# type: (bool) -> None
"""Set the dataset to be of type requestable or not
Args:
requestable (bool): Set whether dataset is requestable. Defaults to True.
Returns:
None
"""
self.data['is_requestdata_ty... | python | def set_requestable(self, requestable=True):
# type: (bool) -> None
"""Set the dataset to be of type requestable or not
Args:
requestable (bool): Set whether dataset is requestable. Defaults to True.
Returns:
None
"""
self.data['is_requestdata_ty... | [
"def",
"set_requestable",
"(",
"self",
",",
"requestable",
"=",
"True",
")",
":",
"# type: (bool) -> None",
"self",
".",
"data",
"[",
"'is_requestdata_type'",
"]",
"=",
"requestable",
"if",
"requestable",
":",
"self",
".",
"data",
"[",
"'private'",
"]",
"=",
... | Set the dataset to be of type requestable or not
Args:
requestable (bool): Set whether dataset is requestable. Defaults to True.
Returns:
None | [
"Set",
"the",
"dataset",
"to",
"be",
"of",
"type",
"requestable",
"or",
"not"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1343-L1355 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.get_filetypes | def get_filetypes(self):
# type: () -> List[str]
"""Return list of filetypes in your data
Returns:
List[str]: List of filetypes
"""
if not self.is_requestable():
return [resource.get_file_type() for resource in self.get_resources()]
return self._g... | python | def get_filetypes(self):
# type: () -> List[str]
"""Return list of filetypes in your data
Returns:
List[str]: List of filetypes
"""
if not self.is_requestable():
return [resource.get_file_type() for resource in self.get_resources()]
return self._g... | [
"def",
"get_filetypes",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"if",
"not",
"self",
".",
"is_requestable",
"(",
")",
":",
"return",
"[",
"resource",
".",
"get_file_type",
"(",
")",
"for",
"resource",
"in",
"self",
".",
"get_resources",
"(",
")",
... | Return list of filetypes in your data
Returns:
List[str]: List of filetypes | [
"Return",
"list",
"of",
"filetypes",
"in",
"your",
"data"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1410-L1419 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.clean_dataset_tags | def clean_dataset_tags(self):
# type: () -> Tuple[bool, bool]
"""Clean dataset tags according to tags cleanup spreadsheet and return if any changes occurred
Returns:
Tuple[bool, bool]: Returns (True if tags changed or False if not, True if error or False if not)
"""
... | python | def clean_dataset_tags(self):
# type: () -> Tuple[bool, bool]
"""Clean dataset tags according to tags cleanup spreadsheet and return if any changes occurred
Returns:
Tuple[bool, bool]: Returns (True if tags changed or False if not, True if error or False if not)
"""
... | [
"def",
"clean_dataset_tags",
"(",
"self",
")",
":",
"# type: () -> Tuple[bool, bool]",
"tags_dict",
",",
"wildcard_tags",
"=",
"Tags",
".",
"tagscleanupdicts",
"(",
")",
"def",
"delete_tag",
"(",
"tag",
")",
":",
"logger",
".",
"info",
"(",
"'%s - Deleting tag %s!... | Clean dataset tags according to tags cleanup spreadsheet and return if any changes occurred
Returns:
Tuple[bool, bool]: Returns (True if tags changed or False if not, True if error or False if not) | [
"Clean",
"dataset",
"tags",
"according",
"to",
"tags",
"cleanup",
"spreadsheet",
"and",
"return",
"if",
"any",
"changes",
"occurred"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1463-L1534 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.set_quickchart_resource | def set_quickchart_resource(self, resource):
# type: (Union[hdx.data.resource.Resource,Dict,str,int]) -> bool
"""Set the resource that will be used for displaying QuickCharts in dataset preview
Args:
resource (Union[hdx.data.resource.Resource,Dict,str,int]): Either resource id or na... | python | def set_quickchart_resource(self, resource):
# type: (Union[hdx.data.resource.Resource,Dict,str,int]) -> bool
"""Set the resource that will be used for displaying QuickCharts in dataset preview
Args:
resource (Union[hdx.data.resource.Resource,Dict,str,int]): Either resource id or na... | [
"def",
"set_quickchart_resource",
"(",
"self",
",",
"resource",
")",
":",
"# type: (Union[hdx.data.resource.Resource,Dict,str,int]) -> bool",
"if",
"isinstance",
"(",
"resource",
",",
"int",
")",
"and",
"not",
"isinstance",
"(",
"resource",
",",
"bool",
")",
":",
"r... | Set the resource that will be used for displaying QuickCharts in dataset preview
Args:
resource (Union[hdx.data.resource.Resource,Dict,str,int]): Either resource id or name, resource metadata from a Resource object or a dictionary or position
Returns:
bool: Returns True if reso... | [
"Set",
"the",
"resource",
"that",
"will",
"be",
"used",
"for",
"displaying",
"QuickCharts",
"in",
"dataset",
"preview"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1556-L1588 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/dataset.py | Dataset.create_default_views | def create_default_views(self, create_datastore_views=False):
# type: (bool) -> None
"""Create default resource views for all resources in dataset
Args:
create_datastore_views (bool): Whether to try to create resource views that point to the datastore
Returns:
N... | python | def create_default_views(self, create_datastore_views=False):
# type: (bool) -> None
"""Create default resource views for all resources in dataset
Args:
create_datastore_views (bool): Whether to try to create resource views that point to the datastore
Returns:
N... | [
"def",
"create_default_views",
"(",
"self",
",",
"create_datastore_views",
"=",
"False",
")",
":",
"# type: (bool) -> None",
"package",
"=",
"deepcopy",
"(",
"self",
".",
"data",
")",
"if",
"self",
".",
"resources",
":",
"package",
"[",
"'resources'",
"]",
"="... | Create default resource views for all resources in dataset
Args:
create_datastore_views (bool): Whether to try to create resource views that point to the datastore
Returns:
None | [
"Create",
"default",
"resource",
"views",
"for",
"all",
"resources",
"in",
"dataset"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1590-L1605 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration._get_credentials | def _get_credentials(self):
# type: () -> Optional[Tuple[str, str]]
"""
Return HDX site username and password
Returns:
Optional[Tuple[str, str]]: HDX site username and password or None
"""
site = self.data[self.hdx_site]
username = site.get('username... | python | def _get_credentials(self):
# type: () -> Optional[Tuple[str, str]]
"""
Return HDX site username and password
Returns:
Optional[Tuple[str, str]]: HDX site username and password or None
"""
site = self.data[self.hdx_site]
username = site.get('username... | [
"def",
"_get_credentials",
"(",
"self",
")",
":",
"# type: () -> Optional[Tuple[str, str]]",
"site",
"=",
"self",
".",
"data",
"[",
"self",
".",
"hdx_site",
"]",
"username",
"=",
"site",
".",
"get",
"(",
"'username'",
")",
"if",
"username",
":",
"return",
"b... | Return HDX site username and password
Returns:
Optional[Tuple[str, str]]: HDX site username and password or None | [
"Return",
"HDX",
"site",
"username",
"and",
"password"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L244-L258 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration.call_remoteckan | def call_remoteckan(self, *args, **kwargs):
# type: (Any, Any) -> Dict
"""
Calls the remote CKAN
Args:
*args: Arguments to pass to remote CKAN call_action method
**kwargs: Keyword arguments to pass to remote CKAN call_action method
Returns:
D... | python | def call_remoteckan(self, *args, **kwargs):
# type: (Any, Any) -> Dict
"""
Calls the remote CKAN
Args:
*args: Arguments to pass to remote CKAN call_action method
**kwargs: Keyword arguments to pass to remote CKAN call_action method
Returns:
D... | [
"def",
"call_remoteckan",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Any, Any) -> Dict",
"requests_kwargs",
"=",
"kwargs",
".",
"get",
"(",
"'requests_kwargs'",
",",
"dict",
"(",
")",
")",
"credentials",
"=",
"self",
".",
"... | Calls the remote CKAN
Args:
*args: Arguments to pass to remote CKAN call_action method
**kwargs: Keyword arguments to pass to remote CKAN call_action method
Returns:
Dict: The response from the remote CKAN call_action method | [
"Calls",
"the",
"remote",
"CKAN"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L286-L306 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration._environment_variables | def _environment_variables(**kwargs):
# type: (Any) -> Any
"""
Overwrite keyword arguments with environment variables
Args:
**kwargs: See below
hdx_url (str): HDX url to use. Overrides hdx_site.
hdx_site (str): HDX site to use eg. prod, test. Defaults... | python | def _environment_variables(**kwargs):
# type: (Any) -> Any
"""
Overwrite keyword arguments with environment variables
Args:
**kwargs: See below
hdx_url (str): HDX url to use. Overrides hdx_site.
hdx_site (str): HDX site to use eg. prod, test. Defaults... | [
"def",
"_environment_variables",
"(",
"*",
"*",
"kwargs",
")",
":",
"# type: (Any) -> Any",
"hdx_key",
"=",
"os",
".",
"getenv",
"(",
"'HDX_KEY'",
")",
"if",
"hdx_key",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'hdx_key'",
"]",
"=",
"hdx_key",
"hdx_url",
"... | Overwrite keyword arguments with environment variables
Args:
**kwargs: See below
hdx_url (str): HDX url to use. Overrides hdx_site.
hdx_site (str): HDX site to use eg. prod, test. Defaults to test.
hdx_key (str): Your HDX key. Ignored if hdx_read_only = True.
... | [
"Overwrite",
"keyword",
"arguments",
"with",
"environment",
"variables"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L309-L335 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration.create_remoteckan | def create_remoteckan(cls, site_url, user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None,
session=None, **kwargs):
# type: (str, Optional[str], Optional[str], Optional[str], requests.Session, Any) -> ckanapi.RemoteCKAN
"""
Create remote CKAN instance fr... | python | def create_remoteckan(cls, site_url, user_agent=None, user_agent_config_yaml=None, user_agent_lookup=None,
session=None, **kwargs):
# type: (str, Optional[str], Optional[str], Optional[str], requests.Session, Any) -> ckanapi.RemoteCKAN
"""
Create remote CKAN instance fr... | [
"def",
"create_remoteckan",
"(",
"cls",
",",
"site_url",
",",
"user_agent",
"=",
"None",
",",
"user_agent_config_yaml",
"=",
"None",
",",
"user_agent_lookup",
"=",
"None",
",",
"session",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, Optional[... | Create remote CKAN instance from configuration
Args:
site_url (str): Site url.
user_agent (Optional[str]): User agent string. HDXPythonLibrary/X.X.X- is prefixed.
user_agent_config_yaml (Optional[str]): Path to YAML user agent configuration. Ignored if user_agent supplied. D... | [
"Create",
"remote",
"CKAN",
"instance",
"from",
"configuration"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L338-L365 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration.setup_remoteckan | def setup_remoteckan(self, remoteckan=None, **kwargs):
# type: (Optional[ckanapi.RemoteCKAN], Any) -> None
"""
Set up remote CKAN from provided CKAN or by creating from configuration
Args:
remoteckan (Optional[ckanapi.RemoteCKAN]): CKAN instance. Defaults to setting one up f... | python | def setup_remoteckan(self, remoteckan=None, **kwargs):
# type: (Optional[ckanapi.RemoteCKAN], Any) -> None
"""
Set up remote CKAN from provided CKAN or by creating from configuration
Args:
remoteckan (Optional[ckanapi.RemoteCKAN]): CKAN instance. Defaults to setting one up f... | [
"def",
"setup_remoteckan",
"(",
"self",
",",
"remoteckan",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[ckanapi.RemoteCKAN], Any) -> None",
"if",
"remoteckan",
"is",
"None",
":",
"self",
".",
"_remoteckan",
"=",
"self",
".",
"create_remotecka... | Set up remote CKAN from provided CKAN or by creating from configuration
Args:
remoteckan (Optional[ckanapi.RemoteCKAN]): CKAN instance. Defaults to setting one up from configuration.
Returns:
None | [
"Set",
"up",
"remote",
"CKAN",
"from",
"provided",
"CKAN",
"or",
"by",
"creating",
"from",
"configuration"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L367-L383 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration.setup | def setup(cls, configuration=None, **kwargs):
# type: (Optional['Configuration'], Any) -> None
"""
Set up the HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from passed arguments.
**kwargs: See ... | python | def setup(cls, configuration=None, **kwargs):
# type: (Optional['Configuration'], Any) -> None
"""
Set up the HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from passed arguments.
**kwargs: See ... | [
"def",
"setup",
"(",
"cls",
",",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional['Configuration'], Any) -> None",
"if",
"configuration",
"is",
"None",
":",
"cls",
".",
"_configuration",
"=",
"Configuration",
"(",
"*",
"*",
"... | Set up the HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from passed arguments.
**kwargs: See below
user_agent (str): User agent string. HDXPythonLibrary/X.X.X- is prefixed. Must be supplied if remoteckan ... | [
"Set",
"up",
"the",
"HDX",
"configuration"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L436-L468 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration._create | def _create(cls, configuration=None, remoteckan=None, **kwargs):
# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str
"""
Create HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from ... | python | def _create(cls, configuration=None, remoteckan=None, **kwargs):
# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str
"""
Create HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from ... | [
"def",
"_create",
"(",
"cls",
",",
"configuration",
"=",
"None",
",",
"remoteckan",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str",
"kwargs",
"=",
"cls",
".",
"_environment_variables",
"(... | Create HDX configuration
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from passed arguments.
remoteckan (Optional[ckanapi.RemoteCKAN]): CKAN instance. Defaults to setting one up from configuration.
**kwargs: See below
... | [
"Create",
"HDX",
"configuration"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L471-L504 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_configuration.py | Configuration.create | def create(cls, configuration=None, remoteckan=None, **kwargs):
# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str
"""
Create HDX configuration. Can only be called once (will raise an error if called more than once).
Args:
configuration (Optional[C... | python | def create(cls, configuration=None, remoteckan=None, **kwargs):
# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str
"""
Create HDX configuration. Can only be called once (will raise an error if called more than once).
Args:
configuration (Optional[C... | [
"def",
"create",
"(",
"cls",
",",
"configuration",
"=",
"None",
",",
"remoteckan",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional['Configuration'], Optional[ckanapi.RemoteCKAN], Any) -> str",
"if",
"cls",
".",
"_configuration",
"is",
"not",
"None... | Create HDX configuration. Can only be called once (will raise an error if called more than once).
Args:
configuration (Optional[Configuration]): Configuration instance. Defaults to setting one up from passed arguments.
remoteckan (Optional[ckanapi.RemoteCKAN]): CKAN instance. Defaults t... | [
"Create",
"HDX",
"configuration",
".",
"Can",
"only",
"be",
"called",
"once",
"(",
"will",
"raise",
"an",
"error",
"if",
"called",
"more",
"than",
"once",
")",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_configuration.py#L507-L539 | train |
hz-inova/run_jnb | run_jnb/util.py | kwargs_to_variable_assignment | def kwargs_to_variable_assignment(kwargs: dict, value_representation=repr,
assignment_operator: str = ' = ',
statement_separator: str = '\n',
statement_per_line: bool = False) -> str:
"""
Convert a dictionary i... | python | def kwargs_to_variable_assignment(kwargs: dict, value_representation=repr,
assignment_operator: str = ' = ',
statement_separator: str = '\n',
statement_per_line: bool = False) -> str:
"""
Convert a dictionary i... | [
"def",
"kwargs_to_variable_assignment",
"(",
"kwargs",
":",
"dict",
",",
"value_representation",
"=",
"repr",
",",
"assignment_operator",
":",
"str",
"=",
"' = '",
",",
"statement_separator",
":",
"str",
"=",
"'\\n'",
",",
"statement_per_line",
":",
"bool",
"=",
... | Convert a dictionary into a string with assignments
Each assignment is constructed based on:
key assignment_operator value_representation(value) statement_separator,
where key and value are the key and value of the dictionary.
Moreover one can seprate the assignment statements by new lines.
Parame... | [
"Convert",
"a",
"dictionary",
"into",
"a",
"string",
"with",
"assignments"
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L12-L56 | train |
hz-inova/run_jnb | run_jnb/util.py | decode_json | def decode_json(json_input: Union[str, None] = None):
"""
Simple wrapper of json.load and json.loads.
If json_input is None the output is an empty dictionary.
If the input is a string that ends in .json it is decoded using json.load.
Otherwise it is decoded using json.loads.
Parameters
---... | python | def decode_json(json_input: Union[str, None] = None):
"""
Simple wrapper of json.load and json.loads.
If json_input is None the output is an empty dictionary.
If the input is a string that ends in .json it is decoded using json.load.
Otherwise it is decoded using json.loads.
Parameters
---... | [
"def",
"decode_json",
"(",
"json_input",
":",
"Union",
"[",
"str",
",",
"None",
"]",
"=",
"None",
")",
":",
"if",
"json_input",
"is",
"None",
":",
"return",
"{",
"}",
"else",
":",
"if",
"isinstance",
"(",
"json_input",
",",
"str",
")",
"is",
"False",... | Simple wrapper of json.load and json.loads.
If json_input is None the output is an empty dictionary.
If the input is a string that ends in .json it is decoded using json.load.
Otherwise it is decoded using json.loads.
Parameters
----------
json_input : str, None, optional
input json ob... | [
"Simple",
"wrapper",
"of",
"json",
".",
"load",
"and",
"json",
".",
"loads",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L69-L104 | train |
hz-inova/run_jnb | run_jnb/util.py | is_jsonable | def is_jsonable(obj) -> bool:
"""
Check if an object is jsonable.
An object is jsonable if it is json serialisable and by loading its json representation the same object is recovered.
Parameters
----------
obj :
Python object
Returns
-------
bool
>>> is_jsonable([1,2,... | python | def is_jsonable(obj) -> bool:
"""
Check if an object is jsonable.
An object is jsonable if it is json serialisable and by loading its json representation the same object is recovered.
Parameters
----------
obj :
Python object
Returns
-------
bool
>>> is_jsonable([1,2,... | [
"def",
"is_jsonable",
"(",
"obj",
")",
"->",
"bool",
":",
"try",
":",
"return",
"obj",
"==",
"json",
".",
"loads",
"(",
"json",
".",
"dumps",
"(",
"obj",
")",
")",
"except",
"TypeError",
":",
"return",
"False",
"except",
":",
"raise"
] | Check if an object is jsonable.
An object is jsonable if it is json serialisable and by loading its json representation the same object is recovered.
Parameters
----------
obj :
Python object
Returns
-------
bool
>>> is_jsonable([1,2,3])
True
>>> is_jsonable((1,2,3))
... | [
"Check",
"if",
"an",
"object",
"is",
"jsonable",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L107-L133 | train |
hz-inova/run_jnb | run_jnb/util.py | is_literal_eval | def is_literal_eval(node_or_string) -> tuple:
"""
Check if an expresion can be literal_eval.
----------
node_or_string :
Input
Returns
-------
tuple
(bool,python object)
If it can be literal_eval the python object is returned. Otherwise None it is returne... | python | def is_literal_eval(node_or_string) -> tuple:
"""
Check if an expresion can be literal_eval.
----------
node_or_string :
Input
Returns
-------
tuple
(bool,python object)
If it can be literal_eval the python object is returned. Otherwise None it is returne... | [
"def",
"is_literal_eval",
"(",
"node_or_string",
")",
"->",
"tuple",
":",
"try",
":",
"obj",
"=",
"ast",
".",
"literal_eval",
"(",
"node_or_string",
")",
"return",
"(",
"True",
",",
"obj",
")",
"except",
":",
"return",
"(",
"False",
",",
"None",
")"
] | Check if an expresion can be literal_eval.
----------
node_or_string :
Input
Returns
-------
tuple
(bool,python object)
If it can be literal_eval the python object is returned. Otherwise None it is returned.
>>> is_literal_eval('[1,2,3]')
(True, ... | [
"Check",
"if",
"an",
"expresion",
"can",
"be",
"literal_eval",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L136-L161 | train |
hz-inova/run_jnb | run_jnb/util.py | find_duplicates | def find_duplicates(l: list) -> set:
"""
Return the duplicates in a list.
The function relies on
https://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-a-list .
Parameters
----------
l : list
Name
Returns
-------
set
Duplicated values
>>> f... | python | def find_duplicates(l: list) -> set:
"""
Return the duplicates in a list.
The function relies on
https://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-a-list .
Parameters
----------
l : list
Name
Returns
-------
set
Duplicated values
>>> f... | [
"def",
"find_duplicates",
"(",
"l",
":",
"list",
")",
"->",
"set",
":",
"return",
"set",
"(",
"[",
"x",
"for",
"x",
"in",
"l",
"if",
"l",
".",
"count",
"(",
"x",
")",
">",
"1",
"]",
")"
] | Return the duplicates in a list.
The function relies on
https://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-a-list .
Parameters
----------
l : list
Name
Returns
-------
set
Duplicated values
>>> find_duplicates([1,2,3])
set()
>>> find_du... | [
"Return",
"the",
"duplicates",
"in",
"a",
"list",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L164-L185 | train |
hz-inova/run_jnb | run_jnb/util.py | sort_dict | def sort_dict(d: dict, by: str = 'key',
allow_duplicates: bool = True) -> collections.OrderedDict:
"""
Sort a dictionary by key or value.
The function relies on
https://docs.python.org/3/library/collections.html#collections.OrderedDict .
The dulicated are determined based on
https... | python | def sort_dict(d: dict, by: str = 'key',
allow_duplicates: bool = True) -> collections.OrderedDict:
"""
Sort a dictionary by key or value.
The function relies on
https://docs.python.org/3/library/collections.html#collections.OrderedDict .
The dulicated are determined based on
https... | [
"def",
"sort_dict",
"(",
"d",
":",
"dict",
",",
"by",
":",
"str",
"=",
"'key'",
",",
"allow_duplicates",
":",
"bool",
"=",
"True",
")",
"->",
"collections",
".",
"OrderedDict",
":",
"if",
"by",
"==",
"'key'",
":",
"i",
"=",
"0",
"elif",
"by",
"==",... | Sort a dictionary by key or value.
The function relies on
https://docs.python.org/3/library/collections.html#collections.OrderedDict .
The dulicated are determined based on
https://stackoverflow.com/questions/9835762/find-and-list-duplicates-in-a-list .
Parameters
----------
d : dict
... | [
"Sort",
"a",
"dictionary",
"by",
"key",
"or",
"value",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L188-L236 | train |
hz-inova/run_jnb | run_jnb/util.py | group_dict_by_value | def group_dict_by_value(d: dict) -> dict:
"""
Group a dictionary by values.
Parameters
----------
d : dict
Input dictionary
Returns
-------
dict
Output dictionary. The keys are the values of the initial dictionary
and the values ae given by a list of keys corre... | python | def group_dict_by_value(d: dict) -> dict:
"""
Group a dictionary by values.
Parameters
----------
d : dict
Input dictionary
Returns
-------
dict
Output dictionary. The keys are the values of the initial dictionary
and the values ae given by a list of keys corre... | [
"def",
"group_dict_by_value",
"(",
"d",
":",
"dict",
")",
"->",
"dict",
":",
"d_out",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"v",
"in",
"d_out",
":",
"d_out",
"[",
"v",
"]",
".",
"append",
"(",
"k",... | Group a dictionary by values.
Parameters
----------
d : dict
Input dictionary
Returns
-------
dict
Output dictionary. The keys are the values of the initial dictionary
and the values ae given by a list of keys corresponding to the value.
>>> group_dict_by_value({2... | [
"Group",
"a",
"dictionary",
"by",
"values",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L239-L266 | train |
hz-inova/run_jnb | run_jnb/util.py | variable_status | def variable_status(code: str,
exclude_variable: Union[set, None] = None,
jsonable_parameter: bool = True) -> tuple:
"""
Find the possible parameters and "global" variables from a python code.
This is achieved by parsing the abstract syntax tree.
Parameters
... | python | def variable_status(code: str,
exclude_variable: Union[set, None] = None,
jsonable_parameter: bool = True) -> tuple:
"""
Find the possible parameters and "global" variables from a python code.
This is achieved by parsing the abstract syntax tree.
Parameters
... | [
"def",
"variable_status",
"(",
"code",
":",
"str",
",",
"exclude_variable",
":",
"Union",
"[",
"set",
",",
"None",
"]",
"=",
"None",
",",
"jsonable_parameter",
":",
"bool",
"=",
"True",
")",
"->",
"tuple",
":",
"if",
"exclude_variable",
"is",
"None",
":"... | Find the possible parameters and "global" variables from a python code.
This is achieved by parsing the abstract syntax tree.
Parameters
----------
code : str
Input code as string.
exclude_variable : set, None, optional
Variable to exclude.
jsonable_parameter: bool, True, optio... | [
"Find",
"the",
"possible",
"parameters",
"and",
"global",
"variables",
"from",
"a",
"python",
"code",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L279-L403 | train |
hz-inova/run_jnb | run_jnb/util.py | increment_name | def increment_name(name: str, start_marker: str = " (",
end_marker: str = ")") -> str:
"""
Increment the name where the incremental part is given by parameters.
Parameters
----------
name : str, nbformat.notebooknode.NotebookNode
Name
start_marker : str
The ma... | python | def increment_name(name: str, start_marker: str = " (",
end_marker: str = ")") -> str:
"""
Increment the name where the incremental part is given by parameters.
Parameters
----------
name : str, nbformat.notebooknode.NotebookNode
Name
start_marker : str
The ma... | [
"def",
"increment_name",
"(",
"name",
":",
"str",
",",
"start_marker",
":",
"str",
"=",
"\" (\"",
",",
"end_marker",
":",
"str",
"=",
"\")\"",
")",
"->",
"str",
":",
"if",
"start_marker",
"==",
"''",
":",
"raise",
"ValueError",
"(",
"\"start_marker can not... | Increment the name where the incremental part is given by parameters.
Parameters
----------
name : str, nbformat.notebooknode.NotebookNode
Name
start_marker : str
The marker used before the incremental
end_marker : str
The marker after the incrementa
Returns
-------... | [
"Increment",
"the",
"name",
"where",
"the",
"incremental",
"part",
"is",
"given",
"by",
"parameters",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/util.py#L406-L455 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/resource_view.py | ResourceView.read_from_hdx | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['ResourceView']
"""Reads the resource view given by identifier from HDX and returns ResourceView object
Args:
identifier (str): Identifier of resource view
configuration... | python | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['ResourceView']
"""Reads the resource view given by identifier from HDX and returns ResourceView object
Args:
identifier (str): Identifier of resource view
configuration... | [
"def",
"read_from_hdx",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> Optional['ResourceView']",
"resourceview",
"=",
"ResourceView",
"(",
"configuration",
"=",
"configuration",
")",
"result",
"=",
"resourceview",... | Reads the resource view given by identifier from HDX and returns ResourceView object
Args:
identifier (str): Identifier of resource view
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
Optional[ResourceView]: Re... | [
"Reads",
"the",
"resource",
"view",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"ResourceView",
"object"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource_view.py#L71-L87 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/resource_view.py | ResourceView.get_all_for_resource | def get_all_for_resource(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> List['ResourceView']
"""Read all resource views for a resource given by identifier from HDX and returns list of ResourceView objects
Args:
identifier (str): Identifier of resource
... | python | def get_all_for_resource(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> List['ResourceView']
"""Read all resource views for a resource given by identifier from HDX and returns list of ResourceView objects
Args:
identifier (str): Identifier of resource
... | [
"def",
"get_all_for_resource",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> List['ResourceView']",
"resourceview",
"=",
"ResourceView",
"(",
"configuration",
"=",
"configuration",
")",
"success",
",",
"result",
... | Read all resource views for a resource given by identifier from HDX and returns list of ResourceView objects
Args:
identifier (str): Identifier of resource
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
List[Re... | [
"Read",
"all",
"resource",
"views",
"for",
"a",
"resource",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"list",
"of",
"ResourceView",
"objects"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource_view.py#L90-L109 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/resource_view.py | ResourceView._update_resource_view | def _update_resource_view(self, log=False):
# type: () -> bool
"""Check if resource view exists in HDX and if so, update resource view
Returns:
bool: True if updated and False if not
"""
update = False
if 'id' in self.data and self._load_from_hdx('resource vi... | python | def _update_resource_view(self, log=False):
# type: () -> bool
"""Check if resource view exists in HDX and if so, update resource view
Returns:
bool: True if updated and False if not
"""
update = False
if 'id' in self.data and self._load_from_hdx('resource vi... | [
"def",
"_update_resource_view",
"(",
"self",
",",
"log",
"=",
"False",
")",
":",
"# type: () -> bool",
"update",
"=",
"False",
"if",
"'id'",
"in",
"self",
".",
"data",
"and",
"self",
".",
"_load_from_hdx",
"(",
"'resource view'",
",",
"self",
".",
"data",
... | Check if resource view exists in HDX and if so, update resource view
Returns:
bool: True if updated and False if not | [
"Check",
"if",
"resource",
"view",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"resource",
"view"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource_view.py#L124-L147 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/resource_view.py | ResourceView.create_in_hdx | def create_in_hdx(self):
# type: () -> None
"""Check if resource view exists in HDX and if so, update it, otherwise create resource view
Returns:
None
"""
self.check_required_fields()
if not self._update_resource_view(log=True):
self._save_to_hdx(... | python | def create_in_hdx(self):
# type: () -> None
"""Check if resource view exists in HDX and if so, update it, otherwise create resource view
Returns:
None
"""
self.check_required_fields()
if not self._update_resource_view(log=True):
self._save_to_hdx(... | [
"def",
"create_in_hdx",
"(",
"self",
")",
":",
"# type: () -> None",
"self",
".",
"check_required_fields",
"(",
")",
"if",
"not",
"self",
".",
"_update_resource_view",
"(",
"log",
"=",
"True",
")",
":",
"self",
".",
"_save_to_hdx",
"(",
"'create'",
",",
"'ti... | Check if resource view exists in HDX and if so, update it, otherwise create resource view
Returns:
None | [
"Check",
"if",
"resource",
"view",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"resource",
"view"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource_view.py#L159-L168 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/resource_view.py | ResourceView.copy | def copy(self, resource_view):
# type: (Union[ResourceView,Dict,str]) -> None
"""Copies all fields except id, resource_id and package_id from another resource view.
Args:
resource_view (Union[ResourceView,Dict,str]): Either a resource view id or resource view metadata either from a ... | python | def copy(self, resource_view):
# type: (Union[ResourceView,Dict,str]) -> None
"""Copies all fields except id, resource_id and package_id from another resource view.
Args:
resource_view (Union[ResourceView,Dict,str]): Either a resource view id or resource view metadata either from a ... | [
"def",
"copy",
"(",
"self",
",",
"resource_view",
")",
":",
"# type: (Union[ResourceView,Dict,str]) -> None",
"if",
"isinstance",
"(",
"resource_view",
",",
"str",
")",
":",
"if",
"is_valid_uuid",
"(",
"resource_view",
")",
"is",
"False",
":",
"raise",
"HDXError",... | Copies all fields except id, resource_id and package_id from another resource view.
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 | [
"Copies",
"all",
"fields",
"except",
"id",
"resource_id",
"and",
"package_id",
"from",
"another",
"resource",
"view",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/resource_view.py#L179-L197 | train |
OCHA-DAP/hdx-python-api | src/hdx/hdx_tagscleanup.py | Tags.tagscleanupdicts | def tagscleanupdicts(configuration=None, url=None, keycolumn=5, failchained=True):
# type: (Optional[Configuration], Optional[str], int, bool) -> Tuple[Dict,List]
"""
Get tags cleanup dictionaries
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to ... | python | def tagscleanupdicts(configuration=None, url=None, keycolumn=5, failchained=True):
# type: (Optional[Configuration], Optional[str], int, bool) -> Tuple[Dict,List]
"""
Get tags cleanup dictionaries
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to ... | [
"def",
"tagscleanupdicts",
"(",
"configuration",
"=",
"None",
",",
"url",
"=",
"None",
",",
"keycolumn",
"=",
"5",
",",
"failchained",
"=",
"True",
")",
":",
"# type: (Optional[Configuration], Optional[str], int, bool) -> Tuple[Dict,List]",
"if",
"not",
"Tags",
".",
... | Get tags cleanup dictionaries
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
url (Optional[str]): Url of tags cleanup spreadsheet. Defaults to None (internal configuration parameter).
keycolumn (int): Column number of tag ... | [
"Get",
"tags",
"cleanup",
"dictionaries"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_tagscleanup.py#L24-L71 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.read_from_hdx | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['User']
"""Reads the user given by identifier from HDX and returns User object
Args:
identifier (str): Identifier of user
configuration (Optional[Configuration]): HDX co... | python | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['User']
"""Reads the user given by identifier from HDX and returns User object
Args:
identifier (str): Identifier of user
configuration (Optional[Configuration]): HDX co... | [
"def",
"read_from_hdx",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> Optional['User']",
"user",
"=",
"User",
"(",
"configuration",
"=",
"configuration",
")",
"result",
"=",
"user",
".",
"_load_from_hdx",
"(... | Reads the user given by identifier from HDX and returns User object
Args:
identifier (str): Identifier of user
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
Optional[User]: User object if successful read, None... | [
"Reads",
"the",
"user",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"User",
"object"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L70-L86 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.update_in_hdx | def update_in_hdx(self):
# type: () -> None
"""Check if user exists in HDX and if so, update user
Returns:
None
"""
capacity = self.data.get('capacity')
if capacity is not None:
del self.data['capacity'] # remove capacity (which comes from users ... | python | def update_in_hdx(self):
# type: () -> None
"""Check if user exists in HDX and if so, update user
Returns:
None
"""
capacity = self.data.get('capacity')
if capacity is not None:
del self.data['capacity'] # remove capacity (which comes from users ... | [
"def",
"update_in_hdx",
"(",
"self",
")",
":",
"# type: () -> None",
"capacity",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'capacity'",
")",
"if",
"capacity",
"is",
"not",
"None",
":",
"del",
"self",
".",
"data",
"[",
"'capacity'",
"]",
"# remove capacit... | Check if user exists in HDX and if so, update user
Returns:
None | [
"Check",
"if",
"user",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"user"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L101-L113 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.create_in_hdx | def create_in_hdx(self):
# type: () -> None
"""Check if user exists in HDX and if so, update it, otherwise create user
Returns:
None
"""
capacity = self.data.get('capacity')
if capacity is not None:
del self.data['capacity']
self._create_i... | python | def create_in_hdx(self):
# type: () -> None
"""Check if user exists in HDX and if so, update it, otherwise create user
Returns:
None
"""
capacity = self.data.get('capacity')
if capacity is not None:
del self.data['capacity']
self._create_i... | [
"def",
"create_in_hdx",
"(",
"self",
")",
":",
"# type: () -> None",
"capacity",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'capacity'",
")",
"if",
"capacity",
"is",
"not",
"None",
":",
"del",
"self",
".",
"data",
"[",
"'capacity'",
"]",
"self",
".",
... | Check if user exists in HDX and if so, update it, otherwise create user
Returns:
None | [
"Check",
"if",
"user",
"exists",
"in",
"HDX",
"and",
"if",
"so",
"update",
"it",
"otherwise",
"create",
"user"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L115-L127 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.email | def email(self, subject, text_body, html_body=None, sender=None, **kwargs):
# type: (str, str, Optional[str], Optional[str], Any) -> None
"""Emails a user.
Args:
subject (str): Email subject
text_body (str): Plain text email body
html_body (str): HTML email b... | python | def email(self, subject, text_body, html_body=None, sender=None, **kwargs):
# type: (str, str, Optional[str], Optional[str], Any) -> None
"""Emails a user.
Args:
subject (str): Email subject
text_body (str): Plain text email body
html_body (str): HTML email b... | [
"def",
"email",
"(",
"self",
",",
"subject",
",",
"text_body",
",",
"html_body",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (str, str, Optional[str], Optional[str], Any) -> None",
"self",
".",
"configuration",
".",
"emai... | Emails a user.
Args:
subject (str): Email subject
text_body (str): Plain text email body
html_body (str): HTML email body
sender (Optional[str]): Email sender. Defaults to SMTP username.
**kwargs: See below
mail_options (List): Mail option... | [
"Emails",
"a",
"user",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L138-L155 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.get_all_users | def get_all_users(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List['User']
"""Get all users in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
q (str): Re... | python | def get_all_users(configuration=None, **kwargs):
# type: (Optional[Configuration], Any) -> List['User']
"""Get all users in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
q (str): Re... | [
"def",
"get_all_users",
"(",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Optional[Configuration], Any) -> List['User']",
"user",
"=",
"User",
"(",
"configuration",
"=",
"configuration",
")",
"user",
"[",
"'id'",
"]",
"=",
"'all users... | Get all users in HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
**kwargs: See below
q (str): Restrict to names containing a string. Defaults to all users.
order_by (str): Field by which to sort - any user f... | [
"Get",
"all",
"users",
"in",
"HDX"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L158-L181 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.email_users | def email_users(users, subject, text_body, html_body=None, sender=None, configuration=None, **kwargs):
# type: (List['User'], str, str, Optional[str], Optional[str], Optional[Configuration], Any) -> None
"""Email a list of users
Args:
users (List[User]): List of users
su... | python | def email_users(users, subject, text_body, html_body=None, sender=None, configuration=None, **kwargs):
# type: (List['User'], str, str, Optional[str], Optional[str], Optional[Configuration], Any) -> None
"""Email a list of users
Args:
users (List[User]): List of users
su... | [
"def",
"email_users",
"(",
"users",
",",
"subject",
",",
"text_body",
",",
"html_body",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"configuration",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (List['User'], str, str, Optional[str], Optional[str], O... | Email a list of users
Args:
users (List[User]): List of users
subject (str): Email subject
text_body (str): Plain text email body
html_body (str): HTML email body
sender (Optional[str]): Email sender. Defaults to SMTP username.
configurati... | [
"Email",
"a",
"list",
"of",
"users"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L184-L209 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/user.py | User.get_organizations | def get_organizations(self, permission='read'):
# type: (str) -> List['Organization']
"""Get organizations in HDX that this user is a member of.
Args:
permission (str): Permission to check for. Defaults to 'read'.
Returns:
List[Organization]: List of organizatio... | python | def get_organizations(self, permission='read'):
# type: (str) -> List['Organization']
"""Get organizations in HDX that this user is a member of.
Args:
permission (str): Permission to check for. Defaults to 'read'.
Returns:
List[Organization]: List of organizatio... | [
"def",
"get_organizations",
"(",
"self",
",",
"permission",
"=",
"'read'",
")",
":",
"# type: (str) -> List['Organization']",
"success",
",",
"result",
"=",
"self",
".",
"_read_from_hdx",
"(",
"'user'",
",",
"self",
".",
"data",
"[",
"'name'",
"]",
",",
"'id'"... | Get organizations in HDX that this user is a member of.
Args:
permission (str): Permission to check for. Defaults to 'read'.
Returns:
List[Organization]: List of organizations in HDX that this user is a member of | [
"Get",
"organizations",
"in",
"HDX",
"that",
"this",
"user",
"is",
"a",
"member",
"of",
"."
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/user.py#L211-L228 | train |
OCHA-DAP/hdx-python-api | src/hdx/facades/simple.py | facade | def facade(projectmainfn, **kwargs):
# (Callable[[None], None], Any) -> None
"""Facade to simplify project setup that calls project main function
Args:
projectmainfn ((None) -> None): main function of project
**kwargs: configuration parameters to pass to HDX Configuration class
Returns... | python | def facade(projectmainfn, **kwargs):
# (Callable[[None], None], Any) -> None
"""Facade to simplify project setup that calls project main function
Args:
projectmainfn ((None) -> None): main function of project
**kwargs: configuration parameters to pass to HDX Configuration class
Returns... | [
"def",
"facade",
"(",
"projectmainfn",
",",
"*",
"*",
"kwargs",
")",
":",
"# (Callable[[None], None], Any) -> None",
"#",
"# Setting up configuration",
"#",
"site_url",
"=",
"Configuration",
".",
"_create",
"(",
"*",
"*",
"kwargs",
")",
"logger",
".",
"info",
"(... | Facade to simplify project setup that calls project main function
Args:
projectmainfn ((None) -> None): main function of project
**kwargs: configuration parameters to pass to HDX Configuration class
Returns:
None | [
"Facade",
"to",
"simplify",
"project",
"setup",
"that",
"calls",
"project",
"main",
"function"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/facades/simple.py#L15-L38 | train |
jorisroovers/pymarkdownlint | pymarkdownlint/cli.py | get_lint_config | def get_lint_config(config_path=None):
""" Tries loading the config from the given path. If no path is specified, the default config path
is tried, and if that is not specified, we the default config is returned. """
# config path specified
if config_path:
config = LintConfig.load_from_file(conf... | python | def get_lint_config(config_path=None):
""" Tries loading the config from the given path. If no path is specified, the default config path
is tried, and if that is not specified, we the default config is returned. """
# config path specified
if config_path:
config = LintConfig.load_from_file(conf... | [
"def",
"get_lint_config",
"(",
"config_path",
"=",
"None",
")",
":",
"# config path specified",
"if",
"config_path",
":",
"config",
"=",
"LintConfig",
".",
"load_from_file",
"(",
"config_path",
")",
"click",
".",
"echo",
"(",
"\"Using config from {0}\"",
".",
"for... | Tries loading the config from the given path. If no path is specified, the default config path
is tried, and if that is not specified, we the default config is returned. | [
"Tries",
"loading",
"the",
"config",
"from",
"the",
"given",
"path",
".",
"If",
"no",
"path",
"is",
"specified",
"the",
"default",
"config",
"path",
"is",
"tried",
"and",
"if",
"that",
"is",
"not",
"specified",
"we",
"the",
"default",
"config",
"is",
"re... | c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65 | https://github.com/jorisroovers/pymarkdownlint/blob/c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65/pymarkdownlint/cli.py#L17-L32 | train |
jorisroovers/pymarkdownlint | pymarkdownlint/cli.py | cli | def cli(list_files, config, ignore, path):
""" Markdown lint tool, checks your markdown for styling issues """
files = MarkdownFileFinder.find_files(path)
if list_files:
echo_files(files)
lint_config = get_lint_config(config)
lint_config.apply_on_csv_string(ignore, lint_config.disable_rule)... | python | def cli(list_files, config, ignore, path):
""" Markdown lint tool, checks your markdown for styling issues """
files = MarkdownFileFinder.find_files(path)
if list_files:
echo_files(files)
lint_config = get_lint_config(config)
lint_config.apply_on_csv_string(ignore, lint_config.disable_rule)... | [
"def",
"cli",
"(",
"list_files",
",",
"config",
",",
"ignore",
",",
"path",
")",
":",
"files",
"=",
"MarkdownFileFinder",
".",
"find_files",
"(",
"path",
")",
"if",
"list_files",
":",
"echo_files",
"(",
"files",
")",
"lint_config",
"=",
"get_lint_config",
... | Markdown lint tool, checks your markdown for styling issues | [
"Markdown",
"lint",
"tool",
"checks",
"your",
"markdown",
"for",
"styling",
"issues"
] | c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65 | https://github.com/jorisroovers/pymarkdownlint/blob/c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65/pymarkdownlint/cli.py#L42-L53 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/__init__.py | main | def main():
""" Main function """
# Read configuration from the config file if present, else fall back to
# command line options
if args.config:
config = config_file_parser.get_configuration(args.config)
access_key_id = config['access-key-id']
secret_access_key = config['secret-a... | python | def main():
""" Main function """
# Read configuration from the config file if present, else fall back to
# command line options
if args.config:
config = config_file_parser.get_configuration(args.config)
access_key_id = config['access-key-id']
secret_access_key = config['secret-a... | [
"def",
"main",
"(",
")",
":",
"# Read configuration from the config file if present, else fall back to",
"# command line options",
"if",
"args",
".",
"config",
":",
"config",
"=",
"config_file_parser",
".",
"get_configuration",
"(",
"args",
".",
"config",
")",
"access_key... | Main function | [
"Main",
"function"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/__init__.py#L109-L171 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/__init__.py | AutoEBSDaemon.run | def run(self, check_interval=300):
""" Run the daemon
:type check_interval: int
:param check_interval: Delay in seconds between checks
"""
while True:
# Read configuration from the config file if present, else fall
# back to command line options
... | python | def run(self, check_interval=300):
""" Run the daemon
:type check_interval: int
:param check_interval: Delay in seconds between checks
"""
while True:
# Read configuration from the config file if present, else fall
# back to command line options
... | [
"def",
"run",
"(",
"self",
",",
"check_interval",
"=",
"300",
")",
":",
"while",
"True",
":",
"# Read configuration from the config file if present, else fall",
"# back to command line options",
"if",
"args",
".",
"config",
":",
"config",
"=",
"config_file_parser",
".",... | Run the daemon
:type check_interval: int
:param check_interval: Delay in seconds between checks | [
"Run",
"the",
"daemon"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/__init__.py#L79-L106 | train |
jorisroovers/pymarkdownlint | pymarkdownlint/lint.py | MarkdownLinter._apply_line_rules | def _apply_line_rules(self, markdown_string):
""" Iterates over the lines in a given markdown string and applies all the enabled line rules to each line """
all_violations = []
lines = markdown_string.split("\n")
line_rules = self.line_rules
line_nr = 1
ignoring = False
... | python | def _apply_line_rules(self, markdown_string):
""" Iterates over the lines in a given markdown string and applies all the enabled line rules to each line """
all_violations = []
lines = markdown_string.split("\n")
line_rules = self.line_rules
line_nr = 1
ignoring = False
... | [
"def",
"_apply_line_rules",
"(",
"self",
",",
"markdown_string",
")",
":",
"all_violations",
"=",
"[",
"]",
"lines",
"=",
"markdown_string",
".",
"split",
"(",
"\"\\n\"",
")",
"line_rules",
"=",
"self",
".",
"line_rules",
"line_nr",
"=",
"1",
"ignoring",
"="... | Iterates over the lines in a given markdown string and applies all the enabled line rules to each line | [
"Iterates",
"over",
"the",
"lines",
"in",
"a",
"given",
"markdown",
"string",
"and",
"applies",
"all",
"the",
"enabled",
"line",
"rules",
"to",
"each",
"line"
] | c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65 | https://github.com/jorisroovers/pymarkdownlint/blob/c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65/pymarkdownlint/lint.py#L13-L35 | train |
jorisroovers/pymarkdownlint | pymarkdownlint/lint.py | MarkdownLinter.lint_files | def lint_files(self, files):
""" Lints a list of files.
:param files: list of files to lint
:return: a list of violations found in the files
"""
all_violations = []
for filename in files:
with open(filename, 'r') as f:
content = f.read()
... | python | def lint_files(self, files):
""" Lints a list of files.
:param files: list of files to lint
:return: a list of violations found in the files
"""
all_violations = []
for filename in files:
with open(filename, 'r') as f:
content = f.read()
... | [
"def",
"lint_files",
"(",
"self",
",",
"files",
")",
":",
"all_violations",
"=",
"[",
"]",
"for",
"filename",
"in",
"files",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"violati... | Lints a list of files.
:param files: list of files to lint
:return: a list of violations found in the files | [
"Lints",
"a",
"list",
"of",
"files",
".",
":",
"param",
"files",
":",
"list",
"of",
"files",
"to",
"lint",
":",
"return",
":",
"a",
"list",
"of",
"violations",
"found",
"in",
"the",
"files"
] | c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65 | https://github.com/jorisroovers/pymarkdownlint/blob/c1044e25e18afd78b3fda8fd9b00a4f67cfbbc65/pymarkdownlint/lint.py#L42-L55 | train |
libyal/dtfabric | dtfabric/runtime/byte_operations.py | StructOperation.ReadFrom | def ReadFrom(self, byte_stream):
"""Read values from a byte stream.
Args:
byte_stream (bytes): byte stream.
Returns:
tuple[object, ...]: values copies from the byte stream.
Raises:
IOError: if byte stream cannot be read.
OSError: if byte stream cannot be read.
"""
try:... | python | def ReadFrom(self, byte_stream):
"""Read values from a byte stream.
Args:
byte_stream (bytes): byte stream.
Returns:
tuple[object, ...]: values copies from the byte stream.
Raises:
IOError: if byte stream cannot be read.
OSError: if byte stream cannot be read.
"""
try:... | [
"def",
"ReadFrom",
"(",
"self",
",",
"byte_stream",
")",
":",
"try",
":",
"return",
"self",
".",
"_struct",
".",
"unpack_from",
"(",
"byte_stream",
")",
"except",
"(",
"TypeError",
",",
"struct",
".",
"error",
")",
"as",
"exception",
":",
"raise",
"IOErr... | Read values from a byte stream.
Args:
byte_stream (bytes): byte stream.
Returns:
tuple[object, ...]: values copies from the byte stream.
Raises:
IOError: if byte stream cannot be read.
OSError: if byte stream cannot be read. | [
"Read",
"values",
"from",
"a",
"byte",
"stream",
"."
] | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/byte_operations.py#L65-L82 | train |
libyal/dtfabric | dtfabric/runtime/byte_operations.py | StructOperation.WriteTo | def WriteTo(self, values):
"""Writes values to a byte stream.
Args:
values (tuple[object, ...]): values to copy to the byte stream.
Returns:
bytes: byte stream.
Raises:
IOError: if byte stream cannot be written.
OSError: if byte stream cannot be read.
"""
try:
re... | python | def WriteTo(self, values):
"""Writes values to a byte stream.
Args:
values (tuple[object, ...]): values to copy to the byte stream.
Returns:
bytes: byte stream.
Raises:
IOError: if byte stream cannot be written.
OSError: if byte stream cannot be read.
"""
try:
re... | [
"def",
"WriteTo",
"(",
"self",
",",
"values",
")",
":",
"try",
":",
"return",
"self",
".",
"_struct",
".",
"pack",
"(",
"*",
"values",
")",
"except",
"(",
"TypeError",
",",
"struct",
".",
"error",
")",
"as",
"exception",
":",
"raise",
"IOError",
"(",... | Writes values to a byte stream.
Args:
values (tuple[object, ...]): values to copy to the byte stream.
Returns:
bytes: byte stream.
Raises:
IOError: if byte stream cannot be written.
OSError: if byte stream cannot be read. | [
"Writes",
"values",
"to",
"a",
"byte",
"stream",
"."
] | 0d2b5719fa257f6e5c661a406737ebcf8c8db266 | https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/byte_operations.py#L84-L101 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/snapshot_manager.py | run | def run(connection):
""" Ensure that we have snapshots for a given volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None
"""
volumes = volume_manager.get_watched_volumes(connection)
for volume in volumes:
_ensure_snapshot... | python | def run(connection):
""" Ensure that we have snapshots for a given volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None
"""
volumes = volume_manager.get_watched_volumes(connection)
for volume in volumes:
_ensure_snapshot... | [
"def",
"run",
"(",
"connection",
")",
":",
"volumes",
"=",
"volume_manager",
".",
"get_watched_volumes",
"(",
"connection",
")",
"for",
"volume",
"in",
"volumes",
":",
"_ensure_snapshot",
"(",
"connection",
",",
"volume",
")",
"_remove_old_snapshots",
"(",
"conn... | Ensure that we have snapshots for a given volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None | [
"Ensure",
"that",
"we",
"have",
"snapshots",
"for",
"a",
"given",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/snapshot_manager.py#L13-L24 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/snapshot_manager.py | _create_snapshot | def _create_snapshot(volume):
""" Create a new snapshot
:type volume: boto.ec2.volume.Volume
:param volume: Volume to snapshot
:returns: boto.ec2.snapshot.Snapshot -- The new snapshot
"""
logger.info('Creating new snapshot for {}'.format(volume.id))
snapshot = volume.create_snapshot(
... | python | def _create_snapshot(volume):
""" Create a new snapshot
:type volume: boto.ec2.volume.Volume
:param volume: Volume to snapshot
:returns: boto.ec2.snapshot.Snapshot -- The new snapshot
"""
logger.info('Creating new snapshot for {}'.format(volume.id))
snapshot = volume.create_snapshot(
... | [
"def",
"_create_snapshot",
"(",
"volume",
")",
":",
"logger",
".",
"info",
"(",
"'Creating new snapshot for {}'",
".",
"format",
"(",
"volume",
".",
"id",
")",
")",
"snapshot",
"=",
"volume",
".",
"create_snapshot",
"(",
"description",
"=",
"\"Automatic snapshot... | Create a new snapshot
:type volume: boto.ec2.volume.Volume
:param volume: Volume to snapshot
:returns: boto.ec2.snapshot.Snapshot -- The new snapshot | [
"Create",
"a",
"new",
"snapshot"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/snapshot_manager.py#L27-L40 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/snapshot_manager.py | _ensure_snapshot | def _ensure_snapshot(connection, volume):
""" Ensure that a given volume has an appropriate snapshot
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None
"""
if 'Au... | python | def _ensure_snapshot(connection, volume):
""" Ensure that a given volume has an appropriate snapshot
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None
"""
if 'Au... | [
"def",
"_ensure_snapshot",
"(",
"connection",
",",
"volume",
")",
":",
"if",
"'AutomatedEBSSnapshots'",
"not",
"in",
"volume",
".",
"tags",
":",
"logger",
".",
"warning",
"(",
"'Missing tag AutomatedEBSSnapshots for volume {}'",
".",
"format",
"(",
"volume",
".",
... | Ensure that a given volume has an appropriate snapshot
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None | [
"Ensure",
"that",
"a",
"given",
"volume",
"has",
"an",
"appropriate",
"snapshot"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/snapshot_manager.py#L43-L96 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/snapshot_manager.py | _remove_old_snapshots | def _remove_old_snapshots(connection, volume):
""" Remove old snapshots
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None
"""
if 'AutomatedEBSSnapshotsRetention'... | python | def _remove_old_snapshots(connection, volume):
""" Remove old snapshots
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None
"""
if 'AutomatedEBSSnapshotsRetention'... | [
"def",
"_remove_old_snapshots",
"(",
"connection",
",",
"volume",
")",
":",
"if",
"'AutomatedEBSSnapshotsRetention'",
"not",
"in",
"volume",
".",
"tags",
":",
"logger",
".",
"warning",
"(",
"'Missing tag AutomatedEBSSnapshotsRetention for volume {}'",
".",
"format",
"("... | Remove old snapshots
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: boto.ec2.volume.Volume
:param volume: Volume to check
:returns: None | [
"Remove",
"old",
"snapshots"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/snapshot_manager.py#L99-L135 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | list | def list(connection):
""" List watched EBS volumes
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None
"""
volumes = get_watched_volumes(connection)
if not volumes:
logger.info('No watched volumes found')
return
l... | python | def list(connection):
""" List watched EBS volumes
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None
"""
volumes = get_watched_volumes(connection)
if not volumes:
logger.info('No watched volumes found')
return
l... | [
"def",
"list",
"(",
"connection",
")",
":",
"volumes",
"=",
"get_watched_volumes",
"(",
"connection",
")",
"if",
"not",
"volumes",
":",
"logger",
".",
"info",
"(",
"'No watched volumes found'",
")",
"return",
"logger",
".",
"info",
"(",
"'+----------------------... | List watched EBS volumes
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:returns: None | [
"List",
"watched",
"EBS",
"volumes"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L24-L90 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | unwatch | def unwatch(connection, volume_id):
""" Remove watching of a volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:returns: bool - True if the watch was successful
"""
... | python | def unwatch(connection, volume_id):
""" Remove watching of a volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:returns: bool - True if the watch was successful
"""
... | [
"def",
"unwatch",
"(",
"connection",
",",
"volume_id",
")",
":",
"try",
":",
"volume",
"=",
"connection",
".",
"get_all_volumes",
"(",
"volume_ids",
"=",
"[",
"volume_id",
"]",
")",
"[",
"0",
"]",
"volume",
".",
"remove_tag",
"(",
"'AutomatedEBSSnapshots'",
... | Remove watching of a volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:returns: bool - True if the watch was successful | [
"Remove",
"watching",
"of",
"a",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L93-L110 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | watch | def watch(connection, volume_id, interval='daily', retention=0):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:type interval: str
:param in... | python | def watch(connection, volume_id, interval='daily', retention=0):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:type interval: str
:param in... | [
"def",
"watch",
"(",
"connection",
",",
"volume_id",
",",
"interval",
"=",
"'daily'",
",",
"retention",
"=",
"0",
")",
":",
"try",
":",
"volume",
"=",
"connection",
".",
"get_all_volumes",
"(",
"volume_ids",
"=",
"[",
"volume_id",
"]",
")",
"[",
"0",
"... | Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume_id: str
:param volume_id: VolumeID to add to the watchlist
:type interval: str
:param interval: Backup interval [hourly|daily|weekly|monthly|yearly]
:type re... | [
"Start",
"watching",
"a",
"new",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L113-L152 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | get_volume_id | def get_volume_id(connection, volume):
"""
Get Volume ID from the given volume. Input can be volume id
or its Name tag.
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: Volume... | python | def get_volume_id(connection, volume):
"""
Get Volume ID from the given volume. Input can be volume id
or its Name tag.
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: Volume... | [
"def",
"get_volume_id",
"(",
"connection",
",",
"volume",
")",
":",
"# Regular expression to check whether input is a volume id",
"volume_id_pattern",
"=",
"re",
".",
"compile",
"(",
"'vol-\\w{8}'",
")",
"if",
"volume_id_pattern",
".",
"match",
"(",
"volume",
")",
":"... | Get Volume ID from the given volume. Input can be volume id
or its Name tag.
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: Volume ID or None if the given volume does not exist | [
"Get",
"Volume",
"ID",
"from",
"the",
"given",
"volume",
".",
"Input",
"can",
"be",
"volume",
"id",
"or",
"its",
"Name",
"tag",
"."
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L155-L189 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | watch_from_file | def watch_from_file(connection, file_name):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None
"""
with open(file_name, 'r') as filehandle:... | python | def watch_from_file(connection, file_name):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None
"""
with open(file_name, 'r') as filehandle:... | [
"def",
"watch_from_file",
"(",
"connection",
",",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"filehandle",
":",
"for",
"line",
"in",
"filehandle",
".",
"xreadlines",
"(",
")",
":",
"volume",
",",
"interval",
",",
"ret... | Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None | [
"Start",
"watching",
"a",
"new",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L192-L207 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | unwatch_from_file | def unwatch_from_file(connection, file_name):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None
"""
with open(file_name, 'r') as filehandl... | python | def unwatch_from_file(connection, file_name):
""" Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None
"""
with open(file_name, 'r') as filehandl... | [
"def",
"unwatch_from_file",
"(",
"connection",
",",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"filehandle",
":",
"for",
"line",
"in",
"filehandle",
".",
"xreadlines",
"(",
")",
":",
"volume",
",",
"interval",
",",
"r... | Start watching a new volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type file_name: str
:param file_name: path to config file
:returns: None | [
"Start",
"watching",
"a",
"new",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L210-L222 | train |
skymill/automated-ebs-snapshots | automated_ebs_snapshots/volume_manager.py | list_snapshots | def list_snapshots(connection, volume):
""" List all snapshots for the volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: None
"""
logger.info(
'+---------------... | python | def list_snapshots(connection, volume):
""" List all snapshots for the volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: None
"""
logger.info(
'+---------------... | [
"def",
"list_snapshots",
"(",
"connection",
",",
"volume",
")",
":",
"logger",
".",
"info",
"(",
"'+----------------'",
"'+----------------------'",
"'+---------------------------+'",
")",
"logger",
".",
"info",
"(",
"'| {snapshot:<14} '",
"'| {snapshot_name:<20.20} '",
"... | List all snapshots for the volume
:type connection: boto.ec2.connection.EC2Connection
:param connection: EC2 connection object
:type volume: str
:param volume: Volume ID or Volume Name
:returns: None | [
"List",
"all",
"snapshots",
"for",
"the",
"volume"
] | 9595bc49d458f6ffb93430722757d2284e878fab | https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/volume_manager.py#L225-L266 | train |
dmirecki/pyMorfologik | pymorfologik/morfologik.py | Morfologik.stem | def stem(self, words, parser, **kwargs):
"""
Get stems for the words using a given parser
Example:
from .parsing import ListParser
parser = ListParser()
stemmer = Morfologik()
stemmer.stem(['ja tańczę a ona śpi], parser)
[
... | python | def stem(self, words, parser, **kwargs):
"""
Get stems for the words using a given parser
Example:
from .parsing import ListParser
parser = ListParser()
stemmer = Morfologik()
stemmer.stem(['ja tańczę a ona śpi], parser)
[
... | [
"def",
"stem",
"(",
"self",
",",
"words",
",",
"parser",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"self",
".",
"_run_morfologik",
"(",
"words",
")",
"return",
"parser",
".",
"parse",
"(",
"output",
",",
"*",
"*",
"kwargs",
")"
] | Get stems for the words using a given parser
Example:
from .parsing import ListParser
parser = ListParser()
stemmer = Morfologik()
stemmer.stem(['ja tańczę a ona śpi], parser)
[
('ja': ['ja']),
('tańczę': ['tańczyć'... | [
"Get",
"stems",
"for",
"the",
"words",
"using",
"a",
"given",
"parser"
] | e4d93a82e8b4c7a108f01e0456fbeb8024df0259 | https://github.com/dmirecki/pyMorfologik/blob/e4d93a82e8b4c7a108f01e0456fbeb8024df0259/pymorfologik/morfologik.py#L29-L49 | train |
dmirecki/pyMorfologik | pymorfologik/morfologik.py | Morfologik._run_morfologik | def _run_morfologik(self, words):
"""
Runs morfologik java jar and assumes that input and output is
UTF-8 encoded.
"""
p = subprocess.Popen(
['java', '-jar', self.jar_path, 'plstem',
'-ie', 'UTF-8',
'-oe', 'UTF-8'],
bufsize=-1,
... | python | def _run_morfologik(self, words):
"""
Runs morfologik java jar and assumes that input and output is
UTF-8 encoded.
"""
p = subprocess.Popen(
['java', '-jar', self.jar_path, 'plstem',
'-ie', 'UTF-8',
'-oe', 'UTF-8'],
bufsize=-1,
... | [
"def",
"_run_morfologik",
"(",
"self",
",",
"words",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'java'",
",",
"'-jar'",
",",
"self",
".",
"jar_path",
",",
"'plstem'",
",",
"'-ie'",
",",
"'UTF-8'",
",",
"'-oe'",
",",
"'UTF-8'",
"]",
",... | Runs morfologik java jar and assumes that input and output is
UTF-8 encoded. | [
"Runs",
"morfologik",
"java",
"jar",
"and",
"assumes",
"that",
"input",
"and",
"output",
"is",
"UTF",
"-",
"8",
"encoded",
"."
] | e4d93a82e8b4c7a108f01e0456fbeb8024df0259 | https://github.com/dmirecki/pyMorfologik/blob/e4d93a82e8b4c7a108f01e0456fbeb8024df0259/pymorfologik/morfologik.py#L52-L66 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/showcase.py | Showcase.read_from_hdx | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Showcase']
"""Reads the showcase given by identifier from HDX and returns Showcase object
Args:
identifier (str): Identifier of showcase
configuration (Optional[Configu... | python | def read_from_hdx(identifier, configuration=None):
# type: (str, Optional[Configuration]) -> Optional['Showcase']
"""Reads the showcase given by identifier from HDX and returns Showcase object
Args:
identifier (str): Identifier of showcase
configuration (Optional[Configu... | [
"def",
"read_from_hdx",
"(",
"identifier",
",",
"configuration",
"=",
"None",
")",
":",
"# type: (str, Optional[Configuration]) -> Optional['Showcase']",
"showcase",
"=",
"Showcase",
"(",
"configuration",
"=",
"configuration",
")",
"result",
"=",
"showcase",
".",
"_load... | Reads the showcase given by identifier from HDX and returns Showcase object
Args:
identifier (str): Identifier of showcase
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
Optional[Showcase]: Showcase object if s... | [
"Reads",
"the",
"showcase",
"given",
"by",
"identifier",
"from",
"HDX",
"and",
"returns",
"Showcase",
"object"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/showcase.py#L76-L92 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/showcase.py | Showcase.get_datasets | def get_datasets(self):
# type: () -> List[hdx.data.dataset.Dataset]
"""Get any datasets in the showcase
Returns:
List[Dataset]: List of datasets
"""
assoc_result, datasets_dicts = self._read_from_hdx('showcase', self.data['id'], fieldname='showcase_id',
... | python | def get_datasets(self):
# type: () -> List[hdx.data.dataset.Dataset]
"""Get any datasets in the showcase
Returns:
List[Dataset]: List of datasets
"""
assoc_result, datasets_dicts = self._read_from_hdx('showcase', self.data['id'], fieldname='showcase_id',
... | [
"def",
"get_datasets",
"(",
"self",
")",
":",
"# type: () -> List[hdx.data.dataset.Dataset]",
"assoc_result",
",",
"datasets_dicts",
"=",
"self",
".",
"_read_from_hdx",
"(",
"'showcase'",
",",
"self",
".",
"data",
"[",
"'id'",
"]",
",",
"fieldname",
"=",
"'showcas... | Get any datasets in the showcase
Returns:
List[Dataset]: List of datasets | [
"Get",
"any",
"datasets",
"in",
"the",
"showcase"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/showcase.py#L179-L193 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/showcase.py | Showcase._get_showcase_dataset_dict | def _get_showcase_dataset_dict(self, dataset):
# type: (Union[hdx.data.dataset.Dataset,Dict,str]) -> Dict
"""Get showcase dataset dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
... | python | def _get_showcase_dataset_dict(self, dataset):
# type: (Union[hdx.data.dataset.Dataset,Dict,str]) -> Dict
"""Get showcase dataset dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
... | [
"def",
"_get_showcase_dataset_dict",
"(",
"self",
",",
"dataset",
")",
":",
"# type: (Union[hdx.data.dataset.Dataset,Dict,str]) -> Dict",
"if",
"isinstance",
"(",
"dataset",
",",
"hdx",
".",
"data",
".",
"dataset",
".",
"Dataset",
")",
"or",
"isinstance",
"(",
"data... | Get showcase dataset dict
Args:
showcase (Union[Showcase,Dict,str]): Either a showcase id or Showcase metadata from a Showcase object or dictionary
Returns:
Dict: showcase dataset dict | [
"Get",
"showcase",
"dataset",
"dict"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/showcase.py#L195-L213 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/showcase.py | Showcase.add_dataset | def add_dataset(self, dataset, datasets_to_check=None):
# type: (Union[hdx.data.dataset.Dataset,Dict,str], List[hdx.data.dataset.Dataset]) -> bool
"""Add a dataset
Args:
dataset (Union[Dataset,Dict,str]): Either a dataset id or dataset metadata either from a Dataset object or a dict... | python | def add_dataset(self, dataset, datasets_to_check=None):
# type: (Union[hdx.data.dataset.Dataset,Dict,str], List[hdx.data.dataset.Dataset]) -> bool
"""Add a dataset
Args:
dataset (Union[Dataset,Dict,str]): Either a dataset id or dataset metadata either from a Dataset object or a dict... | [
"def",
"add_dataset",
"(",
"self",
",",
"dataset",
",",
"datasets_to_check",
"=",
"None",
")",
":",
"# type: (Union[hdx.data.dataset.Dataset,Dict,str], List[hdx.data.dataset.Dataset]) -> bool",
"showcase_dataset",
"=",
"self",
".",
"_get_showcase_dataset_dict",
"(",
"dataset",
... | Add a dataset
Args:
dataset (Union[Dataset,Dict,str]): Either a dataset id or dataset metadata either from a Dataset object or a dictionary
datasets_to_check (List[Dataset]): List of datasets against which to check existence of dataset. Defaults to datasets in showcase.
Returns... | [
"Add",
"a",
"dataset"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/showcase.py#L215-L233 | train |
OCHA-DAP/hdx-python-api | src/hdx/data/showcase.py | Showcase.add_datasets | def add_datasets(self, datasets, datasets_to_check=None):
# type: (List[Union[hdx.data.dataset.Dataset,Dict,str]], List[hdx.data.dataset.Dataset]) -> bool
"""Add multiple datasets
Args:
datasets (List[Union[Dataset,Dict,str]]): A list of either dataset ids or dataset metadata from D... | python | def add_datasets(self, datasets, datasets_to_check=None):
# type: (List[Union[hdx.data.dataset.Dataset,Dict,str]], List[hdx.data.dataset.Dataset]) -> bool
"""Add multiple datasets
Args:
datasets (List[Union[Dataset,Dict,str]]): A list of either dataset ids or dataset metadata from D... | [
"def",
"add_datasets",
"(",
"self",
",",
"datasets",
",",
"datasets_to_check",
"=",
"None",
")",
":",
"# type: (List[Union[hdx.data.dataset.Dataset,Dict,str]], List[hdx.data.dataset.Dataset]) -> bool",
"if",
"datasets_to_check",
"is",
"None",
":",
"datasets_to_check",
"=",
"s... | Add multiple datasets
Args:
datasets (List[Union[Dataset,Dict,str]]): A list of either dataset ids or dataset metadata from Dataset objects or dictionaries
datasets_to_check (List[Dataset]): List of datasets against which to check existence of dataset. Defaults to datasets in showcase.
... | [
"Add",
"multiple",
"datasets"
] | 212440f54f73805826a16db77dbcb6033b18a313 | https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/showcase.py#L235-L252 | train |
hz-inova/run_jnb | run_jnb/core.py | possible_parameter | def possible_parameter(nb, jsonable_parameter=True, end_cell_index=None):
"""
Find the possible parameters from a jupyter notebook (python3 only).
The possible parameters are obtained by parsing the abstract syntax tree of
the python code generated from the jupyter notebook.
For a jupuyter noteboo... | python | def possible_parameter(nb, jsonable_parameter=True, end_cell_index=None):
"""
Find the possible parameters from a jupyter notebook (python3 only).
The possible parameters are obtained by parsing the abstract syntax tree of
the python code generated from the jupyter notebook.
For a jupuyter noteboo... | [
"def",
"possible_parameter",
"(",
"nb",
",",
"jsonable_parameter",
"=",
"True",
",",
"end_cell_index",
"=",
"None",
")",
":",
"jh",
"=",
"_JupyterNotebookHelper",
"(",
"nb",
",",
"jsonable_parameter",
",",
"end_cell_index",
")",
"if",
"jsonable_parameter",
"is",
... | Find the possible parameters from a jupyter notebook (python3 only).
The possible parameters are obtained by parsing the abstract syntax tree of
the python code generated from the jupyter notebook.
For a jupuyter notebook, a variable can be a possible parameter if:
- it is defined in a cell that c... | [
"Find",
"the",
"possible",
"parameters",
"from",
"a",
"jupyter",
"notebook",
"(",
"python3",
"only",
")",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/core.py#L16-L57 | train |
hz-inova/run_jnb | run_jnb/core.py | run_jnb | def run_jnb(input_path, output_path=r"///_run_jnb/*-output",
execution_path=r'///input',
return_mode='except',
overwrite=False,
timeout=ExecutePreprocessor.timeout.default_value,
kernel_name=ExecutePreprocessor.kernel_name.default_value,
ep_kwargs=... | python | def run_jnb(input_path, output_path=r"///_run_jnb/*-output",
execution_path=r'///input',
return_mode='except',
overwrite=False,
timeout=ExecutePreprocessor.timeout.default_value,
kernel_name=ExecutePreprocessor.kernel_name.default_value,
ep_kwargs=... | [
"def",
"run_jnb",
"(",
"input_path",
",",
"output_path",
"=",
"r\"///_run_jnb/*-output\"",
",",
"execution_path",
"=",
"r'///input'",
",",
"return_mode",
"=",
"'except'",
",",
"overwrite",
"=",
"False",
",",
"timeout",
"=",
"ExecutePreprocessor",
".",
"timeout",
"... | Run an input jupyter notebook file and optionally (python3 only)
parametrise it.
One can pass arguments as keyword arguments or in a json format (file or string).
For safety reasons, in order to avoid any code injection,
only json serialisable keywords arguments are available. The keyword
arguments... | [
"Run",
"an",
"input",
"jupyter",
"notebook",
"file",
"and",
"optionally",
"(",
"python3",
"only",
")",
"parametrise",
"it",
"."
] | 55e63de33b0643161948864d2c1ec998f02815bf | https://github.com/hz-inova/run_jnb/blob/55e63de33b0643161948864d2c1ec998f02815bf/run_jnb/core.py#L60-L256 | train |
Tygs/ww | src/ww/wrappers/lists.py | ListWrapper.join | def join(self, joiner, formatter=lambda s, t: t.format(s),
template="{}"):
"""Join values and convert to string
Example:
>>> from ww import l
>>> lst = l('012')
>>> lst.join(',')
u'0,1,2'
>>> lst.join(',', template="{}#")
... | python | def join(self, joiner, formatter=lambda s, t: t.format(s),
template="{}"):
"""Join values and convert to string
Example:
>>> from ww import l
>>> lst = l('012')
>>> lst.join(',')
u'0,1,2'
>>> lst.join(',', template="{}#")
... | [
"def",
"join",
"(",
"self",
",",
"joiner",
",",
"formatter",
"=",
"lambda",
"s",
",",
"t",
":",
"t",
".",
"format",
"(",
"s",
")",
",",
"template",
"=",
"\"{}\"",
")",
":",
"return",
"ww",
".",
"s",
"(",
"joiner",
")",
".",
"join",
"(",
"self",... | Join values and convert to string
Example:
>>> from ww import l
>>> lst = l('012')
>>> lst.join(',')
u'0,1,2'
>>> lst.join(',', template="{}#")
u'0#,1#,2#'
>>> string = lst.join(',',\
formatte... | [
"Join",
"values",
"and",
"convert",
"to",
"string"
] | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/lists.py#L33-L51 | train |
Tygs/ww | src/ww/wrappers/lists.py | ListWrapper.append | def append(self, *values):
"""Append values at the end of the list
Allow chaining.
Args:
values: values to be appened at the end.
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.append(1)
[1]
>>> lst
... | python | def append(self, *values):
"""Append values at the end of the list
Allow chaining.
Args:
values: values to be appened at the end.
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.append(1)
[1]
>>> lst
... | [
"def",
"append",
"(",
"self",
",",
"*",
"values",
")",
":",
"for",
"value",
"in",
"values",
":",
"list",
".",
"append",
"(",
"self",
",",
"value",
")",
"return",
"self"
] | Append values at the end of the list
Allow chaining.
Args:
values: values to be appened at the end.
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.append(1)
[1]
>>> lst
[1]
>>> lst.append(2... | [
"Append",
"values",
"at",
"the",
"end",
"of",
"the",
"list"
] | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/lists.py#L53-L77 | train |
Tygs/ww | src/ww/wrappers/lists.py | ListWrapper.extend | def extend(self, *iterables):
"""Add all values of all iterables at the end of the list
Args:
iterables: iterable which content to add at the end
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.extend([1, 2])
[1, 2]
... | python | def extend(self, *iterables):
"""Add all values of all iterables at the end of the list
Args:
iterables: iterable which content to add at the end
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.extend([1, 2])
[1, 2]
... | [
"def",
"extend",
"(",
"self",
",",
"*",
"iterables",
")",
":",
"for",
"value",
"in",
"iterables",
":",
"list",
".",
"extend",
"(",
"self",
",",
"value",
")",
"return",
"self"
] | Add all values of all iterables at the end of the list
Args:
iterables: iterable which content to add at the end
Example:
>>> from ww import l
>>> lst = l([])
>>> lst.extend([1, 2])
[1, 2]
>>> lst
[1, 2]
>... | [
"Add",
"all",
"values",
"of",
"all",
"iterables",
"at",
"the",
"end",
"of",
"the",
"list"
] | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/lists.py#L79-L101 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.