# Path: datapackage_pipelines/utilities/resources.py
# PATH_PLACEHOLDER = '_'
# 
# def streaming(descriptor):
#     return descriptor.get(PROP_STREAMING)
# 
# Path: datapackage_pipelines/utilities/extended_json.py
# class json(object):
#     dumps = _dumps
#     loads = _loads
#     dumpl = _dumpl
#     loadl = _loadl
#     dump = _dump
#     load = _load
#     JSONDecodeError = _json.JSONDecodeError


import sys
import copy
import logging
import datapackage
from tableschema.exceptions import ValidationError, CastError
from tableschema import Schema
from ..utilities.resources import PATH_PLACEHOLDER, streaming
from ..utilities.extended_json import json

    def next(self):
        return self.__next__()


def read_json(infile, proxy=False):
    line_json = infile.readline().strip()
    if line_json == '':
        sys.exit(-3)
    if proxy:
        print(line_json)
    try:
        return json.loads(line_json)
    except json.JSONDecodeError:
        logging.exception("Failed to decode line %r\nPerhaps there's a rogue print statement somewhere?", line_json)


def process_input(infile, validate=False, debug=False):
    dependency_dp = read_json(infile, True)
    dp = read_json(infile)
    resources = dp.get('resources', [])
    original_resources = copy.deepcopy(resources)

    if len(dp.get('resources', [])) == 0:
        # Currently datapackages with no resources are disallowed in the schema.
        # Since this might happen in the early stages of a pipeline,
        # we're adding this hack to avoid validation errors
        dp_to_validate = copy.deepcopy(dp)
        dp_to_validate['resources'] = [{
            'name': '__placeholder__',

# Path: datapackage_pipelines/utilities/resources.py
# PATH_PLACEHOLDER = '_'
# 
# def streaming(descriptor):
#     return descriptor.get(PROP_STREAMING)
# 
# Path: datapackage_pipelines/utilities/extended_json.py
# class json(object):
#     dumps = _dumps
#     loads = _loads
#     dumpl = _dumpl
#     loadl = _loadl
#     dump = _dump
#     load = _load
#     JSONDecodeError = _json.JSONDecodeError


# Path: datapackage_pipelines/wrapper/input_processor.py
import sys
import copy
import logging
import datapackage
from tableschema.exceptions import ValidationError, CastError
from tableschema import Schema
from ..utilities.resources import PATH_PLACEHOLDER, streaming
from ..utilities.extended_json import json


    def next(self):
        return self.__next__()


def read_json(infile, proxy=False):
    line_json = infile.readline().strip()
    if line_json == '':
        sys.exit(-3)
    if proxy:
        print(line_json)
    try:
        return json.loads(line_json)
    except json.JSONDecodeError:
        logging.exception("Failed to decode line %r\nPerhaps there's a rogue print statement somewhere?", line_json)


def process_input(infile, validate=False, debug=False):
    dependency_dp = read_json(infile, True)
    dp = read_json(infile)
    resources = dp.get('resources', [])
    original_resources = copy.deepcopy(resources)

    if len(dp.get('resources', [])) == 0:
        # Currently datapackages with no resources are disallowed in the schema.
        # Since this might happen in the early stages of a pipeline,
        # we're adding this hack to avoid validation errors
        dp_to_validate = copy.deepcopy(dp)
        dp_to_validate['resources'] = [{
            'name': '__placeholder__',

            'path': PATH_PLACEHOLDER