Mercurial > hg
comparison mercurial/formatter.py @ 31925:5b2241e84982
templatekw: add public function to wrap a dict by _hybrid object
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 05 Apr 2017 22:28:09 +0900 |
parents | 21f129354dd0 |
children | 0fd15522a848 |
comparison
equal
deleted
inserted
replaced
31924:21f129354dd0 | 31925:5b2241e84982 |
---|---|
319 def formatdict(data, key, value, fmt, sep): | 319 def formatdict(data, key, value, fmt, sep): |
320 '''build object that can be evaluated as either plain string or dict''' | 320 '''build object that can be evaluated as either plain string or dict''' |
321 data = util.sortdict(_iteritems(data)) | 321 data = util.sortdict(_iteritems(data)) |
322 def f(): | 322 def f(): |
323 yield _plainconverter.formatdict(data, key, value, fmt, sep) | 323 yield _plainconverter.formatdict(data, key, value, fmt, sep) |
324 return templatekw._hybrid(f(), data, lambda k: {key: k, value: data[k]}, | 324 return templatekw.hybriddict(data, key=key, value=value, fmt=fmt, |
325 lambda d: fmt % (d[key], d[value])) | 325 gen=f()) |
326 @staticmethod | 326 @staticmethod |
327 def formatlist(data, name, fmt, sep): | 327 def formatlist(data, name, fmt, sep): |
328 '''build object that can be evaluated as either plain string or list''' | 328 '''build object that can be evaluated as either plain string or list''' |
329 data = list(data) | 329 data = list(data) |
330 def f(): | 330 def f(): |