# HG changeset patch # User John Mulligan # Date 1257611874 18000 # Sat Nov 07 11:37:54 2009 -0500 # Node ID 5fe3e45db6c50c3e6305fbffa0e31e950a1ce64d # Parent 1233336b8c4fbdffb702c741faaa936d438674a1 clean up version fallback stuff from configreader also remove junk (testing) main section diff --git a/vanity/configreader.py b/vanity/configreader.py --- a/vanity/configreader.py +++ b/vanity/configreader.py @@ -83,12 +83,14 @@ 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 @@ 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 -