Use the directory of the stream name as base when parsing XML
This commit is contained in:
@@ -395,7 +395,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
self.skip_data = False
|
||||
self.modules = modules
|
||||
self.languages = languages
|
||||
self.base_path = None
|
||||
self.base_path = ''
|
||||
|
||||
# Tag handlders are used to delegate the processing
|
||||
self.taghandlerlist = {
|
||||
@@ -413,11 +413,12 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
self.sax_parser.setFeature(sax.handler.feature_namespaces, 0)
|
||||
self.sax_parser.setContentHandler(self)
|
||||
|
||||
def parse_xmlstream(self, stream, base_path):
|
||||
def parse_xmlstream(self, stream):
|
||||
"""
|
||||
Take a byte stream has input and parse the xml content.
|
||||
"""
|
||||
self.base_path = base_path
|
||||
self.base_path = (
|
||||
os.path.dirname(stream.name) if hasattr(stream, 'name') else '')
|
||||
source = sax.InputSource()
|
||||
source.setByteStream(stream)
|
||||
|
||||
@@ -427,7 +428,7 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
except Exception as e:
|
||||
raise ParsingError("in %s" % self.current_state()) from e
|
||||
|
||||
self.base_path = None
|
||||
self.base_path = ''
|
||||
return self.to_delete
|
||||
|
||||
def startElement(self, name, attributes):
|
||||
|
||||
@@ -317,8 +317,7 @@ def load_module_graph(graph, pool, update=None, lang=None, indexes=None):
|
||||
# Feed the parser with xml content:
|
||||
with tools.file_open(
|
||||
os.path.join(module, filename), 'rb') as fp:
|
||||
tryton_parser.parse_xmlstream(
|
||||
fp, base_path=os.path.dirname(filename))
|
||||
tryton_parser.parse_xmlstream(fp)
|
||||
|
||||
modules_todo.append((module, list(tryton_parser.to_delete)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user