# yRc@sddlZddlZddlmZmZmZdefdYZdefdYZdefdYZ d e fd YZ dS( iN(tElementt SubElementttostringtArtifactExceptioncBseZRS((t__name__t __module__(((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyR&stArtifactFormatExceptioncBseZRS((RR(((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyR)stArtifactValidationExceptioncBseZRS((RR(((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyR,stArtifactcBseZdZdddddZdZdZedZddZddZ e e e d Z e d Z e dd Ze dd ZRS( s Simplified representation of Maven artifact for purpose of packaging Package consists mostly of simple properties and string formatting and loading functions to prevent code duplication elsewhere tcCs^|j|_|j|_|j|_|j|_|j|_|j|_dS(N(tstriptgroupIdt artifactIdt extensiont classifiertversiont namespace(tselfR R R RRR((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyt__init__7s c Cs7djd|jd|jd|jd|jd|jS(Nu{gid}:{aid}:{ext}:{cls}:{ver}tgidtaidtexttclstver(tformatR R R RR(R((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyt __unicode__@s    cCst|jtjS(N(tunicodetencodetsystgetfilesystemencoding(R((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyt__str__GscCsd}|jr|jd}ndjd|jd|j}|jrb|djd|j}n|jr|js|d}n|d jd |j}n|r|jstd jd t|n|d jd|j}n|js|jr|d}ndjd|d|S(s6Return representation of artifact as used in RPM dependencies versioned -- return artifact string including version Example outputs: mvn(commons-logging:commons-logging) mvn(commons-logging:commons-logging:1.2) # versioned mvn(commons-logging:commons-logging:war:) mvn(commons-logging:commons-logging:war:1.2) # versioned mvn(commons-logging:commons-logging:war:test-jar:) mvn(commons-logging:commons-logging:war:test-jar:1.3) # versioned maven31-mvn(commons-logging:commons-logging) tmvns-mvns {gid}:{aid}RRs:{ext}Rt:s:{clas}tclassCCannot create versioned string from artifact without version: {art}tarts:{ver}Rs{namespace}({mvnstr})Rtmvnstr( RRR R R RRRtstr(Rt versionedRR#((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyt get_rpm_strJs(        tartifactcCsct|}xPdD]H}t||rt||rt||}t|||_qqW|S(sH Return XML Element node representation of the Artifact R R R RRR(s artifactIdsgroupIds extensionsversions classifiers namespace(RthasattrtgetattrRttext(Rtroottkeytitem((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pytget_xml_elementss  cCs|j|}t|dtS(sL Return XML formatted string representation of the Artifact t pretty_print(R.RtTrue(RR+((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pyt get_xml_strsc Cst}t}t}tjd}xnd D]f}t||} | sIq(n| rXt}n| jdd krvt}n|j| r(t}q(q(W| r|rtd n| r|rtd n| r|rtd ntS(s Function to validate current state of artifact with regards to wildcards, empty parts and backreference usage s@\d+R R R RRRt*isAll parts of artifact are emptysWildcard used in artifactsBackreference used in artifact(s artifactIdsgroupIds extensionsversions classifiers namespace(R0tFalsetretcompileR)tfindtmatchR( Rt allow_emptytallow_wildcardst allow_backreft all_emptyt wildcard_usedt backref_usedt backref_reR,tval((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pytvalidates,       cCsm||j|j|j|j|j|j}x9dD]1}t||s4t||t||q4q4W|S(s Merge two artifacts into one. Information missing in dominant artifact will be copied from recessive artifact. Returns new merged artifact R R R RRR(s artifactIdsgroupIds extensionsversions classifiers namespace(R R R RRRR)tsetattr(Rtdominantt recessivetretR,((s9/usr/lib/python2.7/site-packages/javapackages/artifact.pytmerge_artifactss  cCs idd6dd6dd6dd6dd6}xR|D]J}|jd|}|d k r0|jd k r0|jj||!s