# Path: datapackage_pipelines/utilities/extended_json.py
#     DATE_F_FORMAT = '%Y-%m-%d'
#     DATETIME_F_FORMAT = '%Y-%m-%d %H:%M:%S'
#     DATE_F_FORMAT = '%04Y-%m-%d'
#     DATETIME_F_FORMAT = '%04Y-%m-%d %H:%M:%S'
# DATE_FORMAT = DATE_F_FORMAT
# DATETIME_FORMAT = DATETIME_F_FORMAT
# TIME_FORMAT = '%H:%M:%S'
# DATE_P_FORMAT = '%Y-%m-%d'
# DATETIME_P_FORMAT = '%Y-%m-%d %H:%M:%S'
# TIME_P_FORMAT = TIME_F_FORMAT = TIME_FORMAT
# class LazyJsonLine(LazyDict):
# class CommonJSONDecoder(_json.JSONDecoder):
# class CommonJSONEncoder(_json.JSONEncoder):
# class json(object):
#     def __init__(self, args, kwargs):
#     def _evaluate(self):
#     def __str__(self):
#     def __repr__(self):
#     def object_hook(cls, obj):
#     def __init__(self, **kwargs):
#     def default(self, obj):
# def _dumpl(*args, **kwargs):
# def _loadl(*args, **kwargs):
# def _dumps(*args, **kwargs):
# def _loads(*args, **kwargs):
# def _dump(*args, **kwargs):
# def _load(*args, **kwargs):
# 
# Path: datapackage_pipelines/utilities/resources.py
# def get_path(descriptor):
#     path = descriptor.get('path')
#     if isinstance(path, str):
#         return path
#     if isinstance(path, list):
#         if len(path) > 0:
#             return path.pop(0)
#         else:
#             return None
#     assert path is None, '%r' % path
#     return None


import csv
import json
import os
import isodate
import logging
from datapackage_pipelines.utilities.extended_json import (
    DATETIME_F_FORMAT, DATE_F_FORMAT, TIME_F_FORMAT,
    DATETIME_P_FORMAT, DATE_P_FORMAT, TIME_P_FORMAT,
)
from datapackage_pipelines.utilities.resources import get_path

    def prepare_resource(self, resource):
        for field in resource.get('schema', {}).get('fields', []):
            field.update(self.PYTHON_DIALECT.get(field['type'], {}))

    def __transform_row(self, row, fields):
        try:
            return dict((k, self.__transform_value(v, fields[k]['type']))
                        for k, v in row.items())
        except Exception:
            logging.exception('Failed to transform row %r', row)
            raise

    @classmethod
    def __transform_value(cls, value, field_type):
        if value is None:
            return cls.NULL_VALUE
        serializer = cls.SERIALIZERS.get(field_type, cls.DEFAULT_SERIALIZER)
        return serializer(value)

    def write_row(self, writer, row, fields):
        transformed_row = self.__transform_row(row, fields)
        self.write_transformed_row(writer, transformed_row, fields)


class CSVFormat(FileFormat):

    SERIALIZERS = {
        'array': json_dumps,
        'object': json_dumps,

# Path: datapackage_pipelines/utilities/extended_json.py
#     DATE_F_FORMAT = '%Y-%m-%d'
#     DATETIME_F_FORMAT = '%Y-%m-%d %H:%M:%S'
#     DATE_F_FORMAT = '%04Y-%m-%d'
#     DATETIME_F_FORMAT = '%04Y-%m-%d %H:%M:%S'
# DATE_FORMAT = DATE_F_FORMAT
# DATETIME_FORMAT = DATETIME_F_FORMAT
# TIME_FORMAT = '%H:%M:%S'
# DATE_P_FORMAT = '%Y-%m-%d'
# DATETIME_P_FORMAT = '%Y-%m-%d %H:%M:%S'
# TIME_P_FORMAT = TIME_F_FORMAT = TIME_FORMAT
# class LazyJsonLine(LazyDict):
# class CommonJSONDecoder(_json.JSONDecoder):
# class CommonJSONEncoder(_json.JSONEncoder):
# class json(object):
#     def __init__(self, args, kwargs):
#     def _evaluate(self):
#     def __str__(self):
#     def __repr__(self):
#     def object_hook(cls, obj):
#     def __init__(self, **kwargs):
#     def default(self, obj):
# def _dumpl(*args, **kwargs):
# def _loadl(*args, **kwargs):
# def _dumps(*args, **kwargs):
# def _loads(*args, **kwargs):
# def _dump(*args, **kwargs):
# def _load(*args, **kwargs):
# 
# Path: datapackage_pipelines/utilities/resources.py
# def get_path(descriptor):
#     path = descriptor.get('path')
#     if isinstance(path, str):
#         return path
#     if isinstance(path, list):
#         if len(path) > 0:
#             return path.pop(0)
#         else:
#             return None
#     assert path is None, '%r' % path
#     return None


# Path: datapackage_pipelines/lib/dump/file_formats.py
import csv
import json
import os
import isodate
import logging
from datapackage_pipelines.utilities.extended_json import (
    DATETIME_F_FORMAT, DATE_F_FORMAT, TIME_F_FORMAT,
    DATETIME_P_FORMAT, DATE_P_FORMAT, TIME_P_FORMAT,
)
from datapackage_pipelines.utilities.resources import get_path


    def prepare_resource(self, resource):
        for field in resource.get('schema', {}).get('fields', []):
            field.update(self.PYTHON_DIALECT.get(field['type'], {}))

    def __transform_row(self, row, fields):
        try:
            return dict((k, self.__transform_value(v, fields[k]['type']))
                        for k, v in row.items())
        except Exception:
            logging.exception('Failed to transform row %r', row)
            raise

    @classmethod
    def __transform_value(cls, value, field_type):
        if value is None:
            return cls.NULL_VALUE
        serializer = cls.SERIALIZERS.get(field_type, cls.DEFAULT_SERIALIZER)
        return serializer(value)

    def write_row(self, writer, row, fields):
        transformed_row = self.__transform_row(row, fields)
        self.write_transformed_row(writer, transformed_row, fields)


class CSVFormat(FileFormat):

    SERIALIZERS = {
        'array': json_dumps,
        'object': json_dumps,

        'datetime': lambda d: d.strftime(DATETIME_F_FORMAT),