Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access files as setuptools pkg_resource #2309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from pkg_resources import resource_filename

__title__ = 'safety-db'
__version__ = '2020.4.14'
Expand All @@ -10,14 +11,14 @@
'INSECURE_FULL',
)

with open("data/insecure.json") as __f:
with open(resource_filename("safety_db", "insecure.json")) as __f:
try:
INSECURE = json.loads(__f.read())
except ValueError as e:
INSECURE = []


with open("data/insecure_full.json") as __f:
with open(resource_filename("safety_db", "insecure_full.json")) as __f:
try:
INSECURE_FULL = json.loads(__f.read())
except ValueError as e:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packaging
parameterized
parameterized
setuptools
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
packages=['safety_db'],
license='Attribution-NonCommercial-ShareAlike 4.0 International',
install_requires=[],
install_requires=['setuptools'],
tests_require=tests_require,
include_package_data=True,
)