예제 #1
0
def property_keywords_dictionary_closure(profile):

    profile_dictionary = get_dictionary_by_profile(profile)
    utils.get_fully_qualified_dictionary_values(profile_dictionary)

    def replace_value(value):
        for keyword in profile_dictionary:
            if type(value) is list:
                value = [v.replace('{' + keyword + '}', profile_dictionary[keyword])
                         for v in value]
            else:
                try:
                    value = value.replace('{' + keyword + '}', profile_dictionary[keyword])
                except AttributeError:
                    pass
        return value

    def adjust_property_keywords(property_dictionary):
        updated_property_dictionary = {}
        for key in property_dictionary.iterkeys():
            updated_value = replace_value(property_dictionary[key])
            updated_property_dictionary[key] = updated_value
        return updated_property_dictionary

    return adjust_property_keywords
예제 #2
0
def get_fully_qualified_profile(database, profile=None):
    if profile:
        profile = get_profile_by_name(database, profile)
    else:
        profile = get_default_profile(database)
    try:
        utils.get_fully_qualified_dictionary_values(profile)
    except:
        pass
    return profile