2 new revisions:
Revision: 406aca7da54f
Branch: default
Author: gbtami
Date: Wed Dec 31 10:05:22 2014 UTC
Log: futurize -w -n -f lib2to3.fixes.fix_idioms .
https://code.google.com/p/pychess/source/detail?r=406aca7da54f
Revision: faa33b186b01
Branch: default
Author: gbtami
Date: Wed Dec 31 10:23:32 2014 UTC
Log: Ooops, we have float options too
https://code.google.com/p/pychess/source/detail?r=faa33b186b01
==============================================================================
Revision: 406aca7da54f
Branch: default
Author: gbtami
Date: Wed Dec 31 10:05:22 2014 UTC
Log: futurize -w -n -f lib2to3.fixes.fix_idioms .
https://code.google.com/p/pychess/source/detail?r=406aca7da54f
Modified:
/lib/pychess/Players/PyChessCECP.py
/lib/pychess/Players/UCIEngine.py
/lib/pychess/System/SubProcess.py
/lib/pychess/System/glock.py
/lib/pychess/Utils/Board.py
/lib/pychess/Utils/Cord.py
/lib/pychess/Utils/GameModel.py
/lib/pychess/Utils/Offer.py
/lib/pychess/Utils/Rating.py
/lib/pychess/ic/FICSObjects.py
/lib/pychess/ic/ICLounge.py
/lib/pychess/ic/VerboseTelnet.py
/lib/pychess/ic/__init__.py
/lib/pychess/ic/managers/BoardManager.py
/lib/pychess/widgets/BoardView.py
/lib/pychess/widgets/ChainVBox.py
/lib/pychess/widgets/LogDialog.py
/lib/pychess/widgets/MenuItemsDict.py
/lib/pychess/widgets/ToggleComboBox.py
/lib/pychess/widgets/gamenanny.py
/lib/pychess/widgets/ionest.py
/lib/pychess/widgets/preferencesDialog.py
/lib/pychess/widgets/pydock/OverlayWindow.py
/testing/bitboard.py
/translators.py
=======================================
--- /lib/pychess/Players/PyChessCECP.py Tue Dec 30 19:30:35 2014 UTC
+++ /lib/pychess/Players/PyChessCECP.py Wed Dec 31 10:05:22 2014 UTC
@@ -84,7 +84,7 @@
pass
elif lines[0] == "protover":
- stringPairs = ["=".join([k, '"%s"' % v if type(v) is
str else str(v)]) for k,v in self.features.items()]
+ stringPairs = ["=".join([k, '"%s"' % v if
isinstance(v, str) else str(v)]) for k,v in self.features.items()]
print("feature %s" % " ".join(stringPairs))
print("feature done=1")
=======================================
--- /lib/pychess/Players/UCIEngine.py Tue Dec 30 16:36:34 2014 UTC
+++ /lib/pychess/Players/UCIEngine.py Wed Dec 31 10:05:22 2014 UTC
@@ -106,7 +106,7 @@
self.setOption('MultiPV', self.multipvSetting)
for option, value in self.optionsToBeSent.items():
- if type(value) == bool:
+ if isinstance(value, bool):
value = str(value).lower()
print("setoption name %s value %s" % (option, str(value)),
file=self.engine)
=======================================
--- /lib/pychess/System/SubProcess.py Tue Dec 30 14:13:27 2014 UTC
+++ /lib/pychess/System/SubProcess.py Wed Dec 31 10:05:22 2014 UTC
@@ -129,7 +129,7 @@
# Kill the engine on any signal but 'Resource temporarily
unavailable'
self.subprocExitCode = (code, os.strerror(code))
if code != errno.EWOULDBLOCK:
- if type(code) == str:
+ if isinstance(code, str):
log.error(code, extra={"task":self.defname})
else: log.error(os.strerror(code), extra={"task":self.defname})
self.emit("died")
=======================================
--- /lib/pychess/System/glock.py Mon Dec 29 23:11:25 2014 UTC
+++ /lib/pychess/System/glock.py Wed Dec 31 10:05:22 2014 UTC
@@ -28,7 +28,7 @@
if not thread:
thread = currentThread()
ro = rlock_owner(_rlock)
- if type(ro) is int:
+ if isinstance(ro, int):
return ro == thread.ident
return ro ==
thread.name
=======================================
--- /lib/pychess/Utils/Board.py Tue Dec 30 18:49:45 2014 UTC
+++ /lib/pychess/Utils/Board.py Wed Dec 31 10:05:22 2014 UTC
@@ -363,7 +363,7 @@
return newBoard
def __eq__ (self, other):
- if type(self) != type(other): return False
+ if not isinstance(self, type(other)): return False
return self.board == other.board
def printPieces(self):
=======================================
--- /lib/pychess/Utils/Cord.py Tue Dec 30 16:42:57 2014 UTC
+++ /lib/pychess/Utils/Cord.py Wed Dec 31 10:05:22 2014 UTC
@@ -10,7 +10,7 @@
Cord(17), Cord("b3"), Cord(1,2), Cord("b",3) """
if var2 == None:
- if type(var1) == int:
+ if isinstance(var1, int):
# We assume the format Cord(17)
self.x = FILE(var1)
self.y = RANK(var1)
@@ -19,7 +19,7 @@
self.x = self.charToInt(var1[0])
self.y = int(var1[1]) - 1
else:
- if type(var1) == str:
+ if isinstance(var1, str):
# We assume the format Cord("b",3)
self.x = self.charToInt(var1)
self.y = var2 -1
=======================================
--- /lib/pychess/Utils/GameModel.py Tue Dec 30 22:52:15 2014 UTC
+++ /lib/pychess/Utils/GameModel.py Wed Dec 31 10:05:22 2014 UTC
@@ -480,7 +480,7 @@
def loadAndStart (self, uri, loader, gameno, position):
assert self.status == WAITING_TO_START
- uriIsFile = type(uri) != str
+ uriIsFile = not isinstance(uri, str)
if not uriIsFile:
chessfile = loader.load(protoopen(uri))
else:
@@ -528,7 +528,7 @@
raise error
def save (self, uri, saver, append, position=None):
- if type(uri) == str:
+ if isinstance(uri, str):
fileobj = protosave(uri, append)
self.uri = uri
else:
=======================================
--- /lib/pychess/Utils/Offer.py Fri Sep 24 06:13:18 2010 UTC
+++ /lib/pychess/Utils/Offer.py Wed Dec 31 10:05:22 2014 UTC
@@ -3,7 +3,7 @@
class Offer:
def __init__(self, type_, param=None, index=None):
assert type_ in ACTIONS, "Offer.__init__(): type not in
ACTIONS: %s" % repr(type_)
- assert index is None or type(index) is int, \
+ assert index is None or isinstance(index, int), \
"Offer.__init__(): index not int: %s" % repr(index)
self.type = type_
self.param = param
@@ -13,7 +13,7 @@
return hash((self.type, self.param, self.index))
def __cmp__(self, other):
- assert type(other) is type(self), "Offer.__cmp__(): not of type
Offer: %s" % repr(other)
+ assert isinstance(other, type(self)), "Offer.__cmp__(): not of
type Offer: %s" % repr(other)
return cmp(hash(self), hash(other))
def __repr__(self):
=======================================
--- /lib/pychess/Utils/Rating.py Fri Oct 3 08:01:33 2014 UTC
+++ /lib/pychess/Utils/Rating.py Wed Dec 31 10:05:22 2014 UTC
@@ -7,7 +7,7 @@
GObject.GObject.__init__(self)
self.type = ratingtype
for v in (elo, deviation, wins, losses, draws, bestElo, bestTime):
- assert v == None or type(v) == int, v
+ assert v == None or isinstance(v, int), v
self.elo = elo
self.deviation = deviation
self.wins = wins
@@ -19,7 +19,7 @@
def get_elo (self):
return self._elo
def set_elo (self, elo):
- assert type(elo) == int, type(elo)
+ assert isinstance(elo, int), type(elo)
self._elo = elo
elo = GObject.property(get_elo, set_elo)
=======================================
--- /lib/pychess/ic/FICSObjects.py Tue Dec 30 16:36:34 2014 UTC
+++ /lib/pychess/ic/FICSObjects.py Wed Dec 31 10:05:22 2014 UTC
@@ -71,8 +71,8 @@
class FICSPlayer (GObject.GObject):
def __init__ (self, name, online=False, status=IC_STATUS_UNKNOWN,
game=None,
titles=None):
- assert type(name) is str, name
- assert type(online) is bool, online
+ assert isinstance(name, str), name
+ assert isinstance(online, bool), online
GObject.GObject.__init__(self)
self.name = name
self.online = online
@@ -214,7 +214,7 @@
return hash(
self.name[0:10].lower())
def __eq__ (self, player):
- if type(self) == type(player) and hash(self) == hash(player):
+ if isinstance(self, type(player)) and hash(self) == hash(player):
return True
else:
return False
@@ -262,7 +262,7 @@
@classmethod
def getIconByRating (cls, rating, size=16):
- assert type(rating) == int, "rating not an int: %s" % str(rating)
+ assert isinstance(rating, int), "rating not an int: %s" %
str(rating)
if rating >= 1900:
return load_icon(size, "weather-storm")
elif rating >= 1600:
@@ -275,7 +275,7 @@
return load_icon(size, "weather-clear")
def getIcon (self, size=16, gametype=None):
- assert type(size) == int, "size not an int: %s" % str(size)
+ assert isinstance(size, int), "size not an int: %s" % str(size)
if self.isGuest():
return load_icon(size, "stock_people", "system-users")
elif self.isComputer():
@@ -379,7 +379,7 @@
pass
def __getitem__ (self, player):
- if type(player) is not FICSPlayer: raise TypeError("%s" %
repr(player))
+ if not isinstance(player, FICSPlayer): raise TypeError("%s" %
repr(player))
if hash(player) in self.players:
return self.players[hash(player)]
else:
@@ -387,8 +387,8 @@
def __setitem__ (self, key, value):
""" key and value must be the same FICSPlayer object """
- if type(key) is not FICSPlayer: raise TypeError
- if type(value) is not FICSPlayer: raise TypeError
+ if not isinstance(key, FICSPlayer): raise TypeError
+ if not isinstance(value, FICSPlayer): raise TypeError
if key != value:
raise Exception("Not the same: %s %s" % (repr(key),
repr(value)))
if hash(value) in self.players:
@@ -398,7 +398,7 @@
self.online_changed)
def __delitem__ (self, player):
- if type(player) is not FICSPlayer: raise TypeError
+ if not isinstance(player, FICSPlayer): raise TypeError
if player in self:
del self.players[hash(player)]
if hash(player) in self.players_cids:
@@ -407,7 +407,7 @@
del self.players_cids[hash(player)]
def __contains__ (self, player):
- if type(player) is not FICSPlayer: raise TypeError
+ if not isinstance(player, FICSPlayer): raise TypeError
if hash(player) in self.players:
return True
else:
@@ -463,9 +463,9 @@
class FICSMatch (GObject.GObject):
def __init__ (self, minutes, inc, rated, game_type):
- assert minutes is None or type(minutes) is int, type(minutes)
- assert inc is None or type(inc) is int, inc
- assert type(rated) is bool, rated
+ assert minutes is None or isinstance(minutes, int), type(minutes)
+ assert inc is None or isinstance(inc, int), inc
+ assert isinstance(rated, bool), rated
assert game_type is None or game_type is
GAME_TYPES_BY_FICS_NAME["wild"] \
or game_type in GAME_TYPES.values(), game_type
GObject.GObject.__init__(self)
@@ -514,7 +514,7 @@
class FICSSoughtMatch (FICSMatch):
def __init__ (self, index, player, minutes, inc, rated, color,
game_type):
- assert index is None or type(index) is int, index
+ assert index is None or isinstance(index, int), index
assert isinstance(player, FICSPlayer), player
FICSMatch.__init__(self, minutes, inc, rated, game_type)
self.index = index
@@ -525,7 +525,7 @@
return self.index
def __eq__ (self, sought):
- if type(self) == type(sought) and hash(self) == hash(sought):
+ if isinstance(self, type(sought)) and hash(self) == hash(sought):
return True
else:
return False
@@ -582,11 +582,11 @@
self.connection.bm.connect("playGameCreated", self.onPlayingGame)
def __getitem__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
return self.challenges[index]
def __setitem__ (self, index, challenge):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
if not isinstance(challenge, FICSSoughtMatch): raise TypeError
if index in self:
log.warning("FICSChallenges: not overwriting challenge %s" %
@@ -596,7 +596,7 @@
self.emit('FICSChallengeIssued', challenge)
def __delitem__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
try:
challenge = self.challenges[index]
except KeyError:
@@ -605,7 +605,7 @@
self.emit('FICSChallengeRemoved', challenge)
def __contains__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
if index in self.challenges:
return True
else:
@@ -626,8 +626,8 @@
self.clear()
def get_rating_range_display_text (rmin=0, rmax=9999):
- assert type(rmin) is type(int()) and rmin >= 0 and rmin <= 9999, rmin
- assert type(rmax) is type(int()) and rmax >= 0 and rmax <= 9999, rmax
+ assert isinstance(rmin, type(int())) and rmin >= 0 and rmin <= 9999,
rmin
+ assert isinstance(rmax, type(int())) and rmax >= 0 and rmax <= 9999,
rmax
if rmin > 0:
text = u"%d" % rmin
if rmax == 9999:
@@ -677,11 +677,11 @@
self.connection.bm.connect("curGameEnded", self.onCurGameEnded)
def __getitem__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
return self.seeks[index]
def __setitem__ (self, index, seek):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
if not isinstance(seek, FICSSoughtMatch): raise TypeError
if index in self:
log.warning("FICSSeeks: not overwriting seek %s" % repr(seek))
@@ -690,7 +690,7 @@
self.emit('FICSSeekCreated', seek)
def __delitem__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
try:
seek = self.seeks[index]
except KeyError:
@@ -699,7 +699,7 @@
self.emit('FICSSeekRemoved', seek)
def __contains__ (self, index):
- if not type(index) == int: raise TypeError
+ if not isinstance(index, int): raise TypeError
if index in self.seeks:
return True
else:
@@ -724,8 +724,8 @@
class FICSBoard (object):
def __init__ (self, wms, bms, fen=None, pgn=None):
- assert type(wms) is int, wms
- assert type(bms) is int, bms
+ assert isinstance(wms, int), wms
+ assert isinstance(bms, int), bms
self.wms = wms
self.bms = bms
# assert fen != None or pgn != None
@@ -738,11 +738,11 @@
reason=None, board=None, private=False):
assert isinstance(wplayer, FICSPlayer), wplayer
assert isinstance(bplayer, FICSPlayer), bplayer
- assert gameno is None or type(gameno) is int, gameno
- assert result is None or type(result) is int, result
- assert reason is None or type(reason) is int, reason
+ assert gameno is None or isinstance(gameno, int), gameno
+ assert result is None or isinstance(result, int), result
+ assert reason is None or isinstance(reason, int), reason
assert board is None or isinstance(board, FICSBoard), board
- assert type(private) is bool, private
+ assert isinstance(private, bool), private
FICSMatch.__init__(self, minutes, inc, rated, game_type)
self.wplayer = wplayer
self.bplayer = bplayer
@@ -832,8 +832,8 @@
rated=False, game_type=None, private=False, minutes=None,
inc=None, result=None, reason=None, board=None):
assert our_color is None or our_color in (WHITE, BLACK), our_color
- assert length is None or type(length) is int, length
- assert time is None or type(time) is datetime.datetime, time
+ assert length is None or isinstance(length, int), length
+ assert time is None or isinstance(time, datetime.datetime), time
FICSGame.__init__(self, wplayer, bplayer, rated=rated,
private=private,
game_type=game_type, minutes=minutes, inc=inc, result=result,
reason=reason, board=board)
@@ -924,7 +924,7 @@
def values(self): return self.games.values()
def get_game_by_gameno (self, gameno):
- if type(gameno) is not int: raise TypeError
+ if not isinstance(gameno, int): raise TypeError
return self.games_by_gameno[gameno]
def get (self, game, create=True, emit=True):
=======================================
--- /lib/pychess/ic/ICLounge.py Tue Dec 30 18:35:09 2014 UTC
+++ /lib/pychess/ic/ICLounge.py Wed Dec 31 10:05:22 2014 UTC
@@ -209,7 +209,7 @@
table.props.row_spacing = 4
def label(value, xalign=0, is_error=False):
- if type(value) == float:
+ if isinstance(value, float):
value = str(int(value))
if is_error:
label = Gtk.Label()
@@ -272,7 +272,7 @@
extra={"task":
(self.connection.username, "UIS.oF.callback")})
glock.acquire()
try:
- if type(pingtime) == str:
+ if isinstance(pingtime, str):
self.ping_label.set_text(pingtime)
elif pingtime == -1:
self.ping_label.set_text(_("Unknown"))
@@ -389,7 +389,7 @@
def pixCompareFunction (self, treemodel, iter0, iter1, column):
pix0 = treemodel.get_value(iter0, column)
pix1 = treemodel.get_value(iter1, column)
- if type(pix0) == GdkPixbuf.Pixbuf and type(pix1) ==
GdkPixbuf.Pixbuf:
+ if isinstance(pix0, GdkPixbuf.Pixbuf) and isinstance(pix1,
GdkPixbuf.Pixbuf):
return cmp(pix0.get_pixels(), pix1.get_pixels())
return cmp(pix0, pix1)
@@ -1422,7 +1422,7 @@
def toleranceHBoxGetter (widget):
return self.widgets["toleranceHBox"].get_property("visible")
def toleranceHBoxSetter (widget, visible):
- assert type(visible) is bool
+ assert isinstance(visible, bool)
if visible:
self.widgets["toleranceHBox"].show()
else:
@@ -1786,7 +1786,7 @@
self.lastdifference = difference
def __clamp (self, rating):
- assert type(rating) is int
+ assert isinstance(rating, int)
mod = rating % RATING_SLIDER_STEP
if mod > RATING_SLIDER_STEP / 2:
return rating - mod + RATING_SLIDER_STEP
=======================================
--- /lib/pychess/ic/VerboseTelnet.py Sat Sep 27 08:08:42 2014 UTC
+++ /lib/pychess/ic/VerboseTelnet.py Wed Dec 31 10:05:22 2014 UTC
@@ -110,7 +110,7 @@
match = self.regexps[1].match(line)
if match:
self.matchlist.append(match)
- self.matches = [m if type(m) is str else m.string for m in
self.matchlist]
+ self.matches = [m if isinstance(m, str) else m.string for
m in self.matchlist]
self.callback(self.matchlist)
del self.matchlist[:]
return RETURN_MATCH
=======================================
--- /lib/pychess/ic/__init__.py Thu Sep 25 06:31:02 2014 UTC
+++ /lib/pychess/ic/__init__.py Wed Dec 31 10:05:22 2014 UTC
@@ -159,7 +159,7 @@
return typename[0].upper() + typename[1:]
def time_control_to_gametype (minutes, gain):
- assert type(minutes) == int and type(gain) == int
+ assert isinstance(minutes, int) and isinstance(gain, int)
assert minutes >= 0 and gain >= 0
gainminutes = gain > 0 and (gain*60)-1 or 0
if minutes is 0:
=======================================
--- /lib/pychess/ic/managers/BoardManager.py Tue Dec 30 12:55:47 2014 UTC
+++ /lib/pychess/ic/managers/BoardManager.py Wed Dec 31 10:05:22 2014 UTC
@@ -689,8 +689,7 @@
pgnHead += [ ("Variant", "Suicide") ]
pgn = "\n".join(['[%s "%s"]' % line for line in pgnHead]) + "\n"
- moves = moves.items()
- moves.sort()
+ moves = sorted(moves.items())
for ply, move in moves:
if ply % 2 == 0:
pgn += "%d. " % (ply/2+1)
=======================================
--- /lib/pychess/widgets/BoardView.py Tue Dec 30 16:34:48 2014 UTC
+++ /lib/pychess/widgets/BoardView.py Wed Dec 31 10:05:22 2014 UTC
@@ -629,7 +629,7 @@
# r = Gdk.Rectangle()
# r.x, r.y, r.width, r.height = t
#assert type(r[2]) == int
- assert type(r.width) == int
+ assert isinstance(r.width, int)
if queue:
self.queue_draw_area(r.x, r.y, r.width, r.height)
else:
@@ -806,13 +806,13 @@
self.cordMatrices = [None] * self.FILES*self.RANKS + [None] *
self.FILES*4
self.cordMatricesState = (self.square, self.rotation)
c = x * self.FILES + y
- if type(c) == int and self.cordMatrices[c]:
+ if isinstance(c, int) and self.cordMatrices[c]:
matrices = self.cordMatrices[c]
else:
cx, cy = self.cord2Point(x,y)
matrices = matrixAround(self.matrix, cx+s/2., cy+s/2.)
matrices += (cx, cy)
- if type(c) == int:
+ if isinstance(c, int):
self.cordMatrices[c] = matrices
return matrices
@@ -1417,7 +1417,7 @@
def cord2RectRelative (self, cord, y=None):
""" Like cord2Rect, but gives you bounding rect in case board is
beeing
Rotated """
- if type(cord) == tuple:
+ if isinstance(cord, tuple):
cx, cy, s = cord
else:
cx, cy, s = self.cord2Rect(cord, y)
=======================================
--- /lib/pychess/widgets/ChainVBox.py Tue Dec 30 12:47:46 2014 UTC
+++ /lib/pychess/widgets/ChainVBox.py Wed Dec 31 10:05:22 2014 UTC
@@ -36,7 +36,7 @@
def getActive (self):
return self._active
def setActive (self, active):
- assert type(active) is bool
+ assert isinstance(active, bool)
self._active = active
if self._active is True:
self.image.set_from_file(addDataPrefix("glade/stock-vchain-24.png"))
=======================================
--- /lib/pychess/widgets/LogDialog.py Tue Dec 30 23:25:10 2014 UTC
+++ /lib/pychess/widgets/LogDialog.py Wed Dec 31 10:05:22 2014 UTC
@@ -77,7 +77,7 @@
textview.get_buffer().get_end_iter(), "\n%s\n%s\n"%(t,"-"*60),
str(logging.INFO))
cls.tagToTime[tag] = timestamp
- if type(message) == str:
+ if isinstance(message, str):
message = unicode(message, "utf-8", 'rawreplace')
if not message.endswith("\n"):
message = "%s\n" % message
@@ -87,7 +87,7 @@
@classmethod
def _createPage (cls, parrentIter, tag):
name = tag[-1]
- if type(name) == int:
+ if isinstance(name, int):
name=str(name)
iter = cls.treeview.get_model().append(parrentIter, (name,))
cls.tagToIter[tag] = iter
@@ -141,9 +141,9 @@
@classmethod
def _getPageFromTag (cls, tag):
- if type(tag) == list:
+ if isinstance(tag, list):
tag = tuple(tag)
- elif type(tag) != tuple:
+ elif not isinstance(tag, tuple):
tag = (tag,)
if tag in cls.tagToPage:
=======================================
--- /lib/pychess/widgets/MenuItemsDict.py Tue Dec 30 12:47:46 2014 UTC
+++ /lib/pychess/widgets/MenuItemsDict.py Wed Dec 31 10:05:22 2014 UTC
@@ -10,8 +10,8 @@
class GtkMenuItem (object):
def __init__ (self, name, gamewidget, sensitive=False, label=None,
tooltip=None):
- assert type(sensitive) is bool
- assert label is None or type(label) is str
+ assert isinstance(sensitive, bool)
+ assert label is None or isinstance(label, str)
self.name = name
self.gamewidget = gamewidget
self._sensitive = sensitive
@@ -23,7 +23,7 @@
return self._sensitive
@sensitive.setter
def sensitive (self, sensitive):
- assert type(sensitive) is bool
+ assert isinstance(sensitive, bool)
self._sensitive = sensitive
self._set_widget("sensitive", sensitive)
@@ -67,7 +67,7 @@
class GtkMenuToggleButton (GtkMenuItem):
def __init__ (self, name, gamewidget, sensitive=False, active=False,
label=None):
- assert type(active) is bool
+ assert isinstance(active, bool)
GtkMenuItem.__init__(self, name, gamewidget, sensitive, label)
self._active = active
@@ -76,7 +76,7 @@
return self._active
@active.setter
def active (self, active):
- assert type(active) is bool
+ assert isinstance(active, bool)
self._active = active
self._set_widget("active", active)
=======================================
--- /lib/pychess/widgets/ToggleComboBox.py Sun Oct 12 06:37:45 2014 UTC
+++ /lib/pychess/widgets/ToggleComboBox.py Wed Dec 31 10:05:22 2014 UTC
@@ -45,7 +45,7 @@
return self._active
def _set_active(self, active):
- if type(active) != int:
+ if not isinstance(active, int):
raise TypeError
if active == self._active: return
if active >= len(self._items):
@@ -81,7 +81,7 @@
item = Gtk.MenuItem()
label = Gtk.Label(label=text)
label.props.xalign = 0
- if type(stock) == str:
+ if isinstance(stock, str):
stock = load_icon(12, stock)
image = Gtk.Image()
image.set_from_pixbuf(stock)
=======================================
--- /lib/pychess/widgets/gamenanny.py Tue Dec 30 12:47:46 2014 UTC
+++ /lib/pychess/widgets/gamenanny.py Wed Dec 31 10:05:22 2014 UTC
@@ -198,7 +198,7 @@
return False
def _set_statusbar (gamewidget, message):
- assert type(message) is str or type(message) is unicode
+ assert isinstance(message, str) or isinstance(message, unicode)
gamewidget.status(message)
def game_paused (gamemodel, gmwidg):
=======================================
--- /lib/pychess/widgets/ionest.py Tue Dec 30 17:53:06 2014 UTC
+++ /lib/pychess/widgets/ionest.py Wed Dec 31 10:05:22 2014 UTC
@@ -39,7 +39,7 @@
def onPublished (worker, vallist):
for val in vallist:
# The worker will start by publishing (gmwidg, game)
- if type(val) == tuple:
+ if isinstance(val, tuple):
gmwidg, game = val
gamewidget.attachGameWidget(gmwidg)
gamenanny.nurseGame(gmwidg, game)
=======================================
--- /lib/pychess/widgets/preferencesDialog.py Tue Dec 30 16:34:48 2014 UTC
+++ /lib/pychess/widgets/preferencesDialog.py Wed Dec 31 10:05:22 2014 UTC
@@ -297,7 +297,7 @@
if not conf.get("useSounds", True):
return
- if type(action) == str:
+ if isinstance(action, str):
no = cls.actionToKeyNo[action]
else: no = action
typ = conf.get("soundcombo%d" % no, SOUND_MUTE)
=======================================
--- /lib/pychess/widgets/pydock/OverlayWindow.py Wed Dec 31 09:59:14 2014
UTC
+++ /lib/pychess/widgets/pydock/OverlayWindow.py Wed Dec 31 10:05:22 2014
UTC
@@ -142,7 +142,7 @@
return svg
def __svgToSurface (self, svg, width, height):
- assert type(width) == int
+ assert isinstance(width, int)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
context = cairo.Context(surface)
context.set_operator(cairo.OPERATOR_SOURCE)
=======================================
--- /testing/bitboard.py Tue Dec 30 16:34:48 2014 UTC
+++ /testing/bitboard.py Wed Dec 31 10:05:22 2014 UTC
@@ -48,8 +48,7 @@
for positions,board in self.positionSets:
positions.sort()
- itered = list(iterBits(board))
- itered.sort()
+ itered = sorted(iterBits(board))
self.assertEqual(positions, itered)
if __name__ == '__main__':
=======================================
--- /translators.py Tue Dec 30 17:16:47 2014 UTC
+++ /translators.py Wed Dec 31 10:05:22 2014 UTC
@@ -22,8 +22,7 @@
print("Getting data from Rosetta Launchpad...")
data =
urlopen('
http://translations.launchpad.net/pychess/trunk/+translations').read()
-langs = re.findall('/pychess/trunk/\+pots/pychess/(.*?)/\+translate', data)
-langs.sort()
+langs =
sorted(re.findall('/pychess/trunk/\+pots/pychess/(.*?)/\+translate', data))
def findContributors(lang):
site
= "
https://translations.launchpad.net/pychess/trunk/+pots/pychess/%s/+translate" %
lang
==============================================================================
Revision: faa33b186b01
Branch: default
Author: gbtami
Date: Wed Dec 31 10:23:32 2014 UTC
Log: Ooops, we have float options too
https://code.google.com/p/pychess/source/detail?r=faa33b186b01
Modified:
/lib/pychess/System/conf_configParser.py
=======================================
--- /lib/pychess/System/conf_configParser.py Wed Dec 31 09:39:34 2014 UTC
+++ /lib/pychess/System/conf_configParser.py Wed Dec 31 10:23:32 2014 UTC
@@ -39,6 +39,11 @@
except ValueError:
pass
+ try:
+ return configParser.getfloat(section, key)
+ except ValueError:
+ pass
+
return configParser.get(section, key)
def set (key, value):