Skip to content

Commit

Permalink
final updates before release
Browse files Browse the repository at this point in the history
  • Loading branch information
jamc-code committed Apr 6, 2021
1 parent 2cf86fb commit a4e074d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Search the [DnD5e API](https://www.dnd5eapi.co) and return relevant information

## Requirements

- Python ^3.7
- [appdirs](https://github.com/ActiveState/appdirs)>=1.4.4 for finding
what directories to store data in (helps this function as a
platform-independent application)
- [GitPython](https://github.com/gitpython-developers/GitPython)>=3.1.14 for
downloading the database repository
- [pymongo](https://github.com/mongodb/mongo-python-driver)>=3.11.3 for querying
a local database
- [requests](https://github.com/psf/requests)>=2.25.1 for querying the database
at <https://dnd5eapi.co/api>
- [rich](https://github.com/willmcgugan/rich)>=9.13.0 for formatting retrieved information

## Optional Requirements

- If you want to query a local database (it's faster and works offline!),
Expand Down
20 changes: 2 additions & 18 deletions dnfo/database_ops/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ def download_db(url: str, location: str) -> str:
return hexsha


def hashes_match(lockfile: Path, newlock: str) -> bool:
"""read a lockfile to see if the database needs to be updated.
additionally, check if hashes match"""
try:
with lockfile.open() as file:
oldlock: str = file.read().strip()
if oldlock == newlock:
return False
except FileNotFoundError:
pass
finally:
with lockfile.open() as file:
file.write(newlock.strip())
return True # pylint: disable=W0150


def lock(lockfile: Path, newlock: str) -> bool:
"""read a lockfile to see if the database needs to be updated.
additionally, check if hashes match
Expand Down Expand Up @@ -130,9 +114,9 @@ def populate_db(rebuild=False) -> int:

try:
DB_DIR.mkdir(parents=True)
print(f"Creating '{DB_DIR}' for database storage...")
print(f"Storing JSON files in '{DB_DIR}'.")
except FileExistsError:
print("Using existing database.")
print(f"Existing JSON files found at '{DB_DIR}'.")

with tempfile.TemporaryDirectory(prefix="dnfo.") as tmpdir:
head_hash = download_db(URL, tmpdir)
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/sudo-julia/dnfo",
package_dir={"": "dnfo"},
packages=find_packages(),
modules=["database_ops", "queries"],
classifiers=[
Expand All @@ -32,11 +33,16 @@
"Typing :: Typed",
],
install_requires=[
"appdirs>=1.4.4",
"requests>=2.25.1",
"rich>=>=9.13.0",
"pymongo>=3.11.3",
"GitPython>=3.1.14",
],
python_requires=">=3.7",
entry_points={"console_scripts": ["dnfo = dnfo.__main__:main"]},
project_urls={
"Bug Reports": "https://github.com/sudo-julia/dnfo/issues",
"Source": "https://github.com/sudo-julia/dnfo/issues",
},
)

0 comments on commit a4e074d

Please sign in to comment.