From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QF2Si-0003OE-Uv for garchives@archives.gentoo.org; Wed, 27 Apr 2011 10:59:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8FF161C0D2; Wed, 27 Apr 2011 10:58:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5EF941C0D2 for ; Wed, 27 Apr 2011 10:58:44 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EBE1F1BC01E for ; Wed, 27 Apr 2011 10:58:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5AE8E80509 for ; Wed, 27 Apr 2011 10:58:43 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/config.py X-VCS-Directories: layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: d9de33168cfe46be2e269d04ec52afe003f7ba6d Date: Wed, 27 Apr 2011 10:58:43 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2c736efae5ed0480d555c6516071842d commit: d9de33168cfe46be2e269d04ec52afe003f7ba6d Author: Brian Dolbec gmail com> AuthorDate: Thu Feb 24 07:42:42 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sun Mar 27 02:39:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3Dd9de3316 add being able to set the OptionConfig defaults as well --- layman/config.py | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/layman/config.py b/layman/config.py index cda6fce..1645a3c 100644 --- a/layman/config.py +++ b/layman/config.py @@ -203,19 +203,22 @@ class BareConfig(object): =20 class OptionConfig(BareConfig): """This subclasses BareCongig adding functions to make overriding - defaults and/or setting up options much easier via a dictionary + or resetting defaults and/or setting options much easier + by using dictionaries. """ =20 - def __init__(self, options=3DNone): + def __init__(self, options=3DNone, defaults=3DNone): """ @param options: dictionary of {'option': value, ...} @rtype OptionConfig class instance. """ BareConfig.__init__(self) =20 + self.update_defaults(defaults) + self.update(options) =20 - return self + return =20 def update(self, options): """update the options with new values passed in via options @@ -232,3 +235,12 @@ class OptionConfig(BareConfig): options.pop('quietness') self._options.update(options) return + + def update_defaults(self, new_defaults): + """update the options with new values passed in via options + + @param options + """ + if new_defaults is not None: + self._defaults.update(new_defaults) + return