download_all_domains.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. """Downloads all domain data sets from FAOSTAT website."""
  2. from faostat_data_primap.download import (
  3. download_all_domains,
  4. )
  5. # def download_all_domains(
  6. # domains: list[tuple[str]] = domains,
  7. # downloaded_data_path: str = downloaded_data_path,
  8. # ) -> list[str]:
  9. # """
  10. # Download and unpack all climate-related domains from the FAO stat website.
  11. #
  12. # Extract the date when the data set was last updated and create a directory
  13. # with the same name. Download the zip files for each domain if
  14. # it does not already exist. Unpack the zip file and save in
  15. # the same directory.
  16. #
  17. # Parameters
  18. # ----------
  19. # sources
  20. # Name of data set, url to domain overview,
  21. # and download url
  22. #
  23. # Returns
  24. # -------
  25. # List of input files that have been fetched or found locally.
  26. #
  27. # """
  28. # downloaded_files = []
  29. # for ds_name, urls in domains.items():
  30. # url = urls["url_domain"]
  31. # url_download = urls["url_download"]
  32. # url_methodology = urls["url_methodology"]
  33. #
  34. # soup = get_html_content(url)
  35. #
  36. # last_updated = get_last_updated_date(soup, url)
  37. #
  38. # if not downloaded_data_path.exists():
  39. # downloaded_data_path.mkdir()
  40. #
  41. # ds_path = downloaded_data_path / ds_name
  42. # if not ds_path.exists():
  43. # ds_path.mkdir()
  44. #
  45. # local_data_dir = ds_path / last_updated
  46. # if not local_data_dir.exists():
  47. # local_data_dir.mkdir()
  48. #
  49. # download_methodology(save_path=local_data_dir, url_download=url_methodology)
  50. #
  51. # local_filename = local_data_dir / f"{ds_name}.zip"
  52. #
  53. # download_file(url_download=url_download, save_path=local_filename)
  54. #
  55. # downloaded_files.append(str(local_filename))
  56. #
  57. # unzip_file(local_filename)
  58. #
  59. # return downloaded_files
  60. if __name__ == "__main__":
  61. download_all_domains()