'Validate and parse the environment portion of an application
configuration.
:param unicode application: The name of the application this config
is mapped to.
:param dict environment: A dictionary of environment variable
names and values or a list of strings representing key/value
pairs in the form KEY=VALUE (or just KEY for an empty value)
:raises ConfigurationError: if the environment config does
not validate.
:returns: A ``frozenset`` of environment variable name/value
pairs.'

def _parse_app_environment(self, application, environment):

    _check_type(environment, (dict, list), u"'environment'    must    be    a    dictionary    or    list", application)
    if isinstance(environment, list):
        environment_dict = dict()
        for item in environment:
            _check_type(item, (str, unicode), u"'environment'    value    '{item}'    must    be    a    string".format(item=item), application)
            try:
                (label, value) = item.split(u'=')
            except ValueError:
                label = item
                value = u''
            environment_dict[label] = value
    else:
        environment_dict = environment
    for (var, val) in environment_dict.items():
        _check_type(val, (str, unicode), u"'environment'    value    for    '{var}'    must    be    a    string".format(var=var), application)
    return frozenset(environment_dict.items())
