[game-data-packager] 03/04: doom2-masterlevels: avoid code duplication
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Thu Nov 24 08:20:57 UTC 2016
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 239373c762ea0bdb2cf34b948c708263f7707abb
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Thu Nov 24 08:30:10 2016 +0100
doom2-masterlevels: avoid code duplication
---
runtime/doom2-masterlevels.py | 48 ++++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/runtime/doom2-masterlevels.py b/runtime/doom2-masterlevels.py
index a206008..8dae8c4 100755
--- a/runtime/doom2-masterlevels.py
+++ b/runtime/doom2-masterlevels.py
@@ -207,50 +207,42 @@ class Launcher:
radiobuttonDefault.connect('toggled', self.select_engine)
radiogrid.attach(radiobuttonDefault, 0, 0, 1, 1)
- default = None
alternatives = []
if os.path.islink('/etc/alternatives/doom'):
# on Debian
- default = os.readlink('/etc/alternatives/doom')
- if default == '/usr/games/doomsday-compat':
- default = '/usr/games/doomsday'
+ alternatives=[os.readlink('/etc/alternatives/doom')]
proc = subprocess.check_output(['update-alternatives', '--list', 'doom'],
universal_newlines=True)
for alternative in proc.splitlines():
- if alternative == '/usr/games/doomsday-compat':
- alternative = '/usr/games/doomsday'
- if alternative != default:
+ if alternative not in alternatives:
alternatives.append(alternative)
else:
# not on Debian
for alternative in ('prboom-plus', 'prboom', 'chocolate-doom'):
if which(alternative):
- if not default:
- default = alternative
- else:
- alternatives.append(alternative)
-
- if default:
- radiobuttonDefault.set_label("%s (default)" % default)
- self.select_engine(radiobuttonDefault)
- if default.split('/')[-1] == 'chocolate-doom' and which('chocolate-doom-setup'):
- self.button_conf = Gtk.Button(label="Configure")
- radiogrid.attach(self.button_conf,1, 0, 1, 1)
- self.button_conf.connect("clicked", self.chocolate_setup)
+ alternatives.append(alternative)
+
+ i = 0
+ for alternative in alternatives:
+ if alternative == '/usr/games/doomsday-compat':
+ alternative = '/usr/games/doomsday'
- i = 1
- for alternative in alternatives:
+ if i == 0:
+ radiobuttonDefault.set_label("%s (default)" % alternative)
+ self.select_engine(radiobuttonDefault)
+ else:
radiobutton = Gtk.RadioButton(group=radiobuttonDefault, label=alternative)
radiobutton.connect('toggled', self.select_engine)
- i += 1
radiogrid.attach(radiobutton, 0, i, 1, 1)
- if alternative.split('/')[-1] == 'chocolate-doom' and which('chocolate-doom-setup'):
- self.button_conf = Gtk.Button(label="Configure")
- radiogrid.attach(self.button_conf,1, i, 1, 1)
- self.button_conf.connect("clicked", self.chocolate_setup)
- if os.path.isfile('/etc/debian_version'):
- radiogrid.set_tooltip_text('Default can be changed with update-alternatives(8)')
+
+ if alternative.split('/')[-1] == 'chocolate-doom' and which('chocolate-doom-setup'):
+ self.button_conf = Gtk.Button(label="Configure")
+ radiogrid.attach(self.button_conf,1, i, 1, 1)
+ self.button_conf.connect("clicked", self.chocolate_setup)
+ if os.path.isfile('/etc/debian_version'):
+ radiogrid.set_tooltip_text('Default can be changed with "update-alternatives --config doom"')
+ i += 1
grid.attach(radiogrid, 2, 4, 1, 1)
--
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