Skip to content

Commit

Permalink
fixing it up
Browse files Browse the repository at this point in the history
  • Loading branch information
stringertheory committed Jan 31, 2024
1 parent b1bde45 commit 2906b51
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions clean_links/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
import pkgutil


def read_json(filename: str) -> dict:
data = pkgutil.get_data(__name__, filename)
if data is None:
msg = f"didn't find config file {filename}"
raise FileNotFoundError(msg)

return dict(json.loads(data.decode("utf8")))


def read_config(
additional_config_filename: str = "clearurls_config.json",
) -> dict:
data = pkgutil.get_data(__name__, "clearurls.json").decode("utf8")
clear_urls_rules = dict(json.loads(data))

data = pkgutil.get_data(__name__, additional_config_filename).decode("utf8")
additional_rules = dict(json.loads(data))
clear_urls_rules = read_json("clearurls.json")
additional_rules = read_json(additional_config_filename)

for provider_name, rules in additional_rules["providers"].items():
provider = clear_urls_rules["providers"].get(provider_name)
Expand Down

0 comments on commit 2906b51

Please sign in to comment.