3 í«„^Ë ã@slddlmZmZddlmZddlmZmZddlm Z edddd gƒZ ee ƒZ d d „Z Gd d „d eƒZdS)é)Ú defaultdictÚ namedtupleé)ÚDiffResultDescriptor)Ú DifferenceÚ SymbolWrapper)Útype_wrapper_factoryZ modified_roleÚ added_typesÚ removed_typesÚ matched_typesc Cs>yt|j|Stk r8t|ƒ}|t|j|<|SXdS)z| Wrap roles from the specified policy. This caches results to prevent duplicate wrapper objects in memory. N)Ú _roles_cacheZpolicyÚKeyErrorr)ZroleÚr©rú/usr/lib64/python3.6/roles.pyÚrole_wrapper_factory"s rc@s8eZdZdZedƒZedƒZedƒZdd„Zdd„Z dS)ÚRolesDifferencez7Determine the difference in roles between two policies.Ú diff_rolescCs®|jjdj|ƒƒ|jdd„|jjƒDƒdd„|jjƒDƒƒ\|_|_}t ƒ|_ xX|D]P\}}|jdd„|j ƒDƒdd„|j ƒDƒƒ\}}}|s”|rVt |||ƒ|j |<qVWdS)z6Generate the difference in roles between the policies.zDGenerating role differences from {0.left_policy} to {0.right_policy}css|]}t|ƒVqdS)N)r)Ú.0rrrrú @sz-RolesDifference.diff_roles..css|]}t|ƒVqdS)N)r)rrrrrrAscss|]}t|ƒVqdS)N)r)rÚtrrrrJscss|]}t|ƒVqdS)N)r)rrrrrrKsN) ÚlogÚinfoÚformatZ _set_diffZ left_policyZrolesZ right_policyÚ added_rolesÚ removed_rolesÚdictÚmodified_rolesÚtypesÚmodified_roles_record)ÚselfZ matched_rolesZ left_roleZ right_roler r r rrrr9s  zRolesDifference.diff_rolescCs"|jjdƒd|_d|_d|_dS)z%Reset diff results on policy changes.zResetting role differencesN)rÚdebugrrr)r rrrÚ _reset_diffUs zRolesDifference._reset_diffN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr"rrrrr1s rN)Ú collectionsrrZ descriptorsrÚ differencerrrrrrr rrrrrrÚs