oB]c@sddlZddlZddlmZddlmZddlmZejdZej e Z dZ dZ dZd efd YZd efd YZd ZdZdZdZdS(iN(timporter(tlog(t type_utilss#(^[a-zA-Z_][A-Za-z0-9_]*)\((.*?)\)$slist()+dict()+str()tm_tMergert UnknownMergercBseZdZdZRS(cCs|S(N((tselft _meth_wantedtvaluet _merge_with((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyt_handle_unknownscCstj|}|j}d|}d}||g}t||rXt||}n|sz|j}|jd|n||S(Ns_on_%si(Rtobj_nametlowertNonethasattrtgetattrR tinsert(Rtsourcet merge_witht type_namet method_nametmethtargs((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pytmerge%s    (t__name__t __module__R R(((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyRs t LookupMergercBs&eZddZdZdZRS(cCs2tj||dkr%g|_n ||_dS(N(Rt__init__R t_lookups(Rtlookups((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyR4s   cCsdt|jS(NsLookupMerger: (%s)(tlenR(R((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyt__str__;scCsed}x3|jD](}t||rt||}PqqW|sXtj||||S|||S(N(R RRRRR (Rt meth_wantedRRRtmerger((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyR Cs  N(RRR RRR (((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyR3s  cCsg}|jdd}|dkr9|jdd}n|dkrI|St|tjret|Sx|D]}t|tr|d}|jddj}|d}n/|d}t |dkr|d }ng}|rl|j ||fqlqlW|S( Nt merge_howt merge_typetnamet-t_tsettingsiii( tpopR t isinstancetsixt string_typeststring_extract_mergerstdicttreplacetstripRtappend(tconfigtparsed_mergerst raw_mergerstmR$topts((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pytdict_extract_mergersQs(        cCsg}x|jdD]}|jj}|jdd}|sLqntj|}|szd|}t|n|j\}}|jjd}g|D]$}|jr|jj^q}|j||fqW|S(Nt+R%R&s1Matcher identifer '%s' is not in the right formatt,( tsplitR R/R.t NAME_MTCHtmatcht ValueErrortgroupsR0(R"R2tm_nameR;tmsgtm_opsR4((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyR,js 1cCstttS(N(ttupleR,tDEF_MERGE_TYPE(((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pytdefault_mergerssc Csg}x|D]\}}|jts;tt|}ntj|tgtg\}}|sd|t|f}t|q tj|d}t |t}|j ||fq Wg} t | } x*|D]"\} } | j | | | qW| S(NsICould not find merger module named '%s' with attribute '%s' (searched %s)i( t startswitht MERGER_PREFIXtstrRt find_moduleRt MERGER_ATTRt ImportErrort import_moduleRR0R( R2t mergers_to_beR>R@t merger_locst looked_locsR?tmodtmod_attrtmergerstroottattrR5((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyt constructs*   (treR*t cloudinitRRtloggingRtcompileR:t getLoggerRtLOGRBRERHtobjectRRR6R,RCRS(((s>/usr/lib/python2.7/site-packages/cloudinit/mergers/__init__.pyts