Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clientless pom #8

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/

# Distribution / packaging
.Python
.eggs/
env/
build/
develop-eggs/
Expand Down Expand Up @@ -53,3 +54,7 @@ docs/_build/

# PyBuilder
target/

# PBR
AUTHORS
ChangeLog
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Walter Scheper <Walter.Scheper@sas.com> <ratlaw@gmail.com>
56 changes: 56 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
==========
Change Log
==========

All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog`_
and this project adheres to `Semantic Versioning`_.

`Unreleased`_
=============

Changed
-------

* Use pbr for release management
* Add support for python 3.4, 3.5, and 3.6.
* Pom objects can now be loaded from a file or string and do not require
a maven client.

Fixed
-----

* Add license_file entry to setup.cfg
* Create cache dir securely and usable on non-POSIX filesystems.

Deprecated
----------

* Drop support for python 2.6

`0.2.0`_ - 2017-06-07

Changed
-------

* Unpin dependency versions. Allow major version compatibility.

`0.1.0`_ - 2015-10-10

Added
-----

* A simple maven repository client that can fetch and search for artifacts and
metadata.
* Support for local and http maven repositories.
* A simple cache for http maven repositories
* A python binding to POM data that dynamically loads information from POM
inheritance and dependency management.
* Python implementation of Maven version comparision and Maven version ranges.

.. _Keep a Changelog: http://keepachangelog.com/
.. _Semantic Versioning: http://semver.org/
.. _0.1.0: https://github.com/sassoftware/pymaven/compare/114b10e...3a844cd
.. _0.2.0: https://github.com/sassoftware/pymaven/compare/3a844cd...f99a287
.. _Unreleased: https://github.com/sassoftware/pymaven/compare/f99a287...HEAD
13 changes: 13 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
graft docs
graft pymaven
graft tests

include AUTHORS.rst
include CHANGELOG.rst
include ContributorAgreement.txt
include LICENSE
include README.rst

include tox.ini .travis.yml appveyor.yml

global-exclude *.py[cod] __pycache__ *.so *.dylib
1 change: 0 additions & 1 deletion README

This file was deleted.

13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======
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
10 changes: 0 additions & 10 deletions devreqs.txt

This file was deleted.

1 change: 0 additions & 1 deletion pymaven/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
from .versioning import Version
from .versioning import VersionRange


__all__ = ["Artifact", "Version", "VersionRange"]
24 changes: 17 additions & 7 deletions pymaven/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
in a maven repository
"""

import functools
import re
import sys

import six

from .errors import ArtifactParseError
from .versioning import VersionRange

if sys.version_info > (2,):
from .utils import cmp

MAVEN_COORDINATE_RE = re.compile(
r'(?P<group_id>[^:]+)'
Expand All @@ -34,6 +40,7 @@
)


@functools.total_ordering
class Artifact(object):
"""Represents an artifact within a maven repository."""

Expand Down Expand Up @@ -69,22 +76,18 @@ def __init__(self, coordinate):
def __cmp__(self, other):
if self is other:
return 0

if not isinstance(other, Artifact):
if isinstance(other, basestring):
if isinstance(other, six.string_types):
try:
return cmp(self, Artifact(other))
except ArtifactParseError:
pass
return 1

result = cmp(self.group_id, other.group_id)
if result == 0:
result = cmp(self.artifact_id, other.artifact_id)

if result == 0:
result = cmp(self.type, other.type)

if result == 0:
if self.classifier is None:
if other.classifier is not None:
Expand All @@ -94,13 +97,20 @@ def __cmp__(self, other):
result = -1
else:
result = cmp(self.classifier, other.classifier)

if result == 0:
result = cmp(self.version.version,
other.version.version)

return result

def __eq__(self, other):
return self.__cmp__(other) == 0

def __lt__(self, other):
return self.__cmp__(other) < 0

def __ne__(self, other):
return self.__cmp__(other) != 0

def __hash__(self):
return hash((self.group_id, self.artifact_id, self.version, self.type,
self.classifier))
Expand Down
19 changes: 10 additions & 9 deletions pymaven/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
#


try:
from xml.etree import cElementTree as ElementTree
except ImportError:
from xml.etree import ElementTree

from urlparse import urlparse
import getpass
import hashlib
import json
import logging
import os
import posixpath
import tempfile

from six.moves.urllib.parse import urlparse
import requests
import six

from . import utils
from .artifact import Artifact
Expand All @@ -37,6 +34,10 @@
from .pom import Pom
from .versioning import VersionRange

try:
from xml.etree import cElementTree as ElementTree
except ImportError:
from xml.etree import ElementTree

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -73,9 +74,9 @@ class Cache(object):
"""
def __init__(self, cacheDir=None):
if cacheDir is None:
cacheDir = "/tmp/%s-maven-cache" % getpass.getuser()
cacheDir = tempfile.mkdtemp(prefix=getpass.getuser())
if not os.path.exists(cacheDir):
os.makedirs(cacheDir, mode=0700)
os.makedirs(cacheDir, mode=0o700)
self.cacheDir = cacheDir

def _gen_key(self, method, uri, query_params):
Expand Down Expand Up @@ -155,7 +156,7 @@ class MavenClient(object):
""" Client for talking to a maven repository
"""
def __init__(self, *urls):
if isinstance(urls, basestring):
if isinstance(urls, six.string_types):
urls = [urls]
self._repos = []
for url in urls:
Expand Down
Loading