def determine_resource_type(self, event): # Build an array with the useful attributes # for making the inferrence array = {} array['class_name'] = event.__class__.__name__ array['uri'] = event.get_uri() array['resource_name'] = event['resource_display_name'] content = util.apply_rules(self.content_rules, array) medium = util.apply_rules(self.medium_rules, array) return (content, medium)
def determine_resource_type(self,event): # Build an array with the useful attributes # for making the inferrence array = {} array['class_name'] =event.__class__.__name__ array['uri'] = event.get_uri() array['resource_name'] = event['resource_display_name'] content = util.apply_rules(self.content_rules, array) medium = util.apply_rules(self.medium_rules, array) return (content, medium)
def update_location(self,raw_event): """Updates the user's current location according to the rules specified in UPDATE_LOC_RLS and functions defined in update_loc.py""" new_location = util.apply_rules(self.update_location_rules, raw_event) if new_location: self.engaged_users.update_location(raw_event['anon_screen_name'], new_location, raw_event['time']) #print '[eventformatter.update_location] Location updated to : ' + str(new_location) else: self.engaged_users.remove_user(raw_event['anon_screen_name'])
def inherit_location(self,raw_event): """Try to inherit location according to the rules specified in INHERIT_LOC_RLS and functions defined in inheritloc.py""" current_location = self.engaged_users.get_location(raw_event['anon_screen_name']) if current_location: if not str(current_location[0]): #print '[eventformatter.inherit_location] User has no known previous location' return #print '- Engaged @ ' + str(current_location[0]) #print '- Sequence number :: ' + str(current_location[0].get_seq()) time_gap = (raw_event['time'] - current_location[1]).seconds if time_gap < 3600: raw_event['current_location'] = current_location util.apply_rules(self.inherit_location_rules, raw_event) else: #print '[eventformatter.inherit_location] Location obsolete' return
def do_specific_formatting(self,raw_event): """Apply all specific formatting functions according to the rules specified in SPEC_FORMAT_RLS and functions defined in specformatting.py""" util.apply_rules(self.specific_formatting_rules, raw_event)
def pass_filter(self,raw_event): """ Returns True if the event should be processed further, according to the filtering rules defined in FILTER_RULES """ return util.apply_rules(self.filter_rules, raw_event)
def instanciate_event(self,raw_event): """Instanciates an Event subclass from the now formatted raw_event, according to the rules specified in INST_EVT_RLS and classes defined in events.py""" return util.apply_rules(self.instanciate_event_rules, raw_event)