Code

fix hacked element cloning
authoracspike <acspike@users.sourceforge.net>
Mon, 8 Oct 2007 01:21:34 +0000 (01:21 +0000)
committeracspike <acspike@users.sourceforge.net>
Mon, 8 Oct 2007 01:21:34 +0000 (01:21 +0000)
cloning with fromstring(tostring()) striped xmlns
now using copy.deepcopy()

share/extensions/coloreffect.py
share/extensions/edge3d.py
share/extensions/markers_strokepaint.py
share/extensions/pathmodifier.py

index 76887faf0f21ca25525d29abdb1be83d767d43dc..52eff5c0db5871ff42f97730aa0ac134082b6939 100644 (file)
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software\r
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
 '''\r
-import sys, copy, optparse, simplestyle, inkex\r
+import sys, copy, optparse, simplestyle, inkex, copy\r
 \r
 import random\r
 \r
@@ -81,7 +81,7 @@ class ColorEffect(inkex.Effect):
          #return\r
        #self.visited.append(this_id)\r
        #inkex.debug("visited: " + str(self.visited))\r
-    newnode = inkex.etree.fromstring(inkex.etree.tostring(node))\r
+    newnode = copy.deepcopy(node)\r
     newnode.set('id', newid)\r
     node.getparent().append(newnode)\r
     self.changeStyle(newnode)\r
index 0192da0221116d62c442fae3728fe003f46fca9b..318e97c7266569d6b422e09c8620705af6cdf086 100644 (file)
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 '''
-import inkex, simplepath, sys
+import inkex, simplepath, sys, copy
 from math import degrees, atan2
 
 class Edge3d(inkex.Effect):
@@ -103,7 +103,7 @@ class Edge3d(inkex.Effect):
                     if result:
                         if not g:
                             g = self.getGroup(node)
-                        nn = inkex.etree.fromstring(inkex.etree.tostring(node))
+                        nn = copy.deepcopy(node)
                         nn.set('d',simplepath.formatPath(result))
                         
                         col = 255 - int(255. * level)
@@ -118,7 +118,7 @@ class Edge3d(inkex.Effect):
             # make a clipped group, clip with clone of original, clipped group
             # include original and group of paths
             clip = inkex.etree.SubElement(defs,inkex.addNS('clipPath','svg'))
-            clip.append(inkex.etree.fromstring(inkex.etree.tostring(node)))
+            clip.append(copy.deepcopy(node))
             clipId = self.uniqueId('clipPath')
             clip.set('id', clipId)
             clipG = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))
index cc186eaa2939a8c695a32e425104e724fc8e83a6..04fd4c5c7d3107320c4c64cf383f9954b7bfa43f 100644 (file)
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software\r
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
 '''\r
-import random, inkex, simplestyle\r
+import random, inkex, simplestyle, copy\r
 \r
 class MyEffect(inkex.Effect):\r
     def __init__(self):\r
@@ -47,7 +47,7 @@ class MyEffect(inkex.Effect):
                     try:\r
                         old_mnode = self.xpathSingle('/svg:svg//svg:marker[@id="%s"]' % marker_id)\r
                         if not self.options.modify:\r
-                            mnode = inkex.etree.fromstring(inkex.etree.tostring(old_mnode))\r
+                            mnode = copy.deepcopy(old_mnode)\r
                         else:\r
                             mnode = old_mnode\r
                     except:\r
index 245665588b3e886e641f316eb730fb144f4a766a..baa31fca221d986901d23fa0aceb36b57a889391 100644 (file)
@@ -148,7 +148,7 @@ class PathModifier(inkex.Effect):
     def duplicateNodes(self, aList):\r
         clones={}\r
         for id,node in aList.iteritems():\r
-            clone=inkex.etree.fromstring(inkex.etree.tostring(node))\r
+            clone=copy.deepcopy(node)\r
             #!!!--> should it be given an id?\r
             #seems to work without this!?!\r
             myid = node.tag.split('}')[-1]\r
@@ -187,7 +187,7 @@ class PathModifier(inkex.Effect):
                 refid=node.get(inkex.addNS('href','xlink'))\r
                 path = '//*[@id="%s"]' % refid[1:]\r
                 refnode = self.document.getroot().xpath(path,inkex.NSS)\r
-                newnode=inkex.etree.fromstring(inkex.etree.tostring(refnode))\r
+                newnode=copy.deepcopy(refnode)\r
                 self.recursNewIds(newnode)\r
 \r
                 s = node.get('style')\r