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 1906C138A1A for ; Wed, 4 Feb 2015 17:59:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BD92DE08E8; Wed, 4 Feb 2015 17:58:59 +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 60677E08E8 for ; Wed, 4 Feb 2015 17:58:59 +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 8168C340562 for ; Wed, 4 Feb 2015 17:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4484D110D3 for ; Wed, 4 Feb 2015 17:58:57 +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: <1423072527.9b3c6b3190df328d8a72e6cb6833b13a6819dbbb.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/config_modules/reposconf/ X-VCS-Repository: proj/layman X-VCS-Files: layman/config_modules/reposconf/reposconf.py X-VCS-Directories: layman/config_modules/reposconf/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 9b3c6b3190df328d8a72e6cb6833b13a6819dbbb X-VCS-Branch: master Date: Wed, 4 Feb 2015 17:58:57 +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: 05abf2f2-7f32-4808-9507-6dc41b586d86 X-Archives-Hash: 506bf5b7ab25252777ce83be9097ec7f commit: 9b3c6b3190df328d8a72e6cb6833b13a6819dbbb Author: Devan Franchini gentoo org> AuthorDate: Wed Feb 4 17:55:25 2015 +0000 Commit: Devan Franchini gentoo org> CommitDate: Wed Feb 4 17:55:27 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=9b3c6b31 reposconf.py: Rewrites enable() and disable() functions The enable() function was cleaned up and the doc string was improved to reflect what the function actually does. The previous behavior of the disable function was completely replaced in favor of being a wrapper for the delete() function. The reasoning behind this is that previously the function would simply "comment" out the section and its lines. This lead to an issue where the config manager would no longer list the sections, causing them to no longer be in the repos.conf file if the file was rewritten to by layman for any reason. So commenting the sections out was more work than needed anyway. --- layman/config_modules/reposconf/reposconf.py | 40 +++++----------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/layman/config_modules/reposconf/reposconf.py b/layman/config_modules/reposconf/reposconf.py index cdf5dba..4cb27f8 100644 --- a/layman/config_modules/reposconf/reposconf.py +++ b/layman/config_modules/reposconf/reposconf.py @@ -116,46 +116,22 @@ class ConfigHandler: def disable(self, overlay): ''' - Disables a repos.conf entry. + A wrapper for the delete() function to comply with RepoConfManager class. @param overlay: layman.overlay.Overlay instance. @rtype boolean: reflects a successful/failed write to the config file. ''' - if not self.repo_conf.has_section(overlay.name): - self.output.error('ReposConf: ConfigHandler.disable(); failed '\ - 'to disable "%(repo)s". Section does not exist.'\ - % ({'repo': overlay.name})) - return False - self.repo_conf.remove_section(overlay.name) - current_date = time.strftime('%x') + ' | ' + time.strftime('%X') - - self.repo_conf.add_section(overlay.name) - self.repo_conf.set(overlay.name, '#date disabled', current_date) - self.repo_conf.set(overlay.name, '#priority', str(overlay.priority)) - self.repo_conf.set(overlay.name, '#location', path((self.storage, overlay.name))) - self.repo_conf.set(overlay.name, '#layman-type', overlay.sources[0].type_key) - if sync_type: - self.repo_conf.set(overlay.name, '#sync_type', sync_type) - self.repo_conf.set(overlay.name, '#sync-uri', overlay.sources[0].src) - if overlay.sources[0].branch: - self.repo_conf.set(overlay.name, '#branch', overlay.sources[0].branch) - if sync_type: - self.repo_conf.set(overlay.name, '#auto-sync', self.config['auto_sync']) - - return self.write(disable=overlay.name) + return self.delete(overlay) def enable(self, overlay): ''' - Enables a disabled repos.conf entry. + A wrapper for the add() function to comply with RepoConfManager class. @param overlay: layman.overlay.Overlay instance. @rtype boolean: reflects a successful/failed write to the config file. ''' - self.repo_conf.remove_section(overlay.name) - success = self.add(overlay) - - return success + return self.add(overlay) def update(self, overlay): @@ -170,11 +146,11 @@ class ConfigHandler: return self.write() - def write(self, delete=None, disable=None): + def write(self, delete=None): ''' Writes changes from ConfigParser to /etc/portage/repos.conf/layman.conf. - @params disable: overlay name to be disabled. + @params delete: overlay name to be delete from the config. @return boolean: represents a successful write. ''' try: @@ -186,10 +162,6 @@ class ConfigHandler: if not i == delete: self.add(self.overlays[i]) self.repo_conf.write(laymanconf) - if disable: - # comments out section header of the overlay. - subprocess.call(['sed', '-i', 's/^\[%(ovl)s\]/#[%(ovl)s]/'\ - % {'ovl': disable}, self.path]) return True except IOError as error: self.output.error('ReposConf: ConfigHandler.write(); Failed to write "'\