Skip to content

Commit

Permalink
Merge pull request #6 from JamesWrigley/master
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
hamnis authored Dec 20, 2017
2 parents 0f59672 + f83f124 commit b9d86a9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions maven/artifact.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import os.path

class Artifact(object):
def __init__(self, group_id, artifact_id, version, classifier=None, extension=None):
Expand All @@ -20,20 +20,23 @@ def is_snapshot(self):
return self.version and self.version.endswith("-SNAPSHOT")

def path(self, with_version=True):
base = self.group_id.replace(".", "/") + "/" + self.artifact_id
base = os.path.join(self.group_id.replace(".", "/"), self.artifact_id)
if with_version:
return base + "/" + self.version
return os.path.join(base, self.version)
else:
return base

def uri(self, base, resolved_version=None):
if self.is_snapshot() and not resolved_version:
raise ValueError("Expected uniqueversion for snapshot artifact " + str(self))
raise ValueError("Expected unique version for snapshot artifact " + str(self))
elif not self.is_snapshot():
resolved_version = self.version
if self.classifier:
return base + "/" + self.path() + "/" + self.artifact_id + "-" + resolved_version + "-" + self.classifier + "." + self.extension
return base + "/" + self.path() + "/" + self.artifact_id + "-" + resolved_version + "." + self.extension
return os.path.join(base, self.path(), "%s-%s-%s.%s" % (self.artifact_id, resolved_version,
self.classifier, self.extension))
return os.path.join(base, self.path(), "%s-%s.%s" % (self.artifact_id,
resolved_version,
self.extension))

def with_version(self, _version):
return Artifact(
Expand All @@ -45,9 +48,9 @@ def with_version(self, _version):

def _generate_filename(self):
if not self.classifier:
return self.artifact_id + "." + self.extension
return "%s.%s" % (self.artifact_id, self.extension)
else:
return self.artifact_id + "-" + self.classifier + "." + self.extension
return "%s-%s.%s" % (self.artifact_id, self.classifier, self.extension)

def get_filename(self, filename=None):
if not filename:
Expand Down

0 comments on commit b9d86a9

Please sign in to comment.