import yaml


def get_appname(file):
    """Parse given docker-compose file and returns dict for
        AppName:CertType from environment
    :param file: Full path of docker-compose file.
    :type file: String
    """
    dictApps = {}
    with open(file) as f:
        docs = yaml.load_all(f, Loader=yaml.FullLoader)
        for doc in docs:
            for key, value in doc.items():
                if key == "services":
                    for key, value in value.items():
                        for key, value in value.items():
                            if key == "environment":
                                try:
                                    dictApps.setdefault(value["AppName"],
                                                        value["CertType"])
                                except KeyError as ke:
                                    print(ke)
                                    pass

    return dictApps