From 791b9192ca6168a49cdc3a93bc322415d9668356 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Mon, 24 Aug 2015 13:06:47 +0000 Subject: Add an ignore_version_field option to Package If we're using an external tool to resolve dependencies then we may be want to ignore the version field. Change-Id: Ic41f5b5ac080a5e9a0b4e1b0607464faabb1ec94 --- baserockimport/mainloop.py | 9 ++++++--- baserockimport/package.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py index 33488ea..a70981d 100644 --- a/baserockimport/mainloop.py +++ b/baserockimport/mainloop.py @@ -104,7 +104,7 @@ class ImportLoop(object): ''' def __init__(self, app, goal_kind, goal_name, goal_version, - generate_chunk_morphs=True): + generate_chunk_morphs=True, ignore_version_field=False): '''Set up an ImportLoop to process dependencies of one goal package.''' self.app = app @@ -112,6 +112,7 @@ class ImportLoop(object): self.goal_name = goal_name self.goal_version = goal_version self.generate_chunk_morphs = generate_chunk_morphs + self.ignore_version_field = ignore_version_field self.lorry_set = baserockimport.lorryset.LorrySet( self.app.settings['lorries-dir']) @@ -159,7 +160,8 @@ class ImportLoop(object): os.makedirs(chunk_dir) goal = baserockimport.package.Package( - self.goal_kind, self.goal_name, self.goal_version) + self.goal_kind, self.goal_name, self.goal_version, + ignore_version_field=self.ignore_version_field) to_process = [goal] # Every Package object is added as a node in the 'processed' graph. @@ -310,7 +312,8 @@ class ImportLoop(object): if queue_item is None: queue_item = baserockimport.package.Package( - kind, name, version) + kind, name, version, + ignore_version_field=self.ignore_version_field) to_process.append(queue_item) dep_package = queue_item diff --git a/baserockimport/package.py b/baserockimport/package.py index 6360cd8..8df011b 100644 --- a/baserockimport/package.py +++ b/baserockimport/package.py @@ -22,7 +22,7 @@ class Package(object): packages depend on it, and hence of why it was added to the queue. ''' - def __init__(self, kind, name, version): + def __init__(self, kind, name, version, ignore_version_field=False): self._kind = kind self._name = name self._version = version @@ -33,7 +33,9 @@ class Package(object): self.named_ref = None self.dependencies = None self.is_build_dep = False - self.version_in_use = version + self.match = (self._match if ignore_version_field + else self._match_version) + def __cmp__(self, other): return cmp(self.name, other.name) @@ -52,11 +54,14 @@ class Package(object): def add_required_by(self, item): self.required_by.append('%s-%s' % (item.name, item.version)) - def match(self, kind, name, version): + def _match_version(self, kind, name, version): return (self.kind == kind and self.name == name and self.version == version) + def _match(self, kind, name, version): + return self.kind == kind and self.name == name + @property def kind(self): return self._kind -- cgit v1.2.1