mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
0414047586
commit
27f23b2e88
7 changed files with 378 additions and 341 deletions
|
@ -2,23 +2,13 @@
|
||||||
# -*- mode: python; coding: koi8-r; -*-
|
# -*- mode: python; coding: koi8-r; -*-
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys, os, re, time
|
import sys
|
||||||
from pprint import pprint
|
import os
|
||||||
|
import re
|
||||||
os.environ['LANG'] = 'C'
|
import time
|
||||||
|
# from pprint import pprint
|
||||||
import __builtin__
|
import __builtin__
|
||||||
__builtin__.__dict__['_'] = lambda x: x
|
|
||||||
__builtin__.__dict__['n_'] = lambda x: x
|
|
||||||
|
|
||||||
pysollib_path = os.path.join(sys.path[0], '..')
|
|
||||||
sys.path[0] = os.path.normpath(pysollib_path)
|
|
||||||
rules_dir = os.path.normpath(os.path.join(pysollib_path, 'data/html/rules'))
|
|
||||||
#pprint(sys.path)
|
|
||||||
#print rules_dir
|
|
||||||
|
|
||||||
from pysollib.mygettext import fix_gettext
|
from pysollib.mygettext import fix_gettext
|
||||||
fix_gettext()
|
|
||||||
|
|
||||||
import pysollib.games
|
import pysollib.games
|
||||||
import pysollib.games.special
|
import pysollib.games.special
|
||||||
import pysollib.games.ultra
|
import pysollib.games.ultra
|
||||||
|
@ -28,15 +18,29 @@ from pysollib.gamedb import GAME_DB
|
||||||
from pysollib.gamedb import GI
|
from pysollib.gamedb import GI
|
||||||
from pysollib.mfxutil import latin1_to_ascii
|
from pysollib.mfxutil import latin1_to_ascii
|
||||||
from pysollib.resource import CSI
|
from pysollib.resource import CSI
|
||||||
|
os.environ['LANG'] = 'C'
|
||||||
|
__builtin__.__dict__['_'] = lambda x: x
|
||||||
|
__builtin__.__dict__['n_'] = lambda x: x
|
||||||
|
|
||||||
|
pysollib_path = os.path.join(sys.path[0], '..')
|
||||||
|
sys.path[0] = os.path.normpath(pysollib_path)
|
||||||
|
rules_dir = os.path.normpath(os.path.join(pysollib_path, 'data/html/rules'))
|
||||||
|
# pprint(sys.path)
|
||||||
|
# print rules_dir
|
||||||
|
|
||||||
|
fix_gettext()
|
||||||
|
|
||||||
|
|
||||||
def getGameRulesFilename(n):
|
def getGameRulesFilename(n):
|
||||||
if n.startswith('Mahjongg'): return 'mahjongg.html'
|
if n.startswith('Mahjongg'):
|
||||||
##n = re.sub(r"[\[\(].*$", "", n)
|
return 'mahjongg.html'
|
||||||
|
# n = re.sub(r"[\[\(].*$", "", n)
|
||||||
n = latin1_to_ascii(n)
|
n = latin1_to_ascii(n)
|
||||||
n = re.sub(r"[^\w]", "", n)
|
n = re.sub(r"[^\w]", "", n)
|
||||||
n = n.lower() + ".html"
|
n = n.lower() + ".html"
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
||||||
GAME_BY_TYPE = {
|
GAME_BY_TYPE = {
|
||||||
GI.GT_BAKERS_DOZEN: "Baker's Dozen",
|
GI.GT_BAKERS_DOZEN: "Baker's Dozen",
|
||||||
GI.GT_BELEAGUERED_CASTLE: "Beleaguered Castle",
|
GI.GT_BELEAGUERED_CASTLE: "Beleaguered Castle",
|
||||||
|
@ -70,63 +74,66 @@ GAME_BY_TYPE = {
|
||||||
GI.GT_HANAFUDA: "Hanafuda",
|
GI.GT_HANAFUDA: "Hanafuda",
|
||||||
GI.GT_DASHAVATARA_GANJIFA: "Dashavatara Ganjifa",
|
GI.GT_DASHAVATARA_GANJIFA: "Dashavatara Ganjifa",
|
||||||
GI.GT_MAHJONGG: "Mahjongg",
|
GI.GT_MAHJONGG: "Mahjongg",
|
||||||
GI.GT_MUGHAL_GANJIFA:"Mughal Ganjifa",
|
GI.GT_MUGHAL_GANJIFA: "Mughal Ganjifa",
|
||||||
GI.GT_SHISEN_SHO:"Shisen-Sho",
|
GI.GT_SHISEN_SHO: "Shisen-Sho",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def by_category():
|
def by_category():
|
||||||
games = GAME_DB.getGamesIdSortedById()
|
games = GAME_DB.getGamesIdSortedById()
|
||||||
games_by_cat = {}
|
games_by_cat = {}
|
||||||
for id in games:
|
for id in games:
|
||||||
gi = GAME_DB.get(id)
|
gi = GAME_DB.get(id)
|
||||||
gt = CSI.TYPE_NAME[gi.category]
|
gt = CSI.TYPE_NAME[gi.category]
|
||||||
if games_by_cat.has_key(gt):
|
if gt in games_by_cat:
|
||||||
games_by_cat[gt] += 1
|
games_by_cat[gt] += 1
|
||||||
else:
|
else:
|
||||||
games_by_cat[gt] = 1
|
games_by_cat[gt] = 1
|
||||||
games_by_cat_list = [(i, j) for i, j in games_by_cat.items()]
|
games_by_cat_list = [(i, j) for i, j in games_by_cat.items()]
|
||||||
games_by_cat_list.sort(lambda i, j: cmp(j[1], i[1]))
|
games_by_cat_list.sort(key=lambda x: x[1])
|
||||||
# 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_cat_list:
|
# for i in games_by_cat_list:
|
||||||
# print '<tr><td>%s</td><td>%s</td></tr>' % i
|
# print '<tr><td>%s</td><td>%s</td></tr>' % i
|
||||||
# print '</table>'
|
# print '</table>'
|
||||||
print '<ul>'
|
print('<ul>')
|
||||||
for i in games_by_cat_list:
|
for i in games_by_cat_list:
|
||||||
print '<li>%s (%s games)</li>' % i
|
print('<li>%s (%s games)</li>' % i)
|
||||||
print '</ul>'
|
print('</ul>')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def by_type():
|
def by_type():
|
||||||
games = GAME_DB.getGamesIdSortedById()
|
games = GAME_DB.getGamesIdSortedById()
|
||||||
games_by_type = {}
|
games_by_type = {}
|
||||||
for id in games:
|
for id in games:
|
||||||
gi = GAME_DB.get(id)
|
gi = GAME_DB.get(id)
|
||||||
if not GAME_BY_TYPE.has_key(gi.si.game_type):
|
if gi.si.game_type not in GAME_BY_TYPE:
|
||||||
print gi.si.game_type
|
print(gi.si.game_type)
|
||||||
continue
|
continue
|
||||||
gt = GAME_BY_TYPE[gi.si.game_type]
|
gt = GAME_BY_TYPE[gi.si.game_type]
|
||||||
if games_by_type.has_key(gt):
|
if gt in games_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 = games_by_type.items()
|
||||||
games_by_type_list.sort(lambda i, j: cmp(i[0], j[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:
|
||||||
## print '<tr><td>%s</td><td>%s</td></tr>' % i
|
# print '<tr><td>%s</td><td>%s</td></tr>' % i
|
||||||
## print '</table>'
|
# print '</table>'
|
||||||
print '<ul>'
|
print('<ul>')
|
||||||
for i in games_by_type_list:
|
for i in games_by_type_list:
|
||||||
print '<li>%s (%s games)</li>' % i
|
print('<li>%s (%s games)</li>' % i)
|
||||||
print '</ul>'
|
print('</ul>')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def all_games(sort_by='id'):
|
def all_games(sort_by='id'):
|
||||||
#rules_dir = 'rules'
|
# rules_dir = 'rules'
|
||||||
print '''<table border="2">
|
print('''<table border="2">
|
||||||
<tr><th>ID</th><th>Name</th><th>Alternate names</th><th>Type</th></tr>
|
<tr><th>ID</th><th>Name</th><th>Alternate names</th><th>Type</th></tr>
|
||||||
'''
|
''')
|
||||||
|
|
||||||
if sort_by == 'id':
|
if sort_by == 'id':
|
||||||
get_games_func = GAME_DB.getGamesIdSortedById
|
get_games_func = GAME_DB.getGamesIdSortedById
|
||||||
|
@ -146,38 +153,39 @@ def all_games(sort_by='id'):
|
||||||
altnames = '<br>'.join(gi.altnames).encode('utf-8')
|
altnames = '<br>'.join(gi.altnames).encode('utf-8')
|
||||||
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>
|
||||||
<a href="%s" title="Rules for this game">%s</a>
|
<a href="%s" title="Rules for this game">%s</a>
|
||||||
</td><td>%s</td><td>%s</td></tr>
|
</td><td>%s</td><td>%s</td></tr>
|
||||||
''' % (id, fn, name, altnames, gt)
|
''' % (id, fn, name, altnames, gt))
|
||||||
else:
|
else:
|
||||||
print '''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>
|
print('''<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>
|
||||||
''' % (id, name, altnames, gt)
|
''' % (id, name, altnames, gt))
|
||||||
print '</table>'
|
print('</table>')
|
||||||
|
|
||||||
|
|
||||||
def create_html(sort_by):
|
def create_html(sort_by):
|
||||||
print '''<html>
|
print('''<html>
|
||||||
<head>
|
<head>
|
||||||
<title>PySolFC - List of solitaire games</title>
|
<title>PySolFC - List of solitaire games</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
'''
|
''')
|
||||||
print '<b>Total games: %d</b>' % len(GAME_DB.getGamesIdSortedById())
|
print('<b>Total games: %d</b>' % len(GAME_DB.getGamesIdSortedById()))
|
||||||
print '<h2>Categories</h2>'
|
print('<h2>Categories</h2>')
|
||||||
by_category()
|
by_category()
|
||||||
print '<h2>Types</h2>'
|
print('<h2>Types</h2>')
|
||||||
by_type()
|
by_type()
|
||||||
#print '<h2>All games</h2>'
|
# print '<h2>All games</h2>'
|
||||||
all_games(sort_by)
|
all_games(sort_by)
|
||||||
print '</body></html>'
|
print('</body></html>')
|
||||||
|
|
||||||
|
|
||||||
def get_text():
|
def get_text():
|
||||||
#get_games_func = GAME_DB.getGamesIdSortedById
|
# get_games_func = GAME_DB.getGamesIdSortedById
|
||||||
get_games_func = GAME_DB.getGamesIdSortedByName
|
get_games_func = GAME_DB.getGamesIdSortedByName
|
||||||
|
|
||||||
games_list = {} # for unique
|
games_list = {} # for unique
|
||||||
for id in get_games_func():
|
for id in get_games_func():
|
||||||
gi = GAME_DB.get(id)
|
gi = GAME_DB.get(id)
|
||||||
games_list[gi.name] = ''
|
games_list[gi.name] = ''
|
||||||
|
@ -187,7 +195,7 @@ def get_text():
|
||||||
games_list[n] = ''
|
games_list[n] = ''
|
||||||
games_list = games_list.keys()
|
games_list = games_list.keys()
|
||||||
games_list.sort()
|
games_list.sort()
|
||||||
print '''\
|
print('''\
|
||||||
# SOME DESCRIPTIVE TITLE.
|
# SOME DESCRIPTIVE TITLE.
|
||||||
# Copyright (C) YEAR ORGANIZATION
|
# Copyright (C) YEAR ORGANIZATION
|
||||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
@ -204,44 +212,46 @@ msgstr ""
|
||||||
"Content-Transfer-Encoding: ENCODING\\n"
|
"Content-Transfer-Encoding: ENCODING\\n"
|
||||||
"Generated-By: %s 0.1\\n"
|
"Generated-By: %s 0.1\\n"
|
||||||
|
|
||||||
''' % (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.encode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
def old_plain_text():
|
def old_plain_text():
|
||||||
#get_games_func = GAME_DB.getGamesIdSortedById
|
# get_games_func = GAME_DB.getGamesIdSortedById
|
||||||
get_games_func = GAME_DB.getGamesIdSortedByName
|
get_games_func = GAME_DB.getGamesIdSortedByName
|
||||||
games_list = {} # for unique
|
games_list = {} # for unique
|
||||||
for id in get_games_func():
|
for id in get_games_func():
|
||||||
gi = GAME_DB.get(id)
|
gi = GAME_DB.get(id)
|
||||||
games_list[gi.name] = ''
|
games_list[gi.name] = ''
|
||||||
#if gi.name != gi.short_name:
|
# if gi.name != gi.short_name:
|
||||||
# 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 = 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.encode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
def plain_text():
|
def plain_text():
|
||||||
get_games_func = GAME_DB.getGamesIdSortedByName
|
get_games_func = GAME_DB.getGamesIdSortedByName
|
||||||
for id in get_games_func():
|
for id in get_games_func():
|
||||||
gi = GAME_DB.get(id)
|
gi = GAME_DB.get(id)
|
||||||
if gi.category == GI.GC_FRENCH:
|
if gi.category == GI.GC_FRENCH:
|
||||||
##print str(gi.gameclass)
|
# print str(gi.gameclass)
|
||||||
##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.encode('utf-8'))
|
||||||
for n in gi.altnames:
|
for n in gi.altnames:
|
||||||
print n.encode('utf-8')
|
print(n.encode('utf-8'))
|
||||||
##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, gi.si.game_type == GI.GC_FRENCH
|
# print id, name #, gi.si.game_type,
|
||||||
|
# gi.si.game_type == GI.GC_FRENCH
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
if len(sys.argv) < 2 or sys.argv[1] == 'html':
|
if len(sys.argv) < 2 or sys.argv[1] == 'html':
|
||||||
sort_by = 'id'
|
sort_by = 'id'
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
|
@ -255,6 +265,3 @@ elif sys.argv[1] == 'text':
|
||||||
plain_text()
|
plain_text()
|
||||||
else:
|
else:
|
||||||
sys.exit('invalid argument')
|
sys.exit('invalid argument')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
# -*- mode: python; coding: koi8-r; -*-
|
# -*- mode: python; coding: koi8-r; -*-
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys, os
|
import sys
|
||||||
|
import os
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from math import sqrt, sin, cos, pi
|
from math import sqrt, sin, cos, pi
|
||||||
from Tkinter import *
|
from Tkinter import BOTH, Button, Frame, PhotoImage, NW, Text, Toplevel, X, YES
|
||||||
|
from Tkinter import RIGHT, Tk, Listbox, NS, END, Scrollbar, Canvas, NSEW
|
||||||
|
from Tkinter import HORIZONTAL, Label, EW, IntVar, StringVar, LEFT, Checkbutton
|
||||||
|
from Tkinter import OptionMenu
|
||||||
try:
|
try:
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -25,9 +29,12 @@ cardset_type = {
|
||||||
|
|
||||||
all_imgs = False
|
all_imgs = False
|
||||||
|
|
||||||
|
|
||||||
class Cardset:
|
class Cardset:
|
||||||
def __init__(self, dir, name, type, ext, x, y):
|
def __init__(self, dir, name, type, ext, x, y):
|
||||||
self.dir, self.name, self.type, self.ext, self.x, self.y = dir, name, type, ext, x, y
|
self.dir, self.name, self.type, self.ext, self.x, self.y = \
|
||||||
|
dir, name, type, ext, x, y
|
||||||
|
|
||||||
|
|
||||||
def create_cs_list(ls):
|
def create_cs_list(ls):
|
||||||
cardsets_list = {}
|
cardsets_list = {}
|
||||||
|
@ -38,12 +45,12 @@ def create_cs_list(ls):
|
||||||
try:
|
try:
|
||||||
ext = l0[2]
|
ext = l0[2]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
##print f
|
# print f
|
||||||
ext = '.gif'
|
ext = '.gif'
|
||||||
if len(l0) > 3:
|
if len(l0) > 3:
|
||||||
type = cardset_type[l0[3]]
|
type = cardset_type[l0[3]]
|
||||||
else:
|
else:
|
||||||
#type = 'Unknown'
|
# type = 'Unknown'
|
||||||
type = 'French'
|
type = 'French'
|
||||||
l1 = lines[1].split(';')
|
l1 = lines[1].split(';')
|
||||||
name = l1[1].strip()
|
name = l1[1].strip()
|
||||||
|
@ -53,8 +60,11 @@ def create_cs_list(ls):
|
||||||
cardsets_list[name] = cs
|
cardsets_list[name] = cs
|
||||||
return cardsets_list
|
return cardsets_list
|
||||||
|
|
||||||
|
|
||||||
tk_images = []
|
tk_images = []
|
||||||
zoom = 0
|
zoom = 0
|
||||||
|
|
||||||
|
|
||||||
def show_cardset(*args):
|
def show_cardset(*args):
|
||||||
global tk_images
|
global tk_images
|
||||||
tk_images = []
|
tk_images = []
|
||||||
|
@ -66,10 +76,9 @@ def show_cardset(*args):
|
||||||
if all_imgs:
|
if all_imgs:
|
||||||
ls += glob(os.path.join(cs.dir, 'bottom*'+cs.ext))
|
ls += glob(os.path.join(cs.dir, 'bottom*'+cs.ext))
|
||||||
ls += glob(os.path.join(cs.dir, 'l*'+cs.ext))
|
ls += glob(os.path.join(cs.dir, 'l*'+cs.ext))
|
||||||
#ls = glob(os.path.join(cs.dir, '*.gif'))
|
# ls = glob(os.path.join(cs.dir, '*.gif'))
|
||||||
##if not ls: return
|
# if not ls: return
|
||||||
ls.sort()
|
ls.sort()
|
||||||
n = 0
|
|
||||||
pf = None
|
pf = None
|
||||||
x, y = 10, 10
|
x, y = 10, 10
|
||||||
width, height = 0, 0
|
width, height = 0, 0
|
||||||
|
@ -77,28 +86,28 @@ def show_cardset(*args):
|
||||||
for f in ls:
|
for f in ls:
|
||||||
if Image:
|
if Image:
|
||||||
filter = {
|
filter = {
|
||||||
'NEAREST' : Image.NEAREST,
|
'NEAREST': Image.NEAREST,
|
||||||
'BILINEAR' : Image.BILINEAR,
|
'BILINEAR': Image.BILINEAR,
|
||||||
'BICUBIC' : Image.BICUBIC,
|
'BICUBIC': Image.BICUBIC,
|
||||||
'ANTIALIAS': Image.ANTIALIAS,
|
'ANTIALIAS': Image.ANTIALIAS,
|
||||||
} [filter_var.get()]
|
}[filter_var.get()]
|
||||||
##filter = Image.BILINEAR
|
# filter = Image.BILINEAR
|
||||||
##filter = Image.BICUBIC
|
# filter = Image.BICUBIC
|
||||||
##filter = Image.ANTIALIAS
|
# filter = Image.ANTIALIAS
|
||||||
##print f
|
# print f
|
||||||
im = Image.open(f)
|
im = Image.open(f)
|
||||||
if zoom != 0:
|
if zoom != 0:
|
||||||
w, h = im.size
|
w, h = im.size
|
||||||
im = im.convert('RGBA') # for save transparency
|
im = im.convert('RGBA') # for save transparency
|
||||||
if rotate_var.get():
|
if rotate_var.get():
|
||||||
# rotate
|
# rotate
|
||||||
#if filter == Image.ANTIALIAS:
|
# if filter == Image.ANTIALIAS:
|
||||||
# filter = Image.BICUBIC
|
# filter = Image.BICUBIC
|
||||||
z = zoom*5
|
z = zoom*5
|
||||||
a = abs(pi/2/90*z)
|
a = abs(pi/2/90*z)
|
||||||
neww = int(w*cos(a)+h*sin(a))
|
neww = int(w*cos(a)+h*sin(a))
|
||||||
newh = int(h*cos(a)+w*sin(a))
|
newh = int(h*cos(a)+w*sin(a))
|
||||||
##print w, h, neww, newh
|
# print w, h, neww, newh
|
||||||
d = int(sqrt(w*w+h*h))
|
d = int(sqrt(w*w+h*h))
|
||||||
dx, dy = (d-w)/2, (d-h)/2
|
dx, dy = (d-w)/2, (d-h)/2
|
||||||
newim = Image.new('RGBA', (d, d))
|
newim = Image.new('RGBA', (d, d))
|
||||||
|
@ -115,10 +124,12 @@ def show_cardset(*args):
|
||||||
z = max(0.2, z)
|
z = max(0.2, z)
|
||||||
if 1:
|
if 1:
|
||||||
tmp = Image.new('RGBA', (w+2, h+2))
|
tmp = Image.new('RGBA', (w+2, h+2))
|
||||||
tmp.paste(im, (1,1), im)
|
tmp.paste(im, (1, 1), im)
|
||||||
im = tmp.resize((int(w*z), int(h*z)), resample=filter)
|
im = tmp.resize((int(w*z), int(h*z)),
|
||||||
|
resample=filter)
|
||||||
else:
|
else:
|
||||||
im = im.resize((int(w*z), int(h*z)), resample=filter)
|
im = im.resize((int(w*z), int(h*z)),
|
||||||
|
resample=filter)
|
||||||
t = '%d %%' % int(z*100)
|
t = '%d %%' % int(z*100)
|
||||||
|
|
||||||
zoom_label.config(text=t)
|
zoom_label.config(text=t)
|
||||||
|
@ -140,32 +151,36 @@ def show_cardset(*args):
|
||||||
else:
|
else:
|
||||||
x += image.width()+10
|
x += image.width()+10
|
||||||
canvas.create_image(x, y, image=image, anchor=NW)
|
canvas.create_image(x, y, image=image, anchor=NW)
|
||||||
##canvas.create_rectangle(x, y, x+image.width(), y+image.height())
|
# canvas.create_rectangle(x, y, x+image.width(), y+image.height())
|
||||||
width = max(width, x)
|
width = max(width, x)
|
||||||
height = max(height, y)
|
height = max(height, y)
|
||||||
width, height = width+image.width()+10, height+image.height()+10
|
width, height = width+image.width()+10, height+image.height()+10
|
||||||
canvas.config(scrollregion=(0, 0, width, height))
|
canvas.config(scrollregion=(0, 0, width, height))
|
||||||
##print image.width(), image.height()
|
# print image.width(), image.height()
|
||||||
label.config(text='''\
|
label.config(text='''\
|
||||||
Name: %s
|
Name: %s
|
||||||
Type: %s
|
Type: %s
|
||||||
Directory: %s''' % (cs.name, cs.type, cs.dir))
|
Directory: %s''' % (cs.name, cs.type, cs.dir))
|
||||||
|
|
||||||
|
|
||||||
def zoom_in(*args):
|
def zoom_in(*args):
|
||||||
global zoom
|
global zoom
|
||||||
zoom += 1
|
zoom += 1
|
||||||
show_cardset()
|
show_cardset()
|
||||||
|
|
||||||
|
|
||||||
def zoom_out(*args):
|
def zoom_out(*args):
|
||||||
global zoom
|
global zoom
|
||||||
zoom -= 1
|
zoom -= 1
|
||||||
show_cardset()
|
show_cardset()
|
||||||
|
|
||||||
|
|
||||||
def zoom_cancel(*args):
|
def zoom_cancel(*args):
|
||||||
global zoom
|
global zoom
|
||||||
zoom = 0
|
zoom = 0
|
||||||
show_cardset()
|
show_cardset()
|
||||||
|
|
||||||
|
|
||||||
def show_info(*args):
|
def show_info(*args):
|
||||||
if list_box.curselection():
|
if list_box.curselection():
|
||||||
cs_name = list_box.get(list_box.curselection())
|
cs_name = list_box.get(list_box.curselection())
|
||||||
|
@ -180,6 +195,7 @@ def show_info(*args):
|
||||||
button = Button(b_frame, text='Close', command=top.destroy)
|
button = Button(b_frame, text='Close', command=top.destroy)
|
||||||
button.pack(side=RIGHT)
|
button.pack(side=RIGHT)
|
||||||
|
|
||||||
|
|
||||||
def create_widgets():
|
def create_widgets():
|
||||||
global list_box, canvas, label, zoom_label
|
global list_box, canvas, label, zoom_label
|
||||||
#
|
#
|
||||||
|
@ -253,6 +269,7 @@ def create_widgets():
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if '-a' in sys.argv:
|
if '-a' in sys.argv:
|
||||||
sys.argv.remove('-a')
|
sys.argv.remove('-a')
|
||||||
|
@ -260,7 +277,8 @@ if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
data_dir = sys.argv[1]
|
data_dir = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
data_dir = os.path.normpath(os.path.join(sys.path[0], os.pardir, 'data'))
|
data_dir = os.path.normpath(
|
||||||
|
os.path.join(sys.path[0], os.pardir, 'data'))
|
||||||
ls = glob(os.path.join(data_dir, '*', 'config.txt'))
|
ls = glob(os.path.join(data_dir, '*', 'config.txt'))
|
||||||
cardsets_dict = create_cs_list(ls)
|
cardsets_dict = create_cs_list(ls)
|
||||||
root = create_widgets()
|
root = create_widgets()
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pysollib.settings
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
def execfile(fn):
|
||||||
|
return exec(open(fn).read())
|
||||||
|
|
||||||
prog_name = 'PySol Fan Club edition'
|
prog_name = 'PySol Fan Club edition'
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
dirs_list = []
|
dirs_list = []
|
||||||
files_list = []
|
files_list = []
|
||||||
|
@ -11,8 +18,7 @@ for root, dirs, files in os.walk('dist'):
|
||||||
files_list.append(root)
|
files_list.append(root)
|
||||||
dirs_list.append(root)
|
dirs_list.append(root)
|
||||||
|
|
||||||
execfile(os.path.join('pysollib', 'settings.py'))
|
prog_version = pysollib.settings.VERSION
|
||||||
prog_version = VERSION
|
|
||||||
|
|
||||||
out = open('setup.iss', 'w')
|
out = open('setup.iss', 'w')
|
||||||
|
|
||||||
|
@ -45,5 +51,3 @@ print >> out, 'Source: "*"; DestDir: "{app}"'
|
||||||
for d in files_list[1:]:
|
for d in files_list[1:]:
|
||||||
d = d.replace('dist\\', '')
|
d = d.replace('dist\\', '')
|
||||||
print >> out, 'Source: "%s\\*"; DestDir: "{app}\\%s"' % (d, d)
|
print >> out, 'Source: "%s\\*"; DestDir: "{app}\\%s"' % (d, d)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,202 +1,203 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os.path
|
import os.path
|
||||||
for module_name in [
|
for module_name in \
|
||||||
'pysollib.acard',
|
[
|
||||||
'pysollib.actions',
|
'pysollib.acard',
|
||||||
'pysollib.app',
|
'pysollib.actions',
|
||||||
'pysollib.configobj.configobj',
|
'pysollib.app',
|
||||||
'pysollib.configobj.validate',
|
'pysollib.configobj.configobj',
|
||||||
'pysollib.customgame',
|
'pysollib.configobj.validate',
|
||||||
'pysollib.game',
|
'pysollib.customgame',
|
||||||
'pysollib.gamedb',
|
'pysollib.game',
|
||||||
'pysollib.games.acesup',
|
'pysollib.gamedb',
|
||||||
'pysollib.games.algerian',
|
'pysollib.games.acesup',
|
||||||
'pysollib.games.auldlangsyne',
|
'pysollib.games.algerian',
|
||||||
'pysollib.games.bakersdozen',
|
'pysollib.games.auldlangsyne',
|
||||||
'pysollib.games.bakersgame',
|
'pysollib.games.bakersdozen',
|
||||||
'pysollib.games.beleagueredcastle',
|
'pysollib.games.bakersgame',
|
||||||
'pysollib.games.bisley',
|
'pysollib.games.beleagueredcastle',
|
||||||
'pysollib.games.braid',
|
'pysollib.games.bisley',
|
||||||
'pysollib.games.bristol',
|
'pysollib.games.braid',
|
||||||
'pysollib.games.buffalobill',
|
'pysollib.games.bristol',
|
||||||
'pysollib.games.calculation',
|
'pysollib.games.buffalobill',
|
||||||
'pysollib.games.camelot',
|
'pysollib.games.calculation',
|
||||||
'pysollib.games.canfield',
|
'pysollib.games.camelot',
|
||||||
'pysollib.games.capricieuse',
|
'pysollib.games.canfield',
|
||||||
'pysollib.games.curdsandwhey',
|
'pysollib.games.capricieuse',
|
||||||
'pysollib.games.dieboesesieben',
|
'pysollib.games.curdsandwhey',
|
||||||
'pysollib.games.diplomat',
|
'pysollib.games.dieboesesieben',
|
||||||
'pysollib.games.doublets',
|
'pysollib.games.diplomat',
|
||||||
'pysollib.games.eiffeltower',
|
'pysollib.games.doublets',
|
||||||
'pysollib.games.fan',
|
'pysollib.games.eiffeltower',
|
||||||
'pysollib.games.fortythieves',
|
'pysollib.games.fan',
|
||||||
'pysollib.games.freecell',
|
'pysollib.games.fortythieves',
|
||||||
'pysollib.games.glenwood',
|
'pysollib.games.freecell',
|
||||||
'pysollib.games.golf',
|
'pysollib.games.glenwood',
|
||||||
'pysollib.games.grandduchess',
|
'pysollib.games.golf',
|
||||||
'pysollib.games.grandfathersclock',
|
'pysollib.games.grandduchess',
|
||||||
'pysollib.games.gypsy',
|
'pysollib.games.grandfathersclock',
|
||||||
'pysollib.games.harp',
|
'pysollib.games.gypsy',
|
||||||
'pysollib.games.headsandtails',
|
'pysollib.games.harp',
|
||||||
'pysollib.games.katzenschwanz',
|
'pysollib.games.headsandtails',
|
||||||
'pysollib.games.klondike',
|
'pysollib.games.katzenschwanz',
|
||||||
'pysollib.games.labyrinth',
|
'pysollib.games.klondike',
|
||||||
'pysollib.games.larasgame',
|
'pysollib.games.labyrinth',
|
||||||
'pysollib.games.mahjongg.mahjongg',
|
'pysollib.games.larasgame',
|
||||||
'pysollib.games.mahjongg.mahjongg1',
|
'pysollib.games.mahjongg.mahjongg',
|
||||||
'pysollib.games.mahjongg.mahjongg2',
|
'pysollib.games.mahjongg.mahjongg1',
|
||||||
'pysollib.games.mahjongg.mahjongg3',
|
'pysollib.games.mahjongg.mahjongg2',
|
||||||
'pysollib.games.mahjongg.shisensho',
|
'pysollib.games.mahjongg.mahjongg3',
|
||||||
'pysollib.games.matriarchy',
|
'pysollib.games.mahjongg.shisensho',
|
||||||
'pysollib.games.montana',
|
'pysollib.games.matriarchy',
|
||||||
'pysollib.games.montecarlo',
|
'pysollib.games.montana',
|
||||||
'pysollib.games.napoleon',
|
'pysollib.games.montecarlo',
|
||||||
'pysollib.games.needle',
|
'pysollib.games.napoleon',
|
||||||
'pysollib.games.numerica',
|
'pysollib.games.needle',
|
||||||
'pysollib.games.osmosis',
|
'pysollib.games.numerica',
|
||||||
'pysollib.games.parallels',
|
'pysollib.games.osmosis',
|
||||||
'pysollib.games.pasdedeux',
|
'pysollib.games.parallels',
|
||||||
'pysollib.games.picturegallery',
|
'pysollib.games.pasdedeux',
|
||||||
'pysollib.games.pileon',
|
'pysollib.games.picturegallery',
|
||||||
'pysollib.games.pushpin',
|
'pysollib.games.pileon',
|
||||||
'pysollib.games.pyramid',
|
'pysollib.games.pushpin',
|
||||||
'pysollib.games.royalcotillion',
|
'pysollib.games.pyramid',
|
||||||
'pysollib.games.royaleast',
|
'pysollib.games.royalcotillion',
|
||||||
'pysollib.games.sanibel',
|
'pysollib.games.royaleast',
|
||||||
'pysollib.games.siebenbisas',
|
'pysollib.games.sanibel',
|
||||||
'pysollib.games.simplex',
|
'pysollib.games.siebenbisas',
|
||||||
'pysollib.games.special.hanoi',
|
'pysollib.games.simplex',
|
||||||
'pysollib.games.special.memory',
|
'pysollib.games.special.hanoi',
|
||||||
'pysollib.games.special.pegged',
|
'pysollib.games.special.memory',
|
||||||
'pysollib.games.special.poker',
|
'pysollib.games.special.pegged',
|
||||||
'pysollib.games.special.tarock',
|
'pysollib.games.special.poker',
|
||||||
'pysollib.games.spider',
|
'pysollib.games.special.tarock',
|
||||||
'pysollib.games.sthelena',
|
'pysollib.games.spider',
|
||||||
'pysollib.games.sultan',
|
'pysollib.games.sthelena',
|
||||||
'pysollib.games.takeaway',
|
'pysollib.games.sultan',
|
||||||
'pysollib.games.terrace',
|
'pysollib.games.takeaway',
|
||||||
'pysollib.games.threepeaks',
|
'pysollib.games.terrace',
|
||||||
'pysollib.games.tournament',
|
'pysollib.games.threepeaks',
|
||||||
'pysollib.games.ultra.dashavatara',
|
'pysollib.games.tournament',
|
||||||
'pysollib.games.ultra.hanafuda',
|
'pysollib.games.ultra.dashavatara',
|
||||||
'pysollib.games.ultra.hanafuda1',
|
'pysollib.games.ultra.hanafuda',
|
||||||
'pysollib.games.ultra.hanafuda_common',
|
'pysollib.games.ultra.hanafuda1',
|
||||||
'pysollib.games.ultra.hexadeck',
|
'pysollib.games.ultra.hanafuda_common',
|
||||||
'pysollib.games.ultra.larasgame',
|
'pysollib.games.ultra.hexadeck',
|
||||||
'pysollib.games.ultra.matrix',
|
'pysollib.games.ultra.larasgame',
|
||||||
'pysollib.games.ultra.mughal',
|
'pysollib.games.ultra.matrix',
|
||||||
'pysollib.games.ultra.tarock',
|
'pysollib.games.ultra.mughal',
|
||||||
'pysollib.games.unionsquare',
|
'pysollib.games.ultra.tarock',
|
||||||
'pysollib.games.wavemotion',
|
'pysollib.games.unionsquare',
|
||||||
'pysollib.games.windmill',
|
'pysollib.games.wavemotion',
|
||||||
'pysollib.games.yukon',
|
'pysollib.games.windmill',
|
||||||
'pysollib.games.zodiac',
|
'pysollib.games.yukon',
|
||||||
'pysollib.help',
|
'pysollib.games.zodiac',
|
||||||
'pysollib.hint',
|
'pysollib.help',
|
||||||
'pysollib.images',
|
'pysollib.hint',
|
||||||
'pysollib.init',
|
'pysollib.images',
|
||||||
'pysollib.layout',
|
'pysollib.init',
|
||||||
'pysollib.macosx.appSupport',
|
'pysollib.layout',
|
||||||
'pysollib.main',
|
'pysollib.macosx.appSupport',
|
||||||
'pysollib.mfxutil',
|
'pysollib.main',
|
||||||
'pysollib.move',
|
'pysollib.mfxutil',
|
||||||
'pysollib.mygettext',
|
'pysollib.move',
|
||||||
'pysollib.options',
|
'pysollib.mygettext',
|
||||||
'pysollib.pysolaudio',
|
'pysollib.options',
|
||||||
'pysollib.pysolgtk.card',
|
'pysollib.pysolaudio',
|
||||||
'pysollib.pysolgtk.colorsdialog',
|
'pysollib.pysolgtk.card',
|
||||||
'pysollib.pysolgtk.edittextdialog',
|
'pysollib.pysolgtk.colorsdialog',
|
||||||
'pysollib.pysolgtk.findcarddialog',
|
'pysollib.pysolgtk.edittextdialog',
|
||||||
'pysollib.pysolgtk.fontsdialog',
|
'pysollib.pysolgtk.findcarddialog',
|
||||||
'pysollib.pysolgtk.gameinfodialog',
|
'pysollib.pysolgtk.fontsdialog',
|
||||||
'pysollib.pysolgtk.menubar',
|
'pysollib.pysolgtk.gameinfodialog',
|
||||||
'pysollib.pysolgtk.playeroptionsdialog',
|
'pysollib.pysolgtk.menubar',
|
||||||
'pysollib.pysolgtk.progressbar',
|
'pysollib.pysolgtk.playeroptionsdialog',
|
||||||
'pysollib.pysolgtk.pysoltree',
|
'pysollib.pysolgtk.progressbar',
|
||||||
'pysollib.pysolgtk.selectcardset',
|
'pysollib.pysolgtk.pysoltree',
|
||||||
'pysollib.pysolgtk.selectgame',
|
'pysollib.pysolgtk.selectcardset',
|
||||||
'pysollib.pysolgtk.selecttile',
|
'pysollib.pysolgtk.selectgame',
|
||||||
'pysollib.pysolgtk.soundoptionsdialog',
|
'pysollib.pysolgtk.selecttile',
|
||||||
'pysollib.pysolgtk.statusbar',
|
'pysollib.pysolgtk.soundoptionsdialog',
|
||||||
'pysollib.pysolgtk.timeoutsdialog',
|
'pysollib.pysolgtk.statusbar',
|
||||||
'pysollib.pysolgtk.tkcanvas',
|
'pysollib.pysolgtk.timeoutsdialog',
|
||||||
'pysollib.pysolgtk.tkconst',
|
'pysollib.pysolgtk.tkcanvas',
|
||||||
'pysollib.pysolgtk.tkhtml',
|
'pysollib.pysolgtk.tkconst',
|
||||||
'pysollib.pysolgtk.tkstats',
|
'pysollib.pysolgtk.tkhtml',
|
||||||
'pysollib.pysolgtk.tkutil',
|
'pysollib.pysolgtk.tkstats',
|
||||||
'pysollib.pysolgtk.tkwidget',
|
'pysollib.pysolgtk.tkutil',
|
||||||
'pysollib.pysolgtk.tkwrap',
|
'pysollib.pysolgtk.tkwidget',
|
||||||
'pysollib.pysolgtk.toolbar',
|
'pysollib.pysolgtk.tkwrap',
|
||||||
'pysollib.pysolrandom',
|
'pysollib.pysolgtk.toolbar',
|
||||||
'pysollib.pysoltk',
|
'pysollib.pysolrandom',
|
||||||
'pysollib.resource',
|
'pysollib.pysoltk',
|
||||||
'pysollib.settings',
|
'pysollib.resource',
|
||||||
'pysollib.stack',
|
'pysollib.settings',
|
||||||
'pysollib.stats',
|
'pysollib.stack',
|
||||||
'pysollib.tile.basetilemfxdialog',
|
'pysollib.stats',
|
||||||
'pysollib.tile.colorsdialog',
|
'pysollib.tile.basetilemfxdialog',
|
||||||
'pysollib.tile.edittextdialog',
|
'pysollib.tile.colorsdialog',
|
||||||
'pysollib.tile.fontsdialog',
|
'pysollib.tile.edittextdialog',
|
||||||
'pysollib.tile.gameinfodialog',
|
'pysollib.tile.fontsdialog',
|
||||||
'pysollib.tile.menubar',
|
'pysollib.tile.gameinfodialog',
|
||||||
'pysollib.tile.playeroptionsdialog',
|
'pysollib.tile.menubar',
|
||||||
'pysollib.tile.progressbar',
|
'pysollib.tile.playeroptionsdialog',
|
||||||
'pysollib.tile.selectcardset',
|
'pysollib.tile.progressbar',
|
||||||
'pysollib.tile.selectgame',
|
'pysollib.tile.selectcardset',
|
||||||
'pysollib.tile.selecttile',
|
'pysollib.tile.selectgame',
|
||||||
'pysollib.tile.selecttree',
|
'pysollib.tile.selecttile',
|
||||||
'pysollib.tile.solverdialog',
|
'pysollib.tile.selecttree',
|
||||||
'pysollib.tile.soundoptionsdialog',
|
'pysollib.tile.solverdialog',
|
||||||
'pysollib.tile.statusbar',
|
'pysollib.tile.soundoptionsdialog',
|
||||||
'pysollib.tile.timeoutsdialog',
|
'pysollib.tile.statusbar',
|
||||||
'pysollib.tile.tkhtml',
|
'pysollib.tile.timeoutsdialog',
|
||||||
'pysollib.tile.tkstats',
|
'pysollib.tile.tkhtml',
|
||||||
'pysollib.tile.tktree',
|
'pysollib.tile.tkstats',
|
||||||
'pysollib.tile.tkwidget',
|
'pysollib.tile.tktree',
|
||||||
'pysollib.tile.toolbar',
|
'pysollib.tile.tkwidget',
|
||||||
'pysollib.tile.ttk',
|
'pysollib.tile.toolbar',
|
||||||
'pysollib.tile.wizarddialog',
|
'pysollib.tile.ttk',
|
||||||
'pysollib.tk.colorsdialog',
|
'pysollib.tile.wizarddialog',
|
||||||
'pysollib.tk.edittextdialog',
|
'pysollib.tk.colorsdialog',
|
||||||
'pysollib.tk.fontsdialog',
|
'pysollib.tk.edittextdialog',
|
||||||
'pysollib.tk.gameinfodialog',
|
'pysollib.tk.fontsdialog',
|
||||||
'pysollib.tk.menubar',
|
'pysollib.tk.gameinfodialog',
|
||||||
'pysollib.tk.playeroptionsdialog',
|
'pysollib.tk.menubar',
|
||||||
'pysollib.tk.progressbar',
|
'pysollib.tk.playeroptionsdialog',
|
||||||
'pysollib.tk.selectcardset',
|
'pysollib.tk.progressbar',
|
||||||
'pysollib.tk.selectgame',
|
'pysollib.tk.selectcardset',
|
||||||
'pysollib.tk.selecttile',
|
'pysollib.tk.selectgame',
|
||||||
'pysollib.tk.selecttree',
|
'pysollib.tk.selecttile',
|
||||||
'pysollib.tk.solverdialog',
|
'pysollib.tk.selecttree',
|
||||||
'pysollib.tk.soundoptionsdialog',
|
'pysollib.tk.solverdialog',
|
||||||
'pysollib.tk.statusbar',
|
'pysollib.tk.soundoptionsdialog',
|
||||||
'pysollib.tk.tabpage',
|
'pysollib.tk.statusbar',
|
||||||
'pysollib.tk.timeoutsdialog',
|
'pysollib.tk.tabpage',
|
||||||
'pysollib.tk.tkhtml',
|
'pysollib.tk.timeoutsdialog',
|
||||||
'pysollib.tk.tkstats',
|
'pysollib.tk.tkhtml',
|
||||||
'pysollib.tk.tktree',
|
'pysollib.tk.tkstats',
|
||||||
'pysollib.tk.tkwidget',
|
'pysollib.tk.tktree',
|
||||||
'pysollib.tk.toolbar',
|
'pysollib.tk.tkwidget',
|
||||||
'pysollib.tk.wizarddialog',
|
'pysollib.tk.toolbar',
|
||||||
'pysollib.ui.tktile.card',
|
'pysollib.tk.wizarddialog',
|
||||||
'pysollib.ui.tktile.colorsdialog',
|
'pysollib.ui.tktile.card',
|
||||||
'pysollib.ui.tktile.edittextdialog',
|
'pysollib.ui.tktile.colorsdialog',
|
||||||
'pysollib.ui.tktile.findcarddialog',
|
'pysollib.ui.tktile.edittextdialog',
|
||||||
'pysollib.ui.tktile.menubar',
|
'pysollib.ui.tktile.findcarddialog',
|
||||||
'pysollib.ui.tktile.solverdialog',
|
'pysollib.ui.tktile.menubar',
|
||||||
'pysollib.ui.tktile.tkcanvas',
|
'pysollib.ui.tktile.solverdialog',
|
||||||
'pysollib.ui.tktile.tkconst',
|
'pysollib.ui.tktile.tkcanvas',
|
||||||
'pysollib.ui.tktile.tkhtml',
|
'pysollib.ui.tktile.tkconst',
|
||||||
'pysollib.ui.tktile.tkutil',
|
'pysollib.ui.tktile.tkhtml',
|
||||||
'pysollib.ui.tktile.tkwrap',
|
'pysollib.ui.tktile.tkutil',
|
||||||
'pysollib.util',
|
'pysollib.ui.tktile.tkwrap',
|
||||||
'pysollib.winsystems.aqua',
|
'pysollib.util',
|
||||||
'pysollib.winsystems.common',
|
'pysollib.winsystems.aqua',
|
||||||
'pysollib.winsystems.win32',
|
'pysollib.winsystems.common',
|
||||||
'pysollib.winsystems.x11',
|
'pysollib.winsystems.win32',
|
||||||
'pysollib.wizardpresets',
|
'pysollib.winsystems.x11',
|
||||||
'pysollib.wizardutil',
|
'pysollib.wizardpresets',
|
||||||
]:
|
'pysollib.wizardutil',
|
||||||
|
]:
|
||||||
open(os.path.join(".", "tests", "individually-importing", "import_" + module_name + ".py"), 'w').write('''#!/usr/bin/env python
|
open(os.path.join(".", "tests", "individually-importing", "import_" + module_name + ".py"), 'w').write('''#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
sys.path.append("./tests/lib")
|
sys.path.append("./tests/lib")
|
||||||
|
@ -206,4 +207,4 @@ plan(1)
|
||||||
sys.path.insert(0, ".")
|
sys.path.insert(0, ".")
|
||||||
import %(module_name)s
|
import %(module_name)s
|
||||||
ok(1, "imported")
|
ok(1, "imported")
|
||||||
''' % { 'module_name': module_name })
|
''' % {'module_name': module_name})
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- mode: python; coding: utf-8; -*-
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
|
|
||||||
import sys, os, re
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
|
||||||
|
|
||||||
def decode_layout(layout):
|
def decode_layout(layout):
|
||||||
# decode tile positions
|
# decode tile positions
|
||||||
assert layout[0] == "0"
|
assert layout[0] == "0"
|
||||||
|
@ -21,10 +23,11 @@ def decode_layout(layout):
|
||||||
tiles.sort()
|
tiles.sort()
|
||||||
return tiles
|
return tiles
|
||||||
|
|
||||||
|
|
||||||
def encode_layout(layout):
|
def encode_layout(layout):
|
||||||
# encode positions
|
# encode positions
|
||||||
s = '0'
|
s = '0'
|
||||||
##layout.sort()
|
# layout.sort()
|
||||||
x_max = max([t[1] for t in layout])
|
x_max = max([t[1] for t in layout])
|
||||||
y_max = max([t[2] for t in layout])
|
y_max = max([t[2] for t in layout])
|
||||||
for x in range(x_max+1):
|
for x in range(x_max+1):
|
||||||
|
@ -46,7 +49,6 @@ def encode_layout(layout):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_kyodai(filename):
|
def parse_kyodai(filename):
|
||||||
# Kyodai (http://www.kyodai.com/)
|
# Kyodai (http://www.kyodai.com/)
|
||||||
|
|
||||||
|
@ -179,30 +181,29 @@ if __name__ == '__main__':
|
||||||
layout = parse_func(filename)
|
layout = parse_func(filename)
|
||||||
layout = normalize(layout)
|
layout = normalize(layout)
|
||||||
|
|
||||||
#print filename, len(layout)
|
# print filename, len(layout)
|
||||||
|
|
||||||
s = encode_layout(layout)
|
s = encode_layout(layout)
|
||||||
|
|
||||||
# check
|
# check
|
||||||
lt = decode_layout(s)
|
lt = decode_layout(s)
|
||||||
if lt != layout:
|
if lt != layout:
|
||||||
print '*** ERROR ***'
|
print('*** ERROR ***')
|
||||||
else:
|
else:
|
||||||
##print s
|
# print s
|
||||||
|
|
||||||
gamename = os.path.split(filename)[1].split('.')[0]
|
gamename = os.path.split(filename)[1].split('.')[0]
|
||||||
#classname = gamename.replace(' ', '_')
|
# classname = gamename.replace(' ', '_')
|
||||||
#classname = 'Mahjongg_' + re.sub('\W', '', classname)
|
# classname = 'Mahjongg_' + re.sub('\W', '', classname)
|
||||||
|
|
||||||
ncards = len(layout)
|
ncards = len(layout)
|
||||||
|
|
||||||
if ncards != 144:
|
if ncards != 144:
|
||||||
print '''r(%d, "%s", ncards=%d, layout="%s")
|
print('''r(%d, "%s", ncards=%d, layout="%s")
|
||||||
''' % (gameid, gamename, ncards, s)
|
''' % (gameid, gamename, ncards, s))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print '''r(%d, "%s", layout="%s")
|
print('''r(%d, "%s", layout="%s")
|
||||||
''' % (gameid, gamename, s)
|
''' % (gameid, gamename, s))
|
||||||
|
|
||||||
gameid += 1
|
gameid += 1
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,16 @@
|
||||||
# Added very simple support for ngettext
|
# Added very simple support for ngettext
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import functools
|
||||||
|
|
||||||
# for selftesting
|
# for selftesting
|
||||||
try:
|
try:
|
||||||
import fintl
|
import fintl
|
||||||
_ = fintl.gettext
|
_ = fintl.gettext
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_ = lambda s: s
|
def _(s):
|
||||||
|
return s
|
||||||
|
|
||||||
__doc__ = _("""pygettext -- Python equivalent of xgettext(1)
|
__doc__ = _("""pygettext -- Python equivalent of xgettext(1)
|
||||||
|
|
||||||
|
@ -160,7 +164,6 @@ If `inputfile' is -, standard input is read.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import imp
|
import imp
|
||||||
import sys
|
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
import getopt
|
import getopt
|
||||||
|
@ -168,6 +171,9 @@ import token
|
||||||
import tokenize
|
import tokenize
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
basestring = str
|
||||||
|
|
||||||
__version__ = '1.6con'
|
__version__ = '1.6con'
|
||||||
|
|
||||||
default_keywords = ['_']
|
default_keywords = ['_']
|
||||||
|
@ -176,8 +182,6 @@ default_ngettext_keywords = ['ngettext']
|
||||||
|
|
||||||
EMPTYSTRING = ''
|
EMPTYSTRING = ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
|
# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
|
||||||
# there.
|
# there.
|
||||||
pot_header = _('''\
|
pot_header = _('''\
|
||||||
|
@ -207,9 +211,9 @@ def usage(code, msg=''):
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
escapes = []
|
escapes = []
|
||||||
|
|
||||||
|
|
||||||
def make_escapes(pass_iso8859):
|
def make_escapes(pass_iso8859):
|
||||||
global escapes
|
global escapes
|
||||||
if pass_iso8859:
|
if pass_iso8859:
|
||||||
|
@ -241,7 +245,7 @@ def escape(s):
|
||||||
|
|
||||||
def safe_eval(s):
|
def safe_eval(s):
|
||||||
# unwrap quotes, safely
|
# unwrap quotes, safely
|
||||||
return eval(s, {'__builtins__':{}}, {})
|
return eval(s, {'__builtins__': {}}, {})
|
||||||
|
|
||||||
|
|
||||||
def normalize(s):
|
def normalize(s):
|
||||||
|
@ -269,7 +273,7 @@ def containsAny(str, set):
|
||||||
def _visit_pyfiles(list, dirname, names):
|
def _visit_pyfiles(list, dirname, names):
|
||||||
"""Helper for getFilesForName()."""
|
"""Helper for getFilesForName()."""
|
||||||
# get extension for python source files
|
# get extension for python source files
|
||||||
if not globals().has_key('_py_ext'):
|
if '_py_ext' not in globals():
|
||||||
global _py_ext
|
global _py_ext
|
||||||
_py_ext = [triple[0] for triple in imp.get_suffixes()
|
_py_ext = [triple[0] for triple in imp.get_suffixes()
|
||||||
if triple[2] == imp.PY_SOURCE][0]
|
if triple[2] == imp.PY_SOURCE][0]
|
||||||
|
@ -299,7 +303,8 @@ def _get_modpkg_path(dotted_name, pathlist=None):
|
||||||
# we have a dotted path, import top-level package
|
# we have a dotted path, import top-level package
|
||||||
try:
|
try:
|
||||||
file, pathname, description = imp.find_module(parts[0], pathlist)
|
file, pathname, description = imp.find_module(parts[0], pathlist)
|
||||||
if file: file.close()
|
if file:
|
||||||
|
file.close()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -367,9 +372,9 @@ class TokenEater:
|
||||||
|
|
||||||
def __call__(self, ttype, tstring, stup, etup, line):
|
def __call__(self, ttype, tstring, stup, etup, line):
|
||||||
# dispatch
|
# dispatch
|
||||||
# import token
|
# import token
|
||||||
# print >> sys.stderr, 'ttype:', token.tok_name[ttype], \
|
# print >> sys.stderr, 'ttype:', token.tok_name[ttype], \
|
||||||
# 'tstring:', tstring
|
# 'tstring:', tstring
|
||||||
self.__state(ttype, tstring, stup[0])
|
self.__state(ttype, tstring, stup[0])
|
||||||
|
|
||||||
def __waiting(self, ttype, tstring, lineno):
|
def __waiting(self, ttype, tstring, lineno):
|
||||||
|
@ -435,11 +440,11 @@ class TokenEater:
|
||||||
self.__addentry(tuple(data))
|
self.__addentry(tuple(data))
|
||||||
elif self.__options.verbose:
|
elif self.__options.verbose:
|
||||||
print >> sys.stderr, _(
|
print >> sys.stderr, _(
|
||||||
'*** %(file)s:%(lineno)s: incorrect ngettext format'
|
'*** %(file)s:%(lineno)s: incorrect '
|
||||||
|
'ngettext format'
|
||||||
) % {
|
) % {
|
||||||
'file': self.__curfile,
|
'file': self.__curfile,
|
||||||
'lineno': self.__lineno
|
'lineno': self.__lineno}
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
self.__addentry(EMPTYSTRING.join(self.__data))
|
self.__addentry(EMPTYSTRING.join(self.__data))
|
||||||
self.__state = self.__waiting
|
self.__state = self.__waiting
|
||||||
|
@ -449,13 +454,14 @@ class TokenEater:
|
||||||
token.NEWLINE, tokenize.NL]:
|
token.NEWLINE, tokenize.NL]:
|
||||||
if self.__ngettext and ttype == tokenize.OP and tstring == ',':
|
if self.__ngettext and ttype == tokenize.OP and tstring == ',':
|
||||||
self.__data.append(None)
|
self.__data.append(None)
|
||||||
elif self.__ngettext: # and ttype == tokenize.NUMBER:
|
elif self.__ngettext: # and ttype == tokenize.NUMBER:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# warn if we see anything else than STRING or whitespace
|
# warn if we see anything else than STRING or whitespace
|
||||||
if self.__options.verbose:
|
if self.__options.verbose:
|
||||||
print >> sys.stderr, _(
|
print >> sys.stderr, _(
|
||||||
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
|
'*** %(file)s:%(lineno)s: Seen unexpected '
|
||||||
|
'token "%(token)s"'
|
||||||
) % {
|
) % {
|
||||||
'token': tstring,
|
'token': tstring,
|
||||||
'file': self.__curfile,
|
'file': self.__curfile,
|
||||||
|
@ -466,7 +472,7 @@ class TokenEater:
|
||||||
def __addentry(self, msg, lineno=None, isdocstring=0):
|
def __addentry(self, msg, lineno=None, isdocstring=0):
|
||||||
if lineno is None:
|
if lineno is None:
|
||||||
lineno = self.__lineno
|
lineno = self.__lineno
|
||||||
if not msg in self.__options.toexclude:
|
if msg not in self.__options.toexclude:
|
||||||
entry = (self.__curfile, lineno)
|
entry = (self.__curfile, lineno)
|
||||||
self.__messages.setdefault(msg, {})[entry] = isdocstring
|
self.__messages.setdefault(msg, {})[entry] = isdocstring
|
||||||
|
|
||||||
|
@ -497,7 +503,7 @@ class TokenEater:
|
||||||
# If the entry was gleaned out of a docstring, then add a
|
# If the entry was gleaned out of a docstring, then add a
|
||||||
# comment stating so. This is to aid translators who may wish
|
# comment stating so. This is to aid translators who may wish
|
||||||
# to skip translating some unimportant docstrings.
|
# to skip translating some unimportant docstrings.
|
||||||
if reduce(operator.__add__, v.values()):
|
if functools.reduce(operator.__add__, v.values()):
|
||||||
isdocstring = 1
|
isdocstring = 1
|
||||||
# k is the message string, v is a dictionary-set of (filename,
|
# k is the message string, v is a dictionary-set of (filename,
|
||||||
# lineno) tuples. We want to sort the entries in v first by
|
# lineno) tuples. We want to sort the entries in v first by
|
||||||
|
@ -541,7 +547,6 @@ class TokenEater:
|
||||||
print >> fp, 'msgstr[1] ""\n'
|
print >> fp, 'msgstr[1] ""\n'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global default_keywords
|
global default_keywords
|
||||||
try:
|
try:
|
||||||
|
@ -554,7 +559,7 @@ def main():
|
||||||
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
|
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
|
||||||
'docstrings', 'no-docstrings',
|
'docstrings', 'no-docstrings',
|
||||||
])
|
])
|
||||||
except getopt.error, msg:
|
except getopt.error as msg:
|
||||||
usage(1, msg)
|
usage(1, msg)
|
||||||
|
|
||||||
# for holding option values
|
# for holding option values
|
||||||
|
@ -563,7 +568,7 @@ def main():
|
||||||
GNU = 1
|
GNU = 1
|
||||||
SOLARIS = 2
|
SOLARIS = 2
|
||||||
# defaults
|
# defaults
|
||||||
extractall = 0 # FIXME: currently this option has no effect at all.
|
extractall = 0 # FIXME: currently this option has no effect at all.
|
||||||
escape = 0
|
escape = 0
|
||||||
keywords = []
|
keywords = []
|
||||||
ngettext_keywords = []
|
ngettext_keywords = []
|
||||||
|
@ -578,8 +583,8 @@ def main():
|
||||||
nodocstrings = {}
|
nodocstrings = {}
|
||||||
|
|
||||||
options = Options()
|
options = Options()
|
||||||
locations = {'gnu' : options.GNU,
|
locations = {'gnu': options.GNU,
|
||||||
'solaris' : options.SOLARIS,
|
'solaris': options.SOLARIS,
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse options
|
# parse options
|
||||||
|
@ -615,7 +620,7 @@ def main():
|
||||||
elif opt in ('-v', '--verbose'):
|
elif opt in ('-v', '--verbose'):
|
||||||
options.verbose = 1
|
options.verbose = 1
|
||||||
elif opt in ('-V', '--version'):
|
elif opt in ('-V', '--version'):
|
||||||
print _('pygettext.py (xgettext for Python) %s') % __version__
|
print(_('pygettext.py (xgettext for Python) %s') % __version__)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif opt in ('-w', '--width'):
|
elif opt in ('-w', '--width'):
|
||||||
try:
|
try:
|
||||||
|
@ -671,19 +676,19 @@ def main():
|
||||||
for filename in args:
|
for filename in args:
|
||||||
if filename == '-':
|
if filename == '-':
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print _('Reading standard input')
|
print(_('Reading standard input'))
|
||||||
fp = sys.stdin
|
fp = sys.stdin
|
||||||
closep = 0
|
closep = 0
|
||||||
else:
|
else:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print _('Working on %s') % filename
|
print(_('Working on %s') % filename)
|
||||||
fp = open(filename)
|
fp = open(filename)
|
||||||
closep = 1
|
closep = 1
|
||||||
try:
|
try:
|
||||||
eater.set_filename(filename)
|
eater.set_filename(filename)
|
||||||
try:
|
try:
|
||||||
tokenize.tokenize(fp.readline, eater)
|
tokenize.tokenize(fp.readline, eater)
|
||||||
except tokenize.TokenError, e:
|
except tokenize.TokenError as e:
|
||||||
print >> sys.stderr, '%s: %s, line %d, column %d' % (
|
print >> sys.stderr, '%s: %s, line %d, column %d' % (
|
||||||
e[0], filename, e[1][0], e[1][1])
|
e[0], filename, e[1][0], e[1][1])
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -20,13 +20,14 @@ my %skip =
|
||||||
./pysollib/games/special/__init__.py
|
./pysollib/games/special/__init__.py
|
||||||
./pysollib/games/ultra/__init__.py
|
./pysollib/games/ultra/__init__.py
|
||||||
./pysollib/pysoltk.py
|
./pysollib/pysoltk.py
|
||||||
|
./scripts/all_games.py
|
||||||
./pysollib/tile/ttk.py
|
./pysollib/tile/ttk.py
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
my $cmd = shell_quote( 'flake8',
|
my $cmd = shell_quote( 'flake8',
|
||||||
grep { not exists $skip{$_} } glob('*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py') );
|
grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/ui/tktile/*.py') );
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue