]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/fixes/fix_numliterals.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / lib2to3 / fixes / fix_numliterals.py
CommitLineData
4710c53d 1"""Fixer that turns 1L into 1, 0755 into 0o755.\r
2"""\r
3# Copyright 2007 Georg Brandl.\r
4# Licensed to PSF under a Contributor Agreement.\r
5\r
6# Local imports\r
7from ..pgen2 import token\r
8from .. import fixer_base\r
9from ..fixer_util import Number\r
10\r
11\r
12class FixNumliterals(fixer_base.BaseFix):\r
13 # This is so simple that we don't need the pattern compiler.\r
14\r
15 _accept_type = token.NUMBER\r
16\r
17 def match(self, node):\r
18 # Override\r
19 return (node.value.startswith(u"0") or node.value[-1] in u"Ll")\r
20\r
21 def transform(self, node, results):\r
22 val = node.value\r
23 if val[-1] in u'Ll':\r
24 val = val[:-1]\r
25 elif val.startswith(u'0') and val.isdigit() and len(set(val)) > 1:\r
26 val = u"0o" + val[1:]\r
27\r
28 return Number(val, prefix=node.prefix)\r