a h @s8ddlmZddlmZddlmZGdddeZdS)N)reduce)Profilec@s(eZdZdZddZddZddZdS) Mergerz0 Tool for merging multiple profiles into one. cCsdS)N)selfrr9/usr/lib/python3.9/site-packages/tuned/profiles/merger.py__init__ szMerger.__init__cCst|j|t}|S)z Merge multiple configurations into one. If there are multiple units of the same type, option 'devices' is set for each unit with respect to eliminating any duplicate devices. )r _merge_twor)rZconfigsZ merged_configrrrmerge sz Merger.mergec CsL|jdur|j|_|j|jt|jD]\}}|jtjkr|j rT|j t |j t |j @}|j |j|jrt|jD]}||vr|j j|ddqq.|j s||jvr||j|<q.|j|j|_|j|j|_|j|j|_|jdur|j|j|_|jdur(|j|j|_|jdurB|j|j|_|jdur\|j|j|_|jdurv|j|j|_|jdur|j|j|_|jdur|jD]}|j|j|dqd|_|dkr2|j|jdddur2|j|jdd}|j|j|j||j|jd|j|jd<q.|j|j|jq.|S)z Merge two profiles. The configuration of units with matching names are updated with options from the newer profile. If the 'replace' options of the newer unit is 'True', all options from the older unit are dropped. NF)lastscript)nameoptionsupdatelistZunitsitemstypeconstsZPLUGIN_VARIABLES_UNIT_NAMEreplaceZ variablesclearsetkeysZprependreversed move_to_endZenabledZdevicespriorityZdevices_udev_regexZ cpuinfo_regexZ uname_regexZ script_preZ script_postZdroppopget) rZ profile_aZ profile_bZ unit_nameZunitZoverwritten_variablesvariableoptionr rrrr sP            $"zMerger._merge_twoN)__name__ __module__ __qualname____doc__rr r rrrrrsr)Z tuned.constsr functoolsrZtuned.profiles.profilerobjectrrrrrs