-
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.
tidy and docstrings, get rid of stats error
- Loading branch information
Showing
7 changed files
with
100 additions
and
37 deletions.
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
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,21 +1,38 @@ | ||
""" | ||
The cache dir, which lives at ~/.cache/ienv | ||
It's where all your files have been moved to. | ||
""" | ||
import os | ||
from pathlib import Path | ||
|
||
CACHE_FILE = "venvs.txt" | ||
|
||
|
||
def get_cache_dir(prefix="~"): | ||
""" | ||
Return the cache dir, creating it if it doesn't exist. | ||
""" | ||
cache_dir = Path(f"{prefix}/.cache/ienv/files").expanduser() | ||
cache_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
return cache_dir | ||
|
||
|
||
def load_venv_list(file_path): | ||
""" | ||
Load the list of venvs that have been squished. | ||
""" | ||
if not os.path.exists(file_path): | ||
return set() | ||
with open(file_path, "r") as f: | ||
return set(line.strip() for line in f) | ||
|
||
|
||
def save_venv_list(file_path, venvs): | ||
""" | ||
Save the list of venvs that have been squished. | ||
""" | ||
with open(file_path, "w") as f: | ||
for venv in venvs: | ||
f.write(f"{venv}\n") |
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Stats will go here eventually | ||
""" | ||
from ienv.cache import CACHE_FILE, get_cache_dir, load_venv_list | ||
|
||
|
||
def print_stats(): | ||
""" | ||
Doesn't do much yet really. | ||
""" | ||
cache_dir = get_cache_dir() | ||
venvs = load_venv_list(cache_dir / CACHE_FILE) | ||
print(f"I've mangled {len(venvs)} venvs!") | ||
for venv in venvs: | ||
print(" ", venv) |
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
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