diff --git a/dzgui/api/acf.py b/dzgui/api/acf.py index ab35b3b..ce243a4 100644 --- a/dzgui/api/acf.py +++ b/dzgui/api/acf.py @@ -1,16 +1,18 @@ import logging import re -from collections.abc import Iterator from datetime import datetime from pathlib import Path -from typing import Any +from typing import Any, TYPE_CHECKING from warnings import deprecated from dzgui.const.constants import APP_NAME logger = logging.getLogger(APP_NAME) +if TYPE_CHECKING: + from collections.abc import Iterator + class ACF: def __init__(self, file: Path) -> None: @@ -43,7 +45,7 @@ class ACF: def dequote(cls, s: str) -> str: return s.rstrip('"').lstrip('"') - def parse(self, lines: Iterator[list[str]]) -> dict[str, str]: + def parse(self, lines: "Iterator[list[str]]") -> dict[str, str]: acf: dict[str, Any] = {} try: while True: diff --git a/dzgui/api/steam.py b/dzgui/api/steam.py index ab4649c..40e6bbf 100644 --- a/dzgui/api/steam.py +++ b/dzgui/api/steam.py @@ -392,13 +392,21 @@ def get_running_app() -> int | None: def get_last_updated(path: Path, appid: int) -> str | None: root_path = get_app_path(path, appid) acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf") - return ACF(acf).get_last_updated() + try: + return ACF(acf).get_last_updated() + except Exception as e: + logger.critical(e) + return None def get_last_played(path: Path, appid: int) -> str | None: root_path = get_app_path(path, appid) acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf") - return ACF(acf).get_last_played() + try: + return ACF(acf).get_last_played() + except Exception as e: + logger.critical(e) + return None def get_app_allows_downloads(path: Path, appid: int) -> bool: