def parse_endnote(newdict, md, endnote): parts = endnote.strip().split("\n") authors = "" for part in parts: p = ENDNOTE_CHARREF.sub(charref_replace, part.strip()) if p.startswith("%T "): newdict['title'] = p[3:].strip() newdict['title-is-original-filepath'] = '' elif p.startswith("%P "): newdict['page-numbers'] = p[3:].strip() elif p.startswith("%D "): # we override any existing date, because often the PDF file had # a bad date in it -- the date it was scanned to add to the library year, month, day = parse_date(p[3:].strip()) newdict['date'] = "%s/%s/%s" % (month, day, year) elif p.startswith("%A "): # ignore any author metadata in the PDF file if authors: authors += " and " authors += p[3:].strip() if authors: d['authors'] = authors
def get_date (self): if self.__date is None: d = self.get_metadata('date') if d: self.__date = parse_date(d) return self.__date
def figure_date(datestring): d2 = parse_date(datestring) if (not d2) or (sum(d2) == 0): return 0 return d2[0] * (13 * 32) + d2[1] * 13 + d2[2]