@@ 83,12 83,14 @@ def _scan(fh):
raise ParsingError('invalid configuration line', lnum)
-def _lstrip(txt):
- if hasattr(txt, 'lstrip'):
+if hasattr(str, 'lstrip'):
+ def _lstrip(txt):
return txt.lstrip()
- while (txt[0] in ' \t'):
- txt = txt[1:]
- return txt
+else:
+ def _lstrip(txt):
+ while (txt[0] in ' \t'):
+ txt = txt[1:]
+ return txt
def _combine(nodes):
@@ 212,16 214,5 @@ class ConfigReader(object):
if key is not None:
yield (section, key, self._get(section, key))
-
-
-if __name__ == '__main__':
- #fh = open('sample.cfg')
- #print list(parseini(fh))
- cf = ConfigReader()
- cf.read('sample.cfg')
- print list(cf.sections())
- print dict(cf.items('tag'))
-
# eof
-