Skip to content
Snippets Groups Projects
Commit 0a1dbe9d authored by Christoph Alt's avatar Christoph Alt
Browse files

optionally use backport of importlib resources for json import

parent a3bd8c69
Branches
No related tags found
No related merge requests found
Pipeline #51919 passed
import plotly.graph_objs as go
from dataclasses import dataclass
import json
import importlib
try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources
@dataclass
......@@ -19,7 +24,7 @@ DEFAULT_MARKER = dict(size=10, color='green')
def get_data(file_name="roofline_data.json"):
with importlib.resources.open_text(__package__, file_name) as file:
with pkg_resources.open_text(__package__, file_name) as file:
data = json.load(file)
return data
......
......@@ -23,7 +23,8 @@ setup(name="cb-util",
"requests",
"plotly",
"kaleido",
"kadi-apy"
"kadi-apy",
"importlib_resources ; python_version<'3.7'",
],
setup_requires=['pytest-runner'],
tests_require=['pytest']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment