[game-data-packager] 01/01: HTML webpage: factor out per-shop code

Alexandre Detiste detiste-guest at moszumanska.debian.org
Tue Apr 25 08:33:46 UTC 2017


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 1c7bfb60e1dc5f16e97fb7329bac7e972579413e
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue Apr 25 10:33:12 2017 +0200

    HTML webpage: factor out per-shop code
---
 tools/babel.py | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/tools/babel.py b/tools/babel.py
index 2f474c7..5cdcf65 100755
--- a/tools/babel.py
+++ b/tools/babel.py
@@ -21,6 +21,10 @@
 from game_data_packager import (load_games)
 from game_data_packager.build import (FillResult)
 
+SHOPS=[('url_steam', 'Steam', 'https://steamcommunity.com/groups/debian_gdp#curation'),
+       ('url_gog', 'GOG.com', 'https://www.gog.com/mix/games_supported_by_debians_gamedatapackager'),
+       ('url_misc', 'Misc.', None)]
+
 games = []
 genres = dict()
 langs = dict()
@@ -72,9 +76,8 @@ for name, game in load_games().items():
     stats['fullfree'] = fullfree
     stats['somefree'] = somefree
     stats['url_wikipedia'] = game.wikipedia
-    stats['url_steam'] = game.url_steam
-    stats['url_gog'] = game.url_gog
-    stats['url_misc'] = game.url_misc
+    for shop, _, _ in SHOPS:
+        stats[shop] = getattr(game, shop, None)
     for l in game.missing_langs:
         if l not in langs:
             langs[l] = 0
@@ -166,11 +169,13 @@ html.write('''<table border=1 cellspacing=0>
 )
 for lang in langs_order:
     html.write('  <td><b>%s</b></td>\n' % lang)
-html.write('''<td>Demo</td>
-<td><a href="https://steamcommunity.com/groups/debian_gdp#curation">Steam</a></td>
-<td><a href="https://www.gog.com/mix/games_supported_by_debians_gamedatapackager">GOG.com</a></td>
-<td>Misc.</td></tr>
-''')
+html.write('<td>Demo</td>')
+for _, name, url in SHOPS:
+    if url:
+        html.write('<td><a href="%s">%s</a></td>' % (url, name))
+    else:
+        html.write('<td>%s</td>' % name)
+html.write('</tr>')
 
 # BODY
 last_genre = None
@@ -224,7 +229,7 @@ for game in games:
             html.write('  <td> </td>\n')
 
     if game.get('fullfree', False):
-        html.write('  <td colspan=4 align=center%s><b>freeload</b></td>\n' % css)
+        html.write('  <td colspan=%d align=center%s><b>freeload</b></td>\n' % (len(SHOPS) + 1, css))
     else:
         if 'demos' in game:
             demos += game['demos']
@@ -233,7 +238,7 @@ for game in games:
             html.write('  <td align=center><b>X</b></td>\n')
         else:
             html.write('  <td> </td>\n')
-        for url in ('url_steam', 'url_gog', 'url_misc'):
+        for url, _, _ in SHOPS:
             if url in game and game[url]:
                 html.write('  <td align=center%s><a href="%s"><b>X</b></a></td>\n' % (css, game[url]))
             else:
@@ -241,7 +246,7 @@ for game in games:
     html.write('</tr>\n')
 
 # TOTAL
-html.write('<tr><td colspan=3><b>Total</b></td>\n')
+html.write('<tr><td colspan=%d><b>Total</b></td>\n' % len(SHOPS))
 for lang in langs_order:
     html.write('  <td><b>%i</b></td>\n' % langs[lang])
 

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