Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Wed, 27 Apr 2011 10:59:17
Message-Id: d9de33168cfe46be2e269d04ec52afe003f7ba6d.dol-sen@gentoo
1 commit: d9de33168cfe46be2e269d04ec52afe003f7ba6d
2 Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Thu Feb 24 07:42:42 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sun Mar 27 02:39:13 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d9de3316
7
8 add being able to set the OptionConfig defaults as well
9
10 ---
11 layman/config.py | 18 +++++++++++++++---
12 1 files changed, 15 insertions(+), 3 deletions(-)
13
14 diff --git a/layman/config.py b/layman/config.py
15 index cda6fce..1645a3c 100644
16 --- a/layman/config.py
17 +++ b/layman/config.py
18 @@ -203,19 +203,22 @@ class BareConfig(object):
19
20 class OptionConfig(BareConfig):
21 """This subclasses BareCongig adding functions to make overriding
22 - defaults and/or setting up options much easier via a dictionary
23 + or resetting defaults and/or setting options much easier
24 + by using dictionaries.
25 """
26
27 - def __init__(self, options=None):
28 + def __init__(self, options=None, defaults=None):
29 """
30 @param options: dictionary of {'option': value, ...}
31 @rtype OptionConfig class instance.
32 """
33 BareConfig.__init__(self)
34
35 + self.update_defaults(defaults)
36 +
37 self.update(options)
38
39 - return self
40 + return
41
42 def update(self, options):
43 """update the options with new values passed in via options
44 @@ -232,3 +235,12 @@ class OptionConfig(BareConfig):
45 options.pop('quietness')
46 self._options.update(options)
47 return
48 +
49 + def update_defaults(self, new_defaults):
50 + """update the options with new values passed in via options
51 +
52 + @param options
53 + """
54 + if new_defaults is not None:
55 + self._defaults.update(new_defaults)
56 + return