mirror of https://github.com/VLSIDA/OpenRAM.git
compiler: gdsMill: Modernize codebase.
The few Python 2 statements are replaced with their modern counterparts. These are one of the following: - print() function calls (instead of statements), - Exception and Error raising, - passing/receiving tuples as function/lambda arguments, - the L suffix for numeral constants. * compiler/gdsMill/pyx/box.py, compiler/gdsMill/pyx/connector.py, compiler/gdsMill/pyx/deformer.py, compiler/gdsMill/pyx/dvifile.py, compiler/gdsMill/pyx/epsfile.py, compiler/gdsMill/pyx/font/afm.py, compiler/gdsMill/pyx/font/t1font.py, compiler/gdsMill/pyx/graph/axis/texter.py, compiler/gdsMill/pyx/graph/axis/tick.py, compiler/gdsMill/sram_examples/cell6tDemo.py, compiler/gdsMill/sram_examples/newcell.py: Modernize syntax.
This commit is contained in:
parent
26e11044db
commit
e01e6a567d
|
|
@ -142,8 +142,8 @@ class polygon_pt:
|
|||
def alignvector_pt(self, a, dx, dy, alignlinevector, alignpointvector):
|
||||
n = math.hypot(dx, dy)
|
||||
dx, dy = dx / n, dy / n
|
||||
linevectors = map(lambda (p1, p2), self=self, a=a, dx=dx, dy=dy, alignlinevector=alignlinevector:
|
||||
alignlinevector(a, dx, dy, *(p1 + p2)), self.successivepoints())
|
||||
linevectors = map(lambda p, self=self, a=a, dx=dx, dy=dy, alignlinevector=alignlinevector:
|
||||
alignlinevector(a, dx, dy, *(p[0] + p[1])), self.successivepoints())
|
||||
for linevector in linevectors:
|
||||
if type(linevector) is types.TupleType:
|
||||
return linevector
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ class twolines_pt(connector_pt):
|
|||
if alength is not None: no_lengths += 1
|
||||
|
||||
if no_angles + no_lengths != 2:
|
||||
raise NotImplementedError, "Please specify exactly two angles or lengths"
|
||||
raise NotImplementedError("Please specify exactly two angles or lengths")
|
||||
|
||||
# calculate necessary angles and armlengths
|
||||
# always length1 and relangle1
|
||||
|
|
@ -301,7 +301,7 @@ class twolines_pt(connector_pt):
|
|||
relangle1 = acos((distance**2 + length1**2 - length2**2) / (2.0*distance*length1))
|
||||
middle = self._middle_a(begin, dangle, length1, relangle1)
|
||||
else:
|
||||
raise NotImplementedError, "I found a strange combination of arguments"
|
||||
raise NotImplementedError("I found a strange combination of arguments")
|
||||
|
||||
connectorpath = path.path(path.moveto_pt(*self.box1.center),
|
||||
path.lineto_pt(*middle),
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ def controldists_from_endgeometry_pt(A, B, tangA, tangB, curvA, curvB, allownega
|
|||
return []
|
||||
|
||||
if debug:
|
||||
print "fallback with exact zero value"
|
||||
print("fallback with exact zero value")
|
||||
return [(a, b)]
|
||||
# >>>
|
||||
def fallback_smallT(T, D, E, AB, curvA, curvB, threshold, debug):# <<<
|
||||
|
|
@ -147,7 +147,7 @@ def controldists_from_endgeometry_pt(A, B, tangA, tangB, curvA, curvB, allownega
|
|||
abs(b*T) < threshold * q1 and abs(1.5*a*abs(a)*curvA - D) < threshold * q1 and
|
||||
abs(a*T) < threshold * q2 and abs(1.5*b*abs(b)*curvB - E) < threshold * q2):
|
||||
if debug:
|
||||
print "fallback with T approx 0"
|
||||
print("fallback with T approx 0")
|
||||
return [(a, b)]
|
||||
return []
|
||||
# >>>
|
||||
|
|
@ -161,7 +161,7 @@ def controldists_from_endgeometry_pt(A, B, tangA, tangB, curvA, curvB, allownega
|
|||
abs(1.5*b*b*curvB) < threshold * min(abs(a*T), abs(E)) and
|
||||
abs(a*T - E) < threshold * min(abs(a*T), abs(E))):
|
||||
if debug:
|
||||
print "fallback with curvB approx 0"
|
||||
print("fallback with curvB approx 0")
|
||||
result.append((a, b))
|
||||
|
||||
# is curvA approx zero?
|
||||
|
|
@ -171,7 +171,7 @@ def controldists_from_endgeometry_pt(A, B, tangA, tangB, curvA, curvB, allownega
|
|||
abs(1.5*a*a*curvA) < threshold * min(abs(b*T), abs(D)) and
|
||||
abs(b*T - D) < threshold * min(abs(b*T), abs(D))):
|
||||
if debug:
|
||||
print "fallback with curvA approx 0"
|
||||
print("fallback with curvA approx 0")
|
||||
result.append((a, b))
|
||||
|
||||
return result
|
||||
|
|
@ -754,7 +754,7 @@ class parallel(deformer): # <<<
|
|||
# get the next parallel piece for the normpath
|
||||
try:
|
||||
next_parallel_normpath = self.deformsubpathitem(next_orig_nspitem, epsilon)
|
||||
except InvalidParamException, e:
|
||||
except InvalidParamException as e:
|
||||
invalid_nspitem_param = e.normsubpathitemparam
|
||||
# split the nspitem apart and continue with pieces that do not contain
|
||||
# the invalid point anymore. At the end, simply take one piece, otherwise two.
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class TFMError(exceptions.Exception): pass
|
|||
|
||||
class char_info_word:
|
||||
def __init__(self, word):
|
||||
self.width_index = int((word & 0xFF000000L) >> 24) #make sign-safe
|
||||
self.width_index = int((word & 0xFF000000) >> 24) #make sign-safe
|
||||
self.height_index = (word & 0x00F00000) >> 20
|
||||
self.depth_index = (word & 0x000F0000) >> 16
|
||||
self.italic_index = (word & 0x0000FC00) >> 10
|
||||
|
|
@ -135,10 +135,10 @@ class tfmfile:
|
|||
self.ne <= 256 and
|
||||
self.lf == 6+self.lh+(self.ec-self.bc+1)+self.nw+self.nh+self.nd
|
||||
+self.ni+self.nl+self.nk+self.ne+self.np):
|
||||
raise TFMError, "error in TFM pre-header"
|
||||
raise TFMError("error in TFM pre-header")
|
||||
|
||||
if debug:
|
||||
print "lh=%d" % self.lh
|
||||
print("lh=%d" % self.lh)
|
||||
|
||||
#
|
||||
# read header
|
||||
|
|
@ -160,9 +160,9 @@ class tfmfile:
|
|||
self.fontfamily = None
|
||||
|
||||
if debug:
|
||||
print "(FAMILY %s)" % self.fontfamily
|
||||
print "(CODINGSCHEME %s)" % self.charcoding
|
||||
print "(DESINGSIZE R %f)" % 16.0*self.designsize/16777216L
|
||||
print("(FAMILY %s)" % self.fontfamily)
|
||||
print("(CODINGSCHEME %s)" % self.charcoding)
|
||||
print("(DESINGSIZE R %f)" % 16.0*self.designsize/16777216)
|
||||
|
||||
if self.lh > 17:
|
||||
self.sevenbitsave = self.file.readuchar()
|
||||
|
|
@ -201,7 +201,7 @@ class tfmfile:
|
|||
|
||||
if self.lh > 18:
|
||||
# just ignore the rest
|
||||
print self.file.read((self.lh-18)*4)
|
||||
print(self.file.read((self.lh-18)*4))
|
||||
|
||||
#
|
||||
# read char_info
|
||||
|
|
@ -392,9 +392,9 @@ def readfontmap(filenames):
|
|||
if not (line=="" or line[0] in (" ", "%", "*", ";" , "#")):
|
||||
try:
|
||||
fm = fontmapping(line)
|
||||
except (RuntimeError, UnsupportedPSFragment), e:
|
||||
except (RuntimeError, UnsupportedPSFragment) as e:
|
||||
warnings.warn("Ignoring line %i in mapping file '%s': %s" % (lineno, mappath, e))
|
||||
except UnsupportedFontFormat, e:
|
||||
except UnsupportedFontFormat as e:
|
||||
pass
|
||||
else:
|
||||
fontmap[fm.texname] = fm
|
||||
|
|
@ -468,16 +468,16 @@ class font:
|
|||
|
||||
def __str__(self):
|
||||
return "font %s designed at %g TeX pts used at %g TeX pts" % (self.name,
|
||||
16.0*self.d/16777216L,
|
||||
16.0*self.q/16777216L)
|
||||
16.0*self.d/16777216,
|
||||
16.0*self.q/16777216)
|
||||
__repr__ = __str__
|
||||
|
||||
def getsize_pt(self):
|
||||
""" return size of font in (PS) points """
|
||||
# The factor 16L/16777216L=2**(-20) converts a fix_word (here self.q)
|
||||
# The factor 16/16777216=2**(-20) converts a fix_word (here self.q)
|
||||
# to the corresponding float. Furthermore, we have to convert from TeX
|
||||
# points to points, hence the factor 72/72.27.
|
||||
return 16L*self.q/16777216L*72/72.27
|
||||
return 16*self.q/16777216*72/72.27
|
||||
|
||||
def _convert_tfm_to_dvi(self, length):
|
||||
# doing the integer math with long integers will lead to different roundings
|
||||
|
|
@ -1269,7 +1269,7 @@ class vffile:
|
|||
# of the virtual font itself. Note that realscale has
|
||||
# to be a fix_word (like s)
|
||||
# XXX: check rounding
|
||||
reals = int(round(self.scale * (16*self.ds/16777216L) * s))
|
||||
reals = int(round(self.scale * (16*self.ds/16777216) * s))
|
||||
|
||||
# print ("defining font %s -- VF scale: %g, VF design size: %d, relative font size: %d => real size: %d" %
|
||||
# (fontname, self.scale, self.ds, s, reals)
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ class epsfile(canvas.canvasitem):
|
|||
try:
|
||||
epsfile=open(self.filename,"rb")
|
||||
except:
|
||||
raise IOError, "cannot open EPS file '%s'" % self.filename
|
||||
raise IOError("cannot open EPS file '%s'" % self.filename)
|
||||
|
||||
file.write("BeginEPSF\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -365,7 +365,9 @@ class AFMfile:
|
|||
else:
|
||||
raise AFMError("Unsupported key %s in kerning data section" % key)
|
||||
|
||||
def _processline_kernpairs(self, line, (direction, i)):
|
||||
def _processline_kernpairs(self, line, arg):
|
||||
direction = arg[0]
|
||||
i = arg[1]
|
||||
try:
|
||||
key, args = line.split(None, 1)
|
||||
except ValueError:
|
||||
|
|
@ -484,6 +486,6 @@ class AFMfile:
|
|||
|
||||
if __name__ == "__main__":
|
||||
a = AFMfile("/opt/local/share/texmf-dist/fonts/afm/yandy/lucida/lbc.afm")
|
||||
print a.charmetrics[0].name
|
||||
print(a.charmetrics[0].name)
|
||||
a = AFMfile("/usr/share/enscript/hv.afm")
|
||||
print a.charmetrics[32].name
|
||||
print(a.charmetrics[32].name)
|
||||
|
|
|
|||
|
|
@ -815,9 +815,9 @@ class T1font:
|
|||
elif 251 <= x <= 254: # mid size ints
|
||||
cmds.append(-((x - 251)*256) - code.pop(0) - 108)
|
||||
else: # x = 255, i.e. full size ints
|
||||
y = ((code.pop(0)*256l+code.pop(0))*256+code.pop(0))*256+code.pop(0)
|
||||
if y > (1l << 31):
|
||||
cmds.append(y - (1l << 32))
|
||||
y = ((code.pop(0)*256+code.pop(0))*256+code.pop(0))*256+code.pop(0)
|
||||
if y > (1 << 31):
|
||||
cmds.append(y - (1 << 32))
|
||||
else:
|
||||
cmds.append(y)
|
||||
return cmds
|
||||
|
|
@ -843,7 +843,7 @@ class T1font:
|
|||
code.append(b)
|
||||
else:
|
||||
if cmd < 0:
|
||||
cmd += 1l << 32
|
||||
cmd += 1 << 32
|
||||
cmd, x4 = divmod(cmd, 256)
|
||||
cmd, x3 = divmod(cmd, 256)
|
||||
x1, x2 = divmod(cmd, 256)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class exponential:
|
|||
skipexp1=None,
|
||||
nomantissaexp=r"{10^{%s}}",
|
||||
minusnomantissaexp=r"{-10^{%s}}",
|
||||
mantissamin=tick.rational((1, 1)), mantissamax=tick.rational((10L, 1)),
|
||||
mantissamin=tick.rational((1, 1)), mantissamax=tick.rational((10, 1)),
|
||||
skipmantissa1=0, skipallmantissa1=1,
|
||||
mantissatexter=decimal()):
|
||||
r"""initializes the instance
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class rational:
|
|||
if autolong:
|
||||
self.denom = 10 ** len(commaparts[1])
|
||||
else:
|
||||
self.denom = 10L ** len(commaparts[1])
|
||||
self.denom = 10 ** len(commaparts[1])
|
||||
neg = len(commaparts[0]) and commaparts[0][0] == "-"
|
||||
if neg:
|
||||
commaparts[0] = commaparts[0][1:]
|
||||
|
|
|
|||
|
|
@ -82,5 +82,5 @@ writer.writeToFile(gds_file_out)
|
|||
# inputPath = "./gdsFiles/arrayLayout.gds")
|
||||
|
||||
|
||||
print "LIB: %s" , gds_file_in
|
||||
print "\nCompleted ", gds_file_out
|
||||
print("LIB: %s" , gds_file_in)
|
||||
print("\nCompleted ", gds_file_out)
|
||||
|
|
|
|||
|
|
@ -95,5 +95,5 @@ writer.writeToFile(gds_file_out)
|
|||
# inputPath = "./gdsFiles/arrayLayout.gds")
|
||||
|
||||
|
||||
print "LIB: %s" % gds_file_in
|
||||
print "\nCompleted ", gds_file_out
|
||||
print("LIB: %s" % gds_file_in)
|
||||
print("\nCompleted ", gds_file_out)
|
||||
|
|
|
|||
Loading…
Reference in New Issue