# yRc@s~ddlZddlZddlmZddlmZdefdYZdefdYZ de fd YZ dS( iN(t fromstring(tArtifacttDepmapLoadingExceptioncBseZRS((t__name__t __module__(((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyR'stDepmapInvalidExceptioncBseZRS((RR(((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyR*stDepmapcBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( s Class for working with depmap files (dependency maps). These are files used by XMvn to provide mapping between Maven artifacts and file on the filesystem. Example usage: >>> d = Depmap('maven-idea-plugin.xml') >>> print d.get_java_requires() 1.5 >>> print d.get_provided_artifacts()[0] org.apache.maven.plugins:maven-idea-plugin:None:None:2.2 cCsk||_|j||jdkr@tdjd|n|jsgtdjd|ndS(Ns1Failed to load fragment {path} You have a problemtpaths6Depmap {path} does not contain any provided artifacts (t _Depmap__patht_Depmap__load_depmapt _Depmap__doctNoneRtformattget_provided_mappings(tselfR((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyt__init__;s    c Cst|w}y4tjtjj|dd|}|j}Wn*tk ro|jd|j}nXt ||_ WdQXdS(Ntrbtfileobji( topentgziptGzipFiletosRtbasenametreadtIOErrortseekRR (Rt fragment_pathtftgzftdata((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyt __load_depmapCs   cCsF|j}x!|D]\}}|jrtSqW|jjddk S(snReturn true if depmap is for compatibility package This means package should have versioned providess.//skipProvidesN(R tversiontTrueR tfindR (Rt provided_mapstmtl((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyt is_compatRs   cCsg}x|jjdD]}}|jd}t|dkrOtdntj|d}|jstdjd|jn|j |qW|S(s2Returns list of Artifact provided by given depmap.s .//dependencys./mavenis"Multiple maven nodes in dependencyis5Depmap {path} does not have version in maven providesR( R tfindalltlenRRtfrom_xml_elementRR Rtappend(Rt artifactstdeptartifact((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pytget_provided_artifacts]s cCsg}x|jjdD]}|jd}t|dkrOtdntj|d}|jstdjd|jn|jd}t|dkrtd ntj|d}|j ||fqW|S( sReturn list of (Artifact, Artifact) tuples. First part of returned tuple is Maven artifact identification Second part of returned tuple is local artifact identification s .//dependencys./mavenis"Multiple maven nodes in dependencyis5Depmap {path} does not have version in maven providesRs./jpps Multiple jpp nodes in dependency( R R&R'RRR(RR RR)(RtmappingsR+t m_artifactt l_artifact((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyR js cCsCg}x6|jjdD]"}tj|}|j|qW|S(s2Returns list of Artifact required by given depmap.s.//autoRequires(R R&RR(R)(RR*R+R,((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pytget_required_artifactss cCsCg}x6|jjdD]"}tj|}|j|qW|S(s:Returns list of Artifact that were build but not installeds.//skippedArtifact(R R&RR(R)(RR*R+R,((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pytget_skipped_artifactss cCs.|jjd}|dk r*|j}n|S(s.Returns JVM version required by depmap or Nones.//requiresJavaN(R R!R ttext(Rtjreq((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pytget_java_requiress  cCs.|jjd}|dk r*|j}n|S(s:Returns JVM development version required by depmap or Nones.//requiresJavaDevelN(R R!R R3(RR4((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pytget_java_devel_requiress  ( RRt__doc__RR R%R-R R1R2R5R6(((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyR-s       ( Rtos.pathRt lxml.etreeRtjavapackages.artifactRt ExceptionRRtobjectR(((s7/usr/lib/python2.7/site-packages/javapackages/depmap.pyt s