1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2015 Alexandre Detiste <alexandre@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 https://game-data-packager.debian.net/available.html
from game_data_packager.build import (FillResult)
from game_data_packager.game import (load_games)
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()
langs['total'] = 0
for name, game in load_games().items():
stats = dict()
for package in game.packages.values():
langs['total'] += 1
if package.demo_for:
stats['demos'] = stats.get('demos', 0) + 1
else:
langs[package.lang] = langs.get(package.lang, 0) + 1
stats[package.lang] = stats.get(package.lang, 0) + 1
# free-as-in-beer
fullfree = True
somefree = False
if game.copyright:
year = int(game.copyright[2:6])
else:
year = None
for package in game.packages.values():
if not year:
year = int(package.copyright[2:6])
elif package.copyright:
year = min(year, int(package.copyright[2:6]))
if not package.demo_for:
for m_lang in package.langs:
if m_lang not in stats:
stats[m_lang] = '*'
with game.construct_task() as task:
if task.fill_gaps(package=package,
log=False) is FillResult.IMPOSSIBLE:
if not package.better_versions:
fullfree = False
else:
somefree = True
genre = game.genre or 'Unknown'
genres[genre] = genres.get(genre, 0) + 1
stats['genre'] = genre
if game.franchise:
stats['sort_key'] = game.franchise.lower() + ' ' + '%d' % year + game.shortname
else:
stats['sort_key'] = game.shortname
stats['shortname'] = name
stats['longname'] = game.longname
stats['url_wiki'] = game.wikibase + (game.wiki or '')
stats['total'] = len(game.packages)
stats['missing_langs'] = game.missing_langs
stats['fullfree'] = fullfree
stats['somefree'] = somefree
stats['url_wikipedia'] = game.wikipedia
for shop, _, _ in SHOPS:
stats[shop] = getattr(game, shop, None)
for l in game.missing_langs:
if l not in langs:
langs[l] = 0
games.append(stats)
# add missing games from list
with open('debian/TODO', 'r', encoding='utf8') as missing:
for line in missing:
if line[0:2] == '##':
break
genre = None
for line in missing:
line = line.strip()
if line[0:1] == '#':
genre = line[1:len(line)].strip()
elif line == '':
pass
else:
stats = {'todo': True}
genres[genre] = genres.get(genre, 0) + 1
stats['genre'] = genre
shortname = ''
for char in line.lower():
if 'a' <= char <= 'z' or '0' <= char <= '9':
shortname += char
stats['sort_key'] = shortname
if '#' not in line:
stats['longname'] = line
else:
longname, bug = line.split('#')
if ' ' in bug:
bug, remainder = bug.split(maxsplit=1)
else:
remainder = ''
stats['longname'] = ('%s <a href="https://bugs.debian.org/'
'cgi-bin/bugreport.cgi?bug=%s">#%s</a> %s'
% (longname, bug, bug, remainder))
games.append(stats)
games = sorted(games, key=lambda k: (k['genre'], k['sort_key']))
langs_order = [k for k, v in sorted(langs.items(), key=lambda kv: (-kv[1], kv[0]))]
html = open('out/index.html', 'w', encoding='utf8')
html.write('''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Game-Data-Packager</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="generator" content="https://salsa.debian.org/games-team/game-data-packager/tree/master/tools/babel.py">
<style type="text/css">
'''
)
for lang in langs_order:
if lang in ('total', 'en'):
continue
html.write(' #check-%s:checked ~ * .%s' % (lang, lang))
if lang != langs_order[-1]:
html.write(',\n')
html.write(''' {
background-color: yellow;
}
</style>
</head>
<body>
<h1>Debian Games Team</h1>
<img src="../proposed-logo.png" height="64" width="64" alt="Debian Games Team logo">
<h2>List of games supported by <code>game-data-packager</code> in git</h2>
This is an automaticaly generated list of games supported by then upcoming release.<br>
Please visit the <a href="http://wiki.debian.org/Games/GameDataPackager">Wiki</a>
for more general information.
<br><br>
'''
)
for lang in langs_order:
if lang in ('total', 'en'):
continue
html.write('<!--label for=check-%s-->%s<!--/label--><input id=check-%s type=checkbox> ' % (lang, lang, lang))
html.write('''<table border=1 cellspacing=0>
<tr>
<td colspan=2> </td>
<td>WP</td>
<td>yaml</td>
'''
)
for lang in langs_order:
html.write(' <td><b>%s</b></td>\n' % lang)
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
demos = 0
wikipedia = set()
for game in games:
html.write('<tr>\n')
genre = game['genre']
if genre != last_genre:
html.write('<td rowspan=%i>%s</td>\n' % (genres[genre], genre))
last_genre = genre
highlight = [l for l in langs_order if l not in ('total', 'en') and l in game]
highlight += game.get('missing_langs', [])
if highlight:
css = ' class="%s"' % ' '.join(highlight)
else:
css = ''
html.write(' <td%s>' % css)
if game.get('url_wiki', False):
html.write('<a href="%s">%s</a>' % (game['url_wiki'], game['longname']))
else:
html.write(game['longname'])
html.write('</td>')
wp = game.get('url_wikipedia')
if wp in wikipedia:
html.write('<td><b>″</b></td>')
elif wp:
html.write('<td><a href="%s"><b>W</b></a></td>' % wp)
wikipedia.add(wp)
else:
html.write('<td> </td>')
if 'todo' in game:
html.write('<td> </td>')
else:
html.write('<td><a href="https://salsa.debian.org/games-team/game-data-packager/tree/master/data/%s.yaml">'
'⌨</a></td>' % game['shortname'])
for lang in langs_order:
count = game.get(lang,None)
if lang in ('total', 'en') and count == None:
html.write(' <td bgcolor="orange">!</td>\n')
elif lang in ('total', 'en') or count == '*':
html.write(' <td bgcolor="lightgreen">%s</td>\n' % count)
elif 'missing_langs' in game and lang in game['missing_langs']:
html.write(' <td bgcolor="orange">!</td>\n')
elif count:
html.write(' <td bgcolor="green">%s</td>\n' % count)
else:
html.write(' <td> </td>\n')
if game.get('fullfree', False):
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']
html.write(' <td align=center><b>%i</b></td>\n' % game['demos'])
elif game.get('somefree', False):
html.write(' <td align=center><b>X</b></td>\n')
else:
html.write(' <td> </td>\n')
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:
html.write(' <td%s> </td>\n' % css)
html.write('</tr>\n')
# TOTAL
html.write('<tr><td colspan=4><b>Total</b></td>\n')
for lang in langs_order:
html.write(' <td><b>%i</b></td>\n' % langs[lang])
html.write(' <td><b>%i</b></td>\n' % demos)
html.write('''<td colspan=%s> </td>
</tr>
</table>
<ul>
<li>! : language is missing</li>
<li>* : multi-lang support in a single package</li>
</ul>
</body>
</html>
''' % len(SHOPS)
)
html.close()
|