##// END OF EJS Templates
templater: start passing resource to read from into _readmapfile()...
Martin von Zweigbergk -
r45868:dc10bcd5 default
parent child Browse files
Show More
@@ -814,14 +814,17 b' def stylelist():'
814 814 return b", ".join(sorted(stylelist))
815 815
816 816
817 def _readmapfile(mapfile):
817 def _open_mapfile(mapfile):
818 if os.path.exists(mapfile):
819 return util.posixfile(mapfile, b'rb')
820 raise error.Abort(
821 _(b"style '%s' not found") % mapfile,
822 hint=_(b"available styles: %s") % stylelist(),
823 )
824
825
826 def _readmapfile(fp, mapfile):
818 827 """Load template elements from the given map file"""
819 if not os.path.exists(mapfile):
820 raise error.Abort(
821 _(b"style '%s' not found") % mapfile,
822 hint=_(b"available styles: %s") % stylelist(),
823 )
824
825 828 base = os.path.dirname(mapfile)
826 829 conf = config.config()
827 830
@@ -838,7 +841,7 b' def _readmapfile(mapfile):'
838 841 )
839 842 break
840 843
841 data = util.posixfile(mapfile, b'rb').read()
844 data = fp.read()
842 845 conf.parse(mapfile, data, remap={b'': b'templates'}, include=include)
843 846
844 847 cache = {}
@@ -862,7 +865,8 b' def _readmapfile(mapfile):'
862 865 if os.path.isfile(p3):
863 866 path = p3
864 867
865 cache, tmap, aliases = _readmapfile(path)
868 fp = _open_mapfile(path)
869 cache, tmap, aliases = _readmapfile(fp, path)
866 870
867 871 for key, val in conf[b'templates'].items():
868 872 if not val:
@@ -999,7 +1003,8 b' class templater(object):'
999 1003 ):
1000 1004 """Create templater from the specified map file"""
1001 1005 t = cls(filters, defaults, resources, cache, [], minchunk, maxchunk)
1002 cache, tmap, aliases = _readmapfile(mapfile)
1006 fp = _open_mapfile(mapfile)
1007 cache, tmap, aliases = _readmapfile(fp, mapfile)
1003 1008 t._loader.cache.update(cache)
1004 1009 t._loader._map = tmap
1005 1010 t._loader._aliasmap = _aliasrules.buildmap(aliases)
General Comments 0
You need to be logged in to leave comments. Login now