[PATCH 1 of 8] templater: mark most attributes as private
Gregory Szorc
gregory.szorc at gmail.com
Sat Jun 16 14:02:06 EDT 2018
On Thu, Jun 14, 2018 at 8:40 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1525312409 -32400
> # Thu May 03 10:53:29 2018 +0900
> # Node ID 8541f1e6178053f6cafd2ff22c8b632499ffa298
> # Parent 6196cc6cd37bc7260fdcb1f5c020d4adb7f8c176
> templater: mark most attributes as private
>
Queued this series.
Support for additional template engines was added in 2009 and doesn't seem
to be used in the wild. It was an interesting idea. I agree we can remove
the feature with minimal risk.
>
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -808,14 +808,14 @@ class templater(object):
> if cache is None:
> cache = {}
> self.cache = cache.copy()
> - self.map = {}
> - self.filters = templatefilters.filters.copy()
> - self.filters.update(filters)
> + self._map = {}
> + self._filters = templatefilters.filters.copy()
> + self._filters.update(filters)
> self.defaults = defaults
> self._resources = resources
> self._aliases = aliases
> - self.minchunk, self.maxchunk = minchunk, maxchunk
> - self.ecache = {}
> + self._minchunk, self._maxchunk = minchunk, maxchunk
> + self._ecache = {}
>
> @classmethod
> def frommapfile(cls, mapfile, filters=None, defaults=None,
> resources=None,
> @@ -824,24 +824,24 @@ class templater(object):
> t = cls(filters, defaults, resources, cache, [], minchunk,
> maxchunk)
> cache, tmap, aliases = _readmapfile(mapfile)
> t.cache.update(cache)
> - t.map = tmap
> + t._map = tmap
> t._aliases = aliases
> return t
>
> def __contains__(self, key):
> - return key in self.cache or key in self.map
> + return key in self.cache or key in self._map
>
> def load(self, t):
> '''Get the template for the given template name. Use a local
> cache.'''
> if t not in self.cache:
> try:
> - self.cache[t] = util.readfile(self.map[t][1])
> + self.cache[t] = util.readfile(self._map[t][1])
> except KeyError as inst:
> raise templateutil.TemplateNotFound(
> _('"%s" not in template map') % inst.args[0])
> except IOError as inst:
> reason = (_('template file %s: %s')
> - % (self.map[t][1],
> + % (self._map[t][1],
> stringutil.forcebytestr(inst.args[1])))
> raise IOError(inst.args[0], encoding.strfromlocal(reason))
> return self.cache[t]
> @@ -857,20 +857,20 @@ class templater(object):
> def generate(self, t, mapping):
> """Return a generator that renders the specified named template
> and
> yields chunks"""
> - ttype = t in self.map and self.map[t][0] or 'default'
> - if ttype not in self.ecache:
> + ttype = t in self._map and self._map[t][0] or 'default'
> + if ttype not in self._ecache:
> try:
> ecls = engines[ttype]
> except KeyError:
> raise error.Abort(_('invalid template engine: %s') %
> ttype)
> - self.ecache[ttype] = ecls(self.load, self.filters,
> self.defaults,
> - self._resources, self._aliases)
> - proc = self.ecache[ttype]
> + self._ecache[ttype] = ecls(self.load, self._filters,
> self.defaults,
> + self._resources, self._aliases)
> + proc = self._ecache[ttype]
>
> stream = proc.process(t, mapping)
> - if self.minchunk:
> - stream = util.increasingchunks(stream, min=self.minchunk,
> - max=self.maxchunk)
> + if self._minchunk:
> + stream = util.increasingchunks(stream, min=self._minchunk,
> + max=self._maxchunk)
> return stream
>
> def templatepaths():
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180616/7056f091/attachment.html>
More information about the Mercurial-devel
mailing list