Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drop use of deprecated module pkg_resources #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ee_extra/Apps/utils.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
from typing import Optional, Union

import ee
import pkg_resources

from ee_extra.utils import _load_JSON

@@ -19,9 +18,8 @@ def _get_apps(online: bool) -> dict:
Apps.
"""
if online:
with urllib.request.urlopen(
"https://raw.githubusercontent.com/samapriya/ee-appshot/main/app_urls.json"
) as url:
url = "https://raw.githubusercontent.com/samapriya/ee-appshot/main/app_urls.json"
with urllib.request.urlopen(url) as url:
apps = json.loads(url.read().decode())
else:
apps = _load_JSON("ee-appshot.json")
1 change: 0 additions & 1 deletion ee_extra/ImageCollection/core.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
from typing import Optional, Union

import ee
import pkg_resources

from ee_extra.STAC.utils import _get_platform_STAC

8 changes: 3 additions & 5 deletions ee_extra/JavaScript/install.py
Original file line number Diff line number Diff line change
@@ -5,8 +5,7 @@
import pathlib
import re
import urllib.request

import pkg_resources
from pathlib import Path


def _convert_path_to_ee_sources(path: str) -> str:
@@ -32,9 +31,8 @@ def _get_ee_sources_path() -> str:
Returns:
The ee-sources folder path.
"""
ee_extra_py_file = pkg_resources.resource_filename("ee_extra", "ee_extra.py")
pkgdir = pathlib.Path(ee_extra_py_file).parent
return pkgdir.joinpath("ee-sources").as_posix()
pkgdir = Path(__file__).parents[1]
return (pkgdir / "ee-sources").as_posix()


def _convert_path_to_ee_extra(path: str) -> str:
1 change: 0 additions & 1 deletion ee_extra/STAC/core.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
from typing import Optional, Union

import ee
import pkg_resources

from ee_extra.STAC.utils import _get_platform_STAC
from ee_extra.utils import _load_JSON
1 change: 0 additions & 1 deletion ee_extra/STAC/utils.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
from typing import Optional, Union

import ee
import pkg_resources

from ee_extra.utils import _load_JSON

10 changes: 4 additions & 6 deletions ee_extra/Spectral/utils.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
from typing import Optional, Union, Tuple, Dict

import ee
import pkg_resources

from ee_extra.STAC.utils import _get_platform_STAC
from ee_extra.utils import _load_JSON
@@ -242,9 +241,8 @@ def _get_indices(online: bool) -> dict:
Indices.
"""
if online:
with urllib.request.urlopen(
"https://raw.githubusercontent.com/awesome-spectral-indices/awesome-spectral-indices/main/output/spectral-indices-dict.json"
) as url:
url = "https://raw.githubusercontent.com/awesome-spectral-indices/awesome-spectral-indices/main/output/spectral-indices-dict.json"
with urllib.request.urlopen(url) as url:
indices = json.loads(url.read().decode())
else:
indices = _load_JSON("spectral-indices-dict.json")
@@ -425,8 +423,8 @@ def _get_tc_coefficients(platform: str) -> dict:
"TCW": (0.2254, 0.3681, 0.2250, -0.6053, -0.6298)
}

# Zhai et al. 2022 coefficients were included for L8 TOA over the Baig
# et al. 2014 coefficients for consistency with the L8 SR coefficients,
# Zhai et al. 2022 coefficients were included for L8 TOA over the Baig
# et al. 2014 coefficients for consistency with the L8 SR coefficients,
# which were not calculated by Baig et al.
LANDSAT8_TOA = {
"bands": ("B3", "B4", "B5", "B6", "B7"),
12 changes: 4 additions & 8 deletions ee_extra/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import difflib
import json
import os
from typing import Any, Optional, List, Sequence
from pathlib import Path

import ee
import pkg_resources


def _load_JSON(x: Optional[str] = "ee-catalog-ids.json") -> Any:
@@ -16,12 +15,9 @@ def _load_JSON(x: Optional[str] = "ee-catalog-ids.json") -> Any:
Returns:
JSON file.
"""
eeExtraDir = os.path.dirname(
pkg_resources.resource_filename("ee_extra", "ee_extra.py")
)
dataPath = os.path.join(eeExtraDir, "data/" + x)
f = open(dataPath)
data = json.load(f)
eeExtraDir = Path(__file__).parent
dataPath = eeExtraDir / "data" / x
data = json.loads(dataPath.read_text())

return data