[Zope3-checkins] CVS: Packages/ZConfig - Substitution.py:1.8
Fred L. Drake, Jr.
fred@zope.com
Tue, 3 Dec 2002 10:31:48 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv8172
Modified Files:
Substitution.py
Log Message:
Added function ZConfig.Substitution.getnames().
=== Packages/ZConfig/Substitution.py 1.7 => 1.8 ===
--- Packages/ZConfig/Substitution.py:1.7 Tue Dec 3 10:01:08 2002
+++ Packages/ZConfig/Substitution.py Tue Dec 3 10:31:17 2002
@@ -43,13 +43,26 @@
def substitute(s, section):
"""Interpolate variables from `section` into `s`."""
- if '$' in s:
+ if "$" in s:
accum = []
_interp(accum, s, section, None)
s = ''.join(accum)
return s
+def getnames(s):
+ """Return a list of names referenced by s."""
+ if "$" in s:
+ L = []
+ while s:
+ p, name, s = _split(s, None)
+ if name and name not in L:
+ L.append(name)
+ return L
+ else:
+ return []
+
+
def _interp(accum, rest, section, context):
while 1:
s, name, rest = _split(rest, context)
@@ -106,7 +119,7 @@
return prefix + "$", None, s[i+1:]
name = m.group(0)
i = m.end()
- return prefix, name, s[i:]
+ return prefix, name.lower(), s[i:]
else:
return s, None, None