[Zconfig] SVN: ZConfig/trunk/cfgparser.py isolate the vile case
normalization hackery to make it easier to avoid
Fred L. Drake, Jr.
fdrake at gmail.com
Fri Aug 26 18:00:17 EDT 2005
Log message for revision 38118:
isolate the vile case normalization hackery to make it easier to avoid
Changed:
U ZConfig/trunk/cfgparser.py
-=-
Modified: ZConfig/trunk/cfgparser.py
===================================================================
--- ZConfig/trunk/cfgparser.py 2005-08-26 20:50:46 UTC (rev 38117)
+++ ZConfig/trunk/cfgparser.py 2005-08-26 22:00:17 UTC (rev 38118)
@@ -83,9 +83,9 @@
if not m:
self.error("malformed section header")
type, name = m.group('type', 'name')
- type = type.lower()
+ type = self._normalize_case(type)
if name:
- name = name.lower()
+ name = self._normalize_case(name)
try:
newsect = self.context.startSection(section, type, name)
except ZConfig.ConfigurationError, e:
@@ -101,7 +101,7 @@
def end_section(self, section, rest):
if not self.stack:
self.error("unexpected section end")
- type = rest.rstrip().lower()
+ type = self._normalize_case(rest.rstrip())
opentype, name, prevsection = self.stack.pop()
if type != opentype:
self.error("unbalanced section end")
@@ -155,7 +155,7 @@
def handle_define(self, section, rest):
parts = rest.split(None, 1)
- defname = parts[0].lower()
+ defname = self._normalize_case(parts[0])
defvalue = ''
if len(parts) == 2:
defvalue = parts[1]
@@ -176,7 +176,10 @@
def error(self, message):
raise ZConfig.ConfigurationSyntaxError(message, self.url, self.lineno)
+ def _normalize_case(self, string):
+ return string.lower()
+
import re
# _name_re does not allow "(" or ")" for historical reasons. Though
# the restriction could be lifted, there seems no need to do so.
More information about the ZConfig
mailing list