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
|
# imports
|
||||||
import os, glob, traceback
|
import os
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
import traceback
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import Struct, KwStruct
|
from pysollib.mfxutil import Struct, KwStruct
|
||||||
|
@ -35,9 +38,14 @@ from pysollib.mygettext import _
|
||||||
# * Abstract
|
# * Abstract
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
if sys.version_info > (3,):
|
||||||
|
basestring = str
|
||||||
|
|
||||||
|
|
||||||
class Resource(Struct):
|
class Resource(Struct):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(
|
||||||
|
kw,
|
||||||
name="",
|
name="",
|
||||||
filename="",
|
filename="",
|
||||||
basename="", # basename of filename
|
basename="", # basename of filename
|
||||||
|
@ -118,7 +126,7 @@ class ResourceManager:
|
||||||
dir = os.path.normpath(dir)
|
dir = os.path.normpath(dir)
|
||||||
if dir and os.path.isdir(dir) and dir not in result:
|
if dir and os.path.isdir(dir) and dir not in result:
|
||||||
result.append(dir)
|
result.append(dir)
|
||||||
except EnvironmentError, ex:
|
except EnvironmentError as ex:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getSearchDirs(self, app, search, env=None):
|
def getSearchDirs(self, app, search, env=None):
|
||||||
|
@ -145,11 +153,11 @@ class ResourceManager:
|
||||||
self._addDir(result, d)
|
self._addDir(result, d)
|
||||||
else:
|
else:
|
||||||
self._addDir(result, os.path.join(dir, s))
|
self._addDir(result, os.path.join(dir, s))
|
||||||
except EnvironmentError, ex:
|
except EnvironmentError as ex:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
if DEBUG >= 6:
|
if DEBUG >= 6:
|
||||||
print "getSearchDirs", env, search, "->", result
|
print("getSearchDirs", env, search, "->", result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,7 +302,8 @@ class CSI:
|
||||||
class CardsetConfig(Struct):
|
class CardsetConfig(Struct):
|
||||||
# see config.txt and _readCardsetConfig()
|
# see config.txt and _readCardsetConfig()
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Struct.__init__(self,
|
Struct.__init__(
|
||||||
|
self,
|
||||||
# line[0]
|
# line[0]
|
||||||
version=1,
|
version=1,
|
||||||
ext=".gif",
|
ext=".gif",
|
||||||
|
@ -332,7 +341,8 @@ class Cardset(Resource):
|
||||||
# si is the SelectionInfo struct that will be queried by
|
# si is the SelectionInfo struct that will be queried by
|
||||||
# the "select cardset" dialogs. It can be freely modified.
|
# the "select cardset" dialogs. It can be freely modified.
|
||||||
si = Struct(type=0, size=0, styles=[], nationalities=[], dates=[])
|
si = Struct(type=0, size=0, styles=[], nationalities=[], dates=[])
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(
|
||||||
|
kw,
|
||||||
# essentials
|
# essentials
|
||||||
ranks=(),
|
ranks=(),
|
||||||
suits=(),
|
suits=(),
|
||||||
|
@ -368,7 +378,7 @@ class Cardset(Resource):
|
||||||
if lr >= 4:
|
if lr >= 4:
|
||||||
ls = min(ls, 4)
|
ls = min(ls, 4)
|
||||||
low_ranks, high_ranks = 1, 3
|
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 rank in range(0, low_ranks) + range(lr-high_ranks, lr):
|
||||||
for suit in range(ls):
|
for suit in range(ls):
|
||||||
index = suit * len(self.ranks) + rank
|
index = suit * len(self.ranks) + rank
|
||||||
|
@ -385,7 +395,7 @@ class Cardset(Resource):
|
||||||
self.backname = self.backnames[self.backindex]
|
self.backname = self.backnames[self.backindex]
|
||||||
|
|
||||||
def saveSettings(self):
|
def saveSettings(self):
|
||||||
print 'saveSettings'
|
print('saveSettings')
|
||||||
|
|
||||||
|
|
||||||
class CardsetManager(ResourceManager):
|
class CardsetManager(ResourceManager):
|
||||||
|
@ -481,7 +491,8 @@ class CardsetManager(ResourceManager):
|
||||||
self.registered_styles[s] = self.registered_styles.get(s, 0) + 1
|
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])
|
cs.si.nationalities = tuple([s for s in keys if s in CSI.NATIONALITY])
|
||||||
for s in cs.si.nationalities:
|
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,)
|
keys = (cs.year / 100,)
|
||||||
cs.si.dates = tuple([s for s in keys if s in CSI.DATE])
|
cs.si.dates = tuple([s for s in keys if s in CSI.DATE])
|
||||||
for s in cs.si.dates:
|
for s in cs.si.dates:
|
||||||
|
@ -535,4 +546,3 @@ class Music(Sample):
|
||||||
|
|
||||||
class MusicManager(SampleManager):
|
class MusicManager(SampleManager):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
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
|
# 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