comparison mercurial/formatter.py @ 37839:395571419274

formatter: ditch namedtuple in favor of attr
author Yuya Nishihara <yuya@tcha.org>
date Thu, 03 May 2018 15:08:16 +0900
parents 31750413f8d7
children 8d6109b49b31
comparison
equal deleted inserted replaced
37838:3fe1c9263024 37839:395571419274
105 baz: foo, bar 105 baz: foo, bar
106 """ 106 """
107 107
108 from __future__ import absolute_import, print_function 108 from __future__ import absolute_import, print_function
109 109
110 import collections
111 import contextlib 110 import contextlib
112 import itertools 111 import itertools
113 import os 112 import os
114 113
115 from .i18n import _ 114 from .i18n import _
116 from .node import ( 115 from .node import (
117 hex, 116 hex,
118 short, 117 short,
118 )
119 from .thirdparty import (
120 attr,
119 ) 121 )
120 122
121 from . import ( 123 from . import (
122 error, 124 error,
123 pycompat, 125 pycompat,
411 413
412 def end(self): 414 def end(self):
413 baseformatter.end(self) 415 baseformatter.end(self)
414 self._renderitem('docfooter', {}) 416 self._renderitem('docfooter', {})
415 417
416 templatespec = collections.namedtuple(r'templatespec', 418 @attr.s(frozen=True)
417 r'ref tmpl mapfile') 419 class templatespec(object):
420 ref = attr.ib()
421 tmpl = attr.ib()
422 mapfile = attr.ib()
418 423
419 def lookuptemplate(ui, topic, tmpl): 424 def lookuptemplate(ui, topic, tmpl):
420 """Find the template matching the given -T/--template spec 'tmpl' 425 """Find the template matching the given -T/--template spec 'tmpl'
421 426
422 'tmpl' can be any of the following: 427 'tmpl' can be any of the following: