[game-data-packager] 01/01: iter_steam_path: factorize code

Alexandre Detiste detiste-guest at moszumanska.debian.org
Wed Mar 11 13:37:11 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 3e2da0daca8618f770e3412699faac52e9deac87
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Wed Mar 11 14:36:12 2015 +0100

    iter_steam_path: factorize code
---
 game_data_packager/__init__.py | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index f123220..554a82b 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -2271,6 +2271,12 @@ class GameData(object):
         if packages is None:
             packages = self.packages.values()
 
+        suffixes = set(p.steam.get('path') for p in packages)
+        suffixes.add(self.steam.get('path'))
+        suffixes.discard(None)
+        if not suffixes:
+            return
+
         for prefix in (
                 os.path.expanduser('~/.steam'),
                 os.path.join(os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')),
@@ -2283,8 +2289,7 @@ class GameData(object):
 
             logger.debug('possible Steam root directory at %s', prefix)
 
-            suffix = self.steam.get('path')
-            if suffix is not None:
+            for suffix in suffixes:
                 for middle in ('steamapps', 'steam/steamapps', 'SteamApps',
                         'steam/SteamApps'):
                     path = os.path.join(prefix, middle, suffix)
@@ -2293,18 +2298,6 @@ class GameData(object):
                                 self.shortname, path)
                         yield path
 
-            for package in packages:
-                suffix = package.steam.get('path')
-
-                if suffix is not None:
-                    for middle in ('steamapps', 'steam/steamapps', 'SteamApps',
-                            'steam/SteamApps'):
-                        path = os.path.join(prefix, middle, suffix)
-                        if os.path.isdir(path):
-                            logger.debug('possible %s found in Steam at %s',
-                                    package.name, path)
-                            yield path
-
     def construct_package(self, binary):
         return GameDataPackage(binary)
 

-- 
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