Show More
@@ -7,7 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | import re, sys, os |
|
9 | import re, sys, os | |
10 | from mercurial import util |
|
10 | from mercurial import util, config | |
11 |
|
11 | |||
12 | path = ['templates', '../templates'] |
|
12 | path = ['templates', '../templates'] | |
13 |
|
13 | |||
@@ -63,24 +63,18 b' class templater(object):' | |||||
63 | if not os.path.exists(mapfile): |
|
63 | if not os.path.exists(mapfile): | |
64 | raise util.Abort(_('style not found: %s') % mapfile) |
|
64 | raise util.Abort(_('style not found: %s') % mapfile) | |
65 |
|
65 | |||
66 | i = 0 |
|
66 | conf = config.config() | |
67 |
|
|
67 | conf.read(mapfile) | |
68 | l = l.strip() |
|
68 | ||
69 | i += 1 |
|
69 | for key, val in conf[''].items(): | |
70 |
if |
|
70 | if val[0] in "'\"": | |
71 | m = re.match(r'([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$', l) |
|
71 | try: | |
72 | if m: |
|
72 | self.cache[key] = parsestring(val) | |
73 | key, val = m.groups() |
|
73 | except SyntaxError, inst: | |
74 | if val[0] in "'\"": |
|
74 | raise SyntaxError('%s: %s' % | |
75 | try: |
|
75 | (conf.getsource('', key), inst.args[0])) | |
76 | self.cache[key] = parsestring(val) |
|
|||
77 | except SyntaxError, inst: |
|
|||
78 | raise SyntaxError('%s:%s: %s' % |
|
|||
79 | (mapfile, i, inst.args[0])) |
|
|||
80 | else: |
|
|||
81 | self.map[key] = os.path.join(self.base, val) |
|
|||
82 | else: |
|
76 | else: | |
83 | raise SyntaxError(_("%s:%s: parse error") % (mapfile, i)) |
|
77 | self.map[key] = os.path.join(self.base, val) | |
84 |
|
78 | |||
85 | def __contains__(self, key): |
|
79 | def __contains__(self, key): | |
86 | return key in self.cache or key in self.map |
|
80 | return key in self.cache or key in self.map |
General Comments 0
You need to be logged in to leave comments.
Login now