def items(me, resolvep = True):
"""
- Return a list of (NAME, VALUE) items in this section.
-
- This extends the default method by handling the inheritance chain.
+ Yield a list of item names in the section.
"""
## Initialize for a depth-first walk of the inheritance graph.
if key == '@inherit': stack += value.replace(',', ' ').split()
else: d[key] = None
- ## Now collect the values for the known keys, one by one.
- items = []
- for key in d: items.append((key, me.get(key, resolvep)))
-
## And we're done.
- return items
+ return d.iterkeys()
class MyConfigParser (object):
"""
resolve hostnames will fail!
"""
for sec in me.sections():
- for key, value in sec.items(resolvep = False):
+ for key in sec.items():
+ value = sec.get(key, resolvep = False)
for match in RX_RESOLVE.finditer(value):
me._resolver.prepare(match.group(1))
me._resolver.run()
except MissingKeyException: pass
else: cdb.add('U%s' % u)
url = M.URLEncode(laxp = True, semip = True)
- for key, value in sorted(sec.items(), key = lambda (k, v): k):
+ for key in sorted(sec.items()):
if not key.startswith('@'):
- url.encode(key, ' '.join(M.split(value)[0]))
+ url.encode(key, ' '.join(M.split(sec.get(key))[0]))
cdb.add(label, url.result)
cdb.add('%AUTO', ' '.join(auto))
cdb.finish()