def export_data(self, fp, export_data, fields): if is_sequence(export_data): export_data = [sanitize(it, fields) for it in export_data] else: export_data = [sanitize(export_data, fields)] writer = csv.DictWriter(fp, fields, extrasaction="ignore") writer.writeheader() writer.writerows(export_data)
def has_children(self): return is_sequence(self.value)
def export_data(self, fp, export_data, fields): if is_sequence(export_data): export_data = [sanitize(it, fields) for it in export_data] else: export_data = sanitize(export_data, fields) json.dump(export_data, fp, indent=2)