scourXmlFile(): Set specified 'filename' as input filename so relative references will work
This commit is contained in:
parent
462460a512
commit
8cc97601c4
1 changed files with 7 additions and 0 deletions
|
|
@ -3519,10 +3519,17 @@ def scourString(in_string, options=None):
|
|||
# input is a filename
|
||||
# returns the minidom doc representation of the SVG
|
||||
def scourXmlFile(filename, options=None):
|
||||
# we need to set infilename (otherwise relative references in the SVG won't work)
|
||||
if options is None:
|
||||
options = generateDefaultOptions()
|
||||
options.infilename = filename
|
||||
|
||||
# open the file and scour it
|
||||
with open(filename, "rb") as f:
|
||||
in_string = f.read()
|
||||
out_string = scourString(in_string, options)
|
||||
|
||||
# prepare the output xml.dom.minidom object
|
||||
doc = xml.dom.minidom.parseString(out_string.encode('utf-8'))
|
||||
|
||||
# since minidom does not seem to parse DTDs properly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue