Prepare macOS package and improve output handling
This commit is contained in:
+9
-3
@@ -60,6 +60,11 @@ def normalize_title(value: str) -> str:
|
||||
return value.strip()
|
||||
|
||||
|
||||
def derive_output_dir(overview_url: str) -> Path:
|
||||
page_name = Path(urlparse(overview_url).path.rstrip("/")).name
|
||||
return Path(f"output_{page_name}") if page_name else Path("output")
|
||||
|
||||
|
||||
def get_html(session: requests.Session, url: str, retries: int = 3) -> str:
|
||||
last_error: Exception | None = None
|
||||
for attempt in range(1, retries + 1):
|
||||
@@ -291,8 +296,9 @@ def main() -> int:
|
||||
parser.add_argument("url", nargs="?", default=DEFAULT_URL)
|
||||
parser.add_argument("--limit", type=int, default=None)
|
||||
parser.add_argument("--delay", type=float, default=0.2)
|
||||
parser.add_argument("--output", type=Path, default=Path("output"))
|
||||
parser.add_argument("--output", type=Path, default=None)
|
||||
args = parser.parse_args()
|
||||
output_dir = args.output or derive_output_dir(args.url)
|
||||
|
||||
session = requests.Session()
|
||||
session.headers.update(HEADERS)
|
||||
@@ -329,7 +335,7 @@ def main() -> int:
|
||||
time.sleep(args.delay)
|
||||
|
||||
ranking = aggregate(all_votes)
|
||||
write_outputs(args.output, all_votes, ranking, errors)
|
||||
write_outputs(output_dir, all_votes, ranking, errors)
|
||||
|
||||
print("\nFertig:")
|
||||
print(f" gefundene Seiten: {len(pages)}")
|
||||
@@ -337,7 +343,7 @@ def main() -> int:
|
||||
print(f" Wertungen: {len(all_votes)}")
|
||||
print(f" verschiedene Titel: {len(ranking)}")
|
||||
print(f" Fehler: {len(errors)}")
|
||||
print(f" Ausgabe: {args.output.resolve()}")
|
||||
print(f" Ausgabe: {output_dir.resolve()}")
|
||||
|
||||
return 1 if errors else 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user