def test_setType(self): a = DocumentFields() for t in DocumentFields.TYPES: a.setDocType(t) self.assertEqual(a.getDocType(), t) a.setDocType(DocumentFields.DOC_UNKNOWN) self.assertEqual(a.getDocType(), DocumentFields.DOC_UNKNOWN)
def setType(self): a = DocumentFields() for t in DocumentFields.TYPES: a.setDocType(t) assert (a.getDocType() == t) a.setDocType(DocumentFields.OTHER) assert (a.getDocType() == DocumentFields.OTHER)
def read(self): fields = DocumentFields() with open(self.path.path) as bibtex_file: bibtex_str = bibtex_file.read() bib_database = bibtexparser.loads(bibtex_str) for entry in bib_database.entries: for field, value in entry.items(): if (field == "ENTRYTYPE"): docType = strToDocType(value) fields.setDocType(docType) elif (field != "ID"): fields.setField(field, value) return fields