def __init__(self, doc, options):
     note("processing card %s", doc.fn.value)
     note(4, "card data is %s", doc.prettyPrint())
     self.pdffile = None
     FakePDFDoc.__init__(self, doc, options)
     self.checkocr = false
     self.__options = options.copy()
     self.__card = doc
     self.__timestamp = None
     rev = doc.contents.get("REV") or []
     if rev:
         timestamps = []
         for x in rev:
             # v is a timestamp
             try:
                 timestamp = time.strptime(x.value, "%Y%m%dT%H%M%SZ")
                 timestamps.append(timestamp)
             except:
                 try:
                     timestamp = time.strptime(x.value, "%Y%m%d")
                     timestamps.append(timestamp)
                 except:
                     pass
         timestamps.sort()
         self.__timestamp = timestamps[-1]
 def __init__(self, identifier, options):
     note("processing event %s", identifier)
     self.pdffile = None
     self.__event = options.get("icsevent")
     FakePDFDoc.__init__(self, identifier, options)
     if not isinstance(self.__event, vobject.base.Component):
         note("self.__event is not a Component!  %s, %s", repr(self.__event), repr(type(self.__event)))
     if self.__event.behavior != vobject.icalendar.VEvent:
         note("self.__event.behavior is not a VEvent!  %s, %s", repr(self.__event.behavior), repr(type(self.__event.behavior)))
     assert(isinstance(self.__event, vobject.base.Component) and
            (self.__event.behavior == vobject.icalendar.VEvent))
     self.checkocr = false
     self.__options = options.copy()
     self.__timestamp = None
     self.__uid = options.get("icsuid")
     self.__name = options.get("icsname")
     rev = self.__event.contents.get("REV") or []
     if rev:
         timestamps = []
         for x in rev:
             # v is a timestamp
             try:
                 timestamp = time.strptime(x.value, "%Y%m%dT%H%M%SZ")
                 timestamps.append(timestamp)
             except:
                 try:
                     timestamp = time.strptime(x.value, "%Y%m%d")
                     timestamps.append(timestamp)
                 except:
                     pass
         timestamps.sort()
         self.__timestamp = timestamps[-1]
     contents = self.__event.contents
     self.metadata["event-uid"] = self.__uid
     if self.__name != self.__uid:
         self.metadata["title"] = self.__name
     if self.__timestamp:
         self.metadata['revision-timestamp'] = time.strftime("%Y%m%dT%H%M%SZ", self.__timestamp)
     if 'dtstart' in contents:
         start = self.__event.dtstart.value
         self.metadata["date"] = "%d/%d/%s" % (start.month, start.day, start.year)
         self.metadata["event-start"] = start.isoformat()
         if 'dtend' in contents:
             end = self.__event.dtend.value
             duration = end - start
             duration = (duration.days * SECONDS_PER_DAY) + duration.seconds
             self.metadata['duration'] = str(duration)
             self.metadata['event-end'] = end.isoformat()
     elif 'dtend' in contents:
         end = self.__event.dtend.value
         self.metadata["date"] = "%m/%d/%Y" % (end.month, end.day, end.year)
         self.metadata['event-end'] = end.isoformat()
     if 'location' in contents:
         self.metadata["location"] = re.sub("\s", " ", self.__event.location.value)
     if 'description' in contents:
         self.metadata["summary"] = re.sub("\s", " ", self.__event.description.value)
 def write_metadata(self):
     d = self.doc.contents
     if 'fn' in d:
         self.metadata['title'] = d['fn'][0].value + ' (contact info)'
     elif 'org' in d:
         self.metadata['title'] = ', '.join(d['org'][0].value) + ' (contact info)'
     if self.__timestamp:
         self.metadata['date'] = '%s/%s/%s' % (self.__timestamp[1],
                                               self.__timestamp[2],
                                               self.__timestamp[0])
         self.metadata['revision-timestamp'] = time.strftime("%Y%m%dT%H%M%SZ", self.__timestamp)
     FakePDFDoc.write_metadata(self)
 def write_metadata(self):
     FakePDFDoc.write_metadata(self)
 def calculate_document_fingerprint(self):
     return self.metadata.get("sha-hash") or FakePDFDoc.calculate_document_fingerprint(self)