def dumps(self, aggregated): #start by storing the group parts = [aggregated.group] check_reserved(aggregated.group, [';;']) #store the dates for date_field in self.date_fields: value = getattr(aggregated, date_field) epoch = datetime_to_epoch(value) if value is not None else -1 parts += [epoch] # add the activities serialization serialized_activities = [] for activity in aggregated.activities: serialized = LoveActivitySerializer.dumps(self, activity) check_reserved(serialized, [';', ';;']) serialized_activities.append(serialized) serialized_activities_part = ';'.join(serialized_activities) parts.append(serialized_activities_part) # add the minified activities parts.append(aggregated.minimized_activities) # stick everything together serialized_aggregated = ';;'.join(map(str, parts)) serialized = '%s%s' % (self.identifier, serialized_aggregated) return serialized
def dumps(self, aggregated): self.check_type(aggregated) activity_serializer = self.activity_serializer_class() # start by storing the group parts = [aggregated.group] check_reserved(aggregated.group, ['\t\t']) # store the dates for date_field in self.date_fields: value = getattr(aggregated, date_field) epoch = datetime_to_epoch(value) if value is not None else -1 parts += [epoch] # add the activities serialization serialized_activities = [] if self.dehydrate: if not aggregated.dehydrated: aggregated = aggregated.get_dehydrated() serialized_activities = map(str, aggregated._activity_ids) else: for activity in aggregated.activities: serialized = activity_serializer.dumps(activity) check_reserved(serialized, ['\t', '\t\t']) serialized_activities.append(serialized) serialized_activities_part = ';'.join(serialized_activities) parts.append(serialized_activities_part) # add the minified activities parts.append(aggregated.minimized_activities) # stick everything together serialized_aggregated = '\t\t'.join(map(str, parts)) serialized = '%s%s' % (self.identifier, serialized_aggregated) return serialized
def dumps(self, aggregated): self.check_type(aggregated) activity_serializer = self.activity_serializer_class() # start by storing the group parts = [aggregated.group] check_reserved(aggregated.group, [';;']) # store the dates for date_field in self.date_fields: value = getattr(aggregated, date_field) epoch = datetime_to_epoch(value) if value is not None else -1 parts += [epoch] # add the activities serialization serialized_activities = [] if self.dehydrate: if not aggregated.dehydrated: aggregated = aggregated.get_dehydrated() serialized_activities = map(str, aggregated._activity_ids) else: for activity in aggregated.activities: serialized = activity_serializer.dumps(activity) check_reserved(serialized, [';', ';;']) serialized_activities.append(serialized) serialized_activities_part = ';'.join(serialized_activities) parts.append(serialized_activities_part) # add the minified activities parts.append(aggregated.minimized_activities) # stick everything together serialized_aggregated = ';;'.join(map(str, parts)) serialized = '%s%s' % (self.identifier, serialized_aggregated) return serialized