mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
86b243ad53
commit
e0efb8a02c
10 changed files with 65 additions and 79 deletions
|
@ -124,6 +124,9 @@
|
|||
A badly formatted set of arguments will raise a ``VdtParamError``.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
__docformat__ = "restructuredtext en"
|
||||
|
||||
__version__ = '0.2.3'
|
||||
|
@ -161,8 +164,6 @@ __all__ = (
|
|||
'__docformat__',
|
||||
)
|
||||
|
||||
import sys
|
||||
import re
|
||||
INTP_VER = sys.version_info[:2]
|
||||
if INTP_VER < (2, 2):
|
||||
raise RuntimeError("Python v.2.2 or later needed")
|
||||
|
@ -704,7 +705,7 @@ def _is_num_param(names, values, to_float=False):
|
|||
elif isinstance(val, (int, long, float, StringTypes)):
|
||||
try:
|
||||
out_params.append(fun(val))
|
||||
except ValueError as e:
|
||||
except ValueError:
|
||||
raise VdtParamError(name, val)
|
||||
else:
|
||||
raise VdtParamError(name, val)
|
||||
|
|
|
@ -474,9 +474,9 @@ class Indian(FortyThieves):
|
|||
FortyThieves.createGame(self, XCARDS=74)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit != card2.suit
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (card1.suit != card2.suit and
|
||||
(card1.rank + 1 == card2.rank or
|
||||
card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
class Midshipman(Indian):
|
||||
|
|
|
@ -165,9 +165,9 @@ class ThumbAndPouch(Klondike):
|
|||
Klondike.createGame(self, max_rounds=1)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit != card2.suit
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (card1.suit != card2.suit and
|
||||
(card1.rank + 1 == card2.rank or
|
||||
card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
class Chinaman(ThumbAndPouch):
|
||||
|
|
|
@ -337,8 +337,8 @@ class LarasGame(Game):
|
|||
break
|
||||
i = i + 1 % self.ROW_LENGTH
|
||||
return (card1.suit == card2.suit and
|
||||
((card1.rank + 1) % self.Mod(i) == card2.rank
|
||||
or (card1.rank - 1) % self.Mod(i) == card2.rank))
|
||||
((card1.rank + 1) % self.Mod(i) == card2.rank or
|
||||
(card1.rank - 1) % self.Mod(i) == card2.rank))
|
||||
|
||||
def getHighlightPilesStacks(self):
|
||||
return ()
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#
|
||||
# ---------------------------------------------------------------------------##
|
||||
|
||||
__all__ = []
|
||||
|
||||
# imports
|
||||
|
||||
# PySol imports
|
||||
|
|
|
@ -449,8 +449,8 @@ class Elevens_RowStack(Giza_Reserve):
|
|||
if from_stack is self or not self.cards or len(cards) != 1:
|
||||
return False
|
||||
c = self.cards[-1]
|
||||
return (c.face_up and cards[0].face_up
|
||||
and cards[0].rank + c.rank == self.ACCEPTED_SUM)
|
||||
return (c.face_up and cards[0].face_up and
|
||||
cards[0].rank + c.rank == self.ACCEPTED_SUM)
|
||||
|
||||
def clickHandler(self, event):
|
||||
return OpenStack.clickHandler(self, event)
|
||||
|
@ -651,8 +651,8 @@ class Fifteens(Elevens):
|
|||
else:
|
||||
reserve_ranks = [c.rank for c in reserve.cards]
|
||||
reserve_ranks.sort()
|
||||
if (9 in reserve_ranks or JACK in reserve_ranks
|
||||
or QUEEN in reserve_ranks or KING in reserve_ranks):
|
||||
if (9 in reserve_ranks or JACK in reserve_ranks or
|
||||
QUEEN in reserve_ranks or KING in reserve_ranks):
|
||||
if reserve_ranks == [9, JACK, QUEEN, KING]:
|
||||
self._dropReserve()
|
||||
else:
|
||||
|
|
|
@ -167,8 +167,8 @@ class WheelOfFortune_RowStack(Tarock_OpenStack):
|
|||
return 0
|
||||
if not self.cards:
|
||||
return 1
|
||||
return ((cards[0].suit == self.cards[-1].suit)
|
||||
and (cards[0].rank == self.cards[-1].rank - 1))
|
||||
return ((cards[0].suit == self.cards[-1].suit) and
|
||||
(cards[0].rank == self.cards[-1].rank - 1))
|
||||
|
||||
def getBottomImage(self):
|
||||
return self.game.app.images.getReserveBottom()
|
||||
|
@ -207,8 +207,8 @@ class Nasty_RowStack(SS_RowStack):
|
|||
if not self.basicAcceptsCards(from_stack, cards):
|
||||
return 0
|
||||
if self.cards:
|
||||
return (cards[0].rank == self.cards[-1].rank - 1
|
||||
and cards[0].suit == self.cards[-1].suit)
|
||||
return (cards[0].rank == self.cards[-1].rank - 1 and
|
||||
cards[0].suit == self.cards[-1].suit)
|
||||
return cards[0].rank == 13 + 8 * (cards[0].suit == 4)
|
||||
|
||||
|
||||
|
@ -431,8 +431,7 @@ class Pagat(AbstractTarockGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit == card2.suit and
|
||||
(card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -502,8 +501,7 @@ class Skiz(AbstractTarockGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit == card2.suit and
|
||||
(card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -567,8 +565,7 @@ class FifteenPlus(AbstractTarockGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit == card2.suit and
|
||||
(card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -652,8 +649,7 @@ class Excuse(AbstractTarockGame):
|
|||
self.s.talon.dealRow(rows=self.s.rows[:15])
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank)
|
||||
return (card1.rank + 1 == card2.rank or card1.rank - 1 == card2.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -741,9 +737,9 @@ class Grasshopper(AbstractTarockGame):
|
|||
r.flipMove()
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank)
|
||||
and card1.color != card2.color)
|
||||
return ((card1.rank + 1 == card2.rank or
|
||||
card1.rank - 1 == card2.rank) and
|
||||
card1.color != card2.color)
|
||||
|
||||
|
||||
class DoubleGrasshopper(Grasshopper):
|
||||
|
@ -889,10 +885,10 @@ class Cavalier(AbstractTarockGame):
|
|||
self.s.talon.dealRow(rows=self.s.rows[:6])
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank)
|
||||
and ((card1.suit == 4 or card2.suit == 4)
|
||||
or card1.color != card2.color))
|
||||
return ((card1.rank + 1 == card2.rank or
|
||||
card1.rank - 1 == card2.rank) and
|
||||
((card1.suit == 4 or card2.suit == 4) or
|
||||
card1.color != card2.color))
|
||||
|
||||
|
||||
class FiveAces(Cavalier):
|
||||
|
@ -914,9 +910,9 @@ class Wicked(FiveAces):
|
|||
Cavalier.startGame(self, flip=(1, 1, 1), foundations=1)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return ((card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank)
|
||||
and card1.suit == card2.suit)
|
||||
return ((card1.rank + 1 == card2.rank or
|
||||
card1.rank - 1 == card2.rank) and
|
||||
card1.suit == card2.suit)
|
||||
|
||||
|
||||
class Nasty(Wicked):
|
||||
|
|
|
@ -202,8 +202,8 @@ class ThreePeaks(Game):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
if stack1 == self.s.waste or stack2 == self.s.waste:
|
||||
return ((card1.rank + 1) % 13 == card2.rank
|
||||
or (card1.rank - 1) % 13 == card2.rank)
|
||||
return ((card1.rank + 1) % 13 == card2.rank or
|
||||
(card1.rank - 1) % 13 == card2.rank)
|
||||
return False
|
||||
|
||||
def getHandScore(self):
|
||||
|
|
|
@ -106,8 +106,8 @@ class AppachansWaterfall_Foundation(AbstractFoundationStack):
|
|||
if self.cards:
|
||||
rank = (self.cards[-1].rank + 1) % 12
|
||||
suit = self.cards[-1].suit + (rank == 0)
|
||||
if (not pile or len(pile) <= 11 - rank
|
||||
or not isSameSuitSequence(pile[-(12 - rank):])):
|
||||
if (not pile or len(pile) <= 11 - rank or
|
||||
not isSameSuitSequence(pile[-(12 - rank):])):
|
||||
return 0
|
||||
return cards[0].suit == suit and cards[0].rank == rank
|
||||
|
||||
|
@ -149,8 +149,8 @@ class Dashavatara_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not ((c1.suit + c2.suit) % 2
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not ((c1.suit + c2.suit) % 2 and
|
||||
c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -173,8 +173,7 @@ class Dashavatara_OpenStack(OpenStack):
|
|||
dir = self.cap.dir
|
||||
c1 = cards[0]
|
||||
for c2 in cards[1:]:
|
||||
if not (c1.suit == c2.suit
|
||||
and c1.rank + dir == c2.rank):
|
||||
if not (c1.suit == c2.suit and c1.rank + dir == c2.rank):
|
||||
return 0
|
||||
c1 = c2
|
||||
return 1
|
||||
|
@ -294,9 +293,9 @@ class AppachansWaterfall_RowStack(RK_RowStack):
|
|||
pile, stack, rank = self.getPile(), stacks[0], 0
|
||||
if stack.cards:
|
||||
rank = (stack.cards[-1].rank + 1) % 12
|
||||
if (not pile or len(pile) <= 11 - rank
|
||||
or not isSameSuitSequence(pile[-(12 - rank):])
|
||||
or not stack.acceptsCards(self, pile[-1:])):
|
||||
if (not pile or len(pile) <= 11 - rank or
|
||||
not isSameSuitSequence(pile[-(12 - rank):]) or
|
||||
not stack.acceptsCards(self, pile[-1:])):
|
||||
return (None, 0)
|
||||
return (stack, 1)
|
||||
|
||||
|
@ -335,8 +334,8 @@ class Dashavatara_ReserveStack(ReserveStack):
|
|||
OpenStack.__init__(self, x, y, game, **cap)
|
||||
|
||||
def acceptsCards(self, from_stack, cards):
|
||||
return (ReserveStack.acceptsCards(self, from_stack, cards)
|
||||
and self.game.s.talon.cards)
|
||||
return (ReserveStack.acceptsCards(self, from_stack, cards) and
|
||||
self.game.s.talon.cards)
|
||||
|
||||
|
||||
class Dashavatara_RowStack(BasicRowStack):
|
||||
|
@ -372,9 +371,8 @@ class AbstractDashavataraGame(Game):
|
|||
pass
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit == card2.suit
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card1.rank - 1 == card2.rank))
|
||||
return (card1.suit == card2.suit and
|
||||
(card1.rank + 1 == card2.rank or card1.rank - 1 == card2.rank))
|
||||
|
||||
|
||||
class Journey_Hint(DefaultHint):
|
||||
|
@ -578,8 +576,7 @@ class Balarama(AbstractDashavataraGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.color % 2 != card2.color % 2 and
|
||||
(card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -601,8 +598,7 @@ class Hayagriva(Balarama):
|
|||
Balarama.createGame(self)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank)
|
||||
return (card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -626,10 +622,9 @@ class Shanka(Balarama):
|
|||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
if stack1 in self.s.foundations:
|
||||
return (card1.suit == card2.suit and
|
||||
(card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank)
|
||||
(card1.rank + 1 == card2.rank or
|
||||
card2.rank + 1 == card1.rank))
|
||||
return (card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -659,9 +654,9 @@ class Surukh(Balarama):
|
|||
force1 = 0
|
||||
else:
|
||||
force1 = 1
|
||||
return (force0 != force1
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (force0 != force1 and
|
||||
(card1.rank + 1 == card2.rank or
|
||||
card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -716,8 +711,7 @@ class Matsya(AbstractDashavataraGame):
|
|||
self.s.talon.dealCards()
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank)
|
||||
return (card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -777,9 +771,8 @@ class Narasimha(Matsya):
|
|||
Matsya.createGame(self, max_rounds=1, num_deal=1)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.color % 2 != card2.color % 2
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (card1.color % 2 != card2.color % 2 and
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -801,9 +794,8 @@ class Vamana(Matsya):
|
|||
Matsya.createGame(self, max_rounds=-1, num_deal=3)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.color % 2 != card2.color % 2
|
||||
and (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank))
|
||||
return (card1.color % 2 != card2.color % 2 and
|
||||
(card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank))
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -825,8 +817,7 @@ class Parashurama(Matsya):
|
|||
Matsya.createGame(self, max_rounds=2, num_deal=3)
|
||||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.rank + 1 == card2.rank
|
||||
or card2.rank + 1 == card1.rank)
|
||||
return (card1.rank + 1 == card2.rank or card2.rank + 1 == card1.rank)
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
|
@ -938,8 +929,8 @@ class Journey(AbstractDashavataraGame):
|
|||
|
||||
def shallHighlightMatch(self, stack1, card1, stack2, card2):
|
||||
return (card1.suit == card2.suit and
|
||||
((card1.rank + 1) % 12 == card2.rank
|
||||
or (card2.rank + 1) % 12 == card1.rank))
|
||||
((card1.rank + 1) % 12 == card2.rank or
|
||||
(card2.rank + 1) % 12 == card1.rank))
|
||||
|
||||
def getHighlightPilesStacks(self):
|
||||
return ()
|
||||
|
|
|
@ -44,7 +44,7 @@ while ( my $r = $tree->next_obj )
|
|||
|
||||
my $cmd = shell_quote( 'flake8', @filenames );
|
||||
|
||||
diag("<$cmd>");
|
||||
# diag("<$cmd>");
|
||||
|
||||
# TEST
|
||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||
|
|
Loading…
Add table
Reference in a new issue