Show More
@@ -333,8 +333,9 b' def join(context, mapping, args):' | |||
|
333 | 333 | joiner = evalstring(context, mapping, args[1]) |
|
334 | 334 | if isinstance(joinset, templateutil.wrapped): |
|
335 | 335 | return joinset.join(context, mapping, joiner) |
|
336 | # TODO: perhaps a generator should be stringify()-ed here, but we can't | |
|
337 | # because hgweb abuses it as a keyword that returns a list of dicts. | |
|
336 | # TODO: rethink about join() of a byte string, which had no defined | |
|
337 | # behavior since a string may be either a bytes or a generator. | |
|
338 | # TODO: fix type error on join() of non-iterable | |
|
338 | 339 | joinset = templateutil.unwrapvalue(context, mapping, joinset) |
|
339 | 340 | return templateutil.joinitems(pycompat.maybebytestr(joinset), joiner) |
|
340 | 341 |
@@ -26,9 +26,6 b' generator' | |||
|
26 | 26 | values of any printable types, and will be folded by ``stringify()`` |
|
27 | 27 | or ``flatten()``. |
|
28 | 28 | |
|
29 | BUG: hgweb overloads this type for mappings (i.e. some hgweb keywords | |
|
30 | returns a generator of dicts.) | |
|
31 | ||
|
32 | 29 | None |
|
33 | 30 | sometimes represents an empty value, which can be stringified to ''. |
|
34 | 31 |
@@ -285,12 +285,6 b' def unwraphybrid(context, mapping, thing' | |||
|
285 | 285 | return thing |
|
286 | 286 | return thing.show(context, mapping) |
|
287 | 287 | |
|
288 | def unwrapvalue(context, mapping, thing): | |
|
289 | """Move the inner value object out of the wrapper""" | |
|
290 | if not isinstance(thing, wrapped): | |
|
291 | return thing | |
|
292 | return thing.tovalue(context, mapping) | |
|
293 | ||
|
294 | 288 | def wraphybridvalue(container, key, value): |
|
295 | 289 | """Wrap an element of hybrid container to be mappable |
|
296 | 290 | |
@@ -455,12 +449,10 b' def evalrawexp(context, mapping, arg):' | |||
|
455 | 449 | |
|
456 | 450 | def evalfuncarg(context, mapping, arg): |
|
457 | 451 | """Evaluate given argument as value type""" |
|
458 |
return |
|
|
452 | return unwrapvalue(context, mapping, evalrawexp(context, mapping, arg)) | |
|
459 | 453 | |
|
460 | # TODO: unify this with unwrapvalue() once the bug of templatefunc.join() | |
|
461 | # is fixed. we can't do that right now because join() has to take a generator | |
|
462 | # of byte strings as it is, not a lazy byte string. | |
|
463 | def _unwrapvalue(context, mapping, thing): | |
|
454 | def unwrapvalue(context, mapping, thing): | |
|
455 | """Move the inner value object out of the wrapper""" | |
|
464 | 456 | if isinstance(thing, wrapped): |
|
465 | 457 | return thing.tovalue(context, mapping) |
|
466 | 458 | # evalrawexp() may return string, generator of strings or arbitrary object |
@@ -492,7 +484,7 b' def evaldate(context, mapping, arg, err=' | |||
|
492 | 484 | return unwrapdate(context, mapping, thing, err) |
|
493 | 485 | |
|
494 | 486 | def unwrapdate(context, mapping, thing, err=None): |
|
495 |
thing = |
|
|
487 | thing = unwrapvalue(context, mapping, thing) | |
|
496 | 488 | try: |
|
497 | 489 | return dateutil.parsedate(thing) |
|
498 | 490 | except AttributeError: |
@@ -507,7 +499,7 b' def evalinteger(context, mapping, arg, e' | |||
|
507 | 499 | return unwrapinteger(context, mapping, thing, err) |
|
508 | 500 | |
|
509 | 501 | def unwrapinteger(context, mapping, thing, err=None): |
|
510 |
thing = |
|
|
502 | thing = unwrapvalue(context, mapping, thing) | |
|
511 | 503 | try: |
|
512 | 504 | return int(thing) |
|
513 | 505 | except (TypeError, ValueError): |
@@ -527,7 +519,7 b' def evalstringliteral(context, mapping, ' | |||
|
527 | 519 | return stringify(context, mapping, thing) |
|
528 | 520 | |
|
529 | 521 | _unwrapfuncbytype = { |
|
530 |
None: |
|
|
522 | None: unwrapvalue, | |
|
531 | 523 | bytes: stringify, |
|
532 | 524 | date: unwrapdate, |
|
533 | 525 | int: unwrapinteger, |
General Comments 0
You need to be logged in to leave comments.
Login now