py2to3 automatic conversion. Woot!

This commit is contained in:
Ryan Holmes
2017-06-12 16:12:45 -04:00
parent ad535ccc78
commit 828b18d0fd
147 changed files with 1017 additions and 783 deletions

View File

@@ -67,7 +67,7 @@ class exportHtmlThread(threading.Thread):
FILE.write(HTML.encode('utf-8'))
FILE.close()
except IOError:
print("Failed to write to " + settings.getPath())
print(("Failed to write to " + settings.getPath()))
pass
if self.callback:
@@ -222,7 +222,7 @@ class exportHtmlThread(threading.Thread):
return
try:
dnaFit = Port.exportDna(getFit(fit[0]))
print dnaFit
print(dnaFit)
HTMLship += ' <li><a data-dna="' + dnaFit + '" target="_blank">' + fit[
1] + '</a></li>\n'
except:

View File

@@ -410,7 +410,7 @@ class FloatSpin(wx.PyControl):
height = best_size.GetHeight()
self._validkeycode = [43, 44, 45, 46, 69, 101, 127, 314]
self._validkeycode.extend(range(48, 58))
self._validkeycode.extend(list(range(48, 58)))
self._validkeycode.extend([wx.WXK_RETURN, wx.WXK_TAB, wx.WXK_BACK,
wx.WXK_LEFT, wx.WXK_RIGHT])
@@ -1282,8 +1282,8 @@ class FixedPoint(object):
self.n = n
return
if isinstance(value, type(42)) or isinstance(value, type(42L)):
self.n = long(value) * _tento(p)
if isinstance(value, type(42)) or isinstance(value, type(42)):
self.n = int(value) * _tento(p)
return
if isinstance(value, FixedPoint):
@@ -1303,7 +1303,7 @@ class FixedPoint(object):
# up all bits in 2 iterations for all known binary double-
# precision formats, and small enough to fit in an int.
CHUNK = 28
top = 0L
top = 0
# invariant: |value| = (top + f) * 2**e exactly
while f:
f = math.ldexp(f, CHUNK)
@@ -1321,7 +1321,7 @@ class FixedPoint(object):
if e >= 0:
n = top << e
else:
n = _roundquotient(top, 1L << -e)
n = _roundquotient(top, 1 << -e)
if value < 0:
n = -n
self.n = n
@@ -1329,7 +1329,7 @@ class FixedPoint(object):
if isinstance(value, type(42 - 42j)):
raise TypeError("can't convert complex to FixedPoint: " +
`value`)
repr(value))
# can we coerce to a float?
yes = 1
@@ -1344,14 +1344,14 @@ class FixedPoint(object):
# similarly for long
yes = 1
try:
aslong = long(value)
aslong = int(value)
except:
yes = 0
if yes:
self.__init__(aslong, p)
return
raise TypeError("can't convert to FixedPoint: " + `value`)
raise TypeError("can't convert to FixedPoint: " + repr(value))
def get_precision(self):
"""
@@ -1378,9 +1378,9 @@ class FixedPoint(object):
p = int(precision)
except:
raise TypeError("precision not convertable to int: " +
`precision`)
repr(precision))
if p < 0:
raise ValueError("precision must be >= 0: " + `precision`)
raise ValueError("precision must be >= 0: " + repr(precision))
if p > self.p:
self.n = self.n * _tento(p - self.p)
@@ -1403,7 +1403,7 @@ class FixedPoint(object):
def __repr__(self):
return "FixedPoint" + `(str(self), self.p)`
return "FixedPoint" + repr((str(self), self.p))
def copy(self):
""" Create a copy of the current :class:`FixedPoint`. """
@@ -1434,7 +1434,7 @@ class FixedPoint(object):
# a float, their hashes may differ. This is a teensy bit Bad.
return hash(n) ^ hash(p)
def __nonzero__(self):
def __bool__(self):
return self.n != 0
def __neg__(self):
@@ -1531,7 +1531,7 @@ class FixedPoint(object):
"""
return self - long(self)
return self - int(self)
# return n, p s.t. self == n/10**p and n % 10 != 0
def __reduce(self):
@@ -1550,7 +1550,7 @@ def _tento(n, cache={}):
try:
return cache[n]
except KeyError:
answer = cache[n] = 10L ** n
answer = cache[n] = 10 ** n
return answer
@@ -1632,7 +1632,7 @@ del re
def _string2exact(s):
m = _parser(s)
if m is None:
raise ValueError("can't parse as number: " + `s`)
raise ValueError("can't parse as number: " + repr(s))
exp = m.group('exp')
if exp is None:
@@ -1651,7 +1651,7 @@ def _string2exact(s):
assert intpart
assert fracpart
i, f = long(intpart), long(fracpart)
i, f = int(intpart), int(fracpart)
nfrac = len(fracpart)
i = i * _tento(nfrac) + f
exp = exp - nfrac

View File

@@ -1,7 +1,7 @@
import wx
def YesNoDialog(question=u'Are you sure you want to do this?', caption=u'Yes or no?'):
def YesNoDialog(question='Are you sure you want to do this?', caption='Yes or no?'):
dlg = wx.MessageDialog(None, question, caption, wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal() == wx.ID_YES
dlg.Destroy()

View File

@@ -5,5 +5,5 @@ def formatList(words):
if len(words) == 1:
return words[0]
last = words[-1:][0]
beginning = u", ".join(words[:-1])
return u"{0} and {1}".format(beginning, last)
beginning = ", ".join(words[:-1])
return "{0} and {1}".format(beginning, last)

View File

@@ -17,13 +17,13 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
return ""
# Define suffix maps
posSuffixMap = {3: "k", 6: "M", 9: "B" if currency is True else "G"}
negSuffixMap = {-6: u'\u03bc', -3: "m"}
negSuffixMap = {-6: '\u03bc', -3: "m"}
# Define tuple of the map keys
# As we're going to go from the biggest order of abs(key), sort
# them differently due to one set of values being negative
# and other positive
posOrders = tuple(sorted(posSuffixMap.iterkeys(), reverse=True))
negOrders = tuple(sorted(negSuffixMap.iterkeys(), reverse=False))
posOrders = tuple(sorted(iter(posSuffixMap.keys()), reverse=True))
negOrders = tuple(sorted(iter(negSuffixMap.keys()), reverse=False))
# Find the least abs(key)
posLowest = min(posOrders)
negHighest = max(negOrders)
@@ -89,7 +89,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
mantissa = roundToPrec(mantissa, prec)
sign = "+" if forceSign is True and mantissa > 0 else ""
# Round mantissa and add suffix
result = u"{0}{1}{2}".format(sign, mantissa, suffix)
result = "{0}{1}{2}".format(sign, mantissa, suffix)
return result