Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/libfuturize/fixes/fix_input.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 """ | |
| 2 Fixer for input. | |
| 3 | |
| 4 Does a check for `from builtins import input` before running the lib2to3 fixer. | |
| 5 The fixer will not run when the input is already present. | |
| 6 | |
| 7 | |
| 8 this: | |
| 9 a = input() | |
| 10 becomes: | |
| 11 from builtins import input | |
| 12 a = eval(input()) | |
| 13 | |
| 14 and this: | |
| 15 from builtins import input | |
| 16 a = input() | |
| 17 becomes (no change): | |
| 18 from builtins import input | |
| 19 a = input() | |
| 20 """ | |
| 21 | |
| 22 import lib2to3.fixes.fix_input | |
| 23 from lib2to3.fixer_util import does_tree_import | |
| 24 | |
| 25 | |
| 26 class FixInput(lib2to3.fixes.fix_input.FixInput): | |
| 27 def transform(self, node, results): | |
| 28 | |
| 29 if does_tree_import('builtins', 'input', node): | |
| 30 return | |
| 31 | |
| 32 return super(FixInput, self).transform(node, results) |
