|
40 | 40 | import hdx.data.vocabulary as vocabulary |
41 | 41 | from hdx.api.configuration import Configuration |
42 | 42 | from hdx.api.locations import Locations |
43 | | -from hdx.api.utilities.dataset_title_helper import DatasetTitleHelper |
44 | 43 | from hdx.api.utilities.date_helper import DateHelper |
45 | 44 | from hdx.api.utilities.filestore_helper import FilestoreHelper |
46 | 45 | from hdx.data.hdxobject import HDXError, HDXObject |
@@ -2379,33 +2378,6 @@ def get_api_url(self, prefer_name: bool = True) -> str | None: |
2379 | 2378 | return None |
2380 | 2379 | return f"{self.configuration.get_hdx_site_url()}/api/3/action/package_show?id={name_or_id}" |
2381 | 2380 |
|
2382 | | - def remove_dates_from_title( |
2383 | | - self, change_title: bool = True, set_time_period: bool = False |
2384 | | - ) -> list[tuple[datetime, datetime]]: |
2385 | | - """Remove dates from dataset title returning sorted the dates that were found in |
2386 | | - title. The title in the dataset metadata will be changed by default. The |
2387 | | - dataset's metadata field time period will not be changed by default, but if |
2388 | | - set_time_period is True, then the range with the lowest start date will be used |
2389 | | - to set the time period field. |
2390 | | -
|
2391 | | - Args: |
2392 | | - change_title: Whether to change the dataset title. Defaults to True. |
2393 | | - set_time_period: Whether to set time period from date or range in title. Defaults to False. |
2394 | | -
|
2395 | | - Returns: |
2396 | | - Date ranges found in title |
2397 | | - """ |
2398 | | - if "title" not in self.data: |
2399 | | - raise HDXError("Dataset has no title!") |
2400 | | - title = self.data["title"] |
2401 | | - newtitle, ranges = DatasetTitleHelper.get_dates_from_title(title) |
2402 | | - if change_title: |
2403 | | - self.data["title"] = newtitle |
2404 | | - if set_time_period and len(ranges) != 0: |
2405 | | - startdate, enddate = ranges[0] |
2406 | | - self.set_time_period(startdate, enddate) |
2407 | | - return ranges |
2408 | | - |
2409 | 2381 | def generate_resource( |
2410 | 2382 | self, |
2411 | 2383 | folder: Path | str, |
|
0 commit comments