Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_version(self):
sys.argv.append('--version')
result = self._run_scour()
self.assertEqual(result.status, 0, "Execution of 'scour --version' erorred'")
self.assertEqual(__version__ + "\n", result.stdout, "Unexpected output of 'scour --version'")
def effect(self):
try:
input = file(self.args[0], "r")
self.options.infilename = self.args[0]
sys.stdout.write(scourString(input.read(), self.options).encode("UTF-8"))
input.close()
sys.stdout.close()
except Exception as e:
inkex.errormsg("Error during optimization.")
inkex.errormsg("\nDetails:\n" + str(e))
inkex.errormsg("\nOS version: " + platform.platform())
inkex.errormsg("Python version: " + sys.version)
inkex.errormsg("Scour version: " + scour.__version__)
sys.exit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, platform, inkex
try:
import scour
try:
from scour.scour import scourString
except ImportError: # compatibility for very old Scour (<= 0.26) - deprecated!
try:
from scour import scourString
scour.__version__ = scour.VER
except:
raise
except Exception as e:
inkex.errormsg("Failed to import Python module 'scour'.\nPlease make sure it is installed (e.g. using 'pip install scour' or 'sudo apt-get install python-scour') and try again.")
inkex.errormsg("\nDetails:\n" + str(e))
sys.exit()
try:
import six
except Exception as e:
inkex.errormsg("Failed to import Python module 'six'.\nPlease make sure it is installed (e.g. using 'pip install six' or 'sudo apt-get install python-six') and try again.")
inkex.errormsg("\nDetails:\n" + str(e))
sys.exit()
class ScourInkscape (inkex.Effect):
try:
import psyco
psyco.full()
except ImportError:
pass
# select the most precise walltime measurement function available on the platform
if sys.platform.startswith('win'):
walltime = time.clock
else:
walltime = time.time
from scour import __version__
APP = u'scour'
VER = __version__
COPYRIGHT = u'Copyright Jeff Schiller, Louis Simard, 2010'
NS = {'SVG': 'http://www.w3.org/2000/svg',
'XLINK': 'http://www.w3.org/1999/xlink',
'SODIPODI': 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
'INKSCAPE': 'http://www.inkscape.org/namespaces/inkscape',
'ADOBE_ILLUSTRATOR': 'http://ns.adobe.com/AdobeIllustrator/10.0/',
'ADOBE_GRAPHS': 'http://ns.adobe.com/Graphs/1.0/',
'ADOBE_SVG_VIEWER': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/',
'ADOBE_VARIABLES': 'http://ns.adobe.com/Variables/1.0/',
'ADOBE_SFW': 'http://ns.adobe.com/SaveForWeb/1.0/',
'ADOBE_EXTENSIBILITY': 'http://ns.adobe.com/Extensibility/1.0/',
'ADOBE_FLOWS': 'http://ns.adobe.com/Flows/1.0/',
'ADOBE_IMAGE_REPLACEMENT': 'http://ns.adobe.com/ImageReplacement/1.0/',
'ADOBE_CUSTOM': 'http://ns.adobe.com/GenericCustomNamespace/1.0/',
'ADOBE_XPATH': 'http://ns.adobe.com/XPath/1.0/',