Skip to content

Commit 65346ef

Browse files
committed
[tools] Use doc.origin_filename accessors
1 parent 85c4435 commit 65346ef

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

odml/tools/odmlparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def from_file(self, file, doc_format=None):
186186
par = DictReader(show_warnings=self.show_warnings)
187187
self.doc = par.to_odml(self.parsed_doc)
188188
# Provide original file name via the in memory document
189-
self.doc._origin_file_name = basename(file)
189+
self.doc.origin_file_name = basename(file)
190190
return self.doc
191191

192192
elif self.parser == 'JSON':
@@ -200,7 +200,7 @@ def from_file(self, file, doc_format=None):
200200
par = DictReader(show_warnings=self.show_warnings)
201201
self.doc = par.to_odml(self.parsed_doc)
202202
# Provide original file name via the in memory document
203-
self.doc._origin_file_name = basename(file)
203+
self.doc.origin_file_name = basename(file)
204204
return self.doc
205205

206206
elif self.parser == 'RDF':

odml/tools/rdf_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ def save_document(self, doc, curr_node=None):
184184

185185
# If available, add the documents' filename to the document node
186186
# so we can identify where the data came from.
187-
if hasattr(doc, "_origin_file_name"):
188-
curr_lit = Literal(doc._origin_file_name)
187+
if hasattr(doc, "origin_file_name"):
188+
curr_lit = Literal(doc.origin_file_name)
189189
self.graph.add((curr_node, ODML_NS.hasFileName, curr_lit))
190190

191191
for k in fmt.rdf_map_keys:
@@ -383,7 +383,7 @@ def from_file(self, filename, doc_format):
383383
docs = self.to_odml()
384384
for curr_doc in docs:
385385
# Provide original file name via the document
386-
curr_doc._origin_file_name = os.path.basename(filename)
386+
curr_doc.origin_file_name = os.path.basename(filename)
387387

388388
return docs
389389

odml/tools/xmlparser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ def from_file(self, xml_file):
304304

305305
# Provide original file name via the in memory document
306306
if isinstance(xml_file, unicode):
307-
doc._origin_file_name = basename(xml_file)
307+
doc.origin_file_name = basename(xml_file)
308+
308309
return doc
309310

310311
def from_string(self, string):

0 commit comments

Comments
 (0)