Skip to content

Commit

Permalink
fix: update deprecated importlib methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-RA-King committed Sep 10, 2022
1 parent ded5e20 commit 0e5de3d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/piptools_sync/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Top-level package for piptools_sync."""
# Core Library modules
import logging.config
from importlib import resources
from importlib.resources import as_file, files
from pathlib import Path

# Third party modules
Expand Down Expand Up @@ -39,7 +39,7 @@
formatters:
basic:
style: "{"
format: "{levelname:s}:{name:s}:{message:s}"
format: "{message:s}"
timestamp:
style: "{"
format: "{asctime} - {levelname} - {name} - {message}"
Expand All @@ -54,8 +54,15 @@
logging.config.dictConfig(yaml.safe_load(LOGGING_CONFIG))
logger = logging.getLogger("init")

with resources.path("piptools_sync", "mapping.json") as path:
MAPPING_FILE = path

_toml_text = resources.read_text("piptools_sync", "config.toml")
toml_config = toml.loads(_toml_text)
source_json = files("piptools_sync").joinpath("mapping.json")
if not source_json.is_file():
with as_file(source_json) as _json_file:
_json_file.write_text("{}")
MAPPING_FILE = source_json


source = files("piptools_sync").joinpath("config.toml")
with as_file(source) as _toml_path:
_toml_text = _toml_path.read_text()
toml_config = toml.loads(_toml_text)

0 comments on commit 0e5de3d

Please sign in to comment.