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