[game-data-packager] 01/03: GOG: cache list of owned games as it is called twice by fill_gaps
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Tue Sep 15 10:00:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
detiste-guest pushed a commit to branch master
in repository game-data-packager.
commit 4184fbc0ae4d82b485ae6028671d8471306cf4e5
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Tue Sep 15 11:50:10 2015 +0200
GOG: cache list of owned games as it is called twice by fill_gaps
---
game_data_packager/gog.py | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/game_data_packager/gog.py b/game_data_packager/gog.py
index 6f3ebe0..e481745 100644
--- a/game_data_packager/gog.py
+++ b/game_data_packager/gog.py
@@ -21,19 +21,29 @@ import subprocess
from .util import which
-def owned_gog_games():
- cache = os.path.expanduser('~/.cache/lgogdownloader/gamedetails.json')
- if os.path.isfile(cache):
- data = json.load(open(cache, encoding='utf-8'))
- for key in data['games']:
- yield key['gamename']
- elif which('lgogdownloader'):
- try:
- list = subprocess.check_output(['lgogdownloader', '--list'],
+class Gog:
+ available = None
+
+ def owned_games(self):
+ if self.available is not None:
+ return self.available
+
+ cache = os.path.expanduser('~/.cache/lgogdownloader/gamedetails.json')
+ if os.path.isfile(cache):
+ self.available = []
+ data = json.load(open(cache, encoding='utf-8'))
+ for key in data['games']:
+ self.available.append(key['gamename'])
+ elif which('lgogdownloader'):
+ try:
+ list = subprocess.check_output(['lgogdownloader', '--list'],
stdin=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
universal_newlines=True)
- except subprocess.CalledProcessError:
- return
- for line in list.splitlines():
- yield line
+ self.available = list.splitlines()
+ except subprocess.CalledProcessError:
+ self.available = []
+
+ return self.available
+
+GOG = Gog()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list