Exemplo n.º 1
0
 def _process_event(self, record):
     # Get the event id, its name and its last modification date 
     event_name = re.sub(r'<a [^>]*>([^<]*)</a>', '\g<1>', record['Event'], flags=re.IGNORECASE).replace('\n', '')
     event_id = re.search('href="([^"]*)"', record['Event']).group(1)[1:-1]
     event_last_update_date = datetime.strptime(record['Date'], "%d %b %Y")
     event = Event(event_id)
     
     # Get the last modification date from the end point
     server_version_date = self.triple_store.get_last_version_date(event)
     
     # Check the status of the event in the triple store
     if server_version_date == None or (event_last_update_date - server_version_date).days > 0:
         # The event is not in the triple store or needs to be updated
         print '\t[UPD] %s - %s' % (event_id, event_name)
         
         # Add the topics not already existing
         for t in event.get_topics():
             topic = Topic(t)
             if self.triple_store.get_last_version_date(topic) == None:
                 try:
                     print '\t\t[UPD-TOPIC] %s' % t
                     topic.load_data()
                     self.triple_store.save_rdf_data(topic)
                 except:
                     # It's ok if we miss one
                     pass
                 
         # Update the data about all the persons concerned
         for p in event.get_persons():
             try:
                 print '\t\t[UPD-PERSON] %s' % p
                 person = Person(p)
                 person.load_data()
                 self.triple_store.save_rdf_data(person)
             except:
                 # It's ok if we miss one
                 pass
             
         # Save the RDF data of the event
         event.load_data()
         self.triple_store.save_rdf_data(event)
         
         # Save the CFP from the call    
         file = open(self.data_directory + '/' + event.get_resource_name() + '_cfp.txt', 'w')
         file.write(event.get_cfp_data())
         file.close()
         
     else:
         # The server version is up to date
         print '\t[OK] %s - %s' % (event_id, event_name)