Redirect informational output to stderr when SVG is output to stdout (#67)
fixes #47
This commit is contained in:
parent
4f23ea7a34
commit
8d6301950b
1 changed files with 6 additions and 7 deletions
|
|
@ -68,7 +68,7 @@ from six.moves import range
|
||||||
try:
|
try:
|
||||||
from decimal import Decimal, InvalidOperation, getcontext
|
from decimal import Decimal, InvalidOperation, getcontext
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Scour requires at least Python 2.7 or Python 3.3+.")
|
sys.stderr.write("Scour requires at least Python 2.7 or Python 3.3+.")
|
||||||
|
|
||||||
# Import Psyco if available
|
# Import Psyco if available
|
||||||
try:
|
try:
|
||||||
|
|
@ -1301,14 +1301,11 @@ def removeDuplicateGradients(doc):
|
||||||
referencedIDs = findReferencedElements(doc.documentElement)
|
referencedIDs = findReferencedElements(doc.documentElement)
|
||||||
for masterGrad in list(gradientsToRemove.keys()):
|
for masterGrad in list(gradientsToRemove.keys()):
|
||||||
master_id = masterGrad.getAttribute('id')
|
master_id = masterGrad.getAttribute('id')
|
||||||
# print 'master='+master_id
|
|
||||||
for dupGrad in gradientsToRemove[masterGrad]:
|
for dupGrad in gradientsToRemove[masterGrad]:
|
||||||
# if the duplicate gradient no longer has a parent that means it was
|
# if the duplicate gradient no longer has a parent that means it was
|
||||||
# already re-mapped to another master gradient
|
# already re-mapped to another master gradient
|
||||||
if not dupGrad.parentNode: continue
|
if not dupGrad.parentNode: continue
|
||||||
dup_id = dupGrad.getAttribute('id')
|
dup_id = dupGrad.getAttribute('id')
|
||||||
# print 'dup='+dup_id
|
|
||||||
# print referencedIDs[dup_id]
|
|
||||||
# for each element that referenced the gradient we are going to remove
|
# for each element that referenced the gradient we are going to remove
|
||||||
for elem in referencedIDs[dup_id][1]:
|
for elem in referencedIDs[dup_id][1]:
|
||||||
# find out which attribute referenced the duplicate gradient
|
# find out which attribute referenced the duplicate gradient
|
||||||
|
|
@ -2903,7 +2900,7 @@ def scourString(in_string, options=None):
|
||||||
if options.error_on_flowtext:
|
if options.error_on_flowtext:
|
||||||
raise Exception(errmsg)
|
raise Exception(errmsg)
|
||||||
else:
|
else:
|
||||||
print("WARNING: {}".format(errmsg))
|
print("WARNING: {}".format(errmsg), file = options.ensure_value("stdout", sys.stdout))
|
||||||
|
|
||||||
# remove <metadata> if the user wants to
|
# remove <metadata> if the user wants to
|
||||||
if options.remove_metadata:
|
if options.remove_metadata:
|
||||||
|
|
@ -3342,6 +3339,8 @@ def getInOut(options):
|
||||||
outfile = sys.stdout.buffer
|
outfile = sys.stdout.buffer
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
outfile = sys.stdout
|
outfile = sys.stdout
|
||||||
|
# redirect informational output to stderr when SVG is output to stdout
|
||||||
|
options.stdout = sys.stderr
|
||||||
|
|
||||||
return [infile, outfile]
|
return [infile, outfile]
|
||||||
|
|
||||||
|
|
@ -3392,9 +3391,9 @@ def start(options, input, output):
|
||||||
duration,
|
duration,
|
||||||
newsize,
|
newsize,
|
||||||
oldsize,
|
oldsize,
|
||||||
sizediff))
|
sizediff), file = options.ensure_value("stdout", sys.stdout))
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print(getReport())
|
print(getReport(), file = options.ensure_value("stdout", sys.stdout))
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue