From 43bc173894a916e819b3399b999f99d798a325c7 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 19 May 2007 10:53:14 +0000 Subject: [PATCH] Made Implementation an abstract base class, with the previous implementation in a new ZeroInstallImplementation sub-class. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/trunk/0launch@1762 9f8c893c-44ee-0310-b757-c8ca8341c71e --- tests/testmodel.py | 8 ++++---- zeroinstall/injector/model.py | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/testmodel.py b/tests/testmodel.py index e6be4ab..89fe9bd 100755 --- a/tests/testmodel.py +++ b/tests/testmodel.py @@ -75,11 +75,11 @@ class TestModel(BaseTest): assert a and b and c assert a is c assert a is not b - assert isinstance(a, model.Implementation) + assert isinstance(a, model.ZeroInstallImplementation) def testImpl(self): i = model.Interface('http://foo') - a = model.Implementation(i, 'foo') + a = model.ZeroInstallImplementation(i, 'foo') assert a.id == 'foo' assert a.size == a.version == a.user_stability == None assert a.arch == a.upstream_stability == None @@ -96,13 +96,13 @@ class TestModel(BaseTest): self.assertEquals('1.2.3-rc2-post', a.get_version()) assert str(a) == 'foo' - b = model.Implementation(i, 'foo') + b = model.ZeroInstallImplementation(i, 'foo') b.version = [1,2,1] assert b > a def testDownloadSource(self): i = model.Interface('http://foo') - a = model.Implementation(i, 'foo') + a = model.ZeroInstallImplementation(i, 'foo') a.add_download_source('ftp://foo', 1024, None) a.add_download_source('ftp://foo.tgz', 1025, 'foo') assert a.download_sources[0].url == 'ftp://foo' diff --git a/zeroinstall/injector/model.py b/zeroinstall/injector/model.py index 4ba420e..43628db 100644 --- a/zeroinstall/injector/model.py +++ b/zeroinstall/injector/model.py @@ -228,25 +228,35 @@ class Recipe(RetrievalMethod): class Implementation(object): """An Implementation is a package which implements an Interface.""" - __slots__ = ['os', 'machine', 'upstream_stability', 'user_stability', - 'version', 'size', 'requires', 'main', 'metadata', - 'id', 'download_sources', 'released', 'interface'] + __slots__ = ['upstream_stability', 'user_stability', + 'requires', 'main', 'metadata', + 'id', 'interface'] def __init__(self, interface, id): - """id can be a local path (string starting with /) or a manifest hash (eg "sha1=XXX")""" assert id self.interface = interface self.id = id self.main = None + self.user_stability = None + self.upstream_stability = None + self.metadata = {} # [URI + " "] + localName -> value + self.requires = [] + +class ZeroInstallImplementation(Implementation): + """An implementation where all the information comes from Zero Install. + @since: 0.28""" + __slots__ = ['os', 'machine', 'upstream_stability', 'user_stability', + 'version', 'size', 'requires', 'main', 'metadata', + 'id', 'download_sources', 'released', 'interface'] + + def __init__(self, interface, id): + """id can be a local path (string starting with /) or a manifest hash (eg "sha1=XXX")""" + Implementation.__init__(self, interface, id) self.size = None self.version = None self.released = None - self.user_stability = None - self.upstream_stability = None self.os = None self.machine = None - self.metadata = {} # [URI + " "] + localName -> value - self.requires = [] self.download_sources = [] # [RetrievalMethod] # Deprecated @@ -332,7 +342,7 @@ class Interface(object): def get_impl(self, id): if id not in self.implementations: - self.implementations[id] = Implementation(self, id) + self.implementations[id] = ZeroInstallImplementation(self, id) return self.implementations[id] def set_stability_policy(self, new): -- 2.11.4.GIT