Fixed package detection

This commit is contained in:
2024-08-14 10:46:05 +02:00
committed by Flo Greistorfer
parent e0cb13771c
commit 9de971d2ac
5 changed files with 30 additions and 22 deletions

View File

@@ -17,11 +17,13 @@ from modules.generate_html import list_folder, EXCLUDES
# fmt: off
# Constants
if __package__ == None:
__package__ = ""
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__).removesuffix(__package__))
STATIC_FILES_DIR = os.path.join(os.path.abspath(SCRIPT_DIR), "files")
VERSION = open(os.path.join(SCRIPT_DIR, ".version"), "r", encoding="utf-8").read()
if __package__ is None:
PACKAGE = ""
else:
PACKAGE = __package__
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__).removesuffix(PACKAGE))
STATIC_FILES_DIR = os.path.join(os.path.abspath(SCRIPTDIR), "files")
VERSION = open(os.path.join(SCRIPTDIR, ".version"), "r", encoding="utf-8").read()
RAW_EXTENSIONS = [
".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr",
".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos",
@@ -94,7 +96,7 @@ def copy_static_files(_args: Args) -> None:
if "url" in foldericon:
shutil.copyfile(_args.theme_path, os.path.join(static_dir, "theme.css"))
return
with open(os.path.join(SCRIPT_DIR, foldericon), "r", encoding="utf-8") as f:
with open(os.path.join(SCRIPTDIR, foldericon), "r", encoding="utf-8") as f:
svg = f.read()
if "svg.j2" in foldericon:
colorscheme = extract_colorscheme(_args.theme_path)
@@ -160,9 +162,7 @@ def get_total_folders(folder: str, _args: Args, _total: int = 0) -> int:
items = sorted(os.listdir(folder))
for item in items:
if item not in EXCLUDES and os.path.isdir(os.path.join(folder, item)) and not item.startswith("."):
if item not in _args.exclude_folders and not any(
fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders
):
if item not in _args.exclude_folders and not any(fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders):
_total = get_total_folders(os.path.join(folder, item), _args, _total)
return _total