コード例 #1
0
ファイル: impactsExporter.py プロジェクト: CanalTP/Chaos
    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}
コード例 #2
0
ファイル: impactsExporter.py プロジェクト: azime/Chaos-1
    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}
コード例 #3
0
ファイル: fields.py プロジェクト: CanalTP/Chaos
    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)
コード例 #4
0
ファイル: fields.py プロジェクト: azime/Chaos-1
    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)