From a2a9db4f098398212048681fe393d6717020f6c2 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Wed, 8 Oct 2014 17:08:56 +0200 Subject: [PATCH] create PrintProgress class instead of using IProgress as default one --- weboob/core/ouiboube.py | 4 ++-- weboob/core/repositories.py | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/weboob/core/ouiboube.py b/weboob/core/ouiboube.py index 2cc9765d..bf0de538 100644 --- a/weboob/core/ouiboube.py +++ b/weboob/core/ouiboube.py @@ -23,7 +23,7 @@ import os from weboob.core.bcall import BackendsCall from weboob.core.modules import ModulesLoader, RepositoryModulesLoader, ModuleLoadError from weboob.core.backendscfg import BackendsConfig -from weboob.core.repositories import Repositories, IProgress +from weboob.core.repositories import Repositories, PrintProgress from weboob.core.scheduler import Scheduler from weboob.tools.backend import Module from weboob.tools.config.iconfig import ConfigError @@ -362,7 +362,7 @@ class Weboob(WebNip): elif not os.path.isdir(name): self.logger.error(u'"%s" is not a directory', name) - def update(self, progress=IProgress()): + def update(self, progress=PrintProgress()): """ Update modules from repositories. """ diff --git a/weboob/core/repositories.py b/weboob/core/repositories.py index c7f6d034..a9c3e42d 100644 --- a/weboob/core/repositories.py +++ b/weboob/core/repositories.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright(C) 2010-2012 Romain Bignon, Laurent Bachelier +# Copyright(C) 2010-2014 Romain Bignon, Laurent Bachelier # # This file is part of weboob. # @@ -41,10 +41,6 @@ except ImportError: from configparser import RawConfigParser, DEFAULTSECT -__all__ = ['IProgress', 'ModuleInstallError', 'ModuleInfo', 'RepositoryUnavailable', - 'Repository', 'Versions', 'Repositories', 'InvalidSignature', 'Keyring'] - - class ModuleInfo(object): """ Information about a module available on a repository. @@ -375,6 +371,16 @@ class Versions(object): class IProgress(object): + def progress(self, percent, message): + raise NotImplementedError() + + def error(self, message): + raise NotImplementedError() + + def __repr__(self): + return '<%s>' % self.__class__.__name__ + +class PrintProgress(IProgress): def progress(self, percent, message): print('=== [%3.0f%%] %s' % (percent*100, message)) @@ -546,7 +552,7 @@ class Repositories(object): l.append(line) return l - def update_repositories(self, progress=IProgress()): + def update_repositories(self, progress=PrintProgress()): self.load_browser() """ Update list of repositories by downloading them @@ -594,7 +600,7 @@ class Repositories(object): l.append(repository) return True - def update(self, progress=IProgress()): + def update(self, progress=PrintProgress()): """ Update repositories and install new packages versions. @@ -608,7 +614,7 @@ class Repositories(object): if not info.is_local() and info.is_installed(): to_update.append(info) - class InstallProgress(IProgress): + class InstallProgress(PrintProgress): def __init__(self, n): self.n = n @@ -622,7 +628,7 @@ class Repositories(object): except ModuleInstallError as e: inst_progress.progress(1.0, unicode(e)) - def install(self, module, progress=IProgress()): + def install(self, module, progress=PrintProgress()): """ Install a module.