Show More
@@ -2,7 +2,7 b' from i18n import _' | |||
|
2 | 2 | import re, error, os |
|
3 | 3 | |
|
4 | 4 | class sortdict(dict): |
|
5 |
'a simple |
|
|
5 | 'a simple sorted dictionary' | |
|
6 | 6 | def __init__(self, data=None): |
|
7 | 7 | self._list = [] |
|
8 | 8 | if data: |
@@ -23,6 +23,9 b' class sortdict(dict):' | |||
|
23 | 23 | self[k] = src[k] |
|
24 | 24 | def items(self): |
|
25 | 25 | return [(k,self[k]) for k in self._list] |
|
26 | def __delitem__(self, key): | |
|
27 | dict.__delitem__(self, key) | |
|
28 | self._list.remove(key) | |
|
26 | 29 | |
|
27 | 30 | class config: |
|
28 | 31 | def __init__(self, data=None): |
@@ -62,6 +65,7 b' class config:' | |||
|
62 | 65 | itemre = re.compile(r'([^=\s]+)\s*=\s*(.*)') |
|
63 | 66 | contre = re.compile(r'\s+(\S.*)') |
|
64 | 67 | emptyre = re.compile(r'(;|#|\s*$)') |
|
68 | unsetre = re.compile(r'%unset\s+(\S.*)') | |
|
65 | 69 | includere = re.compile(r'%include\s+(\S.*)') |
|
66 | 70 | section = "" |
|
67 | 71 | item = None |
@@ -102,5 +106,12 b' class config:' | |||
|
102 | 106 | self.set(section, item, m.group(2), "%s:%d" % (path, line)) |
|
103 | 107 | cont = 1 |
|
104 | 108 | continue |
|
109 | m = unsetre.match(l) | |
|
110 | if m: | |
|
111 | name = m.group(1) | |
|
112 | if self.get(section, name) != None: | |
|
113 | del self._data[section][name] | |
|
114 | continue | |
|
115 | ||
|
105 | 116 | raise error.ConfigError(_('config error at %s:%d: \'%s\'') |
|
106 | 117 | % (path, line, l.rstrip())) |
General Comments 0
You need to be logged in to leave comments.
Login now