From b0bbc2e7c5541799288403fb4878cc3b7944d5ea Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Fri, 14 Oct 2011 14:07:27 +0200 Subject: [PATCH] Offline state is now settable in repository.conf --- installsystems/repository.py | 26 +++++++++++++++++++++++--- samples/repository.conf | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/installsystems/repository.py b/installsystems/repository.py index 8c02c2d..7b3b704 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -502,10 +502,15 @@ class RepositoryManager(object): if self.filter is not None: if not fnmatch.fnmatch(config.name, self.filter): return + # repository is offline + if config.offline: + debug("Registering offline repository %s (%s)" % (config.path, config.name)) + self.repos.append(Repository(config)) # if path is local, no needs to create a cache - if istools.isfile(config.path): + elif istools.isfile(config.path): debug("Registering direct repository %s (%s)" % (config.path, config.name)) self.repos.append(Repository(config)) + # path is remote, we need to create a cache else: debug("Registering cached repository %s (%s)" % (config.path, config.name)) self.repos.append(self._cachify(config)) @@ -643,7 +648,7 @@ class RepositoryConfig(object): # set default value for arguments self.name = name self.path = "" - self.offline = False + self._offline = False self._dbpath = None self.dbname = "db" self._lastpath = None @@ -658,7 +663,7 @@ class RepositoryConfig(object): def __str__(self): l = [] - for a in ("name", "path", "dbpath", "lastpath", "uid", "gid", "fmod", "dmod"): + for a in ("name", "path", "dbpath", "lastpath", "uid", "gid", "fmod", "dmod", "offline"): l.append("%s: %s" % (a, getattr(self, a))) return os.linesep.join(l) @@ -774,6 +779,21 @@ class RepositoryConfig(object): else: raise ValueError("Directory mode must be an integer") + @property + def offline(self): + ''' + Get the offline state of a repository + ''' + return self._offline + + @offline.setter + def offline(self, value): + if type(value) in (str, unicode): + value = value.lower() not in ("false", "no", "0") + elif type(value) is not bool: + value = bool(value) + self._offline = value + def update(self, *args, **kwargs): ''' Update attribute with checking value diff --git a/samples/repository.conf b/samples/repository.conf index d7c4460..0df88de 100644 --- a/samples/repository.conf +++ b/samples/repository.conf @@ -15,3 +15,4 @@ # smartjog official installsystems repository #[smartjog] #path = http://installsystems.boot.wan/is +#offline = False -- GitLab