Skip to content

Commit

Permalink
fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
otvam committed Dec 10, 2024
1 parent 73239e6 commit 3c5a2f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions scilogger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

# get the version number
try:
with importlib.resources.open_text("scilogger", "version.txt") as file:
__version__ = file.read()
filename = importlib.resources.files("scilogger").joinpath("version.txt")
with filename.open("r") as fid:
__version__ = fid.read()
except FileNotFoundError:
__version__ = 'x.x.x'

Expand Down
7 changes: 4 additions & 3 deletions scilogger/scilogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ def _load_config():
config.optionxform = str

# load the default file
with importlib.resources.path("scilogger", "scilogger.ini") as file:
out = config.read(file)
folder = importlib.resources.files("scilogger")
with importlib.resources.as_file(folder.joinpath("scilogger.ini")) as fid:
out = config.read(fid)
if len(out) != 1:
raise RuntimeError("config file cannot be loaded: %s" % file)
raise RuntimeError("config file cannot be loaded: %s" % fid)

# get file custom file
file = os.getenv("SCILOGGER")
Expand Down

0 comments on commit 3c5a2f9

Please sign in to comment.