mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake 8
This commit is contained in:
parent
c4a0d62963
commit
00e0d81ece
4 changed files with 485 additions and 303 deletions
|
@ -23,7 +23,9 @@
|
|||
|
||||
import os
|
||||
|
||||
n_ = lambda x: x # for gettext
|
||||
|
||||
def n_(x): # for gettext
|
||||
return x
|
||||
|
||||
|
||||
PACKAGE = 'PySolFC'
|
||||
|
@ -31,7 +33,7 @@ TITLE = 'PySol'
|
|||
PACKAGE_URL = 'http://pysolfc.sourceforge.net/'
|
||||
|
||||
VERSION = '3.0'
|
||||
VERSION_TUPLE = (3,0,0)
|
||||
VERSION_TUPLE = (3, 0, 0)
|
||||
|
||||
# Tk windowing system (auto set up in init.py)
|
||||
WIN_SYSTEM = 'x11' # win32, x11, aqua, classic
|
||||
|
@ -52,7 +54,7 @@ SOUND_MOD = 'auto'
|
|||
# freecell-solver
|
||||
USE_FREECELL_SOLVER = True
|
||||
FCS_COMMAND = 'fc-solve'
|
||||
##FCS_HOME = None # path to fcs presets files
|
||||
# FCS_HOME = None # path to fcs presets files
|
||||
|
||||
# data dirs
|
||||
DATA_DIRS = []
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,18 +23,23 @@
|
|||
|
||||
|
||||
# imports
|
||||
import sys
|
||||
import time
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mfxutil import format_time
|
||||
from pysollib.gamedb import GI
|
||||
from pysollib.mygettext import _, n_
|
||||
from pysollib.mygettext import _
|
||||
|
||||
|
||||
if sys.version_info > (3,):
|
||||
xrange = range
|
||||
|
||||
# ************************************************************************
|
||||
# *
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class PysolStatsFormatter:
|
||||
|
||||
def getStatHeader(self):
|
||||
|
@ -95,7 +100,7 @@ class PysolStatsFormatter:
|
|||
self.avrg_time = time
|
||||
self.avrg_moves = moves
|
||||
self.percent = perc
|
||||
#yield (_("Total (%d out of %d games)") % (tgames, len(g)),
|
||||
# yield (_("Total (%d out of %d games)") % (tgames, len(g)),
|
||||
# won+lost, won, lost, time, moves, perc, '')
|
||||
|
||||
def getStatSummary(self):
|
||||
|
@ -135,7 +140,8 @@ class PysolStatsFormatter:
|
|||
name = _("** UNKNOWN %d **") % gameid
|
||||
f = pg[1]
|
||||
if len(f) == 16:
|
||||
##gamenumber = "%s-%s-%s-%s" % (f[0:4], f[4:8], f[8:12], f[12:16])
|
||||
# gamenumber = "%s-%s-%s-%s" % \
|
||||
# (f[0:4], f[4:8], f[8:12], f[12:16])
|
||||
gamenumber = "%s-%s-%s" % (f[4:8], f[8:12], f[12:16])
|
||||
elif len(f) <= 20:
|
||||
gamenumber = f
|
||||
|
@ -147,8 +153,10 @@ class PysolStatsFormatter:
|
|||
t_won, tlost = t_won + won, tlost + (1 - won)
|
||||
status = "*error*"
|
||||
if -2 <= pg[2] <= 2:
|
||||
status = (_("Loaded"), _("Not won"), _("Lost"), _("Won"), _("Perfect")) [pg[2]+2]
|
||||
#writer.plog(name, gamenumber, date, status, gameid=gameid, won=pg[2])
|
||||
status = (_("Loaded"), _("Not won"), _("Lost"),
|
||||
_("Won"), _("Perfect"))[pg[2]+2]
|
||||
# writer.plog(name, gamenumber, date, status, gameid=gameid,
|
||||
# won=pg[2])
|
||||
yield [name, gamenumber, date, status, pg[2], gameid]
|
||||
|
||||
#
|
||||
|
@ -157,8 +165,10 @@ class PysolStatsFormatter:
|
|||
|
||||
def writeStats(self, player, sort_by='name'):
|
||||
pass
|
||||
|
||||
def writeFullLog(self, player):
|
||||
pass
|
||||
|
||||
def writeSessionLog(self, player):
|
||||
pass
|
||||
|
||||
|
@ -183,7 +193,8 @@ class FileStatsFormatter(PysolStatsFormatter):
|
|||
self.p(s)
|
||||
|
||||
def plog(self, gamename, gamenumber, date, status, gameid=-1, won=-1):
|
||||
self.p("%-25s %-20s %17s %s\n" % (gamename, gamenumber, date, status))
|
||||
self.p("%-25s %-20s %17s %s\n" %
|
||||
(gamename, gamenumber, date, status))
|
||||
|
||||
def writeHeader(self, header, pagewidth=72):
|
||||
date = time.ctime(time.time())
|
||||
|
@ -194,7 +205,8 @@ class FileStatsFormatter(PysolStatsFormatter):
|
|||
self.pheader("\n")
|
||||
|
||||
def writeStats(self, player, sort_by='name'):
|
||||
if player is None: player = _('Demo')
|
||||
if player is None:
|
||||
player = _('Demo')
|
||||
header = _("Statistics for ") + player
|
||||
self.writeHeader(header, 62)
|
||||
header = self.getStatHeader()
|
||||
|
@ -206,7 +218,7 @@ class FileStatsFormatter(PysolStatsFormatter):
|
|||
self.nl()
|
||||
total, played, won, lost, time, moves, perc = self.getStatSummary()
|
||||
self.pstats(_("Total (%d out of %d games)") % (played, total),
|
||||
won+lost, won, lost, time, moves, perc)
|
||||
won+lost, won, lost, time, moves, perc)
|
||||
self.nl(2)
|
||||
return played
|
||||
|
||||
|
@ -225,13 +237,15 @@ class FileStatsFormatter(PysolStatsFormatter):
|
|||
return 1
|
||||
|
||||
def writeFullLog(self, player):
|
||||
if player is None: player = _('Demo')
|
||||
if player is None:
|
||||
player = _('Demo')
|
||||
header = _("Full log for ") + player
|
||||
prev_games = self.app.stats.prev_games.get(player)
|
||||
return self.writeLog(player, header, prev_games)
|
||||
|
||||
def writeSessionLog(self, player):
|
||||
if player is None: player = _('Demo')
|
||||
if player is None:
|
||||
player = _('Demo')
|
||||
header = _("Session log for ") + player
|
||||
prev_games = self.app.stats.session_games.get(player)
|
||||
return self.writeLog(player, header, prev_games)
|
||||
|
@ -258,21 +272,21 @@ class ProgressionFormatter:
|
|||
start_time = g[3]
|
||||
t = time.localtime(start_time)[:3]
|
||||
if t not in all_results:
|
||||
all_results[t] = [0,0]
|
||||
all_results[t] = [0, 0]
|
||||
all_results[t][0] += 1
|
||||
if status > 0:
|
||||
all_results[t][1] += 1
|
||||
if id == gameid:
|
||||
if t not in game_results:
|
||||
game_results[t] = [0,0]
|
||||
game_results[t] = [0, 0]
|
||||
game_results[t][0] += 1
|
||||
if status > 0:
|
||||
game_results[t][1] += 1
|
||||
##from pprint import pprint; pprint(all_results)
|
||||
# from pprint import pprint; pprint(all_results)
|
||||
|
||||
def norm_time(self, t):
|
||||
if len(t) == 3:
|
||||
t = list(t)+[0,0,0,-1,-1,-1]
|
||||
t = list(t)+[0, 0, 0, -1, -1, -1]
|
||||
return list(time.localtime(time.mktime((t))))
|
||||
|
||||
def getResults(self, interval, all_games=True):
|
||||
|
@ -337,8 +351,7 @@ class ProgressionFormatter:
|
|||
res = []
|
||||
ct = list(time.localtime())
|
||||
while lt <= ct:
|
||||
##assert type(lt) is type(ct)
|
||||
sum = [0,0]
|
||||
# assert type(lt) is type(ct)
|
||||
played = 0
|
||||
won = 0
|
||||
text = None
|
||||
|
@ -356,6 +369,5 @@ class ProgressionFormatter:
|
|||
ct = self.norm_time(ct)
|
||||
res.append((text, played, won))
|
||||
res.reverse()
|
||||
##from pprint import pprint; pprint(res)
|
||||
# from pprint import pprint; pprint(res)
|
||||
return res
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
|
|||
|
||||
# my $cmd = shell_quote( 'flake8', '.' );
|
||||
my $cmd = shell_quote( 'flake8',
|
||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/[a-r]*.py') );
|
||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/[a-s]*.py') );
|
||||
|
||||
# TEST
|
||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||
|
|
Loading…
Add table
Reference in a new issue