Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_numliterals.py
"""Fixer that turns 1L into 1, 0755 into 0o755.
[0] Fix | Delete
"""
[1] Fix | Delete
# Copyright 2007 Georg Brandl.
[2] Fix | Delete
# Licensed to PSF under a Contributor Agreement.
[3] Fix | Delete
[4] Fix | Delete
# Local imports
[5] Fix | Delete
from ..pgen2 import token
[6] Fix | Delete
from .. import fixer_base
[7] Fix | Delete
from ..fixer_util import Number
[8] Fix | Delete
[9] Fix | Delete
[10] Fix | Delete
class FixNumliterals(fixer_base.BaseFix):
[11] Fix | Delete
# This is so simple that we don't need the pattern compiler.
[12] Fix | Delete
[13] Fix | Delete
_accept_type = token.NUMBER
[14] Fix | Delete
[15] Fix | Delete
def match(self, node):
[16] Fix | Delete
# Override
[17] Fix | Delete
return (node.value.startswith("0") or node.value[-1] in "Ll")
[18] Fix | Delete
[19] Fix | Delete
def transform(self, node, results):
[20] Fix | Delete
val = node.value
[21] Fix | Delete
if val[-1] in 'Ll':
[22] Fix | Delete
val = val[:-1]
[23] Fix | Delete
elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
[24] Fix | Delete
val = "0o" + val[1:]
[25] Fix | Delete
[26] Fix | Delete
return Number(val, prefix=node.prefix)
[27] Fix | Delete
[28] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function