Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/libpasteurize/fixes/fix_division.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 u""" | |
| 2 Fixer for division: from __future__ import division if needed | |
| 3 """ | |
| 4 | |
| 5 from lib2to3 import fixer_base | |
| 6 from libfuturize.fixer_util import token, future_import | |
| 7 | |
| 8 def match_division(node): | |
| 9 u""" | |
| 10 __future__.division redefines the meaning of a single slash for division, | |
| 11 so we match that and only that. | |
| 12 """ | |
| 13 slash = token.SLASH | |
| 14 return node.type == slash and not node.next_sibling.type == slash and \ | |
| 15 not node.prev_sibling.type == slash | |
| 16 | |
| 17 class FixDivision(fixer_base.BaseFix): | |
| 18 run_order = 4 # this seems to be ignored? | |
| 19 | |
| 20 def match(self, node): | |
| 21 u""" | |
| 22 Since the tree needs to be fixed once and only once if and only if it | |
| 23 matches, then we can start discarding matches after we make the first. | |
| 24 """ | |
| 25 return match_division(node) | |
| 26 | |
| 27 def transform(self, node, results): | |
| 28 future_import(u"division", node) |
