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
fc90baffa7
commit
c4a0d62963
2 changed files with 90 additions and 80 deletions
|
@ -23,7 +23,10 @@
|
|||
|
||||
|
||||
# imports
|
||||
import os, glob, traceback
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import traceback
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mfxutil import Struct, KwStruct
|
||||
|
@ -35,22 +38,27 @@ from pysollib.mygettext import _
|
|||
# * Abstract
|
||||
# ************************************************************************
|
||||
|
||||
if sys.version_info > (3,):
|
||||
basestring = str
|
||||
|
||||
|
||||
class Resource(Struct):
|
||||
def __init__(self, **kw):
|
||||
kw = KwStruct(kw,
|
||||
name = "",
|
||||
filename = "",
|
||||
basename = "", # basename of filename
|
||||
absname = "", # absolute filename
|
||||
kw = KwStruct(
|
||||
kw,
|
||||
name="",
|
||||
filename="",
|
||||
basename="", # basename of filename
|
||||
absname="", # absolute filename
|
||||
# implicit
|
||||
index = -1,
|
||||
error = 0, # error while loading this resource
|
||||
index=-1,
|
||||
error=0, # error while loading this resource
|
||||
)
|
||||
Struct.__init__(self, **kw.getKw())
|
||||
|
||||
def getSortKey(self):
|
||||
return self.name.lower()
|
||||
#return latin1_to_ascii(self.name).lower()
|
||||
# return latin1_to_ascii(self.name).lower()
|
||||
|
||||
|
||||
class ResourceManager:
|
||||
|
@ -118,7 +126,7 @@ class ResourceManager:
|
|||
dir = os.path.normpath(dir)
|
||||
if dir and os.path.isdir(dir) and dir not in result:
|
||||
result.append(dir)
|
||||
except EnvironmentError, ex:
|
||||
except EnvironmentError as ex:
|
||||
pass
|
||||
|
||||
def getSearchDirs(self, app, search, env=None):
|
||||
|
@ -145,11 +153,11 @@ class ResourceManager:
|
|||
self._addDir(result, d)
|
||||
else:
|
||||
self._addDir(result, os.path.join(dir, s))
|
||||
except EnvironmentError, ex:
|
||||
except EnvironmentError as ex:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
if DEBUG >= 6:
|
||||
print "getSearchDirs", env, search, "->", result
|
||||
print("getSearchDirs", env, search, "->", result)
|
||||
return result
|
||||
|
||||
|
||||
|
@ -160,16 +168,16 @@ class ResourceManager:
|
|||
# CardsetInfo constants
|
||||
class CSI:
|
||||
# cardset size
|
||||
SIZE_TINY = 1
|
||||
SIZE_SMALL = 2
|
||||
SIZE_TINY = 1
|
||||
SIZE_SMALL = 2
|
||||
SIZE_MEDIUM = 3
|
||||
SIZE_LARGE = 4
|
||||
SIZE_LARGE = 4
|
||||
SIZE_XLARGE = 5
|
||||
|
||||
# cardset types
|
||||
TYPE_FRENCH = 1
|
||||
TYPE_FRENCH = 1
|
||||
TYPE_HANAFUDA = 2
|
||||
TYPE_TAROCK = 3
|
||||
TYPE_TAROCK = 3
|
||||
TYPE_MAHJONGG = 4
|
||||
TYPE_HEXADECK = 5
|
||||
TYPE_MUGHAL_GANJIFA = 6
|
||||
|
@ -224,28 +232,28 @@ class CSI:
|
|||
7: _("Classic look"), #
|
||||
8: _("Collectors"), # scanned collectors cardsets
|
||||
9: _("Computers"), #
|
||||
10: _("Engines"), #
|
||||
11: _("Fantasy"), #
|
||||
30: _("Ganjifa"), #
|
||||
12: _("Hanafuda"), #
|
||||
29: _("Hex A Deck"), #
|
||||
13: _("Holiday"), #
|
||||
28: _("Mahjongg"), #
|
||||
14: _("Movies"), #
|
||||
31: _("Matrix"), #
|
||||
15: _("Music"), #
|
||||
16: _("Nature"), #
|
||||
17: _("Operating Systems"), # e.g. cards with Linux logos
|
||||
19: _("People"), # famous people
|
||||
20: _("Places"), #
|
||||
21: _("Plain"), #
|
||||
22: _("Products"), #
|
||||
18: _("Round cardsets"), #
|
||||
23: _("Science Fiction"), #
|
||||
24: _("Sports"), #
|
||||
27: _("Tarock"), #
|
||||
25: _("Vehicels"), #
|
||||
26: _("Video Games"), #
|
||||
10: _("Engines"), #
|
||||
11: _("Fantasy"), #
|
||||
30: _("Ganjifa"), #
|
||||
12: _("Hanafuda"), #
|
||||
29: _("Hex A Deck"), #
|
||||
13: _("Holiday"), #
|
||||
28: _("Mahjongg"), #
|
||||
14: _("Movies"), #
|
||||
31: _("Matrix"), #
|
||||
15: _("Music"), #
|
||||
16: _("Nature"), #
|
||||
17: _("Operating Systems"), # e.g. cards with Linux logos
|
||||
19: _("People"), # famous people
|
||||
20: _("Places"), #
|
||||
21: _("Plain"), #
|
||||
22: _("Products"), #
|
||||
18: _("Round cardsets"), #
|
||||
23: _("Science Fiction"), #
|
||||
24: _("Sports"), #
|
||||
27: _("Tarock"), #
|
||||
25: _("Vehicels"), #
|
||||
26: _("Video Games"), #
|
||||
}
|
||||
|
||||
# cardset nationality (suit and rank symbols)
|
||||
|
@ -294,33 +302,34 @@ class CSI:
|
|||
class CardsetConfig(Struct):
|
||||
# see config.txt and _readCardsetConfig()
|
||||
def __init__(self):
|
||||
Struct.__init__(self,
|
||||
Struct.__init__(
|
||||
self,
|
||||
# line[0]
|
||||
version = 1,
|
||||
ext = ".gif",
|
||||
type = CSI.TYPE_FRENCH,
|
||||
ncards = -1,
|
||||
styles = [],
|
||||
year = 0,
|
||||
version=1,
|
||||
ext=".gif",
|
||||
type=CSI.TYPE_FRENCH,
|
||||
ncards=-1,
|
||||
styles=[],
|
||||
year=0,
|
||||
# line[1]
|
||||
ident = "",
|
||||
name = "",
|
||||
ident="",
|
||||
name="",
|
||||
# line[2]
|
||||
CARDW = 0,
|
||||
CARDH = 0,
|
||||
CARDD = 0,
|
||||
CARDW=0,
|
||||
CARDH=0,
|
||||
CARDD=0,
|
||||
# line[3]
|
||||
CARD_XOFFSET = 0,
|
||||
CARD_YOFFSET = 0,
|
||||
SHADOW_XOFFSET = 0,
|
||||
SHADOW_YOFFSET = 0,
|
||||
CARD_XOFFSET=0,
|
||||
CARD_YOFFSET=0,
|
||||
SHADOW_XOFFSET=0,
|
||||
SHADOW_YOFFSET=0,
|
||||
# line[4]
|
||||
backindex = 0,
|
||||
backindex=0,
|
||||
# line[5]
|
||||
backnames = (),
|
||||
backnames=(),
|
||||
# other
|
||||
CARD_DX = 0, # relative pos of real card image within Card
|
||||
CARD_DY = 0,
|
||||
CARD_DX=0, # relative pos of real card image within Card
|
||||
CARD_DY=0,
|
||||
)
|
||||
|
||||
|
||||
|
@ -332,19 +341,20 @@ class Cardset(Resource):
|
|||
# si is the SelectionInfo struct that will be queried by
|
||||
# the "select cardset" dialogs. It can be freely modified.
|
||||
si = Struct(type=0, size=0, styles=[], nationalities=[], dates=[])
|
||||
kw = KwStruct(kw,
|
||||
kw = KwStruct(
|
||||
kw,
|
||||
# essentials
|
||||
ranks = (),
|
||||
suits = (),
|
||||
trumps = (),
|
||||
nbottoms = 7,
|
||||
nletters = 4,
|
||||
nshadows = 1 + 13,
|
||||
ranks=(),
|
||||
suits=(),
|
||||
trumps=(),
|
||||
nbottoms=7,
|
||||
nletters=4,
|
||||
nshadows=1 + 13,
|
||||
# selection criteria
|
||||
si = si,
|
||||
si=si,
|
||||
# implicit
|
||||
backname = None,
|
||||
dir = "",
|
||||
backname=None,
|
||||
dir="",
|
||||
)
|
||||
Resource.__init__(self, **kw.getKw())
|
||||
|
||||
|
@ -368,7 +378,7 @@ class Cardset(Resource):
|
|||
if lr >= 4:
|
||||
ls = min(ls, 4)
|
||||
low_ranks, high_ranks = 1, 3
|
||||
###if self.type == 3: high_ranks = 4
|
||||
# if self.type == 3: high_ranks = 4
|
||||
for rank in range(0, low_ranks) + range(lr-high_ranks, lr):
|
||||
for suit in range(ls):
|
||||
index = suit * len(self.ranks) + rank
|
||||
|
@ -385,7 +395,7 @@ class Cardset(Resource):
|
|||
self.backname = self.backnames[self.backindex]
|
||||
|
||||
def saveSettings(self):
|
||||
print 'saveSettings'
|
||||
print('saveSettings')
|
||||
|
||||
|
||||
class CardsetManager(ResourceManager):
|
||||
|
@ -432,7 +442,7 @@ class CardsetManager(ResourceManager):
|
|||
cs.ranks = range(12)
|
||||
cs.suits = "abcdefgh"
|
||||
elif s == CSI.TYPE_NAVAGRAHA_GANJIFA:
|
||||
#???return 0 ## FIXME
|
||||
# ???return 0 ## FIXME
|
||||
cs.nbottoms = 12
|
||||
cs.ranks = range(12)
|
||||
cs.suits = "abcdefghi"
|
||||
|
@ -441,11 +451,11 @@ class CardsetManager(ResourceManager):
|
|||
cs.ranks = range(12)
|
||||
cs.suits = "abcdefghij"
|
||||
elif s == CSI.TYPE_TRUMP_ONLY:
|
||||
#???return 0 ## FIXME
|
||||
#cs.nbottoms = 7
|
||||
#cs.ranks = ()
|
||||
#cs.suits = ""
|
||||
#cs.trumps = range(cs.ncards)
|
||||
# ???return 0 ## FIXME
|
||||
# cs.nbottoms = 7
|
||||
# cs.ranks = ()
|
||||
# cs.suits = ""
|
||||
# cs.trumps = range(cs.ncards)
|
||||
cs.nbottoms = 1
|
||||
cs.nletters = 0
|
||||
cs.nshadows = 0
|
||||
|
@ -481,7 +491,8 @@ class CardsetManager(ResourceManager):
|
|||
self.registered_styles[s] = self.registered_styles.get(s, 0) + 1
|
||||
cs.si.nationalities = tuple([s for s in keys if s in CSI.NATIONALITY])
|
||||
for s in cs.si.nationalities:
|
||||
self.registered_nationalities[s] = self.registered_nationalities.get(s, 0) + 1
|
||||
self.registered_nationalities[s] = \
|
||||
self.registered_nationalities.get(s, 0) + 1
|
||||
keys = (cs.year / 100,)
|
||||
cs.si.dates = tuple([s for s in keys if s in CSI.DATE])
|
||||
for s in cs.si.dates:
|
||||
|
@ -535,4 +546,3 @@ class Music(Sample):
|
|||
|
||||
class MusicManager(SampleManager):
|
||||
pass
|
||||
|
||||
|
|
|
@ -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-p]*.py') );
|
||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/[a-r]*.py') );
|
||||
|
||||
# TEST
|
||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||
|
|
Loading…
Add table
Reference in a new issue