Move updating existing_profiles out of parse_profile_data()

parse_profile_data() returns the parsed profiles, but writes to
existing_profiles directly.

read_profiles() calls parse_profile_data() and already handles adding
the parsed profiles to aa, original_aa or extras, which means updating
existing_profiles there is a much better place.

This commit also includes a hidden change: Previously, when parsing
include files, they were also added to existing_profiles. This is
superfluous, only real profiles need to be stored there.

(cherry picked from commit 8809218ac8)
This commit is contained in:
Christian Boltz 2018-10-22 23:11:22 +02:00
parent b6c96f3933
commit 7b07832459
Failed to generate hash of commit

View file

@ -2106,9 +2106,21 @@ def read_profile(file, active_profile):
if profile_data and active_profile: if profile_data and active_profile:
attach_profile_data(aa, profile_data) attach_profile_data(aa, profile_data)
attach_profile_data(original_aa, profile_data) attach_profile_data(original_aa, profile_data)
for profile in profile_data: # TODO: also honor hats
name = profile_data[profile][profile]['name']
filename = profile_data[profile][profile]['filename']
existing_profiles[name] = filename
elif profile_data: elif profile_data:
attach_profile_data(extras, profile_data) attach_profile_data(extras, profile_data)
for profile in profile_data: # TODO: also honor hats
name = profile_data[profile][profile]['name']
filename = profile_data[profile][profile]['filename']
existing_profiles[name] = filename
def attach_profile_data(profiles, profile_data): def attach_profile_data(profiles, profile_data):
# Make deep copy of data to avoid changes to # Make deep copy of data to avoid changes to
@ -2200,9 +2212,6 @@ def parse_profile_data(data, file, do_include):
if pps_set_hat_external: if pps_set_hat_external:
profile_data[profile][hat]['external'] = True profile_data[profile][hat]['external'] = True
# Profile stored
existing_profiles[profile] = file
# save profile name and filename # save profile name and filename
profile_data[profile][hat]['name'] = profile profile_data[profile][hat]['name'] = profile
profile_data[profile][hat]['filename'] = file profile_data[profile][hat]['filename'] = file