1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-15 02:54:09 -04:00

Convert scripts/all_games.py to python 3

This commit is contained in:
Roderik Ploszek 2018-03-19 17:26:52 +01:00
parent 819dbc6a2e
commit f1161cdae0

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python3
# -*- mode: python; coding: koi8-r; -*- # -*- mode: python; coding: koi8-r; -*-
# #
@ -6,7 +6,7 @@ import sys
import os import os
import time import time
# from pprint import pprint # from pprint import pprint
import __builtin__ import builtins
from pysollib.mygettext import fix_gettext from pysollib.mygettext import fix_gettext
import pysollib.games import pysollib.games
import pysollib.games.special import pysollib.games.special
@ -18,8 +18,8 @@ from pysollib.gamedb import GI
from pysollib.mfxutil import latin1_normalize from pysollib.mfxutil import latin1_normalize
from pysollib.resource import CSI from pysollib.resource import CSI
os.environ['LANG'] = 'C' os.environ['LANG'] = 'C'
__builtin__.__dict__['_'] = lambda x: x builtins.__dict__['_'] = lambda x: x
__builtin__.__dict__['n_'] = lambda x: x builtins.__dict__['n_'] = lambda x: x
pysollib_path = os.path.join(sys.path[0], '..') pysollib_path = os.path.join(sys.path[0], '..')
sys.path[0] = os.path.normpath(pysollib_path) sys.path[0] = os.path.normpath(pysollib_path)
@ -112,7 +112,7 @@ def by_type():
games_by_type[gt] += 1 games_by_type[gt] += 1
else: else:
games_by_type[gt] = 1 games_by_type[gt] = 1
games_by_type_list = games_by_type.items() games_by_type_list = list(games_by_type.items())
games_by_type_list.sort(key=lambda x: x[0]) games_by_type_list.sort(key=lambda x: x[0])
# print '<table border="2"><tr><th>Name</th><th>Number</th></tr>' # print '<table border="2"><tr><th>Name</th><th>Number</th></tr>'
# for i in games_by_type_list: # for i in games_by_type_list:
@ -145,8 +145,8 @@ def all_games(sort_by='id'):
gt = CSI.TYPE_NAME[gi.category] gt = CSI.TYPE_NAME[gi.category]
if gt == 'French': if gt == 'French':
gt = 'French (%s)' % GAME_BY_TYPE[gi.si.game_type] gt = 'French (%s)' % GAME_BY_TYPE[gi.si.game_type]
name = gi.name.encode('utf-8') name = gi.name
altnames = '<br>'.join(gi.altnames).encode('utf-8') altnames = '<br>'.join(gi.altnames)
fn = os.path.join(rules_dir, rules_fn) fn = os.path.join(rules_dir, rules_fn)
if 1 and os.path.exists(fn): if 1 and os.path.exists(fn):
print('''<tr><td>%s</td><td> print('''<tr><td>%s</td><td>
@ -189,7 +189,7 @@ def get_text():
games_list[gi.short_name] = '' games_list[gi.short_name] = ''
for n in gi.altnames: for n in gi.altnames:
games_list[n] = '' games_list[n] = ''
games_list = games_list.keys() games_list = list(games_list.keys())
games_list.sort() games_list.sort()
print('''\ print('''\
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
@ -210,7 +210,7 @@ msgstr ""
''' % (time.asctime(), sys.argv[0])) ''' % (time.asctime(), sys.argv[0]))
for g in games_list: for g in games_list:
print('msgid "%s"\nmsgstr ""\n' % g.encode('utf-8')) print('msgid "%s"\nmsgstr ""\n' % g)
def old_plain_text(): def old_plain_text():
@ -227,7 +227,7 @@ def old_plain_text():
games_list = games_list.keys() games_list = games_list.keys()
games_list.sort() games_list.sort()
for g in games_list: for g in games_list:
print(g.encode('utf-8')) print(g)
def plain_text(): def plain_text():
@ -239,9 +239,9 @@ def plain_text():
# gc = gi.gameclass # gc = gi.gameclass
# h = gc.Hint_Class is None and 'None' or gc.Hint_Class.__name__ # h = gc.Hint_Class is None and 'None' or gc.Hint_Class.__name__
# print gi.name.encode('utf-8'), h # print gi.name.encode('utf-8'), h
print(gi.name.encode('utf-8')) print(gi.name)
for n in gi.altnames: for n in gi.altnames:
print(n.encode('utf-8')) print(n)
# name = gi.name.lower() # name = gi.name.lower()
# name = re.sub('\W', '', name) # name = re.sub('\W', '', name)
# print id, name #, gi.si.game_type, # print id, name #, gi.si.game_type,