Skip to content

Commit

Permalink
Use _ochapath_default
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Nov 18, 2024
1 parent 547a975 commit fa69943
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ charset-normalizer==3.4.0
# via requests
click==8.1.7
# via typer
coverage==7.6.5
coverage==7.6.7
# via pytest-cov
distlib==0.3.9
# via virtualenv
Expand Down
20 changes: 9 additions & 11 deletions src/hdx/location/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ class Country:
_countriesdata = None
_ochaurl_default = "https://docs.google.com/spreadsheets/d/1NjSI2LaS3SqbgYc0HdD8oIb7lofGtiHgoKKATCpwVdY/export?format=csv&gid=1088874596"
_ochaurl = _ochaurl_default
_ochapath = None
_ochapath_default = script_dir_plus_file(
"Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv",
CountryError,
)
_ochapath = _ochapath_default
_country_name_overrides = {}
_country_name_mappings = {}

Expand Down Expand Up @@ -239,14 +243,8 @@ def countriesdata(
"Download from OCHA feed failed! Falling back to stored file."
)
if countries is None:
file_path = script_dir_plus_file(
"Countries & Territories Taxonomy MVP - C&T Taxonomy with HXL Tags.csv",
CountryError,
)
if cls._ochapath:
file_path = cls._ochapath
countries = hxl.data(
file_path,
cls._ochapath,
InputOptions(allow_local=True, encoding="utf-8"),
)
cls.set_countriesdata(countries)
Expand All @@ -269,7 +267,7 @@ def set_use_live_default(cls, use_live: Optional[bool] = None) -> None:
cls._use_live = use_live

@classmethod
def set_ocha_url(cls, url: Optional[str] = None) -> None:
def set_ocha_url(cls, url: str = None) -> None:
"""
Set OCHA url from which to retrieve countries data
Expand All @@ -294,8 +292,8 @@ def set_ocha_path(cls, path: Optional[str] = None) -> None:
Returns:
None
"""
if path and not os.path.exists(path):
path = None
if not path or (path and not os.path.exists(path)):
path = cls._ochapath_default
cls._ochapath = path

@classmethod
Expand Down

0 comments on commit fa69943

Please sign in to comment.