Substitute Decimals for floats in a string of statements. Based on an example from the tokenize module docs.
(tokens)
| 455 | |
| 456 | @ipt.TokenInputTransformer.wrap |
| 457 | def decistmt(tokens): |
| 458 | """Substitute Decimals for floats in a string of statements. |
| 459 | |
| 460 | Based on an example from the tokenize module docs. |
| 461 | """ |
| 462 | result = [] |
| 463 | for toknum, tokval, _, _, _ in tokens: |
| 464 | if toknum == tokenize.NUMBER and '.' in tokval: # replace NUMBER tokens |
| 465 | for newtok in [ |
| 466 | (tokenize.NAME, 'Decimal'), |
| 467 | (tokenize.OP, '('), |
| 468 | (tokenize.STRING, repr(tokval)), |
| 469 | (tokenize.OP, ')') |
| 470 | ]: |
| 471 | yield newtok |
| 472 | else: |
| 473 | yield (toknum, tokval) |
| 474 | |
| 475 | |
| 476 |
nothing calls this directly
no outgoing calls
no test coverage detected