-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
621685f
commit 66841a6
Showing
1 changed file
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
from pathlib import Path | ||
import json | ||
|
||
db_location = "/Users/dailis/.pm/pm.json" | ||
pm_directory = Path.home() / ".pm" | ||
db_location = pm_directory / "pm.json" | ||
|
||
|
||
empty_db = { | ||
"issues": [], | ||
"prs": [], | ||
"project_items": { | ||
"items": [] | ||
} | ||
} | ||
|
||
|
||
def retrieve(): | ||
ensure_pm_directory_exists() | ||
with open(db_location, "r") as f: | ||
return json.load(f) | ||
|
||
|
||
def store(contents): | ||
ensure_pm_directory_exists() | ||
with open(db_location, "w") as f: | ||
json.dump(contents, f) | ||
|
||
|
||
def ensure_pm_directory_exists(): | ||
pm_directory.mkdir(parents=True, exist_ok=True) | ||
if not db_location.is_file(): | ||
print("Creating empty database at" , db_location) | ||
with open(db_location, "w") as f: | ||
json.dump(empty_db, f) |