diff --git a/pirate/data.py b/pirate/data.py index 27ca62d..73869d1 100644 --- a/pirate/data.py +++ b/pirate/data.py @@ -1,7 +1,13 @@ import json +import pkgutil -categories = json.load(open('data/categories.json')) -sorts = json.load(open('data/sorts.json')) + +def get_resource(filename): + return pkgutil.get_data(__package__, 'data/' + filename) + + +categories = json.loads(get_resource('categories.json').decode()) +sorts = json.loads(get_resource('sorts.json').decode()) default_headers = {'User-Agent': 'pirate get'} default_timeout = 10 diff --git a/data/categories.json b/pirate/data/categories.json similarity index 100% rename from data/categories.json rename to pirate/data/categories.json diff --git a/data/sorts.json b/pirate/data/sorts.json similarity index 100% rename from data/sorts.json rename to pirate/data/sorts.json diff --git a/setup.py b/setup.py index 83fbcab..fcbd94b 100755 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ setup(name='pirate-get', author_email='me@viktorstanchev.com', license='GPL', packages=find_packages(), + package_data={'': ["data/*.json"]}, entry_points={ 'console_scripts': ['pirate-get = pirate.pirate:main'] },