# Path: birdy/client/utils.py
# def filter_case_insensitive(names, complete_list):
# def pretty_repr(obj, linebreaks=True):
# def build_wps_client_doc(wps, processes):
# def build_process_doc(process):
# def format_type(obj):
# def is_embedded_in_request(url, value):
# def to_owslib(value, data_type, encoding=None, mimetype=None, schema=None):
# def from_owslib(value, data_type):
# def py_type(data_type):
# def extend_instance(obj, cls):
# def add_output_format(output_dictionary, output_identifier, as_ref=None, mimetype=None):
# def create_output_dictionary(output_identifier, as_ref=None, mimetype=None):
# 
# Path: birdy/client/converters.py
# def convert(self):
#     """To be subclassed."""
#     raise NotImplementedError
# 
# Path: birdy/exceptions.py
# class ProcessFailed(Exception):  # noqa: D101
#     pass
# 
# class ProcessIsNotComplete(Exception):  # noqa: D101
#     pass
# 
# Path: birdy/utils.py
# def delist(data):
#     """If data is a sequence with a single element, returns this element, otherwise return the sequence."""
#     if (
#         isinstance(data, collections.abc.Iterable)
#         and not isinstance(data, str)
#         and len(data) == 1
#     ):
#         return data[0]
#     return data
# 
# def sanitize(name):
#     """Lower-case name and replace all non-ascii chars by `_`.
# 
#     If name is a Python keyword (like `return`) then add a trailing `_`.
#     """
#     new_name = re.sub(r"\W|^(?=\d)", "_", name.lower())
#     if keyword.iskeyword(new_name):
#         new_name = new_name + "_"
#     return new_name


import tempfile
from collections import namedtuple
from owslib.wps import WPSExecution
from birdy.client import utils
from birdy.client.converters import convert
from birdy.exceptions import ProcessFailed, ProcessIsNotComplete
from birdy.utils import delist, sanitize
        """Attach the outputs according to converters.

        Parameters
        ----------
        wps_outputs: dict
        converters: dict
          Converter dictionary {name: object}
        """
        self._wps_outputs = wps_outputs
        self._converters = converters
        self._path = tempfile.mkdtemp()

    def get(self, asobj=False):
        """Return the process response outputs.

        Parameters
        ----------
        asobj: bool
          If True, object_converters will be used.
        """
        if not self.isComplete():
            raise ProcessIsNotComplete("Please wait ...")
        if not self.isSucceded():
            # TODO: add reason for failure
            raise ProcessFailed("Sorry, process failed.")
        return self._make_output(asobj)

    def _make_output(self, convert_objects=False):
        Output = namedtuple(
            sanitize(self.process.identifier) + "Response",

# Path: birdy/client/utils.py
# def filter_case_insensitive(names, complete_list):
# def pretty_repr(obj, linebreaks=True):
# def build_wps_client_doc(wps, processes):
# def build_process_doc(process):
# def format_type(obj):
# def is_embedded_in_request(url, value):
# def to_owslib(value, data_type, encoding=None, mimetype=None, schema=None):
# def from_owslib(value, data_type):
# def py_type(data_type):
# def extend_instance(obj, cls):
# def add_output_format(output_dictionary, output_identifier, as_ref=None, mimetype=None):
# def create_output_dictionary(output_identifier, as_ref=None, mimetype=None):
# 
# Path: birdy/client/converters.py
# def convert(self):
#     """To be subclassed."""
#     raise NotImplementedError
# 
# Path: birdy/exceptions.py
# class ProcessFailed(Exception):  # noqa: D101
#     pass
# 
# class ProcessIsNotComplete(Exception):  # noqa: D101
#     pass
# 
# Path: birdy/utils.py
# def delist(data):
#     """If data is a sequence with a single element, returns this element, otherwise return the sequence."""
#     if (
#         isinstance(data, collections.abc.Iterable)
#         and not isinstance(data, str)
#         and len(data) == 1
#     ):
#         return data[0]
#     return data
# 
# def sanitize(name):
#     """Lower-case name and replace all non-ascii chars by `_`.
# 
#     If name is a Python keyword (like `return`) then add a trailing `_`.
#     """
#     new_name = re.sub(r"\W|^(?=\d)", "_", name.lower())
#     if keyword.iskeyword(new_name):
#         new_name = new_name + "_"
#     return new_name


# Path: birdy/client/outputs.py
import tempfile
from collections import namedtuple
from owslib.wps import WPSExecution
from birdy.client import utils
from birdy.client.converters import convert
from birdy.exceptions import ProcessFailed, ProcessIsNotComplete
from birdy.utils import delist, sanitize

        """Attach the outputs according to converters.

        Parameters
        ----------
        wps_outputs: dict
        converters: dict
          Converter dictionary {name: object}
        """
        self._wps_outputs = wps_outputs
        self._converters = converters
        self._path = tempfile.mkdtemp()

    def get(self, asobj=False):
        """Return the process response outputs.

        Parameters
        ----------
        asobj: bool
          If True, object_converters will be used.
        """
        if not self.isComplete():
            raise ProcessIsNotComplete("Please wait ...")
        if not self.isSucceded():
            # TODO: add reason for failure
            raise ProcessFailed("Sorry, process failed.")
        return self._make_output(asobj)

    def _make_output(self, convert_objects=False):
        Output = namedtuple(
            sanitize(self.process.identifier) + "Response",

            [sanitize(o.identifier) for o in self.processOutputs],