This commit is contained in:
@@ -9,6 +9,11 @@ from src.prompt_helper import PromptHelper
|
||||
# Commandline options support
|
||||
import argparse
|
||||
|
||||
# basic attempt at making program faster
|
||||
import datetime
|
||||
from src.timing import timeit
|
||||
from cachier import cachier
|
||||
cachier = cachier(stale_after=datetime.timedelta(days=1), cache_dir='/tmp/.cache')
|
||||
|
||||
|
||||
class TableItem:
|
||||
@@ -90,14 +95,23 @@ class SteamGamePathTool:
|
||||
else:
|
||||
console.print("No game found")
|
||||
|
||||
@timeit
|
||||
@cachier
|
||||
def prepare_all_games(self):
|
||||
game_rend = [Panel(self.get_game_content(game), expand=True) for game in self.games]
|
||||
return game_rend
|
||||
|
||||
def print_all_games(self):
|
||||
game_rend = self.prepare_all_games()
|
||||
console = Console()
|
||||
console.print(Columns(game_rend))
|
||||
|
||||
def prompt_user(self):
|
||||
game = self.prompter.prompt_game(text="Input (game name | appid | all | q/quit): ")
|
||||
if game is None:
|
||||
return
|
||||
elif game == 'fetch_all_games':
|
||||
console = Console()
|
||||
game_rend = [Panel(self.get_game_content(game), expand=True) for game in self.games]
|
||||
console.print(Columns(game_rend))
|
||||
self.print_all_games()
|
||||
else:
|
||||
console = Console()
|
||||
console.print(Panel(self.get_game_content(game), expand=True))
|
||||
@@ -106,6 +120,7 @@ class SteamGamePathTool:
|
||||
def sort_games(self, games):
|
||||
return sorted(games, key=lambda x: x['name'])
|
||||
|
||||
@cachier
|
||||
def get_game_content(self, game):
|
||||
"""
|
||||
Takes a game dictionary and returns a string that formats game information into a string renderable by the console in the rich library.
|
||||
|
||||
Reference in New Issue
Block a user