Commit 006353b6 authored by Thomas Holder's avatar Thomas Holder

extensions 2to3: ne raise except has_key

parent e05b578f
...@@ -52,7 +52,7 @@ class ColorEffect(inkex.Effect): ...@@ -52,7 +52,7 @@ class ColorEffect(inkex.Effect):
if new_val != val: if new_val != val:
node.set(attr, new_val) node.set(attr, new_val)
if node.attrib.has_key('style'): if 'style' in node.attrib:
# References for style attribute: # References for style attribute:
# http://www.w3.org/TR/SVG11/styling.html#StyleAttribute, # http://www.w3.org/TR/SVG11/styling.html#StyleAttribute,
# http://www.w3.org/TR/CSS21/syndata.html # http://www.w3.org/TR/CSS21/syndata.html
...@@ -131,7 +131,7 @@ class ColorEffect(inkex.Effect): ...@@ -131,7 +131,7 @@ class ColorEffect(inkex.Effect):
for child in newnode: for child in newnode:
self.changeStyle(child) self.changeStyle(child)
xlink = inkex.addNS('href','xlink') xlink = inkex.addNS('href','xlink')
if newnode.attrib.has_key(xlink): if xlink in newnode.attrib:
href=newnode.get(xlink) href=newnode.get(xlink)
if href.startswith('#'): if href.startswith('#'):
id = href[len('#'):len(href)] id = href[len('#'):len(href)]
......
...@@ -66,10 +66,10 @@ class SplitIt(inkex.Effect): ...@@ -66,10 +66,10 @@ class SplitIt(inkex.Effect):
dashes = [] dashes = []
offset = 0 offset = 0
style = simplestyle.parseStyle(node.get('style')) style = simplestyle.parseStyle(node.get('style'))
if style.has_key('stroke-dasharray'): if 'stroke-dasharray' in style:
if style['stroke-dasharray'].find(',') > 0: if style['stroke-dasharray'].find(',') > 0:
dashes = [float (dash) for dash in style['stroke-dasharray'].split(',')] dashes = [float (dash) for dash in style['stroke-dasharray'].split(',')]
if style.has_key('stroke-dashoffset'): if 'stroke-dashoffset' in style:
offset = style['stroke-dashoffset'] offset = style['stroke-dashoffset']
if dashes: if dashes:
p = cubicsuperpath.parsePath(node.get('d')) p = cubicsuperpath.parsePath(node.get('d'))
......
...@@ -409,7 +409,7 @@ class DPISwitcher(inkex.Effect): ...@@ -409,7 +409,7 @@ class DPISwitcher(inkex.Effect):
namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) namedview = svg.find(inkex.addNS('namedview', 'sodipodi'))
namedview.set(inkex.addNS('document-units', 'inkscape'), "px") namedview.set(inkex.addNS('document-units', 'inkscape'), "px")
self.units = self.parse_length(svg.get('width'))[1] self.units = self.parse_length(svg.get('width'))[1]
if self.units and self.units <> "px" and self.units <> "" and self.units <> "%": if self.units and self.units != "px" and self.units != "" and self.units != "%":
if self.options.switcher == "0": if self.options.switcher == "0":
self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units]) self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units])
else: else:
......
...@@ -262,7 +262,7 @@ def export_DIMENSION(): ...@@ -262,7 +262,7 @@ def export_DIMENSION():
y = height - scale*(vals[groups['21']][0] - ymin) y = height - scale*(vals[groups['21']][0] - ymin)
size = 12 # default fontsize in px size = 12 # default fontsize in px
if vals[groups['3']]: if vals[groups['3']]:
if DIMTXT.has_key(vals[groups['3']][0]): if vals[groups['3']][0] in DIMTXT:
size = scale*DIMTXT[vals[groups['3']][0]] size = scale*DIMTXT[vals[groups['3']][0]]
if size < 2: if size < 2:
size = 2 size = 2
...@@ -428,7 +428,7 @@ else: ...@@ -428,7 +428,7 @@ else:
desc.text = '%s - scale = %f, origin = (%f, %f), method = %s' % (unicode(args[0], options.input_encode), scale, xmin, ymin, options.scalemethod) desc.text = '%s - scale = %f, origin = (%f, %f), method = %s' % (unicode(args[0], options.input_encode), scale, xmin, ymin, options.scalemethod)
scale *= 96.0/25.4 # convert from mm to pixels scale *= 96.0/25.4 # convert from mm to pixels
if not layer_nodes.has_key('0'): if '0' not in layer_nodes:
attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '0'} attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '0'}
layer_nodes['0'] = inkex.etree.SubElement(doc.getroot(), 'g', attribs) layer_nodes['0'] = inkex.etree.SubElement(doc.getroot(), 'g', attribs)
layer_colors['0'] = 7 layer_colors['0'] = 7
...@@ -454,7 +454,7 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): ...@@ -454,7 +454,7 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
inENTITIES = True inENTITIES = True
elif line[1] == 'POLYLINE': elif line[1] == 'POLYLINE':
polylines += 1 polylines += 1
if entity and groups.has_key(line[0]): if entity and line[0] in groups:
seqs.append(line[0]) # list of group codes seqs.append(line[0]) # list of group codes
if line[0] == '1' or line[0] == '2' or line[0] == '3' or line[0] == '6' or line[0] == '8': # text value if line[0] == '1' or line[0] == '2' or line[0] == '3' or line[0] == '6' or line[0] == '8': # text value
val = line[1].replace('\~', ' ') val = line[1].replace('\~', ' ')
...@@ -474,24 +474,24 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): ...@@ -474,24 +474,24 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
else: # unscaled float value else: # unscaled float value
val = float(line[1]) val = float(line[1])
vals[groups[line[0]]].append(val) vals[groups[line[0]]].append(val)
elif entities.has_key(line[1]): elif line[1] in entities:
if entities.has_key(entity): if entity in entities:
if block != defs: # in a BLOCK if block != defs: # in a BLOCK
layer = block layer = block
elif vals[groups['8']]: # use Common Layer Name elif vals[groups['8']]: # use Common Layer Name
if not vals[groups['8']][0]: if not vals[groups['8']][0]:
vals[groups['8']][0] = '0' # use default name vals[groups['8']][0] = '0' # use default name
if not layer_nodes.has_key(vals[groups['8']][0]): if vals[groups['8']][0] not in layer_nodes:
attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % vals[groups['8']][0]} attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % vals[groups['8']][0]}
layer_nodes[vals[groups['8']][0]] = inkex.etree.SubElement(doc.getroot(), 'g', attribs) layer_nodes[vals[groups['8']][0]] = inkex.etree.SubElement(doc.getroot(), 'g', attribs)
layer = layer_nodes[vals[groups['8']][0]] layer = layer_nodes[vals[groups['8']][0]]
color = '#000000' # default color color = '#000000' # default color
if vals[groups['8']]: if vals[groups['8']]:
if layer_colors.has_key(vals[groups['8']][0]): if vals[groups['8']][0] in layer_colors:
if colors.has_key(layer_colors[vals[groups['8']][0]]): if layer_colors[vals[groups['8']][0]] in colors:
color = colors[layer_colors[vals[groups['8']][0]]] color = colors[layer_colors[vals[groups['8']][0]]]
if vals[groups['62']]: # Common Color Number if vals[groups['62']]: # Common Color Number
if colors.has_key(vals[groups['62']][0]): if vals[groups['62']][0] in colors:
color = colors[vals[groups['62']][0]] color = colors[vals[groups['62']][0]]
style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none'}) style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none'})
w = 0.5 # default lineweight for POINT w = 0.5 # default lineweight for POINT
...@@ -502,7 +502,7 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): ...@@ -502,7 +502,7 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES):
w = 0.5 w = 0.5
style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none', 'stroke-width': '%.1f' % w}) style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none', 'stroke-width': '%.1f' % w})
if vals[groups['6']]: # Common Linetype if vals[groups['6']]: # Common Linetype
if linetypes.has_key(vals[groups['6']][0]): if vals[groups['6']][0] in linetypes:
style += ';' + linetypes[vals[groups['6']][0]] style += ';' + linetypes[vals[groups['6']][0]]
extrude = 1.0 extrude = 1.0
if vals[groups['230']]: if vals[groups['230']]:
......
...@@ -194,7 +194,7 @@ class MyEffect(inkex.Effect): ...@@ -194,7 +194,7 @@ class MyEffect(inkex.Effect):
style = node.get('style') style = node.get('style')
if style: if style:
style = simplestyle.parseStyle(style) style = simplestyle.parseStyle(style)
if style.has_key('stroke'): if 'stroke' in style:
if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url': if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url':
rgb = simplestyle.parseColor(style['stroke']) rgb = simplestyle.parseColor(style['stroke'])
hsl = coloreffect.ColorEffect.rgb_to_hsl(coloreffect.ColorEffect(),rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0) hsl = coloreffect.ColorEffect.rgb_to_hsl(coloreffect.ColorEffect(),rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0)
...@@ -286,7 +286,7 @@ class MyEffect(inkex.Effect): ...@@ -286,7 +286,7 @@ class MyEffect(inkex.Effect):
style = group.get('style') style = group.get('style')
if style: if style:
style = simplestyle.parseStyle(style) style = simplestyle.parseStyle(style)
if style.has_key('display'): if 'display' in style:
if style['display'] == 'none' and self.options.layer_option and self.options.layer_option=='visible': if style['display'] == 'none' and self.options.layer_option and self.options.layer_option=='visible':
return return
layer = group.get(inkex.addNS('label', 'inkscape')) layer = group.get(inkex.addNS('label', 'inkscape'))
......
...@@ -1325,7 +1325,7 @@ def csp_segment_convex_hull(sp1,sp2): ...@@ -1325,7 +1325,7 @@ def csp_segment_convex_hull(sp1,sp2):
if not (m1 and m2) and m3 : return [c,a,d] if not (m1 and m2) and m3 : return [c,a,d]
if not (m1 and m3) and m2 : return [b,c,d] if not (m1 and m3) and m2 : return [b,c,d]
raise ValueError, "csp_segment_convex_hull happened which is something that shouldn't happen!" raise ValueError("csp_segment_convex_hull happened which is something that shouldn't happen!")
################################################################################ ################################################################################
...@@ -1474,7 +1474,7 @@ def atan2(*arg): ...@@ -1474,7 +1474,7 @@ def atan2(*arg):
return (math.pi/2 - math.atan2(arg[0],arg[1]) ) % math.pi2 return (math.pi/2 - math.atan2(arg[0],arg[1]) ) % math.pi2
else : else :
raise ValueError, "Bad argumets for atan! (%s)" % arg raise ValueError("Bad argumets for atan! (%s)" % arg)
def get_text(node) : def get_text(node) :
value = None value = None
...@@ -2331,11 +2331,11 @@ def biarc(sp1, sp2, z1, z2, depth=0): ...@@ -2331,11 +2331,11 @@ def biarc(sp1, sp2, z1, z2, depth=0):
elif csmall and a!=0: beta = -b/a elif csmall and a!=0: beta = -b/a
elif not asmall: elif not asmall:
discr = b*b-4*a*c discr = b*b-4*a*c
if discr < 0: raise ValueError, (a,b,c,discr) if discr < 0: raise ValueError(a,b,c,discr)
disq = discr**.5 disq = discr**.5
beta1 = (-b - disq) / 2 / a beta1 = (-b - disq) / 2 / a
beta2 = (-b + disq) / 2 / a beta2 = (-b + disq) / 2 / a
if beta1*beta2 > 0 : raise ValueError, (a,b,c,disq,beta1,beta2) if beta1*beta2 > 0 : raise ValueError(a,b,c,disq,beta1,beta2)
beta = max(beta1, beta2) beta = max(beta1, beta2)
elif asmall and bsmall: elif asmall and bsmall:
return biarc_split(sp1, sp2, z1, z2, depth) return biarc_split(sp1, sp2, z1, z2, depth)
...@@ -2984,7 +2984,7 @@ class Polygon: ...@@ -2984,7 +2984,7 @@ class Polygon:
while len(edges)>0 : while len(edges)>0 :
poly = [] poly = []
if loops > len_edges : raise ValueError, "Hull error" if loops > len_edges : raise ValueError("Hull error")
loops+=1 loops+=1
# Find left most vertex. # Find left most vertex.
start = (1e100,1) start = (1e100,1)
...@@ -2995,7 +2995,7 @@ class Polygon: ...@@ -2995,7 +2995,7 @@ class Polygon:
loops1 = 0 loops1 = 0
while (last[1]!=start[0] or first_run) : while (last[1]!=start[0] or first_run) :
first_run = False first_run = False
if loops1 > len_edges : raise ValueError, "Hull error" if loops1 > len_edges : raise ValueError("Hull error")
loops1 += 1 loops1 += 1
next = get_closes_edge_by_angle(edges[last[1]],last) next = get_closes_edge_by_angle(edges[last[1]],last)
#draw_pointer(next[0]+next[1],"Green","line", comment=i, width= 1) #draw_pointer(next[0]+next[1],"Green","line", comment=i, width= 1)
...@@ -4894,11 +4894,11 @@ class Gcodetools(inkex.Effect): ...@@ -4894,11 +4894,11 @@ class Gcodetools(inkex.Effect):
elif csmall and a!=0: beta = -b/a elif csmall and a!=0: beta = -b/a
elif not asmall: elif not asmall:
discr = b*b-4*a*c discr = b*b-4*a*c
if discr < 0: raise ValueError, (a,b,c,discr) if discr < 0: raise ValueError(a,b,c,discr)
disq = discr**.5 disq = discr**.5
beta1 = (-b - disq) / 2 / a beta1 = (-b - disq) / 2 / a
beta2 = (-b + disq) / 2 / a beta2 = (-b + disq) / 2 / a
if beta1*beta2 > 0 : raise ValueError, (a,b,c,disq,beta1,beta2) if beta1*beta2 > 0 : raise ValueError(a,b,c,disq,beta1,beta2)
beta = max(beta1, beta2) beta = max(beta1, beta2)
elif asmall and bsmall: elif asmall and bsmall:
return biarc_split(sp1, sp2, z1, z2, depth) return biarc_split(sp1, sp2, z1, z2, depth)
...@@ -6359,7 +6359,7 @@ G01 Z1 (going to cutting z)\n""", ...@@ -6359,7 +6359,7 @@ G01 Z1 (going to cutting z)\n""",
time_ = l/feed time_ = l/feed
c1,c2 = self.graffiti_reference_points[layer][0][0],self.graffiti_reference_points[layer][1][0] c1,c2 = self.graffiti_reference_points[layer][0][0],self.graffiti_reference_points[layer][1][0]
d = math.sqrt( (c1[0]-c2[0])**2 + (c1[1]-c2[1])**2 ) d = math.sqrt( (c1[0]-c2[0])**2 + (c1[1]-c2[1])**2 )
if d == 0 : raise ValueError, "Error! Reference points should not be the same!" if d == 0 : raise ValueError("Error! Reference points should not be the same!")
for i in range(int(time_*emmit+1)) : for i in range(int(time_*emmit+1)) :
t = i/(time_*emmit) t = i/(time_*emmit)
r1,r2 = start[0]*(1-t) + end[0]*t, start[1]*(1-t) + end[1]*t r1,r2 = start[0]*(1-t) + end[0]*t, start[1]*(1-t) + end[1]*t
......
...@@ -183,14 +183,14 @@ class Pattern(inkex.Effect): ...@@ -183,14 +183,14 @@ class Pattern(inkex.Effect):
# link selected object to pattern # link selected object to pattern
obj = self.selected[self.options.ids[0]] obj = self.selected[self.options.ids[0]]
style = {} style = {}
if obj.attrib.has_key('style'): if 'style' in obj.attrib:
style = simplestyle.parseStyle(obj.attrib['style']) style = simplestyle.parseStyle(obj.attrib['style'])
style['fill'] = 'url(#%s)' % pattern.get('id') style['fill'] = 'url(#%s)' % pattern.get('id')
obj.attrib['style'] = simplestyle.formatStyle(style) obj.attrib['style'] = simplestyle.formatStyle(style)
if obj.tag == inkex.addNS('g', 'svg'): if obj.tag == inkex.addNS('g', 'svg'):
for node in obj: for node in obj:
style = {} style = {}
if node.attrib.has_key('style'): if 'style' in node.attrib:
style = simplestyle.parseStyle(node.attrib['style']) style = simplestyle.parseStyle(node.attrib['style'])
style['fill'] = 'url(#%s)' % pattern.get('id') style['fill'] = 'url(#%s)' % pattern.get('id')
node.attrib['style'] = simplestyle.formatStyle(style) node.attrib['style'] = simplestyle.formatStyle(style)
......
...@@ -189,7 +189,7 @@ class Grid_Polar(inkex.Effect): ...@@ -189,7 +189,7 @@ class Grid_Polar(inkex.Effect):
rmax*sin(angle), rmax*cos(angle), rmax*sin(angle), rmax*cos(angle),
self.options.a_subdivs_th, 'RadialMinorGridline'+str(i), grid) self.options.a_subdivs_th, 'RadialMinorGridline'+str(i), grid)
if self.options.c_dot_dia <> 0: #if a non-zero diameter, draw the centre dot if self.options.c_dot_dia != 0: #if a non-zero diameter, draw the centre dot
draw_SVG_circle(self.options.c_dot_dia /2.0, draw_SVG_circle(self.options.c_dot_dia /2.0,
0, 0, 0, '#000000', 'CentreDot', grid) 0, 0, 0, '#000000', 'CentreDot', grid)
......
...@@ -59,7 +59,7 @@ except Exception as inst: ...@@ -59,7 +59,7 @@ except Exception as inst:
exit(1) exit(1)
else: else:
type, value, traceback = sys.exc_info() type, value, traceback = sys.exc_info()
raise ValueError, ("", type, value), traceback raise ValueError("", type, value).with_traceback(traceback)
# issue warning if unknown commands where found # issue warning if unknown commands where found
if 'UNKNOWN_COMMANDS' in warnings: if 'UNKNOWN_COMMANDS' in warnings:
......
...@@ -58,7 +58,7 @@ class HpglOutput(inkex.Effect): ...@@ -58,7 +58,7 @@ class HpglOutput(inkex.Effect):
return return
else: else:
type, value, traceback = sys.exc_info() type, value, traceback = sys.exc_info()
raise ValueError, ("", type, value), traceback raise ValueError("", type, value).with_traceback(traceback)
# convert raw HPGL to HPGL # convert raw HPGL to HPGL
hpglInit = 'IN' hpglInit = 'IN'
if self.options.force > 0: if self.options.force > 0:
......
...@@ -152,7 +152,7 @@ class Interp(inkex.Effect): ...@@ -152,7 +152,7 @@ class Interp(inkex.Effect):
sst = copy.deepcopy(styles[sorted_ids[i-1]]) sst = copy.deepcopy(styles[sorted_ids[i-1]])
est = copy.deepcopy(styles[sorted_ids[i]]) est = copy.deepcopy(styles[sorted_ids[i]])
basestyle = copy.deepcopy(sst) basestyle = copy.deepcopy(sst)
if basestyle.has_key('stroke-width'): if 'stroke-width' in basestyle:
basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0) basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0)
#prepare for experimental style tweening #prepare for experimental style tweening
......
...@@ -59,7 +59,7 @@ class JessyInk_AutoTexts(inkex.Effect): ...@@ -59,7 +59,7 @@ class JessyInk_AutoTexts(inkex.Effect):
elif self.options.autoText == "numberOfSlides": elif self.options.autoText == "numberOfSlides":
nodes[0].set("{" + inkex.NSS["jessyink"] + "}autoText","numberOfSlides") nodes[0].set("{" + inkex.NSS["jessyink"] + "}autoText","numberOfSlides")
else: else:
if nodes[0].attrib.has_key("{" + inkex.NSS["jessyink"] + "}autoText"): if "{" + inkex.NSS["jessyink"] + "}autoText" in nodes[0].attrib:
del nodes[0].attrib["{" + inkex.NSS["jessyink"] + "}autoText"] del nodes[0].attrib["{" + inkex.NSS["jessyink"] + "}autoText"]
# Create effect instance # Create effect instance
......
...@@ -55,19 +55,19 @@ class JessyInk_Effects(inkex.Effect): ...@@ -55,19 +55,19 @@ class JessyInk_Effects(inkex.Effect):
if (self.options.effectIn == "appear") or (self.options.effectIn == "fade") or (self.options.effectIn == "pop"): if (self.options.effectIn == "appear") or (self.options.effectIn == "fade") or (self.options.effectIn == "pop"):
node.set("{" + inkex.NSS["jessyink"] + "}effectIn","name:" + self.options.effectIn + ";order:" + self.options.effectInOrder + ";length:" + str(int(self.options.effectInDuration * 1000))) node.set("{" + inkex.NSS["jessyink"] + "}effectIn","name:" + self.options.effectIn + ";order:" + self.options.effectInOrder + ";length:" + str(int(self.options.effectInDuration * 1000)))
# Remove possible view argument. # Remove possible view argument.
if node.attrib.has_key("{" + inkex.NSS["jessyink"] + "}view"): if "{" + inkex.NSS["jessyink"] + "}view" in node.attrib:
del node.attrib["{" + inkex.NSS["jessyink"] + "}view"] del node.attrib["{" + inkex.NSS["jessyink"] + "}view"]
else: else:
if node.attrib.has_key("{" + inkex.NSS["jessyink"] + "}effectIn"): if "{" + inkex.NSS["jessyink"] + "}effectIn" in node.attrib:
del node.attrib["{" + inkex.NSS["jessyink"] + "}effectIn"] del node.attrib["{" + inkex.NSS["jessyink"] + "}effectIn"]
if (self.options.effectOut == "appear") or (self.options.effectOut == "fade") or (self.options.effectOut == "pop"): if (self.options.effectOut == "appear") or (self.options.effectOut == "fade") or (self.options.effectOut == "pop"):
node.set("{" + inkex.NSS["jessyink"] + "}effectOut","name:" + self.options.effectOut + ";order:" + self.options.effectOutOrder + ";length:" + str(int(self.options.effectOutDuration * 1000))) node.set("{" + inkex.NSS["jessyink"] + "}effectOut","name:" + self.options.effectOut + ";order:" + self.options.effectOutOrder + ";length:" + str(int(self.options.effectOutDuration * 1000)))
# Remove possible view argument. # Remove possible view argument.
if node.attrib.has_key("{" + inkex.NSS["jessyink"] + "}view"): if "{" + inkex.NSS["jessyink"] + "}view" in node.attrib:
del node.attrib["{" + inkex.NSS["jessyink"] + "}view"] del node.attrib["{" + inkex.NSS["jessyink"] + "}view"]
else: else:
if node.attrib.has_key("{" + inkex.NSS["jessyink"] + "}effectOut"): if "{" + inkex.NSS["jessyink"] + "}effectOut" in node.attrib:
del node.attrib["{" + inkex.NSS["jessyink"] + "}effectOut"] del node.attrib["{" + inkex.NSS["jessyink"] + "}effectOut"]
# Create effect instance # Create effect instance
......
...@@ -53,7 +53,7 @@ def dictToPropStr(dictio): ...@@ -53,7 +53,7 @@ def dictToPropStr(dictio):
def setStyle(node, propKey, propValue): def setStyle(node, propKey, propValue):
props = {} props = {}
if node.attrib.has_key("style"): if "style" in node.attrib:
props = propStrToDict(node.get("style")) props = propStrToDict(node.get("style"))
props[propKey] = propValue props[propKey] = propValue
......
...@@ -97,7 +97,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -97,7 +97,7 @@ class JessyInk_Summary(inkex.Effect):
if transitionInAttribute: if transitionInAttribute:
transInDict = propListToDict(propStrToList(transitionInAttribute)) transInDict = propListToDict(propStrToList(transitionInAttribute))
if (transInDict["name"] != "appear") and transInDict.has_key("length"): if (transInDict["name"] != "appear") and "length" in transInDict:
inkex.errormsg(_("{0}Transition in: {1} ({2!s} s)").format(prefix, transInDict["name"], int(transInDict["length"]) / 1000.0)) inkex.errormsg(_("{0}Transition in: {1} ({2!s} s)").format(prefix, transInDict["name"], int(transInDict["length"]) / 1000.0))
else: else:
inkex.errormsg(_("{0}Transition in: {1}").format(prefix, transInDict["name"])) inkex.errormsg(_("{0}Transition in: {1}").format(prefix, transInDict["name"]))
...@@ -106,7 +106,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -106,7 +106,7 @@ class JessyInk_Summary(inkex.Effect):
if transitionOutAttribute: if transitionOutAttribute:
transOutDict = propListToDict(propStrToList(transitionOutAttribute)) transOutDict = propListToDict(propStrToList(transitionOutAttribute))
if (transOutDict["name"] != "appear") and transOutDict.has_key("length"): if (transOutDict["name"] != "appear") and "length" in transOutDict:
inkex.errormsg(_("{0}Transition out: {1} ({2!s} s)").format(prefix, transOutDict["name"], int(transOutDict["length"]) / 1000.0)) inkex.errormsg(_("{0}Transition out: {1} ({2!s} s)").format(prefix, transOutDict["name"], int(transOutDict["length"]) / 1000.0))
else: else:
inkex.errormsg(_("{0}Transition out: {1}").format(prefix, transOutDict["name"])) inkex.errormsg(_("{0}Transition out: {1}").format(prefix, transOutDict["name"]))
...@@ -130,7 +130,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -130,7 +130,7 @@ class JessyInk_Summary(inkex.Effect):
dictio["id"] = effectNode.get("id") dictio["id"] = effectNode.get("id")
dictio["type"] = "effect" dictio["type"] = "effect"
if not effects.has_key(dictio["order"]): if dictio["order"] not in effects:
effects[dictio["order"]] = [] effects[dictio["order"]] = []
effects[dictio["order"]].append(dictio) effects[dictio["order"]].append(dictio)
...@@ -141,7 +141,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -141,7 +141,7 @@ class JessyInk_Summary(inkex.Effect):
dictio["id"] = effectNode.get("id") dictio["id"] = effectNode.get("id")
dictio["type"] = "effect" dictio["type"] = "effect"
if not effects.has_key(dictio["order"]): if dictio["order"] not in effects:
effects[dictio["order"]] = [] effects[dictio["order"]] = []
effects[dictio["order"]].append(dictio) effects[dictio["order"]].append(dictio)
...@@ -151,7 +151,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -151,7 +151,7 @@ class JessyInk_Summary(inkex.Effect):
dictio["id"] = viewNode.get("id") dictio["id"] = viewNode.get("id")
dictio["type"] = "view" dictio["type"] = "view"
if not effects.has_key(dictio["order"]): if dictio["order"] not in effects:
effects[dictio["order"]] = [] effects[dictio["order"]] = []
effects[dictio["order"]].append(dictio) effects[dictio["order"]].append(dictio)
...@@ -182,7 +182,7 @@ class JessyInk_Summary(inkex.Effect): ...@@ -182,7 +182,7 @@ class JessyInk_Summary(inkex.Effect):
if item["name"] != "appear": if item["name"] != "appear":
tmpStr += _(" using effect \"{0}\"").format(item["name"]) tmpStr += _(" using effect \"{0}\"").format(item["name"])
if item.has_key("length"): if "length" in item:
tmpStr += _(" in {0!s} s").format(int(item["length"]) / 1000.0) tmpStr += _(" in {0!s} s").format(int(item["length"]) / 1000.0)
inkex.errormsg(tmpStr + ".\n") inkex.errormsg(tmpStr + ".\n")
......
...@@ -86,15 +86,15 @@ def findInternalLinks(node, docRoot, nodeDict = {}): ...@@ -86,15 +86,15 @@ def findInternalLinks(node, docRoot, nodeDict = {}):
for entry in re.findall("url\(#.*\)", etree.tostring(node)): for entry in re.findall("url\(#.*\)", etree.tostring(node)):
linkId = entry[5:len(entry) - 1] linkId = entry[5:len(entry) - 1]
if not nodeDict.has_key(linkId): if linkId not in nodeDict:
nodeDict[linkId] = deepcopy(docRoot.xpath("//*[@id='" + linkId + "']", namespaces=inkex.NSS)[0]) nodeDict[linkId] = deepcopy(docRoot.xpath("//*[@id='" + linkId + "']", namespaces=inkex.NSS)[0])
nodeDict = findInternalLinks(nodeDict[linkId], docRoot, nodeDict) nodeDict = findInternalLinks(nodeDict[linkId], docRoot, nodeDict)
for entry in node.iter(): for entry in node.iter():
if entry.attrib.has_key('{' + inkex.NSS['xlink'] + '}href'): if '{' + inkex.NSS['xlink'] + '}href' in entry.attrib:
linkId = entry.attrib['{' + inkex.NSS['xlink'] + '}href'][1:len(entry.attrib['{' + inkex.NSS['xlink'] + '}href'])] linkId = entry.attrib['{' + inkex.NSS['xlink'] + '}href'][1:len(entry.attrib['{' + inkex.NSS['xlink'] + '}href'])]
if not nodeDict.has_key(linkId): if linkId not in nodeDict:
nodeDict[linkId] = deepcopy(docRoot.xpath("//*[@id='" + linkId + "']", namespaces=inkex.NSS)[0]) nodeDict[linkId] = deepcopy(docRoot.xpath("//*[@id='" + linkId + "']", namespaces=inkex.NSS)[0])
nodeDict = findInternalLinks(nodeDict[linkId], docRoot, nodeDict) nodeDict = findInternalLinks(nodeDict[linkId], docRoot, nodeDict)
...@@ -112,7 +112,7 @@ def getNewId(prefix, docRoot): ...@@ -112,7 +112,7 @@ def getNewId(prefix, docRoot):
def deleteIds(node): def deleteIds(node):
for entry in node.iter(): for entry in node.iter():
if entry.attrib.has_key('id'): if 'id' in entry.attrib:
del entry.attrib['id'] del entry.attrib['id']
# Create effect instance # Create effect instance
......
...@@ -90,13 +90,13 @@ class JessyInk_Effects(inkex.Effect): ...@@ -90,13 +90,13 @@ class JessyInk_Effects(inkex.Effect):
rect.set("{" + inkex.NSS["jessyink"] + "}view","name:view;order:" + self.options.viewOrder + ";length:" + str(int(self.options.viewDuration * 1000))) rect.set("{" + inkex.NSS["jessyink"] + "}view","name:view;order:" + self.options.viewOrder + ";length:" + str(int(self.options.viewDuration * 1000)))
# Remove possible effect arguments. # Remove possible effect arguments.
if rect.attrib.has_key("{" + inkex.NSS["jessyink"] + "}effectIn"): if "{" + inkex.NSS["jessyink"] + "}effectIn" in rect.attrib:
del rect.attrib["{" + inkex.NSS["jessyink"] + "}effectIn"] del rect.attrib["{" + inkex.NSS["jessyink"] + "}effectIn"]
if rect.attrib.has_key("{" + inkex.NSS["jessyink"] + "}effectOut"): if "{" + inkex.NSS["jessyink"] + "}effectOut" in rect.attrib:
del rect.attrib["{" + inkex.NSS["jessyink"] + "}effectOut"] del rect.attrib["{" + inkex.NSS["jessyink"] + "}effectOut"]
else: else:
if node.attrib.has_key("{" + inkex.NSS["jessyink"] + "}view"): if "{" + inkex.NSS["jessyink"] + "}view" in node.attrib:
del node.attrib["{" + inkex.NSS["jessyink"] + "}view"] del node.attrib["{" + inkex.NSS["jessyink"] + "}view"]
# Create effect instance # Create effect instance
......
...@@ -123,7 +123,7 @@ class MyEffect(inkex.Effect): ...@@ -123,7 +123,7 @@ class MyEffect(inkex.Effect):
stroke = "none"; stroke = "none";
for mprop in mprops: for mprop in mprops:
if style.has_key(mprop) and style[mprop] != 'none'and style[mprop][:5] == 'url(#': if mprop in style and style[mprop] != 'none'and style[mprop][:5] == 'url(#':
marker_id = style[mprop][5:-1] marker_id = style[mprop][5:-1]
try: try:
......
...@@ -56,7 +56,7 @@ class Style(dict): ...@@ -56,7 +56,7 @@ class Style(dict):
def add(self, c, el): def add(self, c, el):
self.total.append( (c, el) ) self.total.append( (c, el) )
for name,value in c.iteritems(): for name,value in c.iteritems():
if not self.has_key(name): if name not in self:
self[name] = value self[name] = value
if self[name] == value: if self[name] == value:
self.weights[name] += 1 self.weights[name] += 1
...@@ -76,7 +76,7 @@ class Style(dict): ...@@ -76,7 +76,7 @@ class Style(dict):
def __eq__(self, o): def __eq__(self, o):
"""Not equals, prefer to overload 'in' but that doesn't seem possible""" """Not equals, prefer to overload 'in' but that doesn't seem possible"""
for arg in self.keys(): for arg in self.keys():
if o.has_key(arg) and self[arg] != o[arg]: if arg in o and self[arg] != o[arg]: