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 E29B4138A2F for ; Tue, 19 Aug 2014 01:49:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 40A6AE081D; Tue, 19 Aug 2014 01:49:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6F07AE081D for ; Tue, 19 Aug 2014 01:49:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6149F33F900 for ; Tue, 19 Aug 2014 01:49:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0E8963B84 for ; Tue, 19 Aug 2014 01:49:05 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1408141249.d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/repoconfmanager.py X-VCS-Directories: layman/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9 X-VCS-Branch: master Date: Tue, 19 Aug 2014 01:49:05 +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: 10f67d9f-89b4-443b-8a91-f78f57e801dc X-Archives-Hash: 1ca6215de7ca7809f0f8f2945fee48cf commit: d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9 Author: Devan Franchini gentoo org> AuthorDate: Fri Aug 15 20:55:33 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Fri Aug 15 22:20:49 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d8a60bef repoconfmanager.py: Adds plug-in module controller --- layman/repoconfmanager.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/layman/repoconfmanager.py b/layman/repoconfmanager.py index cb7c3c5..260ae3d 100644 --- a/layman/repoconfmanager.py +++ b/layman/repoconfmanager.py @@ -15,17 +15,19 @@ # Devan Franchini # +import os import re import sys -import layman.reposconf as reposconf -import layman.makeconf as makeconf +from layman.module import Modules, InvalidModuleName if sys.hexversion >= 0x30200f0: STR = str else: STR = basestring +MOD_PATH = path = os.path.join(os.path.dirname(__file__), 'config_modules') + class RepoConfManager: def __init__(self, config, overlays): @@ -35,11 +37,9 @@ class RepoConfManager: self.conf_types = config['conf_type'] self.output = config['output'] self.overlays = overlays - - self.modules = { - 'make.conf': (makeconf, 'ConfigHandler'), - 'repos.conf': (reposconf, 'ConfigHandler') - } + self.module_controller = Modules(path=MOD_PATH, + namepath='layman.config_modules', + output=self.output) if isinstance(self.conf_types, STR): self.conf_types = re.split(',\s+', self.conf_types) @@ -59,8 +59,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.add(overlay) results.append(conf_ok) return results @@ -78,8 +79,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.delete(overlay) results.append(conf_ok) return results @@ -96,8 +98,9 @@ class RepoConfManager: ''' if self.config['require_repoconfig']: for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.disable(overlay) return conf_ok return True @@ -113,8 +116,9 @@ class RepoConfManager: ''' if self.config['require_repoconfig']: for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.enable(overlay) return conf_ok return True @@ -130,8 +134,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.update(overlay) results.append(conf_ok) return results 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 9FABE13877A for ; Fri, 15 Aug 2014 22:33:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 24C7FE0B02; Fri, 15 Aug 2014 22:33:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3BCA9E0B00 for ; Fri, 15 Aug 2014 22:33:26 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 482263405FF for ; Fri, 15 Aug 2014 22:33:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id EC8481881F for ; Fri, 15 Aug 2014 22:33:22 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1408141249.d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/repoconfmanager.py X-VCS-Directories: layman/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9 X-VCS-Branch: master Date: Fri, 15 Aug 2014 22:33:22 +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: e1ddf1ef-9c45-411b-a6bc-4b4ce9447544 X-Archives-Hash: fa356aa1fdf95b888b5598598bf869df Message-ID: <20140815223322.XkplGtzxI03JsrMFPhaAn_qupHqaZyEQXaUfPDwCz6g@z> commit: d8a60befbaf4867f80ae7e0c7fe94c78fea5a5d9 Author: Devan Franchini gentoo org> AuthorDate: Fri Aug 15 20:55:33 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Fri Aug 15 22:20:49 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d8a60bef repoconfmanager.py: Adds plug-in module controller --- layman/repoconfmanager.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/layman/repoconfmanager.py b/layman/repoconfmanager.py index cb7c3c5..260ae3d 100644 --- a/layman/repoconfmanager.py +++ b/layman/repoconfmanager.py @@ -15,17 +15,19 @@ # Devan Franchini # +import os import re import sys -import layman.reposconf as reposconf -import layman.makeconf as makeconf +from layman.module import Modules, InvalidModuleName if sys.hexversion >= 0x30200f0: STR = str else: STR = basestring +MOD_PATH = path = os.path.join(os.path.dirname(__file__), 'config_modules') + class RepoConfManager: def __init__(self, config, overlays): @@ -35,11 +37,9 @@ class RepoConfManager: self.conf_types = config['conf_type'] self.output = config['output'] self.overlays = overlays - - self.modules = { - 'make.conf': (makeconf, 'ConfigHandler'), - 'repos.conf': (reposconf, 'ConfigHandler') - } + self.module_controller = Modules(path=MOD_PATH, + namepath='layman.config_modules', + output=self.output) if isinstance(self.conf_types, STR): self.conf_types = re.split(',\s+', self.conf_types) @@ -59,8 +59,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.add(overlay) results.append(conf_ok) return results @@ -78,8 +79,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.delete(overlay) results.append(conf_ok) return results @@ -96,8 +98,9 @@ class RepoConfManager: ''' if self.config['require_repoconfig']: for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.disable(overlay) return conf_ok return True @@ -113,8 +116,9 @@ class RepoConfManager: ''' if self.config['require_repoconfig']: for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.enable(overlay) return conf_ok return True @@ -130,8 +134,9 @@ class RepoConfManager: if self.config['require_repoconfig']: results = [] for types in self.conf_types: - conf = getattr(self.modules[types][0], - self.modules[types][1])(self.config, self.overlays) + types = types.replace('.', '') + conf = self.module_controller.get_class(types)\ + (self.config, self.overlays) conf_ok = conf.update(overlay) results.append(conf_ok) return results