[game-data-packager] 01/01: add tool to print some pretty HTML in 90's style

Alexandre Detiste detiste-guest at moszumanska.debian.org
Thu Jun 18 20:05:12 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 d60b17e96140dcfc623186f19a408b1743ef3cd5
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Thu Jun 18 22:04:11 2015 +0200

    add tool to print some pretty HTML in 90's style
    
    http://users.teledisnet.be/ade15809/babel.html
---
 tools/babel.py | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/tools/babel.py b/tools/babel.py
new file mode 100755
index 0000000..cfac7c9
--- /dev/null
+++ b/tools/babel.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# You can find the GPL license text on a Debian system under
+# /usr/share/common-licenses/GPL-2.
+
+
+# Online at http://users.teledisnet.be/ade15809/babel.html
+
+from game_data_packager import load_games
+from game_data_packager.util import ascii_safe
+
+games = []
+genres = dict()
+langs = dict()
+langs['total'] = 0
+for name, game in load_games().items():
+    stats = dict()
+    for package in game.packages.values():
+        lang = package.lang
+        langs[lang] = langs.get(lang, 0) + 1
+        langs['total'] += 1
+        stats[lang] = stats.get(lang, 0) + 1
+    genres[game.genre] = genres.get(game.genre, 0) + 1
+    stats['genre'] = game.genre
+    stats['shortname'] = name
+    stats['longname'] = ascii_safe(game.longname, force=True)
+    stats['total'] = len(game.packages)
+    games.append(stats)
+
+games = sorted(games, key=lambda k: (k['genre'], k['shortname'], k['longname']))
+
+langs_order = sorted(langs, key=langs.get, reverse=True)
+
+html = open('/home/tchet/Utilitaires/Homepage/babel.html', 'w', encoding='latin1')
+html.write('''
+<html>
+<head>
+<title>Game-Data-Packager</title>
+</head>
+<table border=1 cellspacing=0>
+<tr>
+<td colspan=2>&nbsp</td>
+'''
+)
+for lang in langs_order:
+    html.write('  <td><b>%s</b></td>\n' % lang)
+html.write('</tr>\n')
+
+# BODY
+last_genre = None
+for game in games:
+    genre = game['genre']
+    if genre != last_genre:
+        html.write('<tr><td rowspan=%i>%s</td>\n' % (genres[genre], genre))
+        last_genre = genre
+    html.write('  <td>%s</td>\n' % game['longname'])
+    for lang in langs_order:
+        count = game.get(lang,None)
+        if lang in ('total', 'en'):
+            html.write('  <td bgcolor="lightgreen">%s</td>\n' % count)
+        elif count:
+            html.write('  <td bgcolor="green">%s</td>\n' % count)
+        else:
+            html.write('  <td> </td>\n')
+
+    html.write('</tr>\n')
+
+# TOTAL
+html.write('<tr><td colspan=2><b>Total</b></td>\n')
+for lang in langs_order:
+    html.write('  <td><b>%s</b></td>\n' % langs[lang])
+
+html.write('''
+</tr>
+</table>
+</html>
+'''
+)
+

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