Skip to content

Commit 74b0db5

Browse files
committed
Update load_data_.py to use pkutil
1 parent fa74862 commit 74b0db5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

axelrod/load_data_.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import pathlib
22
from typing import Dict, List, Text, Tuple
33

4-
import pkg_resources
5-
4+
import pkgutil
65

76
def axl_filename(path: pathlib.Path) -> pathlib.Path:
87
"""Given a path under Axelrod/, return absolute filepath.
@@ -24,9 +23,11 @@ def axl_filename(path: pathlib.Path) -> pathlib.Path:
2423
def load_file(filename: str, directory: str) -> List[List[str]]:
2524
"""Loads a data file stored in the Axelrod library's data subdirectory,
2625
likely for parameters for a strategy."""
27-
path = "/".join((directory, filename))
28-
data_bytes = pkg_resources.resource_string(__name__, path)
26+
27+
path = str(pathlib.Path(directory) / filename)
28+
data_bytes = pkgutil.get_data(__name__, path)
2929
data = data_bytes.decode("UTF-8", "replace")
30+
3031
rows = []
3132
for line in data.split("\n"):
3233
if line.startswith("#") or len(line) == 0:

0 commit comments

Comments
 (0)