ó ¡îRac@sCdZddlmZddlZddlZddlmZddlmZdZye Wne k rxd„Z nXe ƒZ dadefd „ƒYZd efd „ƒYZd d „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zedkr?ejeejƒƒndS(séMake the format of a vcproj really pretty. This script normalize and sort an xml. It also fetches all the properties inside linked vsprops and include them explicitly in the vcproj. It outputs the resulting xml to stdout. iÿÿÿÿ(tprint_functionN(tparse(tNodesnsylvain (Nicolas Sylvain)cCs||k||kS(N((txty((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pytcmpstCmpTuplecBseZdZd„ZRS(s!Compare function between 2 tuple.cCst|d|dƒS(Ni(R(tselfRR((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyt__call__%s(t__name__t __module__t__doc__R(((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyR#stCmpNodecBseZdZd„ZRS(s%Compare function between 2 xml nodes.cCs"d„}t||ƒ||ƒƒS(NcSsÃd}||j7}|jr,||j7}n|jr¿||jdƒ7}g}x0|jjƒD]\}}|j||fƒq^W|jtƒƒx+|D] \}}||7}||7}q˜Wn|S(NtnodetName(tnodeNamet nodeValuet attributest getAttributetitemstappendtsortR(R t node_stringt all_nodestnametvalue((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyt get_string-s    (R(RRRR((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyR,s (R R R R(((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyR )sicCs½|jtjkrI|jjƒrEtdd||jjƒfƒndS|jr_|jƒnd}|jr}|jj }n|dkr§tdd||j fƒn¨tdd||j fƒg}x@|jj ƒD]/\}}|j ||fƒ|j tƒƒqØWx/|D]'\}}tdd|||fƒqWtdd|ƒ|jrvtdd||jfƒnx%|jD]}t|d |d ƒq€Wtd d||j fƒdS( Ns%s%st is%s<%s>s%s<%ss %s %s="%s"s%s>s%s %stindentis%s(tnodeTypeRt TEXT_NODEtdatatstriptprintt childNodest normalizeRtlengthRRRRRRtPrettyPrintNode(R Rt attr_counttall_attributesRRtsub_node((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyR%Es0$     cCsrg}|jr(|jdƒdkr(gSxC|jD]8}|jdkr]|jt|ƒƒq2|j|ƒq2W|S(s-Returns a list of all the node and sub nodes.Rt_excluded_filestFilter(RRR"Rtextendt FlattenFilterR(R t node_listtcurrent((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyR,gs cCsŸg}x’|D]Š}|r x$tD]}|j|t|ƒ}q Wtj|ƒ|jdƒ}|jdƒr{|j|ƒq—|jtjj|ƒƒq q W|S(Ns"' t$( t REPLACEMENTStreplacetostchdirR t startswithRtpathtabspath(t filenamestcurrent_directorytnew_listtfilenametkey((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyt FixFilenamesys    cCsœ|jr˜xŒ|jjƒD]x\}}|d kr{|jdƒ}t|tjjtdƒƒ}|j|dj |ƒƒn|s|j |ƒqqWnd S( s=Makes all the properties we know about in this node absolute.tInheritedPropertySheetst RelativePathtAdditionalIncludeDirectoriestIntermediateDirectorytOutputDirectorytAdditionalLibraryDirectoriest;iN(R=R>R?R@RARB( RRtsplitR<R2R5tdirnamet ARGUMENTSt setAttributetjointremoveAttribute(R RRt path_listR9((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyt AbsoluteNodeˆs  c Cs8x%|jD]}t|ƒt|ƒq Wxh|jD]]}|jtjkr2|jjddƒ|_|jjddƒ|_|jjƒ|_q2q2W|j r9xš|j j ƒD]†\}}t |j dƒƒ}g}x-|D]%}|j |ƒsÚ|j|ƒqÚqÚW|j|dj|ƒƒ|s¬|j|ƒq¬q¬Wn|jrO|jƒng}xf|jr½|jdr½|jd}|j|ƒ|jdkr­|jt|ƒƒqX|j|ƒqXW|jtƒƒxc|D][} | jdkr| j r| j jdkrqÕqn| jd kr#qÕn|j| ƒqÕWd S( s5For each sub node, we call recursively this function.s ts RCiR*tToolit UserMacroN(R"RKt CleanupVcprojRRRRR1trstripRRtsortedRDtcountRRGRHRIR#t removeChildRR+R,RR R$t appendChild( R R(RRt sorted_listt unique_listtit node_arrayR.tnew_node((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyRO˜sF         cCscg}xV|jD]K}|jdkrx3|jD]%}|jdkr/|j|ƒq/q/WqqW|S(NtConfigurationst Configuration(R"RR(tvcprojtnodesR R(((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pytGetConfiguationNodesÓscCsPt|ƒ}|jjrL|jjdƒ}t|jdƒtjj|ƒƒSgS(NR=RC( RtdocumentElementRRR<RDR2R5RE(R:tdomtvsprops((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pytGetChildrenVspropsßs   "cCs{|jtjkrdS|jdƒ}|s/dSxE|jD]:}|j|jkr9|jdƒ}||krs|Sq9q9WdS(NR(RRRtNoneRR"R(tnode1tchild2t current_nameR(R((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyt SeekToNodeæs  cCsµ|js dSx¡|jjƒD]\}}|dkr;qn|j|ƒ}|r||kr‘|j|dj||gƒƒq‘n|j||ƒ|dkr|j|ƒqqWdS(NRRCR=(RRRRGRHRI(Rdtnode2Rtvalue2tvalue1((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pytMergeAttributesüs   % cCs`t||ƒxL|jD]A}t||ƒ}|rBt||ƒq|j|jtƒƒqWdS(N(RkR"RgtMergePropertiesRTt cloneNodetTrue(RdRhRetchild1((sk/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/pretty_vcproj.pyRls  c CsA|at|ƒdkr.td|dƒdSx@tdt|ƒƒD])}||jdƒ\}}|t| s6      "    ;    1