def format_impacts(self, impacts): navitia = Navitia(self.navitia_url, self.coverage, self.token) columns = impacts.keys() rows = [] for sub_dict in impacts.fetchall(): row = [] for column in columns: val = sub_dict[column] if column == 'pt_object_name' : val = navitia.find_tc_object_name(sub_dict['pt_object_uri'], sub_dict['pt_object_type']) elif column == 'periodicity': val = 'yes' if val else 'no' elif column == 'status' and val == 'archived': val = 'deleted' elif isinstance(val, datetime.date): val = utils.utc_to_local(val, self.time_zone) row.append(utils.sanitize_csv_data(val)) rows.append(row) return {'columns' : columns, 'rows' : rows}
def format_impacts(self, impacts): navitia = Navitia(self.navitia_url, self.coverage, self.token) columns = impacts.keys() rows = [] for sub_dict in impacts.fetchall(): row = [] for column in columns: val = sub_dict[column] if column == 'pt_object_name': val = navitia.find_tc_object_name( sub_dict['pt_object_uri'], sub_dict['pt_object_type']) elif column == 'periodicity': val = 'yes' if val else 'no' elif column == 'status' and val == 'archived': val = 'deleted' elif isinstance(val, datetime.date): val = utils.utc_to_local(val, self.time_zone) row.append(utils.sanitize_csv_data(val)) rows.append(row) return {'columns': columns, 'rows': rows}
def output(self, key, obj): if not obj: return None if isinstance(obj, dict) and 'uri' in obj and 'type' in obj: obj_uri = obj['uri'] obj_type = obj['type'] else: obj_uri = obj.uri obj_type = obj.type navitia = Navitia( current_app.config['NAVITIA_URL'], get_coverage(request), get_token(request)) return navitia.find_tc_object_name(obj_uri, obj_type)
def output(self, key, obj): # for history if hasattr(obj, 'name'): return obj.name if not obj: return None if isinstance(obj, dict) and 'uri' in obj and 'type' in obj: obj_uri = obj['uri'] obj_type = obj['type'] else: obj_uri = obj.uri obj_type = obj.type navitia = Navitia(current_app.config['NAVITIA_URL'], get_coverage(request), get_token(request)) return navitia.find_tc_object_name(obj_uri, obj_type)