Show More
@@ -14,9 +14,10 b' class ui(object):' | |||||
14 | def __init__(self, verbose=False, debug=False, quiet=False, |
|
14 | def __init__(self, verbose=False, debug=False, quiet=False, | |
15 | interactive=True, parentui=None): |
|
15 | interactive=True, parentui=None): | |
16 | self.overlay = {} |
|
16 | self.overlay = {} | |
|
17 | if parentui is None: | |||
|
18 | # this is the parent of all ui children | |||
|
19 | self.parentui = None | |||
17 | self.cdata = ConfigParser.SafeConfigParser() |
|
20 | self.cdata = ConfigParser.SafeConfigParser() | |
18 | self.parentui = parentui and parentui.parentui or parentui |
|
|||
19 | if parentui is None: |
|
|||
20 | self.readconfig(util.rcpath) |
|
21 | self.readconfig(util.rcpath) | |
21 |
|
22 | |||
22 | self.quiet = self.configbool("ui", "quiet") |
|
23 | self.quiet = self.configbool("ui", "quiet") | |
@@ -27,9 +28,15 b' class ui(object):' | |||||
27 | self.updateopts(verbose, debug, quiet, interactive) |
|
28 | self.updateopts(verbose, debug, quiet, interactive) | |
28 | self.diffcache = None |
|
29 | self.diffcache = None | |
29 | else: |
|
30 | else: | |
30 | self.cdata._defaults = parentui.cdata._defaults |
|
31 | # parentui may point to an ui object which is already a child | |
31 | for key, value in parentui.cdata._sections.iteritems(): |
|
32 | self.parentui = parentui.parentui or parentui | |
32 | self.cdata._sections[key] = value.copy() |
|
33 | parent_cdata = self.parentui.cdata | |
|
34 | self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) | |||
|
35 | # make interpolation work | |||
|
36 | for section in parent_cdata.sections(): | |||
|
37 | self.cdata.add_section(section) | |||
|
38 | for name, value in parent_cdata.items(section, raw=True): | |||
|
39 | self.cdata.set(section, name, value) | |||
33 |
|
40 | |||
34 | def __getattr__(self, key): |
|
41 | def __getattr__(self, key): | |
35 | return getattr(self.parentui, key) |
|
42 | return getattr(self.parentui, key) |
General Comments 0
You need to be logged in to leave comments.
Login now