Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_intern.py
# Copyright 2006 Georg Brandl.
[0] Fix | Delete
# Licensed to PSF under a Contributor Agreement.
[1] Fix | Delete
[2] Fix | Delete
"""Fixer for intern().
[3] Fix | Delete
[4] Fix | Delete
intern(s) -> sys.intern(s)"""
[5] Fix | Delete
[6] Fix | Delete
# Local imports
[7] Fix | Delete
from .. import fixer_base
[8] Fix | Delete
from ..fixer_util import ImportAndCall, touch_import
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
class FixIntern(fixer_base.BaseFix):
[12] Fix | Delete
BM_compatible = True
[13] Fix | Delete
order = "pre"
[14] Fix | Delete
[15] Fix | Delete
PATTERN = """
[16] Fix | Delete
power< 'intern'
[17] Fix | Delete
trailer< lpar='('
[18] Fix | Delete
( not(arglist | argument<any '=' any>) obj=any
[19] Fix | Delete
| obj=arglist<(not argument<any '=' any>) any ','> )
[20] Fix | Delete
rpar=')' >
[21] Fix | Delete
after=any*
[22] Fix | Delete
>
[23] Fix | Delete
"""
[24] Fix | Delete
[25] Fix | Delete
def transform(self, node, results):
[26] Fix | Delete
if results:
[27] Fix | Delete
# I feel like we should be able to express this logic in the
[28] Fix | Delete
# PATTERN above but I don't know how to do it so...
[29] Fix | Delete
obj = results['obj']
[30] Fix | Delete
if obj:
[31] Fix | Delete
if (obj.type == self.syms.argument and
[32] Fix | Delete
obj.children[0].value in {'**', '*'}):
[33] Fix | Delete
return # Make no change.
[34] Fix | Delete
names = ('sys', 'intern')
[35] Fix | Delete
new = ImportAndCall(node, results, names)
[36] Fix | Delete
touch_import(None, 'sys', node)
[37] Fix | Delete
return new
[38] Fix | Delete
[39] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function