3 À<×e®ã@stddlZddlZddlmZmZddljZddlZ ddl Z ddl Zddl Z ddl mZejjƒZGdd„deƒZdS)éN)Ú ConfigParserÚError)ÚInvalidProfileExceptionc@sveZdZdZdddddgZdd„Zd d „Zed d „ƒZe d d„ƒZ dd„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)ÚLoaderz Profiles loader. Ú_profile_locatorÚ_profile_mergerÚ_profile_factoryÚ_global_configÚ _variablescCs"||_||_||_||_||_dS)N)rrrr r )ÚselfÚprofile_locatorZprofile_factoryZprofile_mergerZ global_configÚ variables©rú/usr/lib/python3.6/loader.pyÚ__init__s zLoader.__init__cCstjjj||ƒS)N)ÚtunedÚprofilesÚprofileZProfile)r Ú profile_nameÚconfigrrrÚ_create_profileszLoader._create_profilecCs tjd|ƒS)Nz^[a-zA-Z0-9_.-]+$)ÚreÚmatch)ÚclsrrrrÚ safe_nameszLoader.safe_namecCs|jS)N)r)r rrrr "szLoader.profile_locatorcCsît|ƒtk r|jƒ}tt|j|ƒƒ}t|ƒdkr8tdƒ‚t|ƒdkrZtjddj |ƒƒntjd|dƒg}g}|j |||ƒt|ƒdkrœ|j j |ƒ}n|d}dj |ƒ|_ d|jkrÖ|jj|jdjƒ|jd=|j|ƒ|j|ƒ|S) Nrz.No profile or invalid profiles were specified.ézloading profiles: %sz, zloading profile: %sú r )ÚtypeÚlistÚsplitÚfilterrÚlenrÚlogÚinfoÚjoinÚ _load_profilerÚmergeÚnameÚunitsr Z add_from_cfgÚoptionsÚ_expand_vars_in_devicesÚ_expand_vars_in_regexes)r Ú profile_namesrÚprocessed_filesZ final_profilerrrÚload&s*        z Loader.loadcCs0x*|jD] }|jj|j|jƒ|j|_qWdS)N)r(r ÚexpandZdevices)r rÚunitrrrr*Ds zLoader._expand_vars_in_devicescCsLxF|jD]<}|jj|j|jƒ|j|_|jj|j|jƒ|j|_qWdS)N)r(r r/Z cpuinfo_regexZ uname_regex)r rr0rrrr+Hs zLoader._expand_vars_in_regexesc Cs®x¨|D] }|jj||ƒ}|dkr"q|dkrFtd|tt|jjƒƒfƒ‚|j|ƒ|j|ƒ}|jj ||ƒ}d|j krœt j d|j j|j jdƒƒƒ}|j|||ƒ|j|ƒqWdS)NÚz!Cannot find profile '%s' in '%s'.Úincludez \s*[,;]\s*)rZ get_configrrÚreversedZ_load_directoriesÚappendÚ_load_config_datarZcreater)rrr r/Úpopr%) r r,rr-r'ÚfilenamerrZ include_namesrrrr%Ms    zLoader._load_profilecCstjd||ƒS)Nz(?s