Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/libfuturize/fixes/fix_input.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
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) |