##// END OF EJS Templates
templater: use new config parser...
Matt Mackall -
r8194:63c47e4a default
parent child Browse files
Show More
@@ -7,7 +7,7 b''
7 7
8 8 from i18n import _
9 9 import re, sys, os
10 from mercurial import util
10 from mercurial import util, config
11 11
12 12 path = ['templates', '../templates']
13 13
@@ -63,24 +63,18 b' class templater(object):'
63 63 if not os.path.exists(mapfile):
64 64 raise util.Abort(_('style not found: %s') % mapfile)
65 65
66 i = 0
67 for l in file(mapfile):
68 l = l.strip()
69 i += 1
70 if not l or l[0] in '#;': continue
71 m = re.match(r'([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$', l)
72 if m:
73 key, val = m.groups()
66 conf = config.config()
67 conf.read(mapfile)
68
69 for key, val in conf[''].items():
74 70 if val[0] in "'\"":
75 71 try:
76 72 self.cache[key] = parsestring(val)
77 73 except SyntaxError, inst:
78 raise SyntaxError('%s:%s: %s' %
79 (mapfile, i, inst.args[0]))
74 raise SyntaxError('%s: %s' %
75 (conf.getsource('', key), inst.args[0]))
80 76 else:
81 77 self.map[key] = os.path.join(self.base, val)
82 else:
83 raise SyntaxError(_("%s:%s: parse error") % (mapfile, i))
84 78
85 79 def __contains__(self, key):
86 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