diff --git a/maven/artifact.py b/maven/artifact.py index 5855772..22670d7 100644 --- a/maven/artifact.py +++ b/maven/artifact.py @@ -1,4 +1,4 @@ -import os +import os.path class Artifact(object): def __init__(self, group_id, artifact_id, version, classifier=None, extension=None): @@ -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( @@ -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: