diff --git a/spath.spec b/spath.spec index 8f5f577..072eb67 100644 --- a/spath.spec +++ b/spath.spec @@ -1,11 +1,14 @@ # -*- mode: python ; coding: utf-8 -*- +from PyInstaller.utils.hooks import collect_data_files +datas = [] +datas += collect_data_files('cachier') a = Analysis( ['main.py'], pathex=[], binaries=[], - datas=[], + datas=datas, hiddenimports=[], hookspath=[], hooksconfig={}, diff --git a/src/prompt_helper.py b/src/prompt_helper.py index c437e04..a27bb1d 100644 --- a/src/prompt_helper.py +++ b/src/prompt_helper.py @@ -4,9 +4,10 @@ import sys from cachier import cachier import datetime +cachier = cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') -@cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') +@cachier def generate_completer(game_list): g_list = [x['name'] for x in game_list] + [x['appid'] for x in game_list] g_list.append("q") @@ -19,13 +20,13 @@ class PromptHelper: self.game_list = game_list self.completer = generate_completer(game_list) - @cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') + @cachier def find_game_str(self, game_name) -> dict|None: for game in self.game_list: if game['name'] == game_name: return game - @cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') + @cachier def find_game_num(self, appid: str) -> dict|None: for game in self.game_list: if game['appid'] == appid: diff --git a/src/vdfparser.py b/src/vdfparser.py index 5fca25f..df66e16 100644 --- a/src/vdfparser.py +++ b/src/vdfparser.py @@ -2,8 +2,9 @@ import os import vdf from cachier import cachier import datetime +cachier = cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') -@cachier(stale_after=datetime.timedelta(days=1)) +@cachier def parse_vdf(steam_vdf_path) -> dict: """ Reads the Steam vdf file at the given path and returns the corresponding dict. @@ -14,7 +15,7 @@ def parse_vdf(steam_vdf_path) -> dict: vdf_data = vdf.loads(open(steam_vdf_path, 'r').read()) return vdf_data -@cachier(stale_after=datetime.timedelta(days=1)) +@cachier def fetch_ids(vdf_json: dict): """ Prints all Steam app IDs from the given vdf data. @@ -80,13 +81,13 @@ def find_extra_locations(vdf_json): return steam_library_locations # Reads manifest of individual game vdfs -@cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') +@cachier def read_game_vdf(gameID: int, steam_vdf_json: dict, path, game) -> dict: with open(os.path.join(path, game), 'r') as f: game_vdf = vdf.loads(f.read()) return game_vdf['AppState'] -@cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache') +@cachier def fetchall_vdfs(steam_vdf_json: dict): """ Reads all Steam game manifests in the given Steam VDF data and returns a list of dictionaries containing information about each game.