-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(meta_helpers: find_aur_pkgs_with_double_requirements): extra…
…ct common function
- Loading branch information
1 parent
de950a0
commit 01dd5d5
Showing
2 changed files
with
25 additions
and
22 deletions.
There are no files selected for viewing
25 changes: 3 additions & 22 deletions
25
pikaur_meta_helpers/find_aur_pkgs_with_double_requirements.py
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,22 @@ | ||
import pickle # nosec B403 | ||
from pathlib import Path | ||
from typing import Final | ||
|
||
from pikaur.aur import AURPackageInfo, get_all_aur_packages | ||
|
||
PICKLE_FILE: Final = Path("aur_db.dump") | ||
|
||
|
||
def load_aur_dump() -> list[AURPackageInfo]: | ||
aur_pkgs: list[AURPackageInfo] | ||
if PICKLE_FILE.exists(): | ||
print(f"Opening db dump '{PICKLE_FILE}'...") | ||
with PICKLE_FILE.open("rb") as fobj_read: | ||
aur_pkgs = pickle.load(fobj_read) # nosec B301 | ||
else: | ||
print("Fetching...") | ||
aur_pkgs = get_all_aur_packages() | ||
print(f"Saving db dump to '{PICKLE_FILE}'...") | ||
with PICKLE_FILE.open("wb") as fobj_write: | ||
pickle.dump(aur_pkgs, fobj_write) | ||
return aur_pkgs |