Update for 0.15: --keep-editor-data command-line option to keep Adobe, Inkscape, Sodipodi elements and attributes
This commit is contained in:
parent
8e589a80b4
commit
e9f1e07a02
5 changed files with 35 additions and 15 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
SCOURVER="0.14"
|
||||
SCOURVER="0.15"
|
||||
cd ..
|
||||
tar cvf scour/tarballs/scour-$SCOURVER.tar scour/scour.py scour/svg_regex.py scour/LICENSE scour/NOTICE scour/README.txt scour/release-notes.html
|
||||
gzip scour/tarballs/scour-$SCOURVER.tar
|
||||
|
|
|
|||
|
|
@ -9,6 +9,16 @@
|
|||
|
||||
<p>Copyright 2009, Jeff Schiller</p>
|
||||
|
||||
<section id="0.15">
|
||||
<header>
|
||||
<h2><a href="#0.14">Version 0.15</a></h2>
|
||||
</header>
|
||||
|
||||
<ul>
|
||||
<li>added --keep-editor-data command-line option</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="0.14">
|
||||
<header>
|
||||
<h2><a href="#0.14">Version 0.14</a></h2>
|
||||
|
|
|
|||
25
scour.py
25
scour.py
|
|
@ -29,21 +29,18 @@
|
|||
#
|
||||
# * Clean up Definitions
|
||||
# * Collapse duplicate gradient definitions
|
||||
# * Clean up paths
|
||||
# * Eliminate last segment in a polygon
|
||||
# * Process Transformations
|
||||
# * Process quadratic Bezier curves
|
||||
# * Collapse all group based transformations
|
||||
|
||||
# Suggestion from Richard Hutch:
|
||||
# * Put id attributes first in the serialization (or make the d attribute last)
|
||||
# This would require my own serialization fo the DOM objects (not impossible)
|
||||
# This would require my own serialization of the DOM objects (not impossible)
|
||||
|
||||
# Next Up:
|
||||
# + fix bug with consecutive path coordinates not being translated properly to relative commands
|
||||
# + convert straight curves to lines
|
||||
# + eliminate last segment in a polygon
|
||||
# - provide command-line option to disable raster-to-base64 conversion
|
||||
# + add option to keep inkscape, adobe, sodipodi elements and attributes
|
||||
# - ensure a really good understanding of prec vs. quantize and what I want --set-precision to do
|
||||
# - enable the precision argument to affect all numbers: polygon points, lengths, coordinates
|
||||
# - remove id if it matches the Inkscape-style of IDs (also provide a switch to disable this)
|
||||
# - convert polygons/polylines to path? (actually the change in semantics may not be worth the marginal savings)
|
||||
# - prevent elements from being stripped if they are referenced in a <style> element
|
||||
|
|
@ -72,7 +69,7 @@ except ImportError:
|
|||
Decimal = FixedPoint
|
||||
|
||||
APP = 'scour'
|
||||
VER = '0.14'
|
||||
VER = '0.15'
|
||||
COPYRIGHT = 'Copyright Jeff Schiller, 2009'
|
||||
|
||||
NS = { 'SVG': 'http://www.w3.org/2000/svg',
|
||||
|
|
@ -1487,10 +1484,11 @@ def scourString(in_string, options=None):
|
|||
# for whatever reason this does not always remove all inkscape/sodipodi attributes/elements
|
||||
# on the first pass, so we do it multiple times
|
||||
# does it have to do with removal of children affecting the childlist?
|
||||
while removeNamespacedElements( doc.documentElement, unwanted_ns ) > 0 :
|
||||
pass
|
||||
while removeNamespacedAttributes( doc.documentElement, unwanted_ns ) > 0 :
|
||||
pass
|
||||
if options.keep_editor_data == False:
|
||||
while removeNamespacedElements( doc.documentElement, unwanted_ns ) > 0 :
|
||||
pass
|
||||
while removeNamespacedAttributes( doc.documentElement, unwanted_ns ) > 0 :
|
||||
pass
|
||||
|
||||
# remove the xmlns: declarations now
|
||||
xmlnsDeclsToRemove = []
|
||||
|
|
@ -1627,6 +1625,9 @@ _options_parser.add_option("--enable-id-stripping",
|
|||
_options_parser.add_option("--disable-embed-rasters",
|
||||
action="store_false", dest="embed_rasters", default=True,
|
||||
help="won't embed rasters as base64-encoded data")
|
||||
_options_parser.add_option("--keep-editor-data",
|
||||
action="store_true", dest="keep_editor_data", default=False,
|
||||
help="won't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes")
|
||||
|
||||
# GZ: this is confusing, most people will be thinking in terms of
|
||||
# decimal places, which is not what decimal precision is doing
|
||||
|
|
|
|||
4
scra.py
4
scra.py
|
|
@ -64,7 +64,8 @@ class ScourOptions:
|
|||
style_to_xml = True
|
||||
group_collapse = True
|
||||
strip_ids = False
|
||||
digits = 5
|
||||
digits = 5
|
||||
embed_rasters = False
|
||||
|
||||
# params are the form elements (if a checkbox is unchecked it will not be present)
|
||||
def fetch(req, indoc,**params):
|
||||
|
|
@ -81,7 +82,6 @@ def fetch(req, indoc,**params):
|
|||
if not params.has_key('simplifyColors'):
|
||||
options.simple_colors = False
|
||||
options.digits = int(params['digits'])
|
||||
options.embed_rasters = False
|
||||
|
||||
req.write(scourString(indoc,options))
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@ def walkTree(elem, func):
|
|||
if walkTree(child, func) == False: return False
|
||||
return True
|
||||
|
||||
class ScourOptions:
|
||||
simple_colors = True
|
||||
style_to_xml = True
|
||||
group_collapse = True
|
||||
strip_ids = False
|
||||
digits = 5
|
||||
embed_rasters = True
|
||||
|
||||
class NoInkscapeElements(unittest.TestCase):
|
||||
def runTest(self):
|
||||
self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/sodipodi.svg').documentElement,
|
||||
|
|
@ -588,6 +596,7 @@ class DoNotRemovePolgonLastPoint(unittest.TestCase):
|
|||
self.assertEquals(p.getAttribute('points'), '200,50 300,50 300,150 200,150',
|
||||
'Last point of polygon removed' )
|
||||
|
||||
# TODO: write tests for --set-precision for path data, for polygon data, for attributes
|
||||
# TODO; write a test for embedding rasters
|
||||
# TODO: write a test for --disable-embed-rasters
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue