Mercurial > hg
comparison mercurial/formatter.py @ 36921:32f9b7e3f056
templater: move hybrid class and functions to templateutil module
And make _hybrid and _mappable classes public. _showlist() is still marked
as private since it's weird and third-party codes shouldn't depend on it.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 08 Mar 2018 23:15:09 +0900 |
parents | 6ff6e1d6b5b8 |
children | 255f635c3204 |
comparison
equal
deleted
inserted
replaced
36920:6ff6e1d6b5b8 | 36921:32f9b7e3f056 |
---|---|
357 def formatdict(data, key, value, fmt, sep): | 357 def formatdict(data, key, value, fmt, sep): |
358 '''build object that can be evaluated as either plain string or dict''' | 358 '''build object that can be evaluated as either plain string or dict''' |
359 data = util.sortdict(_iteritems(data)) | 359 data = util.sortdict(_iteritems(data)) |
360 def f(): | 360 def f(): |
361 yield _plainconverter.formatdict(data, key, value, fmt, sep) | 361 yield _plainconverter.formatdict(data, key, value, fmt, sep) |
362 return templatekw.hybriddict(data, key=key, value=value, fmt=fmt, gen=f) | 362 return templateutil.hybriddict(data, key=key, value=value, fmt=fmt, |
363 gen=f) | |
363 @staticmethod | 364 @staticmethod |
364 def formatlist(data, name, fmt, sep): | 365 def formatlist(data, name, fmt, sep): |
365 '''build object that can be evaluated as either plain string or list''' | 366 '''build object that can be evaluated as either plain string or list''' |
366 data = list(data) | 367 data = list(data) |
367 def f(): | 368 def f(): |
368 yield _plainconverter.formatlist(data, name, fmt, sep) | 369 yield _plainconverter.formatlist(data, name, fmt, sep) |
369 return templatekw.hybridlist(data, name=name, fmt=fmt, gen=f) | 370 return templateutil.hybridlist(data, name=name, fmt=fmt, gen=f) |
370 | 371 |
371 class templateformatter(baseformatter): | 372 class templateformatter(baseformatter): |
372 def __init__(self, ui, out, topic, opts): | 373 def __init__(self, ui, out, topic, opts): |
373 baseformatter.__init__(self, ui, topic, opts, _templateconverter) | 374 baseformatter.__init__(self, ui, topic, opts, _templateconverter) |
374 self._out = out | 375 self._out = out |