##// 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 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 for l in file(mapfile):
67 conf.read(mapfile)
68 l = l.strip()
68
69 i += 1
69 for key, val in conf[''].items():
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()
74 if val[0] in "'\"":
70 if val[0] in "'\"":
75 try:
71 try:
76 self.cache[key] = parsestring(val)
72 self.cache[key] = parsestring(val)
77 except SyntaxError, inst:
73 except SyntaxError, inst:
78 raise SyntaxError('%s:%s: %s' %
74 raise SyntaxError('%s: %s' %
79 (mapfile, i, inst.args[0]))
75 (conf.getsource('', key), inst.args[0]))
80 else:
76 else:
81 self.map[key] = os.path.join(self.base, val)
77 self.map[key] = os.path.join(self.base, val)
82 else:
83 raise SyntaxError(_("%s:%s: parse error") % (mapfile, i))
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