Use collections.UserDict for LineConfigParser.
This commit is contained in:
parent
75ba75a0d7
commit
cdb2e34513
@ -21,12 +21,13 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import collections
|
||||||
|
|
||||||
from qutebrowser.utils import log, utils
|
from qutebrowser.utils import log, utils
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
|
|
||||||
|
|
||||||
class LineConfigParser:
|
class LineConfigParser(collections.UserList):
|
||||||
|
|
||||||
"""Parser for configuration files which are simply line-based.
|
"""Parser for configuration files which are simply line-based.
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ class LineConfigParser:
|
|||||||
limit: Config tuple (section, option) which contains a limit.
|
limit: Config tuple (section, option) which contains a limit.
|
||||||
binary: Whether to open the file in binary mode.
|
binary: Whether to open the file in binary mode.
|
||||||
"""
|
"""
|
||||||
|
super().__init__()
|
||||||
self._configdir = configdir
|
self._configdir = configdir
|
||||||
self._configfile = os.path.join(self._configdir, fname)
|
self._configfile = os.path.join(self._configdir, fname)
|
||||||
self._fname = fname
|
self._fname = fname
|
||||||
@ -65,10 +67,6 @@ class LineConfigParser:
|
|||||||
configdir=self._configdir, fname=self._fname,
|
configdir=self._configdir, fname=self._fname,
|
||||||
limit=self._limit, binary=self._binary)
|
limit=self._limit, binary=self._binary)
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
"""Iterate over the set data."""
|
|
||||||
return self.data.__iter__()
|
|
||||||
|
|
||||||
def read(self, filename):
|
def read(self, filename):
|
||||||
"""Read the data from a file."""
|
"""Read the data from a file."""
|
||||||
if self._binary:
|
if self._binary:
|
||||||
|
Loading…
Reference in New Issue
Block a user