Commit a46a6caf authored by Thomas Holder's avatar Thomas Holder

extensions 2to3: dict

parent 9fcc4c63
......@@ -82,7 +82,7 @@ class SplitIt(inkex.Effect):
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
p = cubicsuperpath.parsePath(node.get('d'))
......
......@@ -32,7 +32,7 @@ class CharDataEffect(inkex.Effect):
if len(self.selected)==0:
self.recurse(self.document.getroot())
else:
for id,node in self.selected.iteritems():
for id,node in self.selected.items():
self.recurse(node)
def recurse(self,node):
......
......@@ -36,7 +36,7 @@ class ColorEffect(inkex.Effect):
if len(self.selected)==0:
self.getAttribs(self.document.getroot())
else:
for id,node in self.selected.iteritems():
for id,node in self.selected.items():
self.getAttribs(node)
def getAttribs(self,node):
......
......@@ -52,7 +52,7 @@ class SplitIt(inkex.Effect):
self.not_converted = []
def effect(self):
for i, node in self.selected.iteritems():
for i, node in self.selected.items():
self.convert2dash(node)
if len(self.not_converted):
inkex.errormsg(_('Total number of objects not converted: {}\n').format(len(self.not_converted)))
......
......@@ -171,7 +171,7 @@ class Dimension(pathmodifier.PathModifier):
line.set('stroke-width', str(0.5*scale))
group.append(line)
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
group.append(node)
layer.append(group)
......
......@@ -46,7 +46,7 @@ class Dots(inkex.Effect):
def effect(self):
selection = self.selected
if (selection):
for id, node in selection.iteritems():
for id, node in selection.items():
if node.tag == inkex.addNS('path','svg'):
self.addDot(node)
else:
......
......@@ -237,9 +237,9 @@ class DPISwitcher(inkex.Effect):
def parse_length(self, length, percent=False):
"""Parse SVG length."""
if self.options.switcher == "0": # dpi90to96
known_units = self.__uuconvLegacy.keys()
known_units = list(self.__uuconvLegacy.keys())
else: # dpi96to90
known_units = self.__uuconv.keys()
known_units = list(self.__uuconv.keys())
if percent:
unitmatch = re.compile('(%s)$' % '|'.join(known_units + ['%']))
else:
......
......@@ -316,7 +316,7 @@ class Draw_From_Triangle(inkex.Effect):
so = self.options #shorthand
pts = [] #initialise in case nothing is selected and following loop is not executed
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
pts = get_n_points_from_path( node, 3 ) #find the (x,y) coordinates of the first 3 points of the path
......
......@@ -72,7 +72,7 @@ class Edge3d(inkex.Effect):
for the current shade. shade is a floating point 0-1 white-black"""
# size of a wedge for shade i, wedges come in pairs
delta = 360. / self.options.shades / 2.
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = simplepath.parsePath(d)
......
......@@ -51,7 +51,7 @@ class Embedder(inkex.Effect):
self.document=document
self.selected=selected
if (self.options.ids):
for id, node in selected.iteritems():
for id, node in selected.items():
if node.tag == inkex.addNS('image','svg'):
self.embedImage(node)
......
......@@ -44,7 +44,7 @@ class MyEffect(inkex.Effect):
path = self.options.filepath
if (path != ''):
if (self.options.ids):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('image','svg'):
xlink = node.get(inkex.addNS('href','xlink'))
if (xlink[:4]=='data'):
......
......@@ -35,7 +35,7 @@ class Extrude(inkex.Effect):
def effect(self):
paths = []
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == '{http://www.w3.org/2000/svg}path':
paths.append(node)
if len(paths) < 2:
......
......@@ -26,7 +26,7 @@ class MyEffect(inkex.Effect):
dest="flat", default=10.0,
help="Minimum flatness of the subdivided curves")
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = cubicsuperpath.parsePath(d)
......
......@@ -55,7 +55,7 @@ class PathFractalize(inkex.Effect):
dest="smooth", default="4.0",
help="Smoothness of the subdivision")
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = simplepath.parsePath(d)
......
......@@ -251,7 +251,7 @@ class FuncPlot(inkex.Effect):
def effect(self):
newpath = None
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('rect','svg'):
# create new path with basic dimensions of selected rectangle
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
......
......@@ -3018,7 +3018,7 @@ class Polygon:
self.polygon += [ poly ]
# Remove all edges that are intersects new poly (any vertex inside new poly)
poly_ = Polygon([poly])
for p in edges.keys()[:] :
for p in list(edges.keys()) :
if poly_.point_inside(list(p)) : del edges[p]
self.draw(color="Green", width=1)
......@@ -4545,7 +4545,7 @@ class Gcodetools(inkex.Effect):
self.check_dir()
gcode = ""
biarc_group = inkex.etree.SubElement( self.selected_paths.keys()[0] if len(self.selected_paths.keys())>0 else self.layers[0], inkex.addNS('g','svg') )
biarc_group = inkex.etree.SubElement( list(self.selected_paths.keys())[0] if len(self.selected_paths)>0 else self.layers[0], inkex.addNS('g','svg') )
print_(("self.layers=",self.layers))
print_(("paths=",paths))
colors = {}
......@@ -6038,7 +6038,7 @@ G01 Z1 (going to cutting z)\n""",
else :
paths = self.selected_paths
# Set group
group = inkex.etree.SubElement( self.selected_paths.keys()[0] if len(self.selected_paths.keys())>0 else self.layers[0], inkex.addNS('g','svg') )
group = inkex.etree.SubElement( list(self.selected_paths.keys())[0] if len(self.selected_paths)>0 else self.layers[0], inkex.addNS('g','svg') )
trans_ = [[1,0.3,0],[0,0.5,0]]
self.set_markers()
......
......@@ -20,7 +20,7 @@ import inkex, simplepath, simplestyle
class Handles(inkex.Effect):
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
p = simplepath.parsePath(node.get('d'))
a =[]
......
......@@ -105,13 +105,13 @@ class SetAttrImage(inkex.Effect):
def change_selected_only(self, selected, attribute):
if selected:
for node_id, node in selected.iteritems():
for node_id, node in selected.items():
if node.tag == inkex.addNS('image', 'svg'):
self.change_attribute(node, attribute)
def change_in_selection(self, selected, attribute):
if selected:
for node_id, node in selected.iteritems():
for node_id, node in selected.items():
self.change_all_images(node, attribute)
def change_in_document(self, selected, attribute):
......@@ -119,7 +119,7 @@ class SetAttrImage(inkex.Effect):
def change_on_parent_group(self, selected, attribute):
if selected:
for node_id, node in selected.iteritems():
for node_id, node in selected.items():
self.change_attribute(node.getparent(), attribute)
def change_on_root_only(self, selected, attribute):
......
......@@ -19,7 +19,7 @@ class FollowLink(inkex.Effect):
def effect(self):
if (self.options.ids):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('a','svg'):
self.url = node.get(inkex.addNS('href','xlink'))
vwswli = VisitWebSiteWithoutLockingInkscape(self.url)
......
......@@ -134,7 +134,7 @@ class Interp(inkex.Effect):
if self.options.zsort:
# work around selection order swapping with Live Preview
sorted_ids = pathmodifier.zSort(self.document.getroot(),self.selected.keys())
sorted_ids = pathmodifier.zSort(self.document.getroot(),list(self.selected.keys()))
else:
# use selection order (default)
sorted_ids = self.options.ids
......@@ -209,9 +209,9 @@ class Interp(inkex.Effect):
t += l / etotal
lengths.setdefault(t,0)
lengths[t] += -1
sadd = [k for (k,v) in lengths.iteritems() if v < 0]
sadd = [k for (k,v) in lengths.items() if v < 0]
sadd.sort()
eadd = [k for (k,v) in lengths.iteritems() if v > 0]
eadd = [k for (k,v) in lengths.items() if v > 0]
eadd.sort()
t = 0
......
......@@ -121,7 +121,7 @@ class InterpAttG(inkex.Effect):
if len( self.selected ) > 1:
# multiple selection
if self.options.zsort:
sorted_ids = zSort(self.document.getroot(),self.selected.keys())
sorted_ids = zSort(self.document.getroot(),list(self.selected.keys()))
else:
sorted_ids = self.options.ids
self.collection = list(sorted_ids)
......
......@@ -83,7 +83,7 @@ class JitterNodes(inkex.Effect):
help="The selected UI-tab when OK was pressed")
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = cubicsuperpath.parsePath(d)
......
......@@ -217,7 +217,7 @@ class MyEffect(inkex.Effect):
def effect(self):
found=0
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('flowRoot','svg'):
found+=1
if found==1:
......
......@@ -74,7 +74,7 @@ class MyEffect(inkex.Effect):
if defs == None:
defs = inkex.etree.SubElement(self.document.getroot(),inkex.addNS('defs','svg'))
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
mprops = ['marker','marker-start','marker-mid','marker-end']
try:
style = simplestyle.parseStyle(node.get('style'))
......
......@@ -227,7 +227,7 @@ class Length(inkex.Effect):
self.options.fontsize /= factor
factor *= scale/self.unittouu('1'+self.options.unit)
# loop over all selected paths
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
mat = simpletransform.composeParents(node, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
p = cubicsuperpath.parsePath(node.get('d'))
......
......@@ -38,7 +38,7 @@ class Style(dict):
self[name.strip()] = value.strip()
def entries(self):
return [ "%s:%s;" % (n,v) for (n,v) in self.iteritems() ]
return [ "%s:%s;" % (n,v) for (n,v) in self.items() ]
def to_str(self, sep="\n "):
return " " + "\n ".join(self.entries())
......@@ -55,7 +55,7 @@ class Style(dict):
def add(self, c, el):
self.total.append( (c, el) )
for name,value in c.iteritems():
for name,value in c.items():
if name not in self:
self[name] = value
if self[name] == value:
......@@ -63,7 +63,7 @@ class Style(dict):
def clean(self, threshold):
"""Removes any elements that aren't the same using a weighted threshold"""
for attr in self.keys():
for attr in list(self.keys()):
if self.weights[attr] < len(self.total) - threshold:
self.pop(attr)
......@@ -119,7 +119,7 @@ class MergeStyles(inkex.Effect):
styles.text = (styles.text or "") + "\n" + common.css( newclass )
for (st, el) in common.all_matches():
st.remove(common.keys())
st.remove(list(common.keys()))
el.attrib['style'] = st.to_str("")
olds = 'class' in el.attrib and el.attrib['class'].split() or []
......
......@@ -59,7 +59,7 @@ class Motion(inkex.Effect):
def effect(self):
self.vx = math.cos(math.radians(self.options.angle))*self.options.magnitude
self.vy = math.sin(math.radians(self.options.angle))*self.options.magnitude
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
group = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))
self.facegroup = inkex.etree.SubElement(group, inkex.addNS('g','svg'))
......
......@@ -51,7 +51,7 @@ class NewGlyphLayer(inkex.Effect):
#TODO: make it optional ("Use current selection as template glyph")
# Move selection to the newly created layer
for id,node in self.selected.iteritems():
for id,node in self.selected.items():
layer.append(node)
if __name__ == '__main__':
......
......@@ -198,7 +198,7 @@ class ParamCurves(inkex.Effect):
help="dummy")
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('rect','svg'):
# create new path with basic dimensions of selected rectangle
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
......
......@@ -232,7 +232,7 @@ class PathAlongPath(pathmodifier.Diffeo):
if dx < 0.01:
exit(_("The total length of the pattern is too small :\nPlease choose a larger object or set 'Space between copies' > 0"))
for id, node in self.patterns.iteritems():
for id, node in self.patterns.items():
if node.tag == inkex.addNS('path','svg') or node.tag=='path':
d = node.get('d')
p0 = cubicsuperpath.parsePath(d)
......@@ -240,7 +240,7 @@ class PathAlongPath(pathmodifier.Diffeo):
flipxy(p0)
newp=[]
for skelnode in self.skeletons.itervalues():
for skelnode in self.skeletons.values():
self.curSekeleton=cubicsuperpath.parsePath(skelnode.get('d'))
if self.options.vertical:
flipxy(self.curSekeleton)
......
......@@ -65,7 +65,7 @@ class PathModifier(inkex.Effect):
def duplicateNodes(self, aList):
clones={}
for id,node in aList.iteritems():
for id,node in aList.items():
clone=copy.deepcopy(node)
#!!!--> should it be given an id?
#seems to work without this!?!
......@@ -82,7 +82,7 @@ class PathModifier(inkex.Effect):
return(id)
def expandGroups(self,aList,transferTransform=True):
for id, node in aList.items():
for id, node in list(aList.items()):
if node.tag == inkex.addNS('g','svg') or node.tag=='g':
mat=parseTransform(node.get("transform"))
for child in node:
......@@ -95,7 +95,7 @@ class PathModifier(inkex.Effect):
return(aList)
def expandGroupsUnlinkClones(self,aList,transferTransform=True,doReplace=True):
for id in aList.keys()[:]:
for id in list(aList.keys()):
node=aList[id]
if node.tag == inkex.addNS('g','svg') or node.tag=='g':
self.expandGroups(aList,transferTransform)
......@@ -223,7 +223,7 @@ class PathModifier(inkex.Effect):
return(self.groupToPath(node,doReplace))
elif node.tag == inkex.addNS('path','svg') or node.tag == 'path':
#remove inkscape attributes, otherwise any modif of 'd' will be discarded!
for attName in node.attrib.keys():
for attName in list(node.attrib.keys()):
if ("sodipodi" in attName) or ("inkscape" in attName):
del node.attrib[attName]
fuseTransform(node)
......@@ -237,7 +237,7 @@ class PathModifier(inkex.Effect):
def objectsToPaths(self,aList,doReplace=True):
newSelection={}
for id,node in aList.items():
for id,node in list(aList.items()):
newnode=self.objectToPath(node,doReplace)
del aList[id]
aList[newnode.get('id')]=newnode
......@@ -253,7 +253,7 @@ class PathModifier(inkex.Effect):
#self.expandGroupsUnlinkClones(self.selected, True)
self.objectsToPaths(self.selected, True)
self.bbox=computeBBox(self.selected.values())
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = cubicsuperpath.parsePath(d)
......@@ -298,7 +298,7 @@ class Diffeo(PathModifier):
self.expandGroups(self.selected, True)
self.objectsToPaths(self.selected, True)
self.bbox=computeBBox(self.selected.values())
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path','svg') or node.tag=='path':
d = node.get('d')
p = cubicsuperpath.parsePath(d)
......
......@@ -168,7 +168,7 @@ class PathScatter(pathmodifier.Diffeo):
if self.options.copymode=="copy":
duplist=self.duplicateNodes({id:self.patternNode})
self.patternNode = duplist.values()[0]
self.patternNode = list(duplist.values())[0]
#TODO: allow 4th option: duplicate the first copy and clone the next ones.
if "%s"%self.options.copymode=="clone":
......@@ -251,7 +251,7 @@ class PathScatter(pathmodifier.Diffeo):
#inkex.debug(patternList)
counter=0
for skelnode in self.skeletons.itervalues():
for skelnode in self.skeletons.values():
self.curSekeleton=cubicsuperpath.parsePath(skelnode.get('d'))
for comp in self.curSekeleton:
self.skelcomp,self.lengths=linearize(comp)
......
......@@ -496,7 +496,7 @@ class PixelSnapEffect(inkex.Effect):
self.document_offset = self.unittouu(svg.attrib['height']) % 1 # although SVG units are absolute, the elements are positioned relative to the top of the page, rather than zero
for id, elem in self.selected.iteritems():
for id, elem in self.selected.items():
try:
self.pixel_snap(elem)
except TransformError as e:
......
......@@ -187,7 +187,7 @@ class ReplaceFont(inkex.Effect):
to_return = []
if scope == "selection_only":
self.selected_items = []
for item in self.selected.iteritems():
for item in self.selected.items():
self.find_child_text_items(item[1])
items = self.selected_items
if len(items) == 0:
......
......@@ -118,13 +118,13 @@ class Restack(inkex.Effect):
f.close
#find the center of all selected objects **Not the average!
x,y,w,h = dimen[objects.keys()[0]]
x,y,w,h = dimen[list(objects.keys())[0]]
minx = x
miny = y
maxx = x + w
maxy = y + h
for id, node in objects.iteritems():
for id, node in objects.items():
# get the bounding box
x,y,w,h = dimen[id]
if x < minx:
......@@ -140,7 +140,7 @@ class Restack(inkex.Effect):
midy = (miny + maxy) / 2
#calculate distances for each selected object
for id, node in objects.iteritems():
for id, node in objects.items():
# get the bounding box
x,y,w,h = dimen[id]
......@@ -194,7 +194,7 @@ class Restack(inkex.Effect):
objects.append(child)
else:
parentnode = self.current_layer
for id_ in zSort(self.document.getroot(), self.selected.keys()):
for id_ in zSort(self.document.getroot(), list(self.selected.keys())):
objects.append(self.selected[id_])
if self.options.zsort == "rev":
objects.reverse()
......
......@@ -180,7 +180,7 @@ def parseStyle(s):
def formatStyle(a):
"""Format an inline style attribute from a dictionary"""
return ";".join([att+":"+str(val) for att,val in a.iteritems()])
return ";".join([att+":"+str(val) for att,val in a.items()])
def isColor(c):
"""Determine if its a color we can use. If not, leave it unchanged."""
......
......@@ -194,7 +194,7 @@ class Split(inkex.Effect):
preserve = self.options.preserve
#checks if the selected elements are text nodes
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if not (node.tag == inkex.addNS("text", "svg") or node.tag == inkex.addNS("flowRoot", "svg")):
inkex.debug("Please select only text elements.")
break
......
......@@ -38,7 +38,7 @@ class SegmentStraightener(inkex.Effect):
dest="behave", default=1,
help="straightening behavior for cubic segments")
def effect(self):
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
if node.tag == inkex.addNS('path', 'svg'):
d = node.get('d')
p = simplepath.parsePath(d)
......
......@@ -195,7 +195,7 @@ blend_method_names = {
19 : "alpha over" #deprecated
}
blend_methods = dict((v, k) for (k, v) in blend_method_names.iteritems())
blend_methods = dict((v, k) for (k, v) in blend_method_names.items())
###### Functions ##########################################
def paramType(layer, param, value=None):
......
......@@ -91,13 +91,13 @@ class Extract(inkex.Effect):
f.close
#find the center of all selected objects **Not the average!
x,y,w,h = dimen[self.selected.keys()[0]]
x,y,w,h = dimen[list(self.selected.keys())[0]]
minx = x
miny = y
maxx = x + w
maxy = y + h
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
# get the bounding box
x,y,w,h = dimen[id]
if x < minx:
......@@ -113,7 +113,7 @@ class Extract(inkex.Effect):
midy = (miny + maxy) / 2
#calculate distances for each selected object
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
# get the bounding box
x,y,w,h = dimen[id]
......
......@@ -99,13 +99,13 @@ class Merge(inkex.Effect):
f.close
#find the center of all selected objects **Not the average!
x,y,w,h = dimen[self.selected.keys()[0]]
x,y,w,h = dimen[list(self.selected.keys())[0]]
minx = x
miny = y
maxx = x + w
maxy = y + h
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
# get the bounding box
x,y,w,h = dimen[id]
if x < minx:
......@@ -121,7 +121,7 @@ class Merge(inkex.Effect):
midy = (miny + maxy) / 2
#calculate distances for each selected object
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
# get the bounding box
x,y,w,h = dimen[id]
......
......@@ -270,7 +270,7 @@ class Ungroup(inkex.Effect):
def effect(self):
if len(self.selected):
for elem in self.selected.itervalues():
for elem in self.selected.values():
self._deep_ungroup(elem)
else:
for elem in self.document.getroot():
......
......@@ -69,7 +69,7 @@ class WebSlicer_CreateGroup(WebSlicer_Effect):
if len(self.selected) == 0:
inkex.errormsg(_('You must to select some "Slicer rectangles" or other "Layout groups".'))
exit(1)
for id,node in self.selected.iteritems():
for id,node in self.selected.items():
if node not in self.layer_descendants:
inkex.errormsg(_('Oops... The element "%s" is not in the Web Slicer layer') % id)
exit(2)
......@@ -81,7 +81,7 @@ class WebSlicer_CreateGroup(WebSlicer_Effect):
'width_unity', 'height_unity',
'bg_color' ] )
for id,node in self.selected.iteritems():
for id,node in self.selected.items():
group.insert( 1, node )
......
......@@ -32,7 +32,7 @@ class Whirl(inkex.Effect):
help="direction of rotation")
def effect(self):
view_center = computePointInNode(list(self.view_center), self.current_layer)
for id, node in self.selected.iteritems():
for id, node in self.selected.items():
rotation = -1
if self.options.rotation == True:
rotation = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment