Commit dabf31bc authored by shadMod's avatar shadMod 💬

replaced pkg_resources with os.path

parent 7cafc9c0
...@@ -24,32 +24,28 @@ import collections ...@@ -24,32 +24,28 @@ import collections
import flask import flask
import itsdangerous import itsdangerous
import requests import requests
import pkg_resources
from . import cache from . import cache
from . import launchpad from . import launchpad
CONFIG_FILE = "/data/downloads.toml"
CONFIG_FILE = "data/downloads.toml"
CACHE_FILE = "download-cache.json" CACHE_FILE = "download-cache.json"
CACHE_FILE_VERSION = 1 CACHE_FILE_VERSION = 1
class Downloads: class Downloads:
def __init__(self, data_path): def __init__(self, data_path):
# Load the configuration # Load the configuration
raw = pkg_resources.resource_string("uitwww", CONFIG_FILE) path = os.path.dirname(os.path.abspath(__file__)) + CONFIG_FILE
self.config = toml.loads( self.config = toml.load(
raw.decode("utf-8"), path, # _dict=collections.OrderedDict,
_dict=collections.OrderedDict,
) )
self._strip_non_lts_releases() self._strip_non_lts_releases()
# Save the hash of the configuration # Save the hash of the configuration
self._config_hash = "sha1=%s" % hashlib.sha1(raw).hexdigest() with open(path, "rb") as raw:
self._config_hash = "sha1=%s" % hashlib.sha1(raw.read()).hexdigest()
self._cache_file = os.path.join(data_path, CACHE_FILE) self._cache_file = os.path.join(data_path, CACHE_FILE)
@property @property
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment