From 08f268cc331ea62bc15ac83b0d37d6a7cf3010fa Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 4 Mar 2009 16:03:35 +0000 Subject: [PATCH] better with constructor param --- pisi/db/componentdb.py | 5 +++-- pisi/db/lazydb.py | 5 +++-- pisi/db/packagedb.py | 5 +++-- pisi/db/sourcedb.py | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pisi/db/componentdb.py b/pisi/db/componentdb.py index d2e44e8f..7200f30a 100644 --- a/pisi/db/componentdb.py +++ b/pisi/db/componentdb.py @@ -25,9 +25,10 @@ import pisi.db.lazydb as lazydb class ComponentDB(lazydb.LazyDB): - def init(self): - self.cacheable = True + def __init__(self): + lazydb.LazyDB.__init__(self, cacheable=True) + def init(self): component_nodes = {} component_packages = {} component_sources = {} diff --git a/pisi/db/lazydb.py b/pisi/db/lazydb.py index 71565211..0513efaf 100644 --- a/pisi/db/lazydb.py +++ b/pisi/db/lazydb.py @@ -22,15 +22,16 @@ class Singleton(object): return type._the_instance class LazyDB(Singleton): - def __init__(self): + def __init__(self, cacheable=False): if not self.__dict__.has_key("initialized"): self.initialized = False + self.cacheable = cacheable def is_initialized(self): return self.initialized def cache_save(self): - if os.access("/var/cache/pisi", os.W_OK) and self.__class__._the_instance.__dict__.has_key("cacheable"): + if os.access("/var/cache/pisi", os.W_OK) and self.cacheable: cPickle.dump(self.__class__._the_instance.__dict__, file('/var/cache/pisi/%s.cache' % self.__class__.__name__.lower(), 'wb'), 1) diff --git a/pisi/db/packagedb.py b/pisi/db/packagedb.py index a8a8a2e2..68e5a1cf 100644 --- a/pisi/db/packagedb.py +++ b/pisi/db/packagedb.py @@ -35,9 +35,10 @@ import pisi.db.lazydb as lazydb class PackageDB(lazydb.LazyDB): - def init(self): - self.cacheable = True + def __init__(self): + lazydb.LazyDB.__init__(self, cacheable=True) + def init(self): self.__package_nodes = {} # Packages self.__revdeps = {} # Reverse dependencies self.__obsoletes = {} # Obsoletes diff --git a/pisi/db/sourcedb.py b/pisi/db/sourcedb.py index 8c7cc7dc..627e8968 100644 --- a/pisi/db/sourcedb.py +++ b/pisi/db/sourcedb.py @@ -24,9 +24,10 @@ import pisi.db.lazydb as lazydb class SourceDB(lazydb.LazyDB): - def init(self): - self.cacheable = True + def __init__(self): + lazydb.LazyDB.__init__(self, cacheable=True) + def init(self): self.__source_nodes = {} self.__pkgstosrc = {} self.__revdeps = {}