insert null values instead of empty attributes

This commit is contained in:
Patrick Jentsch 2020-01-29 13:57:38 +01:00
parent eeba8ad2e4
commit c1adcb93ee

View File

@ -403,17 +403,17 @@ class CorpusFile(db.Model):
self.dir, self.filename)
element_tree = ET.parse(file)
text_node = element_tree.find('text')
text_node.set('address', self.address)
text_node.set('address', self.address if self.address else "NULL")
text_node.set('author', self.author)
text_node.set('booktitle', self.booktitle)
text_node.set('chapter', self.chapter)
text_node.set('editor', self.editor)
text_node.set('institution', self.institution)
text_node.set('journal', self.journal)
text_node.set('pages', self.pages)
text_node.set('publisher', self.publisher)
text_node.set('booktitle', self.booktitle if self.booktitle else "NULL")
text_node.set('chapter', self.chapter if self.chapter else "NULL")
text_node.set('editor', self.editor if self.editor else "NULL")
text_node.set('institution', self.institution if self.institution else "NULL")
text_node.set('journal', self.journal if self.journal else "NULL")
text_node.set('pages', self.pages if self.pages else "NULL")
text_node.set('publisher', self.publisher if self.publisher else "NULL")
text_node.set('publishing_year', str(self.publishing_year))
text_node.set('school', self.school)
text_node.set('school', self.school if self.school else "NULL")
text_node.set('title', self.title)
element_tree.write(file)
self.corpus.status = 'unprepared'