QGIS/scripts/qgis_fixes/fix_print_with_import.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
710 B
Python
Raw Normal View History

import re
from lib2to3.fixer_util import Leaf, Node, find_indentation, syms
2024-11-29 14:26:30 +01:00
from libfuturize.fixes.fix_print_with_import import (
FixPrintWithImport as FixPrintWithImportOrig,
2024-11-29 14:26:30 +01:00
)
2016-04-03 01:42:37 +02:00
class FixPrintWithImport(FixPrintWithImportOrig):
def transform(self, node, results):
if "fix_print_with_import" in node.prefix:
return node
r = super().transform(node, results)
if not r or r == node:
return r
if not r.prefix:
indentation = find_indentation(node)
r.prefix = "# fix_print_with_import\n" + indentation
else:
r.prefix = re.sub("([ \t]*$)", r"\1# fix_print_with_import\n\1", r.prefix)
return r