From 4db7bd1b305d645305bfe37fa7d3a8bb8c404c0c Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Fri, 9 Jun 2017 12:59:11 +0200 Subject: [PATCH] Check objects type rather than None for deps and properties * this allow subclasses working without clients to override the _get_pom_factory method and return plain artifacts from coordinates rather than full Pom objects when there is no client to retrieve an artifact remotely. Link: https://github.com/sassoftware/pymaven/issues/3 Link: https://github.com/sassoftware/pymaven/issues/4 Signed-off-by: Philippe Ombredanne --- pymaven/pom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pymaven/pom.py b/pymaven/pom.py index b66a5fd..f7176c0 100644 --- a/pymaven/pom.py +++ b/pymaven/pom.py @@ -278,7 +278,7 @@ def dependencies(self): dependencies = {} # we depend on our parent - if self.parent is not None: + if isinstance(self.parent, Pom): group = self.parent.group_id artifact = self.parent.artifact_id version = self.parent.version @@ -305,7 +305,7 @@ def dependency_management(self): dep_mgmt = {} # add parent's block first so we can override it - if self.parent is not None: + if isinstance(self.parent, Pom): dep_mgmt.update(self.parent.dependency_management) dep_mgmt.update(self._find_dependency_management()) @@ -329,8 +329,9 @@ def parent(self): def properties(self): properties = {} - if self.parent is not None: + if isinstance(self.parent, Pom): properties.update(self.parent.properties) + if isinstance(self.parent, Artifact): properties['parent.groupId'] = self.parent.group_id properties['parent.artifactId'] = self.parent.artifact_id properties['parent.version'] = str(self.parent.version)