# Path: binstar_client/utils/yaml.py
# def yaml_load(stream):
#     """Loads a dictionary from a stream"""
#     return safe_load(stream)


import logging
from ..yaml import yaml_load

        return self.doc_pfile is not None


class ConfigurationInspector(object):
    valid_names = [
        'project.yml',
        'project.yaml'
    ]

    def __init__(self, pfiles):
        self.pfiles = pfiles
        self.config_pfile = None

    def update(self, metadata):
        try:
            if self.has_config():
                with open(self.config_pfile.fullpath) as configfile:
                    metadata['configuration'] = yaml_load(configfile)
        except:
            logger.warning("Could not parse configuration file.")
        return metadata

    def has_config(self):
        def is_config(basename, relativepath, fullpath):
            return basename == relativepath and basename in self.valid_names

        for pfile in self.pfiles:
            if pfile.validate(is_config):
                self.config_pfile = pfile

# Path: binstar_client/utils/yaml.py
# def yaml_load(stream):
#     """Loads a dictionary from a stream"""
#     return safe_load(stream)


# Path: binstar_client/utils/projects/inspectors.py
import logging
from ..yaml import yaml_load


        return self.doc_pfile is not None


class ConfigurationInspector(object):
    valid_names = [
        'project.yml',
        'project.yaml'
    ]

    def __init__(self, pfiles):
        self.pfiles = pfiles
        self.config_pfile = None

    def update(self, metadata):
        try:
            if self.has_config():
                with open(self.config_pfile.fullpath) as configfile:
                    metadata['configuration'] = yaml_load(configfile)
        except:
            logger.warning("Could not parse configuration file.")
        return metadata

    def has_config(self):
        def is_config(basename, relativepath, fullpath):
            return basename == relativepath and basename in self.valid_names

        for pfile in self.pfiles:
            if pfile.validate(is_config):
                self.config_pfile = pfile

                break