3 À<×eˆã@s(ddlZddlmZGdd„deƒZdS)éN)Úreducec@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚMergerz0 Tool for merging multiple profiles into one. cCsdS)N©)Úselfrrú/usr/lib/python3.6/merger.pyÚ__init__ szMerger.__init__cCst|j|ƒ}|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_two)rZconfigsZ merged_configrrrÚmerge s z Merger.mergecCs¨|jj|jƒx’t|jjƒƒD]~\}}|js:||jkrF||j|<q |j|j|_|j|j|_|j|j|_|j dk rˆ|j |j|_ |j dk r |j |j|_ |j dk r¸|j |j|_ |j dk rÐ|j |j|_ |j dk rè|j |j|_ |jdk rx"|jD]}|j|jj|dƒqüWd|_|dkrŒ|j|jjddƒdk rŒ|j|jjddƒ}|j|jj|jƒ||j|jd|j|jd<q |j|jj|jƒq W|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. NÚscript)ZoptionsÚupdateÚlistZunitsÚitemsÚreplaceÚtypeZenabledZdevicesZdevices_udev_regexZ cpuinfo_regexZ uname_regexZ script_preZ script_postZdropÚpopÚget)rZ profile_aZ profile_bZ unit_nameZunitZoptionr rrrrs6        $"zMerger._merge_twoN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr rrrrrrsr)Ú collectionsÚ functoolsrÚobjectrrrrrÚs