1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

* refactoring: replaced map(lambda...), filter(lambda...) to list comprehension (thanks to 2to3)

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@199 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2007-08-25 21:19:40 +00:00
parent e436702403
commit f86de9b176
21 changed files with 59 additions and 52 deletions

View file

@ -40,6 +40,7 @@ import os, locale
# PySol imports # PySol imports
from mfxutil import SubclassResponsibility from mfxutil import SubclassResponsibility
from mfxutil import Struct, openURL from mfxutil import Struct, openURL
from mfxutil import print_err
from pysolrandom import constructRandom from pysolrandom import constructRandom
from settings import TITLE, PACKAGE_URL from settings import TITLE, PACKAGE_URL
from settings import TOP_TITLE from settings import TOP_TITLE
@ -651,7 +652,7 @@ class PysolMenubarActions:
## TODO ## TODO
pass pass
else: else:
print "stats problem:", mode, demo, player print_err("stats problem: %s %s %s" % (mode, demo, player))
pass pass
if d.status != 0: if d.status != 0:
break break

View file

@ -142,6 +142,7 @@ class GameStat:
game_start_time = game.gstats.start_time game_start_time = game.gstats.start_time
# update number of games # update number of games
# status: # status:
# -1 - NOT WON (not played)
# 0 - LOST # 0 - LOST
# 1 - WON # 1 - WON
# 2 - PERFECT # 2 - PERFECT
@ -223,7 +224,7 @@ class Statistics:
if gameid == 0: if gameid == 0:
del games[player] del games[player]
else: else:
games[player] = filter(lambda a, b=gameid: a[0] != b, games[player]) games[player] = [g for g in games[player] if g[0] != gameid]
def getStats(self, player, gameid): def getStats(self, player, gameid):
# returned (won, lost) # returned (won, lost)
@ -241,10 +242,10 @@ class Statistics:
return (0, 0, 0, 0) return (0, 0, 0, 0)
def getSessionStats(self, player, gameid): def getSessionStats(self, player, gameid):
g = self.session_games.get(player, []) games = self.session_games.get(player, [])
g = filter(lambda a, b=gameid: a[0] == b, g) games = [g for g in games if g[0] == gameid]
won = len(filter(lambda a, b=gameid: a[2] > 0, g)) won = len([g for g in games if g[2] > 0])
lost = len(filter(lambda a, b=gameid: a[2] == 0, g)) lost = len([g for g in games if g[2] == 0])
return won, lost return won, lost
def updateStats(self, player, game, status): def updateStats(self, player, game, status):
@ -1291,11 +1292,11 @@ Please select a %s type %s.
if not DEBUG: if not DEBUG:
return return
if field: if field:
print '_parseCardsetConfig error: line #%d, fields#%d %s' \ print_err('_parseCardsetConfig error: line #%d, field #%d %s'
% (line, field, msg) % (line, field, msg))
else: else:
print '_parseCardsetConfig error: line #%d: %s' \ print_err('_parseCardsetConfig error: line #%d: %s'
% (line, msg) % (line, msg))
if len(line) < 6: if len(line) < 6:
perr(1, msg='number of lines') perr(1, msg='number of lines')
return 0 return 0
@ -1421,7 +1422,8 @@ Please select a %s type %s.
found.append(cs) found.append(cs)
#print '+', cs.name #print '+', cs.name
else: else:
print 'fail _readCardsetConfig:', d, f1 print_err('fail _readCardsetConfig: %s %s'
% (d, f1))
pass pass
except Exception, err: except Exception, err:
##traceback.print_exc() ##traceback.print_exc()

View file

@ -161,8 +161,10 @@ class Game:
if self.app.intro.progress: self.app.intro.progress.update(step=1) if self.app.intro.progress: self.app.intro.progress.update(step=1)
self.createGame() self.createGame()
# set some defaults # set some defaults
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks) self.sg.openstacks = [s for s in self.sg.openstacks
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks) if s.cap.max_accept >= s.cap.min_accept]
self.sg.hp_stacks = [s for s in self.sg.dropstacks
if s.cap.max_move >= 2]
self.createSnGroups() self.createSnGroups()
# convert stackgroups to tuples (speed) # convert stackgroups to tuples (speed)
self.allstacks = tuple(self.allstacks) self.allstacks = tuple(self.allstacks)
@ -307,8 +309,10 @@ class Game:
# create game # create game
self.createGame() self.createGame()
# set some defaults # set some defaults
self.sg.openstacks = filter(lambda s: s.cap.max_accept >= s.cap.min_accept, self.sg.openstacks) self.sg.openstacks = [s for s in self.sg.openstacks
self.sg.hp_stacks = filter(lambda s: s.cap.max_move >= 2, self.sg.dropstacks) if s.cap.max_accept >= s.cap.min_accept]
self.sg.hp_stacks = [s for s in self.sg.dropstacks
if s.cap.max_move >= 2]
# init the stack view # init the stack view
for stack in self.allstacks: for stack in self.allstacks:
stack.prepareStack() stack.prepareStack()
@ -822,7 +826,7 @@ class Game:
i = i - 1 i = i - 1
sitems.sort() sitems.sort()
sitems.reverse() sitems.reverse()
scards = map(lambda item: item[2], sitems) scards = [item[2] for item in sitems]
return cards, scards return cards, scards
@ -2006,7 +2010,7 @@ Congratulations, you did it !
width = 4 width = 4
xmargin, ymargin = 0, 0 xmargin, ymargin = 0, 0
x0, y0 = x+width/2-xmargin, y+width/2-ymargin x0, y0 = x+width/2-xmargin, y+width/2-ymargin
x1, y1 = x+w-width-xmargin, y+h-width-ymargin x1, y1 = x+w-width/2-xmargin, y+h-width/2-ymargin
r = MfxCanvasRectangle(self.canvas, x0, y0, x1, y1, r = MfxCanvasRectangle(self.canvas, x0, y0, x1, y1,
width=width, fill=None, outline=color) width=width, fill=None, outline=color)
self.canvas.update_idletasks() self.canvas.update_idletasks()

View file

@ -150,7 +150,7 @@ class Fortunes(AcesUp):
class RussianAces_Talon(DealRowTalonStack): class RussianAces_Talon(DealRowTalonStack):
def dealCards(self, sound=False): def dealCards(self, sound=False):
rows = filter(lambda s: not s.cards, self.game.s.rows) rows = [s for s in self.game.s.rows if not s.cards]
if not rows: if not rows:
rows = self.game.s.rows rows = self.game.s.rows
return self.dealRowAvail(rows=rows, sound=sound) return self.dealRowAvail(rows=rows, sound=sound)

View file

@ -716,7 +716,7 @@ class Demon(Canfield):
INITIAL_RESERVE_CARDS = 40 INITIAL_RESERVE_CARDS = 40
RowStack_Class = StackWrapper(AC_RowStack, mod=13) RowStack_Class = StackWrapper(AC_RowStack, mod=13)
def createGame(self): def createGame(self):
Canfield.createGame(self, rows=8, max_rounds=UNLIMITED_REDEALS, num_deal=1) Canfield.createGame(self, rows=8, max_rounds=UNLIMITED_REDEALS, num_deal=3)
# /*********************************************************************** # /***********************************************************************

View file

@ -942,7 +942,8 @@ registerGame(GameInfo(516, Troika, "Troika",
registerGame(GameInfo(517, Quads, "Quads", registerGame(GameInfo(517, Quads, "Quads",
GI.GT_FAN_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL)) GI.GT_FAN_TYPE | GI.GT_OPEN | GI.GT_ORIGINAL, 1, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(625, FascinationFan, "Fascination Fan", registerGame(GameInfo(625, FascinationFan, "Fascination Fan",
GI.GT_FAN_TYPE, 1, 6, GI.SL_BALANCED)) GI.GT_FAN_TYPE, 1, 6, GI.SL_BALANCED,
altnames=('Demon Fan',) ))
registerGame(GameInfo(647, Crescent, "Crescent", registerGame(GameInfo(647, Crescent, "Crescent",
GI.GT_FAN_TYPE, 2, 3, GI.SL_MOSTLY_SKILL)) GI.GT_FAN_TYPE, 2, 3, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(714, ShamrocksII, "Shamrocks II", registerGame(GameInfo(714, ShamrocksII, "Shamrocks II",

View file

@ -202,11 +202,11 @@ class Mahjongg_RowStack(OpenStack):
OpenStack._position(self, card) OpenStack._position(self, card)
# #
if TOOLKIT == 'tk': if TOOLKIT == 'tk':
rows = filter(lambda s: s.cards, self.game.s.rows[:self.id]) rows = [s for s in self.game.s.rows[:self.id] if s.cards]
if rows: if rows:
self.group.tkraise(rows[-1].group) self.group.tkraise(rows[-1].group)
return return
rows = filter(lambda s: s.cards, self.game.s.rows[self.id+1:]) rows = [s for s in self.game.s.rows[self.id+1:] if s.cards]
if rows: if rows:
self.group.lower(rows[0].group) self.group.lower(rows[0].group)
return return
@ -728,7 +728,7 @@ class AbstractMahjonggGame(Game):
# check if this layout is solvable (backtracking) # check if this layout is solvable (backtracking)
ret = create_solvable(cards[:], nc) ret = create_solvable(cards[:], nc)
if ret: if ret:
ret = filter(lambda x: x != 1, ret) ret = [x for x in ret if x != 1]
return ret return ret
nc[s1.id] = nc[s2.id] = None # try another way nc[s1.id] = nc[s2.id] = None # try another way

View file

@ -50,7 +50,7 @@ class Montana_Hint(DefaultHint):
def computeHints(self): def computeHints(self):
game = self.game game = self.game
RLEN, RSTEP, RBASE = game.RLEN, game.RSTEP, game.RBASE RLEN, RSTEP, RBASE = game.RLEN, game.RSTEP, game.RBASE
freerows = filter(lambda s: not s.cards, game.s.rows) freerows = [s for s in game.s.rows if not s.cards]
# for each stack # for each stack
for r in game.s.rows: for r in game.s.rows:
if not r.cards: if not r.cards:
@ -272,7 +272,7 @@ class BlueMoon(Montana):
if i % self.RSTEP == 0: # left column if i % self.RSTEP == 0: # left column
continue continue
self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames) self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames)
ace_rows = filter(lambda r: r.cards and r.cards[-1].rank == ACE, self.s.rows) ace_rows = [r for r in self.s.rows if r.cards and r.cards[-1].rank == ACE]
j = 0 j = 0
for r in ace_rows: for r in ace_rows:
self.moveMove(1, r, self.s.rows[j]) self.moveMove(1, r, self.s.rows[j])

View file

@ -51,7 +51,7 @@ from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
class SiebenBisAs_Hint(CautiousDefaultHint): class SiebenBisAs_Hint(CautiousDefaultHint):
def computeHints(self): def computeHints(self):
game = self.game game = self.game
freerows = filter(lambda s: not s.cards, game.s.rows) freerows = [s for s in game.s.rows if not s.cards]
# for each stack # for each stack
for r in game.sg.dropstacks: for r in game.sg.dropstacks:
if not r.cards: if not r.cards:
@ -149,7 +149,7 @@ class SiebenBisAs(Game):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow() self.s.talon.dealRow()
self.s.talon.dealRow(rows=self.s.reserves) self.s.talon.dealRow(rows=self.s.reserves)
stacks = filter(lambda r: r.cards[-1].rank == 6, self.s.rows) stacks = [r for r in self.s.rows if r.cards[-1].rank == 6]
for r in stacks: for r in stacks:
self.moveMove(1, r, self.s.foundations[r.cards[-1].suit]) self.moveMove(1, r, self.s.foundations[r.cards[-1].suit])
@ -246,7 +246,7 @@ class Maze(Game):
self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames) self.s.talon.dealRow(rows=(self.s.rows[i],), frames=frames)
def isGameWon(self): def isGameWon(self):
rows = filter(lambda s: s.cards, self.s.rows) rows = [s for s in self.s.rows if s.cards]
if len(rows) != 48: if len(rows) != 48:
return False # no cards dealt yet return False # no cards dealt yet
i = 0 i = 0

View file

@ -51,7 +51,7 @@ class Pegged_Hint(AbstractHint):
def computeHints(self): def computeHints(self):
game = self.game game = self.game
# get free stacks # get free stacks
stacks = filter(lambda r: not r.cards, game.s.rows) stacks = [r for r in game.s.rows if not r.cards]
# #
for t in stacks: for t in stacks:
for dx, dy in game.STEPS: for dx, dy in game.STEPS:
@ -192,7 +192,7 @@ class Pegged(Game):
def getWinStatus(self): def getWinStatus(self):
won, status, updated = Game.getWinStatus(self) won, status, updated = Game.getWinStatus(self)
if status == 2: if status == 2:
stacks = filter(lambda r: r.cards, self.s.rows) stacks = [r for r in self.s.rows if r.cards]
assert len(stacks) == 1 assert len(stacks) == 1
if stacks[0].id != self.EMPTY_STACK_ID: if stacks[0].id != self.EMPTY_STACK_ID:
# not perfect # not perfect

View file

@ -188,7 +188,7 @@ class GroundForADivorce_Talon(TalonStack):
# A single click deals a new cards to each non-empty row. # A single click deals a new cards to each non-empty row.
def dealCards(self, sound=True): def dealCards(self, sound=True):
if self.cards: if self.cards:
rows = filter(lambda r: r.cards, self.game.s.rows) rows = [r for r in self.game.s.rows if r.cards]
if not rows: if not rows:
# deal one card to first row if all rows are emtpy # deal one card to first row if all rows are emtpy
rows = self.game.s.rows[:1] rows = self.game.s.rows[:1]

View file

@ -107,7 +107,7 @@ class Terrace_RowStack(AC_RowStack):
self.game.moveMove(ncards, self, to_stack, frames=frames, shadow=shadow) self.game.moveMove(ncards, self, to_stack, frames=frames, shadow=shadow)
for s in self.game.s.foundations: for s in self.game.s.foundations:
s.cap.base_rank = to_stack.cards[0].rank s.cap.base_rank = to_stack.cards[0].rank
freerows = filter(lambda s: not s.cards, self.game.s.rows) freerows = [s for s in self.game.s.rows if not s.cards]
self.game.s.talon.dealRow(rows=freerows, sound=True) self.game.s.talon.dealRow(rows=freerows, sound=True)
self.game.s.talon.dealCards() # deal first card to WasteStack self.game.s.talon.dealCards() # deal first card to WasteStack

View file

@ -435,14 +435,13 @@ class AShuffleStackMove(AtomicMove):
def __init__(self, stack, game): def __init__(self, stack, game):
self.stack_id = stack.id self.stack_id = stack.id
# save cards and state # save cards and state
self.card_ids = tuple(map(lambda c: c.id, stack.cards)) self.card_ids = tuple([c.id for c in stack.cards])
self.state = game.random.getstate() self.state = game.random.getstate()
def redo(self, game): def redo(self, game):
stack = game.allstacks[self.stack_id] stack = game.allstacks[self.stack_id]
# paranoia # paranoia
assert stack is game.s.talon assert stack is game.s.talon
assert self.card_ids == tuple(map(lambda c: c.id, stack.cards))
# shuffle (see random) # shuffle (see random)
game.random.setstate(self.state) game.random.setstate(self.state)
seq = stack.cards seq = stack.cards

View file

@ -158,7 +158,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
gobject.TYPE_INT) gobject.TYPE_INT)
manager = self.manager manager = self.manager
all_cardsets = manager.getAllSortedByName() all_cardsets = manager.getAllSortedByName()
all_cardsets = filter(lambda obj: not obj.error, all_cardsets) all_cardsets = [obj for obj in all_cardsets if not obj.error]
cs = self._selectCardset(all_cardsets, None) cs = self._selectCardset(all_cardsets, None)
self._addCardsets(store, None, 'All cadsets', cs) self._addCardsets(store, None, 'All cadsets', cs)

View file

@ -118,8 +118,8 @@ class SelectTileDialogWithPreview(MfxDialog):
index += 1 index += 1
# #
tiles = manager.getAllSortedByName() tiles = manager.getAllSortedByName()
tiles = filter(lambda obj: not obj.error, tiles) tiles = [obj for obj in tiles if not obj.error]
tiles = filter(lambda tile: tile.index > 0 and tile.filename, tiles) tiles = [tile for tile in tiles if tile.index > 0 and tile.filename]
# #
iter = model.append(None) iter = model.append(None)
model.set(iter, 0, _('All Backgrounds'), 1, -1) model.set(iter, 0, _('All Backgrounds'), 1, -1)

View file

@ -114,9 +114,9 @@ class ResourceManager:
def getAllSortedByName(self): def getAllSortedByName(self):
if self._objects_by_name is None: if self._objects_by_name is None:
l = map(lambda obj: (obj.getSortKey(), obj), self._objects) l = [(obj.getSortKey(), obj) for obj in self._objects]
l.sort() l.sort()
self._objects_by_name = tuple(map(lambda item: item[1], l)) self._objects_by_name = tuple([item[1] for item in l])
return self._objects_by_name return self._objects_by_name
# #
@ -470,14 +470,14 @@ class CardsetManager(ResourceManager):
cs.si.size = CSI.SIZE_XLARGE cs.si.size = CSI.SIZE_XLARGE
# #
keys = cs.styles[:] keys = cs.styles[:]
cs.si.styles = tuple(filter(lambda s: s in CSI.STYLE, keys)) cs.si.styles = tuple([s for s in keys if s in CSI.STYLE])
for s in cs.si.styles: for s in cs.si.styles:
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(filter(lambda s: s in CSI.NATIONALITY, keys)) 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(filter(lambda s: s in CSI.DATE, keys)) 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:
self.registered_dates[s] = self.registered_dates.get(s, 0) + 1 self.registered_dates[s] = self.registered_dates.get(s, 0) + 1
# #

View file

@ -200,7 +200,7 @@ def isAnySuitButOwnSequence(cards, mod=8192, dir=-1):
return True return True
def getNumberOfFreeStacks(stacks): def getNumberOfFreeStacks(stacks):
return len(filter(lambda s: not s.cards, stacks)) return len([s for s in stacks if not s.cards])
# collect the top cards of several stacks into a pile # collect the top cards of several stacks into a pile
def getPileFromStacks(stacks, reverse=0): def getPileFromStacks(stacks, reverse=0):
@ -372,11 +372,11 @@ class Stack:
if isinstance(ox, int): if isinstance(ox, int):
self.CARD_XOFFSET = (ox,) self.CARD_XOFFSET = (ox,)
else: else:
self.CARD_XOFFSET = tuple(map(int, map(round, ox))) self.CARD_XOFFSET = tuple([int(round(x)) for x in ox])
if isinstance(oy, int): if isinstance(oy, int):
self.CARD_YOFFSET = (oy,) self.CARD_YOFFSET = (oy,)
else: else:
self.CARD_YOFFSET = tuple(map(int, map(round, oy))) self.CARD_YOFFSET = tuple([int(round(y)) for y in oy])
if self.can_hide_cards < 0: if self.can_hide_cards < 0:
self.can_hide_cards = self.is_visible self.can_hide_cards = self.is_visible
if self.cap.max_cards < 3: if self.cap.max_cards < 3:
@ -1946,7 +1946,7 @@ class GroundForADivorceTalonStack(DealRowRedealTalonStack):
# A single click deals a new cards to each non-empty row. # A single click deals a new cards to each non-empty row.
def dealCards(self, sound=True): def dealCards(self, sound=True):
if self.cards: if self.cards:
rows = filter(lambda r: r.cards, self.game.s.rows) rows = [r for r in self.game.s.rows if r.cards]
## if not rows: ## if not rows:
## # deal one card to first row if all rows are emtpy ## # deal one card to first row if all rows are emtpy
## rows = self.game.s.rows[:1] ## rows = self.game.s.rows[:1]

View file

@ -79,7 +79,7 @@ class SelectCardsetData(SelectDialogTreeData):
def __init__(self, manager, key): def __init__(self, manager, key):
SelectDialogTreeData.__init__(self) SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName() self.all_objects = manager.getAllSortedByName()
self.all_objects = filter(lambda obj: not obj.error, self.all_objects) self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ]
# #
select_by_type = None select_by_type = None

View file

@ -74,8 +74,8 @@ class SelectTileData(SelectDialogTreeData):
def __init__(self, manager, key): def __init__(self, manager, key):
SelectDialogTreeData.__init__(self) SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName() self.all_objects = manager.getAllSortedByName()
self.all_objects = filter(lambda obj: not obj.error, self.all_objects) self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.all_objects = filter(lambda tile: tile.index > 0 and tile.filename, self.all_objects) self.all_objects = [tile for tile in self.all_objects if tile.index > 0 and tile.filename]
self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ] self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ]
e1 = isinstance(key, str) or len(self.all_objects) <=17 e1 = isinstance(key, str) or len(self.all_objects) <=17
e2 = 1 e2 = 1

View file

@ -78,7 +78,7 @@ class SelectCardsetData(SelectDialogTreeData):
def __init__(self, manager, key): def __init__(self, manager, key):
SelectDialogTreeData.__init__(self) SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName() self.all_objects = manager.getAllSortedByName()
self.all_objects = filter(lambda obj: not obj.error, self.all_objects) self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ]
# #
select_by_type = None select_by_type = None

View file

@ -72,8 +72,8 @@ class SelectTileData(SelectDialogTreeData):
def __init__(self, manager, key): def __init__(self, manager, key):
SelectDialogTreeData.__init__(self) SelectDialogTreeData.__init__(self)
self.all_objects = manager.getAllSortedByName() self.all_objects = manager.getAllSortedByName()
self.all_objects = filter(lambda obj: not obj.error, self.all_objects) self.all_objects = [obj for obj in self.all_objects if not obj.error]
self.all_objects = filter(lambda tile: tile.index > 0 and tile.filename, self.all_objects) self.all_objects = [tile for tile in self.all_objects if tile.index > 0 and tile.filename]
self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ] self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ]
e1 = isinstance(key, str) or len(self.all_objects) <=17 e1 = isinstance(key, str) or len(self.all_objects) <=17
e2 = 1 e2 = 1