[game-data-packager] 01/04: Turn better_versions into a set, with backwards compatibility
Simon McVittie
smcv at debian.org
Wed Jan 20 00:43:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit ff723fb6c9a348979ff6f5f2339a62e92e254a22
Author: Simon McVittie <smcv at debian.org>
Date: Tue Jan 19 23:44:53 2016 +0000
Turn better_versions into a set, with backwards compatibility
Morrowind's base game has three better versions: with Tribunal,
with Bloodmoon and with both. Making them behave like expansions
is not trivial, because each overwrites a few files from the others.
---
game_data_packager/__init__.py | 25 +++++++++++++++++++------
game_data_packager/build.py | 21 +++++++++++----------
game_data_packager/gog.py | 14 +++++++++++---
tools/babel.py | 4 ++--
4 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index b3500eb..2cb73cc 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -198,7 +198,7 @@ class GameDataPackage(object):
# Names of relative packages
self.demo_for = set()
- self.better_version = None
+ self._better_versions = set()
self.expansion_for = None
# use this to group together dubs
self.provides = None
@@ -363,6 +363,13 @@ class GameDataPackage(object):
self._optional = set(value)
@property
+ def better_versions(self):
+ return self._better_versions
+ @better_versions.setter
+ def better_versions(self, value):
+ self._better_versions = set(value)
+
+ @property
def type(self):
"""type of package: full, demo or expansion
@@ -398,6 +405,7 @@ class GameDataPackage(object):
for k in (
'aliases',
+ 'better_versions',
'demo_for',
'depends',
'dotemu',
@@ -427,7 +435,6 @@ class GameDataPackage(object):
ret['optional'] = sorted(self.optional)
for k in (
- 'better_version',
'copyright',
'copyright_notice',
'description',
@@ -812,13 +819,17 @@ class GameData(object):
def _populate_package(self, package, d):
for k in ('expansion_for', 'expansion_for_ext', 'longname', 'symlinks', 'install_to',
'install_contents_of', 'description', 'depends',
- 'rip_cd', 'architecture', 'aliases', 'better_version', 'langs', 'mutually_exclusive',
+ 'rip_cd', 'architecture', 'aliases', 'better_versions', 'langs', 'mutually_exclusive',
'copyright', 'engine', 'lang', 'component', 'section', 'disks', 'provides',
'steam', 'gog', 'dotemu', 'origin', 'url_misc', 'wiki', 'copyright_notice',
'short_description', 'long_description', 'empty'):
if k in d:
setattr(package, k, d[k])
+ if 'better_version' in d:
+ assert 'better_versions' not in d
+ package.better_versions = set([d['better_version']])
+
for port in (
# packaging formats (we treat "debian" as "any dpkg-based"
# for historical reasons)
@@ -892,7 +903,7 @@ class GameData(object):
package.longname = self.longname + ' (%s)' % package.lang
if package.mutually_exclusive:
- assert package.demo_for or package.better_version or package.provides
+ assert package.demo_for or package.better_versions or package.provides
if 'expansion_for' in d:
if package.disks is None:
@@ -1216,8 +1227,10 @@ class GameData(object):
break
else:
raise Exception('virtual pkg %s not found' % package.expansion_for)
- assert (not package.better_version or
- package.better_version in self.packages), package.better_version
+
+ if package.better_versions:
+ for v in package.better_versions:
+ assert v in self.packages, v
# check for stale missing_langs
if not package.demo_for:
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 5fb33a3..86221a1 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -1793,8 +1793,7 @@ class PackagingTask(object):
if package.mutually_exclusive:
dep['conflicts'] |= package.demo_for
- if package.better_version:
- dep['conflicts'].add(package.better_version)
+ dep['conflicts'] |= package.better_versions
if package.provides:
dep['provides'].add(package.provides)
@@ -1823,9 +1822,11 @@ class PackagingTask(object):
if (other_package.expansion_for and
other_package.expansion_for in (package.name, package.provides)):
dep['suggests'].add(other_package.name)
+
if other_package.mutually_exclusive:
- if other_package.better_version == package.name:
+ if package.name in other_package.better_versions:
dep['replaces'].add(other_package.name)
+
if package.name in other_package.demo_for:
dep['replaces'].add(other_package.name)
@@ -2332,13 +2333,13 @@ class PackagingTask(object):
# this check is done before the language check to avoid to end up with
# simon-the-sorcerer1-fr-data + simon-the-sorcerer1-dos-en-data
for package in set(possible):
- if (package.better_version
- and self.game.packages[package.better_version] in possible):
- logger.info('will not produce "%s" because better version '
- '"%s" is also available',
- package.name,
- package.better_version)
- possible.discard(package)
+ for v in package.better_versions:
+ if self.game.packages[v] in possible:
+ logger.info('will not produce "%s" because better '
+ 'version "%s" is also available',
+ package.name, v)
+ possible.discard(package)
+ break
for package in set(possible):
score = max(set(lang_score(l) for l in package.langs))
diff --git a/game_data_packager/gog.py b/game_data_packager/gog.py
index eb4c47c..d32a303 100644
--- a/game_data_packager/gog.py
+++ b/game_data_packager/gog.py
@@ -142,9 +142,17 @@ def run_gog_meta_mode(parsed, games):
continue
if lang_score(package.lang) == 0:
continue
- if package.better_version:
- if data.gog_download_name(data.packages[package.better_version]):
- continue
+
+ can_do_better = False
+
+ for v in package.better_versions:
+ if data.gog_download_name(data.packages[v]):
+ can_do_better = True
+ break
+
+ if can_do_better:
+ continue
+
installed = packaging.is_installed(package.name)
if parsed.new and installed:
continue
diff --git a/tools/babel.py b/tools/babel.py
index f57f0b2..637a8ce 100755
--- a/tools/babel.py
+++ b/tools/babel.py
@@ -47,8 +47,8 @@ for name, game in load_games().items():
with game.construct_task() as task:
if task.fill_gaps(package=package,
log=False) is FillResult.IMPOSSIBLE:
- if package.better_version is None:
- fullfree = False
+ if not package.better_versions:
+ fullfree = False
else:
somefree = True
genre = game.genre or 'Unknown'
--
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