add Config.getlist
method
This commit is contained in:
parent
8f86109cb6
commit
6071a85787
@ -44,6 +44,9 @@ class Section:
|
||||
def getint(self, key):
|
||||
return self.conf.getint(self.section, key)
|
||||
|
||||
def getlist(self, key):
|
||||
return self.conf.getlist(self.section, key)
|
||||
|
||||
def getiter(self, key):
|
||||
return self.conf.getiter(self.section, key)
|
||||
|
||||
@ -62,6 +65,7 @@ class IssoParser(ConfigParser):
|
||||
... [foo]
|
||||
... bar = 1h
|
||||
... baz = 12
|
||||
... spam = a, b, cdef
|
||||
... bla =
|
||||
... spam
|
||||
... ham
|
||||
@ -71,6 +75,8 @@ class IssoParser(ConfigParser):
|
||||
3600
|
||||
>>> parser.getint("foo", "baz")
|
||||
12
|
||||
>>> parser.getlist("foo", "spam") # doctest: +IGNORE_UNICODE
|
||||
['a', 'b', 'cdef']
|
||||
>>> list(parser.getiter("foo", "bla")) # doctest: +IGNORE_UNICODE
|
||||
['spam', 'ham']
|
||||
>>> list(parser.getiter("foo", "asd")) # doctest: +IGNORE_UNICODE
|
||||
@ -92,6 +98,9 @@ class IssoParser(ConfigParser):
|
||||
except AttributeError:
|
||||
return int(IssoParser._total_seconds(delta))
|
||||
|
||||
def getlist(self, section, key):
|
||||
return list(map(str.strip, self.get(section, key).split(',')))
|
||||
|
||||
def getiter(self, section, key):
|
||||
for item in map(str.strip, self.get(section, key).split('\n')):
|
||||
if item:
|
||||
|
Loading…
Reference in New Issue
Block a user