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 E41FD138A2F for ; Fri, 15 Aug 2014 22:32:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A8837E0AE9; Fri, 15 Aug 2014 22:32:44 +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 07D7CE0ACF for ; Fri, 15 Aug 2014 22:32:41 +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 DD4003405D3 for ; Fri, 15 Aug 2014 22:32:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id BB4F31882D for ; Fri, 15 Aug 2014 22:32:37 +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: <1408138962.4be4ecf142526e54ff052118aa856699a7251986.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/ X-VCS-Repository: proj/layman X-VCS-Files: layman/overlays/overlay.py X-VCS-Directories: layman/overlays/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 4be4ecf142526e54ff052118aa856699a7251986 X-VCS-Branch: gsoc2014 Date: Fri, 15 Aug 2014 22:32:37 +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: 226445e9-0f3d-4c84-a0d4-6ab8fa214733 X-Archives-Hash: d28f79a841379065cc4a2829e05d544f commit: 4be4ecf142526e54ff052118aa856699a7251986 Author: Devan Franchini gentoo org> AuthorDate: Fri Aug 1 21:05:54 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Fri Aug 15 21:42:42 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4be4ecf1 overlay.py: Adds plug-in module controller This commit implements the module controller system for the overlay plug-in modules. --- layman/overlays/overlay.py | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index 81dadcd..8dd0b4b 100755 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -35,38 +35,16 @@ import codecs import locale import xml.etree.ElementTree as ET # Python 2.5 -from layman.utils import pad, terminal_width, get_encoding, encoder -from layman.compatibility import encode - -from layman.overlays.bzr import BzrOverlay -from layman.overlays.darcs import DarcsOverlay -from layman.overlays.git import GitOverlay -from layman.overlays.g_common import GCommonOverlay -from layman.overlays.g_sorcery import GSorceryOverlay -from layman.overlays.mercurial import MercurialOverlay -from layman.overlays.cvs import CvsOverlay -from layman.overlays.svn import SvnOverlay -from layman.overlays.rsync import RsyncOverlay -from layman.overlays.tar import TarOverlay +from layman.compatibility import encode +from layman.module import Modules, InvalidModuleName +from layman.utils import pad, terminal_width, get_encoding, encoder #=============================================================================== # # Constants # #------------------------------------------------------------------------------- - -OVERLAY_TYPES = dict((e.type_key, e) for e in ( - GitOverlay, - GCommonOverlay, - GSorceryOverlay, - CvsOverlay, - SvnOverlay, - RsyncOverlay, - TarOverlay, - BzrOverlay, - MercurialOverlay, - DarcsOverlay -)) +MOD_PATH = path = os.path.join(os.path.dirname(__file__), 'modules') QUALITY_LEVELS = 'core|stable|testing|experimental|graveyard'.split('|') @@ -80,6 +58,9 @@ class Overlay(object): ignore = 0): self.config = config self.output = config['output'] + self.module_controller = Modules(path=MOD_PATH, + namepath='layman.overlays.modules', + output=self.output) self._encoding_ = get_encoding(self.output) if xml is not None: @@ -124,10 +105,10 @@ class Overlay(object): _branch = source_elem.attrib['branch'] try: - _class = OVERLAY_TYPES[_type] - except KeyError: + _class = self.module_controller.get_class(_type) + except InvalidModuleName: raise Exception('Overlay from_xml(), "' + self.name + \ - 'Unknown overlay type "%s"!' % _type) + '" Unknown overlay type "%s"!' % _type) _location = encode(strip_text(source_elem)) @@ -236,10 +217,10 @@ class Overlay(object): def create_dict_overlay_source(source_): _src, _type, _sub = source_ try: - _class = OVERLAY_TYPES[_type] - except KeyError: + _class = self.module_controller.get_class(_type) + except InvalidModuleName: raise Exception('Overlay from_dict(), "' + self.name + - 'Unknown overlay type "%s"!' % _type) + '" Unknown overlay type "%s"!' % _type) _location = encode(_src) if _sub: self.branch = encode(_sub)