summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-02-05 22:59:18 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-02-05 22:59:18 +0000
commit34ee2e37ef6e6163d65f60299e639a1e60f7cf4e (patch)
tree4752d8f17ff9dbad02a8658831ff1f0f6011ffae /share
parentExtensions: Add about screen for Scour extension (aka "optimized SVG output") (diff)
downloadinkscape-34ee2e37ef6e6163d65f60299e639a1e60f7cf4e.tar.gz
inkscape-34ee2e37ef6e6163d65f60299e639a1e60f7cf4e.zip
Extensions: Add a version check for Scour
If an older version of Scour is installed on the system notify the user that not all options in the extensions Window might be available (can optionally be turned off) (bzr r15483)
Diffstat (limited to 'share')
-rwxr-xr-xshare/extensions/scour.inkscape.py31
-rw-r--r--share/extensions/scour.inx8
2 files changed, 38 insertions, 1 deletions
diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour.inkscape.py
index eb31f308f..0bc1435c5 100755
--- a/share/extensions/scour.inkscape.py
+++ b/share/extensions/scour.inkscape.py
@@ -1,6 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import sys, platform, inkex
+
+import platform
+import sys
+
+from distutils.version import StrictVersion
+
+import inkex
try:
import scour
@@ -17,10 +23,13 @@ except Exception as e:
inkex.errormsg("\nDetails:\n" + str(e))
sys.exit()
+
class ScourInkscape (inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
+
+ # Scour options
self.OptionParser.add_option("--tab", type="string", action="store", dest="tab")
self.OptionParser.add_option("--simplify-colors", type="inkbool", action="store", dest="simple_colors")
self.OptionParser.add_option("--style-to-xml", type="inkbool", action="store", dest="style_to_xml")
@@ -46,7 +55,26 @@ class ScourInkscape (inkex.Effect):
self.OptionParser.add_option("--enable-comment-stripping", type="inkbool", action="store", dest="strip_comments")
self.OptionParser.add_option("--renderer-workaround", type="inkbool", action="store", dest="renderer_workaround")
+ # options for internal use of the extension
+ self.OptionParser.add_option("--scour-version", type="string", action="store", dest="scour_version")
+ self.OptionParser.add_option("--scour-version-warn-old", type="inkbool", action="store", dest="scour_version_warn_old")
+
def effect(self):
+ # version check if enabled in options
+ if (self.options.scour_version_warn_old):
+ scour_version = scour.__version__
+ scour_version_min = self.options.scour_version
+ if (StrictVersion(scour_version) < StrictVersion(scour_version_min)):
+ inkex.errormsg("The extension 'Optimized SVG Output' is designed for Scour " + scour_version_min + " and later "
+ "but you're using the older version Scour " + scour_version + ".")
+ inkex.errormsg("This usually works just fine but not all options available in the UI might be supported "
+ "by the version of Scour installed on your system "
+ "(see https://github.com/scour-project/scour/blob/master/HISTORY.md for release notes of Scour).")
+ inkex.errormsg("Note: You can permanently disable this message on the 'About' tab of the extension window.")
+ del self.options.scour_version
+ del self.options.scour_version_warn_old
+
+ # do the scouring
try:
input = file(self.args[0], "r")
self.options.infilename = self.args[0]
@@ -61,6 +89,7 @@ class ScourInkscape (inkex.Effect):
inkex.errormsg("Scour version: " + scour.__version__)
sys.exit()
+
if __name__ == '__main__':
e = ScourInkscape()
e.affect(output=False)
diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx
index a797f7ac3..5cad00780 100644
--- a/share/extensions/scour.inx
+++ b/share/extensions/scour.inx
@@ -99,6 +99,14 @@
<param name="spacer" type="description">&#160;</param>
<_param name="about_link_desc" type="description">For details please refer to</_param>
<param name="about_link" type="description"> https://github.com/scour-project/scour</param>
+ <param name="spacer" type="description">&#160;</param>
+ <param name="spacer" type="description">&#160;</param>
+ <param name="spacer" type="description">&#160;</param>
+ <_param name="about_version_desc" type="description">This version of the extension is designed for</_param>
+ <param name="about_version" type="description">Scour 0.31+</param>
+ <param name="version" type="string" gui-hidden="true">0.31</param>
+ <param _gui-text="Show warnings for older versions of Scour"
+ name="version_warn_old" type="boolean" indent="1">true</param>
</page>
</param>
<output>