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