diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5ba5e9 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Pymaven + +## Overview + +Pymaven is a Python library for interfacing with the maven build system. There +are two major interfaces: + +- pymaven.client provides a basic maven repository client +- pymaven.pom provides a Pom object that can provide progromatic access to + a maven pom file diff --git a/README.rst b/README.rst deleted file mode 100644 index 10427ea..0000000 --- a/README.rst +++ /dev/null @@ -1 +0,0 @@ -Python library for interfacing with maven diff --git a/pymaven/pom.py b/pymaven/pom.py index ee81da5..a3708a8 100644 --- a/pymaven/pom.py +++ b/pymaven/pom.py @@ -24,15 +24,29 @@ from .artifact import Artifact from .utils import memoize +from .utils import parse_source from .versioning import VersionRange +EMPTY_POM = """\ + + + 4.0.0 + {0.group_id} + {0.artifact_id} + {0.version} + +""" +POM_NAMESPACE = "http://maven.apache.org/POM/4.0.0" +POM = "{%s}" % (POM_NAMESPACE,) +POM_NAMESPACE_LEN = len(POM) POM_PARSER = etree.XMLParser( recover=True, remove_comments=True, remove_pis=True, ) PROPERTY_RE = re.compile(r'\$\{(.*?)\}') -STRIP_NAMESPACE_RE = re.compile(r"") +STRIP_NAMESPACE_RE = re.compile(POM) log = logging.getLogger(__name__) @@ -43,17 +57,12 @@ class Pom(Artifact): RANGE_CHARS = ('[', '(', ']', ')') - __slots__ = ("_client", "_parent", "_dep_mgmt", "_dependencies", - "_properties", "_xml") + __slots__ = ("_client", "_parent", "_dep_mgmt", "_dependencies", "_pom_data", "_properties") - def __init__(self, coordinate, client): - super(Pom, self).__init__(coordinate) - with client.get_artifact(self.coordinate).contents as fh: - xml = fh.read() - self._xml = etree.fromstring( - STRIP_NAMESPACE_RE.sub('', xml[xml.find('