Commit bff3b9f5 authored by Wolfgang Rohdewald's avatar Wolfgang Rohdewald
Browse files

use more list comprehensions

parent 724e5a09
......@@ -240,8 +240,7 @@ class Board(QGraphicsRectItem, StrMixin):
if focusCandidates:
firstCandidate = focusCandidates[0]
if self._focusTile not in focusCandidates:
focusCandidates = list(
x for x in focusCandidates if x.sortKey() >= self.__prevPos)
focusCandidates = [x for x in focusCandidates if x.sortKey() >= self.__prevPos]
focusCandidates.append(firstCandidate)
self.focusTile = focusCandidates[0]
......@@ -337,9 +336,9 @@ class Board(QGraphicsRectItem, StrMixin):
# has no focusable tiles. Like after declaring
# Original Call.
oldPos = self.focusTile.xoffset, self.focusTile.yoffset
tiles = list(
tiles = [
x for x in tiles if (x.xoffset,
x.yoffset) != oldPos or x == self.focusTile)
x.yoffset) != oldPos or x == self.focusTile]
assert tiles, [str(x) for x in self.uiTiles]
tiles.append(tiles[0])
self.focusTile = tiles[tiles.index(self.focusTile) + 1]
......@@ -404,7 +403,7 @@ class Board(QGraphicsRectItem, StrMixin):
def tilesByElement(self, element):
"""returns all child items holding a uiTile for element"""
return list(x for x in self.uiTiles if x.tile is element)
return [x for x in self.uiTiles if x.tile is element]
def rotatedLightSource(self):
"""the light source we need for the original uiTile before it is rotated"""
......@@ -644,8 +643,7 @@ class SelectorBoard(CourtBoard):
for uiTile in self.uiTiles:
uiTile.setBoard(None)
self.uiTiles = []
self.allSelectorTiles = list(UITile(x)
for x in elements.all(game.ruleset))
self.allSelectorTiles = [UITile(x) for x in elements.all(game.ruleset)]
self.refill()
def refill(self):
......@@ -697,9 +695,9 @@ class SelectorBoard(CourtBoard):
assert isinstance(uiTile, UITile), uiTile
result = UIMeld(uiTile)
for tile in meld[1:]:
baseTiles = list(
baseTiles = [
x for x in self.tilesByElement(
tile.exposed) if x not in result)
tile.exposed) if x not in result]
result.append(baseTiles[0])
return result
......
......@@ -113,10 +113,11 @@ class ClientTable(Table):
return False
def __str__(self):
onlineNames = list(x for x in self.playerNames if self.isOnline(x))
onlineNames = [x for x in self.playerNames if self.isOnline(x)]
offlineString = ''
offlineNames = list(x for x in self.playerNames if x not in onlineNames
and not x.startswith('Robot'))
offlineNames = [
x for x in self.playerNames if x not in onlineNames
and not x.startswith('Robot')]
if offlineNames:
offlineString = ' offline:' + ','.join(offlineNames)
return '%d(%s %s%s)' % (self.tableid, self.ruleset.name, ','.join(onlineNames), offlineString)
......@@ -192,7 +193,7 @@ class Client(pb.Referenceable):
def remote_newTables(self, tables):
"""update table list"""
newTables = list(ClientTable(self, *x) for x in tables)
newTables = [ClientTable(self, *x) for x in tables]
self.tables.extend(newTables)
if Debug.table:
_ = ', '.join(str(ClientTable(self, *x)) for x in tables)
......@@ -206,7 +207,7 @@ class Client(pb.Referenceable):
the server always only sends the hash and the client then says "I do
not know this ruleset, please send definition", but that would mean
more changes to the client code"""
return list(x for x in hashes if not Ruleset.hashIsKnown(x))
return [x for x in hashes if not Ruleset.hashIsKnown(x)]
def tableChanged(self, table):
"""update table list"""
......
......@@ -191,7 +191,7 @@ class Debug:
yield opt
if idx < len(options) - 1 and idx % 5 == 4:
yield 'SEPARATOR'
options = list(x for x in Debug.__dict__ if not x.startswith('_'))
options = [x for x in Debug.__dict__ if not x.startswith('_')]
boolOptions = sorted(x for x in options
if isinstance(Debug.__dict__[x], bool))
stringOptions = sorted(x for x in options
......
......@@ -315,9 +315,9 @@ class DeferredBlock(StrMixin):
text = '%s:' % command
answerList = []
for answer in sorted(set(x.prettyAnswer() for x in self.requests if x.deferred.command == command)):
answerList.append((answer, list(
answerList.append((answer, [
x for x in self.requests
if x.deferred.command == command and answer == x.prettyAnswer())))
if x.deferred.command == command and answer == x.prettyAnswer()]))
answerList = sorted(answerList, key=lambda x: len(x[1]))
answerTexts = []
if len(answerList) == 1:
......
......@@ -100,8 +100,8 @@ class RulesetDiffer(QDialog):
if left == right and left.name == right.name:
# rightRulesets.remove(right) this is wrong because it
# removes the first ruleset with the same hash
rightRulesets = list(
x for x in rightRulesets if id(x) != id(right))
rightRulesets = [
x for x in rightRulesets if id(x) != id(right)]
self.leftRulesets = leftRulesets
self.rightRulesets = rightRulesets
self.model = None
......@@ -154,8 +154,8 @@ class RulesetDiffer(QDialog):
"""order the right rulesets by similarity to current left ruleset.
Similarity is defined by the length of the diff list."""
leftRuleset = self.cbRuleset1.current
diffPairs = sorted([(len(x.diff(leftRuleset)), x)
for x in self.rightRulesets])
diffPairs = sorted((len(x.diff(leftRuleset)), x)
for x in self.rightRulesets)
combo = self.cbRuleset2
with BlockSignals(combo):
combo.items = [x[1] for x in diffPairs]
......
......@@ -427,9 +427,9 @@ class Game:
def __exchangeSeats(self):
"""execute seat exchanges according to the rules"""
winds = list(x for x in self.shiftRules.split(',')[(self.roundsFinished - 1) % 4])
players = list(self.players[Wind(x)] for x in winds)
pairs = list(players[x:x + 2] for x in range(0, len(winds), 2))
winds = [x for x in self.shiftRules.split(',')[(self.roundsFinished - 1) % 4]]
players = [self.players[Wind(x)] for x in winds]
pairs = [players[x:x + 2] for x in range(0, len(winds), 2)]
for playerA, playerB in self._mustExchangeSeats(pairs):
playerA.wind, playerB.wind = playerB.wind, playerA.wind
......@@ -565,8 +565,7 @@ class Game:
def maybeRotateWinds(self):
"""rules which make winds rotate"""
result = list(x for x in self.ruleset.filterRules('rotate')
if x.rotate(self))
result = [x for x in self.ruleset.filterRules('rotate') if x.rotate(self)]
if result:
if Debug.explain:
if not self.belongsToRobotPlayer():
......@@ -682,8 +681,7 @@ class Game:
logError('game %d inconsistent: All score records for the same '
'hand must have the same prevailing wind' % gameid)
players = list(tuple([Wind(x[1]), Game.__getName(x[0])])
for x in qScoreRecords)
players = [tuple([Wind(x[1]), Game.__getName(x[0])]) for x in qScoreRecords]
# create the game instance.
game = cls(players, ruleset, gameid=gameid, client=client,
......@@ -1064,8 +1062,7 @@ class PlayingGame(Game):
invisibleTiles = set(x for x in allTiles
if x not in self.visibleTiles)
msg = i18n('Short living wall: Tile is invisible, hence dangerous')
self.dangerousTiles = list(
x for x in self.dangerousTiles if x[1] != msg)
self.dangerousTiles = [x for x in self.dangerousTiles if x[1] != msg]
self.dangerousTiles.append((invisibleTiles, msg))
def appendMove(self, player, command, kwargs):
......
......@@ -235,7 +235,7 @@ class Games(QDialog):
Query("DELETE FROM game WHERE id = ?", (game, ))
self.setQuery() # just reload entire table
allGames = self.view.selectionModel().selectedRows(0)
deleteGames = list(x.data() for x in allGames)
deleteGames = [x.data() for x in allGames]
if not deleteGames:
# should never happen
logException('delete: 0 rows selected')
......
......@@ -329,22 +329,19 @@ class Hand(StrMixin):
else: # not self.won
loserRules = self.__matchingRules(self.ruleset.loserRules)
if loserRules:
self.usedRules.extend(list(UsedRule(x) for x in loserRules))
self.usedRules.extend(UsedRule(x) for x in loserRules)
self.__score = self.__totalScore()
self.__checkHasExclusiveRules()
def matchingWinnerRules(self):
"""returns a list of matching winner rules"""
matching = list(
UsedRule(x)
for x in self.__matchingRules(self.ruleset.winnerRules))
matching = [UsedRule(x) for x in self.__matchingRules(self.ruleset.winnerRules)]
limitRule = self.maxLimitRule(matching)
return [limitRule] if limitRule else matching
def __checkHasExclusiveRules(self):
"""if we have one, remove all others"""
exclusive = list(x for x in self.usedRules
if 'absolute' in x.rule.options)
exclusive = [x for x in self.usedRules if 'absolute' in x.rule.options]
if exclusive:
self.usedRules = exclusive
self.__score = self.__totalScore()
......@@ -389,7 +386,7 @@ class Hand(StrMixin):
if totals:
totals = sorted(totals) # sort by totalScore
maxScore = totals[-1][0]
totals = list(x[1] for x in totals if x[0] == maxScore)
totals = [x[1] for x in totals if x[0] == maxScore]
# now we have a list of only lastMelds reaching maximum score
if prev not in totals or self.__lastMeld not in totals:
if Debug.explain and prev not in totals:
......@@ -424,7 +421,7 @@ class Hand(StrMixin):
lastTile = self.lastTile
if lastMeld == 1:
lastMeld = self.__lastMeld
parts = list(str(x) for x in sorted(melds))
parts = [str(x) for x in sorted(melds)]
if rest:
parts.append('R' + ''.join(str(x) for x in sorted(rest)))
if lastSource or announcements:
......@@ -677,14 +674,14 @@ class Hand(StrMixin):
def __matchingRules(self, rules):
"""return all matching rules for this hand"""
return list(rule for rule in rules if rule.appliesToHand(self))
return [rule for rule in rules if rule.appliesToHand(self)]
@staticmethod
def maxLimitRule(usedRules):
"""returns the rule with the highest limit score or None"""
result = None
maxLimit = 0
usedRules = list(x for x in usedRules if x.rule.score.limits)
usedRules = [x for x in usedRules if x.rule.score.limits]
for usedRule in usedRules:
score = usedRule.rule.score
if score.limits > maxLimit:
......
......@@ -165,7 +165,7 @@ class HandBoard(Board):
def lowerHalfTiles(self):
"""returns a list with all single tiles of the lower half melds
without boni"""
return list(x for x in self.uiTiles if x.yoffset > 0 and not x.isBonus)
return [x for x in self.uiTiles if x.yoffset > 0 and not x.isBonus]
def newLowerMelds(self):
"""a list of melds for the hand as it should look after sync"""
......@@ -194,7 +194,7 @@ class HandBoard(Board):
If there is no space, return None
returns list(TileAttr)"""
positions = list(x.xoffset for x in tilePositions if x.yoffset == bonusY)
positions = [x.xoffset for x in tilePositions if x.yoffset == bonusY]
rightmostTileX = max(positions) if positions else 0
placeBoni = bonusTiles[:]
while 13 - len(placeBoni) < rightmostTileX + 1 + self.exposedMeldDistance:
......@@ -203,7 +203,7 @@ class HandBoard(Board):
placeBoni = placeBoni[:-1]
result = list()
xPos = 13 - len(placeBoni)
newBonusTiles = list(self.tileAttrClass(x) for x in placeBoni)
newBonusTiles = [self.tileAttrClass(x) for x in placeBoni]
for bonus in sorted(newBonusTiles, key=lambda x: x.tile.key):
bonus.xoffset, bonus.yoffset = xPos, bonusY
bonus.dark = False
......@@ -271,7 +271,7 @@ class HandBoard(Board):
if not oldTiles[match.tile]:
del oldTiles[match.tile]
for newBonusPosition in self.newBonusPositions(
list(x for x in tiles if x.isBonus), newPositions):
[x for x in tiles if x.isBonus], newPositions):
result[oldBonusTiles[newBonusPosition.tile][0]] = newBonusPosition
self._avoidCrossingMovements(result)
for uiTile, newPos in result.items():
......@@ -346,12 +346,10 @@ class PlayingHandBoard(HandBoard):
allTiles.extend(adding)
newTiles = self.placeTiles(allTiles)
source = adding if adding else newTiles
focusCandidates = list(x for x in source
if x.focusable and x.tile.isConcealed)
focusCandidates = [x for x in source if x.focusable and x.tile.isConcealed]
if not focusCandidates:
# happens if we just exposed a claimed meld
focusCandidates = list(x for x in newTiles
if x.focusable and x.tile.isConcealed)
focusCandidates = [x for x in newTiles if x.focusable and x.tile.isConcealed]
focusCandidates = sorted(focusCandidates, key=lambda x: x.xoffset)
if focusCandidates:
self.focusTile = focusCandidates[0]
......@@ -395,10 +393,10 @@ class PlayingHandBoard(HandBoard):
items = [x for x in movingPlaces.items()
if x[1].tile is element]
if len(items) > 1:
oldList = sorted(list(x[0] for x in items),
oldList = sorted((x[0] for x in items),
key=lambda x:
bool(x.board != self) * 1000 + x.xoffset)
newList = sorted(list(x[1] for x in items),
newList = sorted((x[1] for x in items),
key=lambda x: x.xoffset)
for idx, oldTile in enumerate(oldList):
places[oldTile] = newList[idx]
......
......@@ -230,7 +230,7 @@ class ClientDialog(QDialog):
def messages(self):
"""a list of all messages returned by the declared buttons"""
return list(x.message for x in self.buttons)
return [x.message for x in self.buttons]
def proposeAction(self):
"""either intelligently or first button by default. May also
......@@ -525,8 +525,7 @@ class HumanClient(Client):
if self.hasLocalServer():
# when playing a local game, only show pending tables with
# previously selected ruleset
self.tables = list(
x for x in self.tables if x.ruleset == self.ruleset)
self.tables = [x for x in self.tables if x.ruleset == self.ruleset]
if self.tables:
self.__updateTableList()
......@@ -540,8 +539,7 @@ class HumanClient(Client):
Ruleset.cached(ruleset).save() # make it known to the cache and save in db
return tables
rulesetHashes = set(x[1] for x in tables)
needRulesets = list(
x for x in rulesetHashes if not Ruleset.hashIsKnown(x))
needRulesets = [x for x in rulesetHashes if not Ruleset.hashIsKnown(x)]
if needRulesets:
self.callServer(
'needRulesets',
......
......@@ -93,9 +93,9 @@ class AIDefault:
else:
filterName = aiFilter.__name__
if Debug.robotAI:
prevWeights = list((x.tile, x.keep) for x in candidates)
prevWeights = ((x.tile, x.keep) for x in candidates)
candidates = aiFilter(self, candidates)
newWeights = list((x.tile, x.keep) for x in candidates)
newWeights = ((x.tile, x.keep) for x in candidates)
for oldW, newW in zip(prevWeights, newWeights):
if oldW != newW:
game.debug('%s: %s: %.3f->%.3f' % (
......@@ -383,7 +383,7 @@ class DiscardCandidates(list):
if Debug.robotAI:
player.game.debug('DiscardCandidates for hand %s are %s' % (
hand, hand.tilesInHand))
self.hiddenTiles = list(x.exposed for x in hand.tilesInHand)
self.hiddenTiles = [x.exposed for x in hand.tilesInHand]
self.groupCounts = IntDict()
# counts for tile groups (sbcdw), exposed
# and concealed
......@@ -393,8 +393,7 @@ class DiscardCandidates(list):
for tile in sum((x for x in hand.declaredMelds), []):
self.groupCounts[tile.lowerGroup] += 1
self.declaredGroupCounts[tile.lowerGroup] += 1
self.extend(list(TileAI(self, x)
for x in sorted(set(self.hiddenTiles))))
self.extend(TileAI(self, x) for x in sorted(set(self.hiddenTiles)))
self.link()
@property
......
......@@ -53,7 +53,7 @@ def initRulesets():
# we have an exact match
Options.ruleset = rulesets[Options.rulesetName]
else:
matches = list(x for x in rulesets if Options.rulesetName in x)
matches = [x for x in rulesets if Options.rulesetName in x]
if len(matches) != 1:
if not matches:
msg = 'Ruleset %s is unknown' % Options.rulesetName
......
......@@ -115,11 +115,11 @@ class Server(StrMixin):
if len(running) >= OPTIONS.clients:
raise TooManyClients
maxClientsPerServer = OPTIONS.clients / OPTIONS.servers
matchingServers = list(
matchingServers = [
x for x in cls.servers
if x.commitId == job.commitId
and x.pythonVersion == job.pythonVersion
and len(x.jobs) < maxClientsPerServer)
and len(x.jobs) < maxClientsPerServer]
if matchingServers:
result = sorted(matchingServers, key=lambda x: len(x.jobs))[0]
else:
......@@ -434,15 +434,15 @@ def closerLook(gameId, gameIdRows):
"""print detailled info about one difference"""
for ruleset in OPTIONS.rulesets:
for intelligence in OPTIONS.allAis:
shouldBeIdentical = list(x for x in gameIdRows if x[RULESETFIELD] == ruleset and x[AIFIELD] == intelligence)
for commit in list(x[COMMITFIELD] for x in shouldBeIdentical):
rows2 = list(x for x in shouldBeIdentical if x[COMMITFIELD] == commit)
shouldBeIdentical = [x for x in gameIdRows if x[RULESETFIELD] == ruleset and x[AIFIELD] == intelligence]
for commit in (x[COMMITFIELD] for x in shouldBeIdentical):
rows2 = [x for x in shouldBeIdentical if x[COMMITFIELD] == commit]
if hasDifferences(rows2):
first = firstDifference(rows2)
print('Game {} {} {} {} has differences between Python2 and Python3'.format(
gameId, ruleset, intelligence, commit))
for py23 in '23':
rows2 = list(x for x in shouldBeIdentical if x[PYTHON23FIELD] == py23)
rows2 = [x for x in shouldBeIdentical if x[PYTHON23FIELD] == py23]
if hasDifferences(rows2):
first = firstDifference(rows2)
print('Game {} {} {} Python{} has differences between commits {} and {}'.format(
......@@ -638,13 +638,12 @@ def improve_options():
usingRulesets = []
wrong = False
for ruleset in wantedRulesets:
matches = list(x for x in OPTIONS.knownRulesets if ruleset in x)
matches = [x for x in OPTIONS.knownRulesets if ruleset in x]
if not matches:
print('ruleset', ruleset, 'is not known', end=' ')
wrong = True
elif len(matches) > 1:
exactMatch = list(
x for x in OPTIONS.knownRulesets if ruleset == x)
exactMatch = [x for x in OPTIONS.knownRulesets if ruleset == x]
if len(exactMatch) == 1:
usingRulesets.append(exactMatch[0])
else:
......@@ -662,8 +661,7 @@ def improve_options():
commits = subprocess.check_output(
'git log --pretty=%h {range}'.format(
range=OPTIONS.git).split()).decode()
OPTIONS.git = list(reversed(list(x.strip()
for x in commits.split('\n') if x.strip())))
OPTIONS.git = [reversed(x.strip() for x in commits.split('\n') if x.strip())]
else:
OPTIONS.git = onlyExistingCommits(OPTIONS.git.split(','))
if not OPTIONS.git:
......
......@@ -582,15 +582,14 @@ class KConfigGroup:
(x for x in items.items() if x[0].startswith(name + '[')))
if i18nItems:
languages = Internal.kajonggrc.group('Locale').readEntry('Language').split(':')
languages = list(x.split('_')[0] for x in languages)
languages = [x.split('_')[0] for x in languages]
for language in languages:
key = '%s[%s]' % (name, language)
if key in i18nItems:
return i18nItems[key]
if name in items:
if self.groupName == 'Locale' and name == 'Language':
languages = list(x for x in items[name].split(
':') if MLocale.isLanguageInstalled(x))
languages = [x for x in items[name].split(':') if MLocale.isLanguageInstalled(x)]
if languages:
return ':'.join(languages)
return QLocale().name()
......@@ -884,9 +883,9 @@ class KSwitchLanguageDialog(KDialog):
def restoreDefaults(self):
"""reset values to default"""
keys = list(x for x in self.languageRows if isinstance(x, KLanguageButton))
for _ in keys:
self.removeLanguage(_)
for _ in self.languageRows:
if isinstance(_, KLanguageButton):
self.removeLanguage(_)
for removeButton in self.languageRows:
if isAlive(removeButton):
removeButton.deleteLater()
......@@ -1213,7 +1212,7 @@ class KConfigDialog(KDialog):
self.iconList.addItem(item)
self.tabSpace.addWidget(configTab)
self.iconList.setIconSize(QSize(80, 80))
icons = list(self.iconList.item(x) for x in range(len(self.iconList)))
icons = [self.iconList.item(x) for x in range(len(self.iconList))]
neededIconWidth = max(self.iconList.visualItemRect(x).width()
for x in icons)
margins = self.iconList.contentsMargins()
......@@ -1507,9 +1506,8 @@ class KEditToolBar(KDialog):
).actions(
).items(
)}
activeNames = list(names[x] for x in activeActions)
Internal.Preferences.toolBarActions = ','.join(
activeNames) # pylint: disable=attribute-defined-outside-init
names[x] for x in activeActions) # pylint: disable=attribute-defined-outside-init
Internal.mainWindow.refreshToolBar()
KGlobal.initStatic()
......@@ -254,7 +254,7 @@ class LoginDlg(QDialog):
localName = i18nc('kajongg name for local game server', Query.localServerName)
self.servers = Query(
'select url,lastname from server order by lasttime desc').records
servers = list(x[0] for x in self.servers if x[0] != Query.localServerName)
servers = [x[0] for x in self.servers if x[0] != Query.localServerName]
# the first server combobox item should be default: either the last used server
# or localName for autoPlay
if localName not in servers:
......@@ -316,7 +316,7 @@ class LoginDlg(QDialog):
"""the user selected a different server"""
records = Query('select player.name from player, passwords '
'where passwords.url=? and passwords.player = player.id', (self.url,)).records
players = list(x[0] for x in records)
players = [x[0] for x in records]
preferPlayer = Options.player
if preferPlayer:
if preferPlayer in players:
......
......@@ -160,18 +160,20 @@ class Meld(TileList, StrMixin):
def __prepareRules(self, ruleset):
"""prepare rules from ruleset"""
rulesetId = id(ruleset)
self.__staticRules[rulesetId] = list(x for x in ruleset.meldRules
if not hasattr(x, 'mayApplyToMeld') and x.appliesToMeld(None, self))
self.__dynamicRules[rulesetId] = list(x for x in ruleset.meldRules
if hasattr(x, 'mayApplyToMeld') and x.mayApplyToMeld(self))
self.__staticRules[rulesetId] = [
x for x in ruleset.meldRules
if not hasattr(x, 'mayApplyToMeld') and x.appliesToMeld(None, self)]
self.__dynamicRules[rulesetId] = [
x for x in ruleset.meldRules
if hasattr(x, 'mayApplyToMeld') and x.mayApplyToMeld(self)]
self.__hasRules = any(len(x) for x in chain(
self.__staticRules.values(), self.__dynamicRules.values()))
self.__staticDoublingRules[rulesetId] = list(
self.__staticDoublingRules[rulesetId] = [
x for x in ruleset.doublingMeldRules
if not hasattr(x, 'mayApplyToMeld') and x.appliesToMeld(None, self))
self.__dynamicDoublingRules[rulesetId] = list(x for x in ruleset.doublingMeldRules
if hasattr(x, 'mayApplyToMeld') and x.mayApplyToMeld(self))
if not hasattr(x, 'mayApplyToMeld') and x.appliesToMeld(None, self)]
self.__dynamicDoublingRules[rulesetId] = [x for x in ruleset.doublingMeldRules
if hasattr(x, 'mayApplyToMeld') and x.mayApplyToMeld(self)]
self.__hasDoublingRules = any(len(x) for x in chain(
self.__staticDoublingRules.values(), self.__dynamicDoublingRules.values()))
......
......@@ -190,7 +190,7 @@ class NotifyAtOnceMessage(ClientMessage):
# default: tell all except the source of the notification
game = request.block.table.game
if game:
return list(x for x in game.players if x != request.player)
return [x for x in game.players if x != request.player]
return []
......@@ -500,7 +500,7 @@ class MessageNoGameStart(NotifyAtOnceMessage):
@classmethod
def receivers(cls, request):
"""notification is not needed for those who already said no game"""
return list(x.player for x in request.block.requests if x.answer != Message.NoGameStart)
return [x.player for x in request.block.requests if x.answer != Message.NoGameStart]
class MessageReadyForHandStart(ServerMessage):
......@@ -828,7 +828,7 @@ class MessageNoClaim(NotifyAtOnceMessage, ServerMessage):
@classmethod
def receivers(cls, request):
"""no Claim notifications are not needed for those who already answered"""
return list(x.player for x in request.block.requests if x.answer is None)
return [x.player for x in request.block.requests if x.answer is None]
def __scanSelf():
......
......@@ -219,7 +219,7 @@ class MLocale:
candidates = (
'share/locale', '/usr/local/share/locale', '/usr/share/locale',
os.path.join(os.path.dirname(sys.argv[0]), 'share/locale'))
result = list(x for x in candidates if os.path.exists(x))
result = [x for x in candidates if os.path.exists(x)]
if not result and Debug.i18n:
Internal.logger.debug('no locale path found. We have:%s', os.listdir('.'))
......@@ -295,8 +295,7 @@ class MLocale:
if languages:
languages = uniqueList(cls.extendRegionLanguages(languages))
languages = list(
x for x in languages if cls.isLanguageInstalled(x))
languages = [x for x in languages if cls.isLanguageInstalled(x)]
if 'en_US' not in languages:
languages.extend(['en_US', 'en'])
if Debug.i18n:
......
......@@ -57,12 +57,11 @@ class Permutations:
honors.append(tile.single)
count -= 1
honors.append(tile.meld(count))
boni = list(x.single for x in self.tiles if x.isBonus)