Created
August 23, 2018 01:09
-
-
Save flaviut/7088e5543b65b1dd1320a822c9cb2ef5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lib2to3 import fixer_base | |
from lib2to3.pytree import Node | |
from lib2to3.pygram import python_symbols as syms | |
from lib2to3.fixer_util import Name, ArgList | |
import libmodernize | |
class FixGetcwd(fixer_base.ConditionalFix): | |
BM_compatible = True | |
skip_on = "six.moves.getcwd" | |
PATTERN = """ | |
power< 'os' trailer< dot='.' name='getcwdu' > any* > | |
""" | |
def transform(self, node, results): | |
new = Node(syms.power, [Name("getcwd"), ArgList([])], prefix="") | |
new.prefix = node.prefix | |
libmodernize.touch_import(u'six.moves', u'getcwd', node) | |
return new | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment