Show More
@@ -87,12 +87,13 b' class ui(object):' | |||
|
87 | 87 | def setconfig(self, section, name, val): |
|
88 | 88 | self.overlay[(section, name)] = val |
|
89 | 89 | |
|
90 |
def config(self, section, name, default |
|
|
90 | def _config(self, section, name, default, funcname): | |
|
91 | 91 | if self.overlay.has_key((section, name)): |
|
92 | 92 | return self.overlay[(section, name)] |
|
93 | 93 | if self.cdata.has_option(section, name): |
|
94 | 94 | try: |
|
95 |
|
|
|
95 | func = getattr(self.cdata, funcname) | |
|
96 | return func(section, name) | |
|
96 | 97 | except ConfigParser.InterpolationError, inst: |
|
97 | 98 | raise util.Abort(_("Error in configuration section [%s] " |
|
98 | 99 | "parameter '%s':\n%s") |
@@ -100,7 +101,13 b' class ui(object):' | |||
|
100 | 101 | if self.parentui is None: |
|
101 | 102 | return default |
|
102 | 103 | else: |
|
103 | return self.parentui.config(section, name, default) | |
|
104 | return self.parentui._config(section, name, default, funcname) | |
|
105 | ||
|
106 | def config(self, section, name, default=None): | |
|
107 | return self._config(section, name, default, 'get') | |
|
108 | ||
|
109 | def configbool(self, section, name, default=False): | |
|
110 | return self._config(section, name, default, 'getboolean') | |
|
104 | 111 | |
|
105 | 112 | def configlist(self, section, name, default=None): |
|
106 | 113 | """Return a list of comma/space separated strings""" |
@@ -111,21 +118,6 b' class ui(object):' | |||
|
111 | 118 | result = result.replace(",", " ").split() |
|
112 | 119 | return result |
|
113 | 120 | |
|
114 | def configbool(self, section, name, default=False): | |
|
115 | if self.overlay.has_key((section, name)): | |
|
116 | return self.overlay[(section, name)] | |
|
117 | if self.cdata.has_option(section, name): | |
|
118 | try: | |
|
119 | return self.cdata.getboolean(section, name) | |
|
120 | except ConfigParser.InterpolationError, inst: | |
|
121 | raise util.Abort(_("Error in configuration section [%s] " | |
|
122 | "parameter '%s':\n%s") | |
|
123 | % (section, name, inst)) | |
|
124 | if self.parentui is None: | |
|
125 | return default | |
|
126 | else: | |
|
127 | return self.parentui.configbool(section, name, default) | |
|
128 | ||
|
129 | 121 | def has_config(self, section): |
|
130 | 122 | '''tell whether section exists in config.''' |
|
131 | 123 | return self.cdata.has_section(section) |
General Comments 0
You need to be logged in to leave comments.
Login now