Skip to content

Commit

Permalink
Replace dependency on deprecated pkg_resources
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
geracnubiral authored and jleclanche committed Sep 30, 2024
1 parent 9913ec6 commit ab3d9e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions iso18245/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import csv
import os.path
from typing import Any, Dict, List, NamedTuple

from pkg_resources import resource_filename
from importlib.resources import files
from typing import Dict, List, NamedTuple

ISO_VERSION_YEAR = 2003

Expand Down Expand Up @@ -42,8 +40,8 @@ class MCC(NamedTuple):

def _load_csv(path: str) -> List[List[str]]:
if path not in _cached_csv:
full_path = resource_filename("iso18245", os.path.join("data", path))
with open(full_path, "r") as f:
ref = files("iso18245") / "data" / path
with ref.open("r") as f:
reader = csv.reader(f)
_cached_csv[path] = list(reader)[1:]

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.8"
importlib_resources = "^5.4.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.2.0"
Expand Down

0 comments on commit ab3d9e3

Please sign in to comment.