Migrate from Poetry and pyenv to uv
This commit is contained in:
Regular → Executable
+26
-13
@@ -16,11 +16,11 @@ Examples:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import random
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
INDEX_FILENAME = ".Curator.!index"
|
||||
@@ -34,7 +34,7 @@ def _load_config_paths(config_path: Path) -> tuple[Path | None, Path | None]:
|
||||
try:
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
cfg = json.load(f)
|
||||
except (OSError, json.JSONDecodeError):
|
||||
except OSError, json.JSONDecodeError:
|
||||
return None, None
|
||||
pool = cfg.get("pool_dir")
|
||||
out = cfg.get("filmoteka_dir")
|
||||
@@ -99,20 +99,33 @@ def generate_tips(pool_dir: Path, output_dir: Path, count: int, subfolder: str)
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Vygeneruje složku Tipy dne.")
|
||||
parser.add_argument("--pool", type=Path, help="Pool root (obsahuje .Curator.!index)")
|
||||
parser.add_argument(
|
||||
"--pool", type=Path, help="Pool root (obsahuje .Curator.!index)"
|
||||
)
|
||||
parser.add_argument("--output", type=Path, help="Výstupní složka Filmotéky")
|
||||
parser.add_argument("--count", type=int, default=DEFAULT_COUNT,
|
||||
help=f"Počet náhodných titulů (výchozí {DEFAULT_COUNT})")
|
||||
parser.add_argument("--subfolder", default=DEFAULT_SUBFOLDER,
|
||||
help=f'Název složky tipů (výchozí "{DEFAULT_SUBFOLDER}")')
|
||||
parser.add_argument("--config", type=Path,
|
||||
help="Cesta ke global configu (.Curator.!gtag) pro doplnění cest")
|
||||
parser.add_argument(
|
||||
"--count",
|
||||
type=int,
|
||||
default=DEFAULT_COUNT,
|
||||
help=f"Počet náhodných titulů (výchozí {DEFAULT_COUNT})",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--subfolder",
|
||||
default=DEFAULT_SUBFOLDER,
|
||||
help=f'Název složky tipů (výchozí "{DEFAULT_SUBFOLDER}")',
|
||||
)
|
||||
parser.add_argument(
|
||||
"--config",
|
||||
type=Path,
|
||||
help="Cesta ke global configu (.Curator.!gtag) pro doplnění cest",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
pool, output = args.pool, args.output
|
||||
if pool is None or output is None:
|
||||
config_path = args.config or (
|
||||
Path(__file__).resolve().parent.parent / GLOBAL_CONFIG_FILENAME)
|
||||
Path(__file__).resolve().parent.parent / GLOBAL_CONFIG_FILENAME
|
||||
)
|
||||
cfg_pool, cfg_out = _load_config_paths(config_path)
|
||||
pool = pool or cfg_pool
|
||||
output = output or cfg_out
|
||||
|
||||
Reference in New Issue
Block a user