From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id A657C1381F3 for ; Wed, 3 Jul 2013 17:20:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7FC83E0933; Wed, 3 Jul 2013 17:20:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 07CD0E0933 for ; Wed, 3 Jul 2013 17:20:38 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B7FB633E896 for ; Wed, 3 Jul 2013 17:20:37 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 50E57E468F for ; Wed, 3 Jul 2013 17:20:36 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1372870781.7dee38ce521eec08275ad6d6a259eaa6ed16602a.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/interface/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/interface/depres.py roverlay/interface/generic.py roverlay/interface/main.py roverlay/interface/root.py X-VCS-Directories: roverlay/interface/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 7dee38ce521eec08275ad6d6a259eaa6ed16602a X-VCS-Branch: gsoc13/next Date: Wed, 3 Jul 2013 17:20:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6be8d509-3b7e-454c-9f82-78eb9560a249 X-Archives-Hash: 4127def80ff2b1d82f0475a6f2b2ab78 commit: 7dee38ce521eec08275ad6d6a259eaa6ed16602a Author: André Erdmann mailerd de> AuthorDate: Wed Jul 3 16:59:41 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Wed Jul 3 16:59:41 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=7dee38ce roverlay/interface: fixup --- roverlay/interface/depres.py | 2 ++ roverlay/interface/generic.py | 4 +++- roverlay/interface/main.py | 30 ++++++++++++++++++++++++++++++ roverlay/interface/root.py | 37 ++++++++++++++++++++++++++++++++----- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/roverlay/interface/depres.py b/roverlay/interface/depres.py index d416312..e9ac5b7 100644 --- a/roverlay/interface/depres.py +++ b/roverlay/interface/depres.py @@ -69,6 +69,7 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): def close ( self ): super ( DepresInterface, self ).close() self._resolver.close() + return self # --- end of close (...) --- def update ( self ): @@ -76,6 +77,7 @@ class DepresInterface ( roverlay.interface.generic.RoverlaySubInterface ): if self._poolstack: self._poolstack[-1].sort() self._update_resolver() + return self # --- end of update (...) --- def has_pool ( self ): diff --git a/roverlay/interface/generic.py b/roverlay/interface/generic.py index 08806ea..c6678f3 100644 --- a/roverlay/interface/generic.py +++ b/roverlay/interface/generic.py @@ -21,10 +21,11 @@ class RoverlayInterface ( object ): def close ( self ): self.close_interfaces() + return self # --- end of close (...) --- def update ( self ): - pass + return self # --- end of update (...) --- def attach_interface ( self, name, interface, close_detached=True ): @@ -37,6 +38,7 @@ class RoverlayInterface ( object ): def detach_interface ( self, name, close=False ): detached = self._interfaces [name] + del self._interfaces [name] if close: detached.close() return True diff --git a/roverlay/interface/main.py b/roverlay/interface/main.py new file mode 100644 index 0000000..dfa89e2 --- /dev/null +++ b/roverlay/interface/main.py @@ -0,0 +1,30 @@ +# R overlay -- +# -*- coding: utf-8 -*- +# Copyright (C) 2013 André Erdmann +# Distributed under the terms of the GNU General Public License; +# either version 2 of the License, or (at your option) any later version. + +import roverlay + +import roverlay.interface.root +import roverlay.interface.depres + +roverlay.setup_initial_logger() + +class MainInterface ( roverlay.interface.root.RootInterface ): + + def __init__ ( self, *args, **kwargs ): + if args or kwargs: + self.setup ( *args, **kwargs ) + # --- end of __init__ (...) --- + + def setup ( self, config_file, *args, **kw ): + self.config_file = config_file + super ( MainInterface, self ).__init__ ( + config_file=config_file, *args, **kw + ) + self.__class__.register_interface ( + "depres", roverlay.interface.depres.DepresInterface + ) + return True + # --- end of setup (...) --- diff --git a/roverlay/interface/root.py b/roverlay/interface/root.py index d500582..a4d287c 100644 --- a/roverlay/interface/root.py +++ b/roverlay/interface/root.py @@ -8,6 +8,7 @@ import logging import roverlay import roverlay.errorqueue +import roverlay.hook import roverlay.interface.generic @@ -28,24 +29,46 @@ class RootInterface ( roverlay.interface.generic.RoverlayInterface ): # --- end of register_interface (...) --- def __init__ ( self, - config_file=None, config=None, additional_config=None + config_file=None, config=None, additional_config=None, is_installed=None ): super ( RootInterface, self ).__init__() self.parent = None self.err_queue = roverlay.errorqueue.ErrorQueue() - if config is not None: + if getattr ( self, 'config', None ): + pass + elif config is not None: self.config = config elif config_file is not None: - self.config = roverlay.load_config_file ( - config_file, extraconf=additional_config - ) + if additional_config is None: + self.config = roverlay.load_config_file ( + config_file, extraconf={ 'installed': False, } + ) + else: + # modifies additional_config + additional_config.update ( { 'installed': False, } ) + + self.config = roverlay.load_config_file ( + config_file, extraconf=additional_config + ) else: raise Exception ( "config, config_file?" ) + + if is_installed is not None: + self.set_installed ( is_installed ) + elif self.config.get ( "installed", None ) is None: + self.set_installed ( False ) + self.logger = logging.getLogger ( self.__class__.__name__ ) + + roverlay.hook.setup() # --- end of __init__ (...) --- + def set_installed ( self, status=True ): + self.config.merge_with ( { 'installed': bool ( status ), } ) + # --- end of set_installed (...) --- + def spawn_interface ( self, name ): if self.has_interface ( name ): return self.get_interface ( name ) @@ -60,3 +83,7 @@ class RootInterface ( roverlay.interface.generic.RoverlayInterface ): name, iface_cls ( parent_interface=self ) ) # --- end of spawn_interface (...) --- + + def run_hook ( self, phase ): + return roverlay.hook.run ( phase, catch_failure=False ) + # --- end of run_hook (...) ---