summaryrefslogtreecommitdiff
path: root/doc/_extensions/pyjsparser/pyjsparserdata.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2018-11-08 15:03:33 +0000
committerAdrian Torres <adt@odoo.com>2018-11-29 09:28:17 +0000
commit758382b3a73da024d6e1dc04a474d2868223767a (patch)
treee37ea57fb6efabf9a14d30b39a74af664ddd1ed3 /doc/_extensions/pyjsparser/pyjsparserdata.py
parent52f5528cfb6d1152ee226e268247dc685a8ba329 (diff)
[REM] pycompat: remove python 2 shims and helpers
Odoo no longer supports python 2, thus some of these helpers can and have been replaced by python 3 built-ins, therefore there is no need for them to stay defined. The removed helpers are: * izip, imap and ifilter * unichr, text_type * implements_to_string, implements_iterator * string_types, integer_types * to_native The python 2 shims have also been removed, and only the python 3 helpers have been kept, because they can still be usable (i.e. accepting both bytes and str for functions that can only accept one of the two) [REM] pyjsparser: remove PY3 shims They're no longer necessary as Odoo doesn't officially support python 2 anymore. closes odoo/odoo#28519
Diffstat (limited to 'doc/_extensions/pyjsparser/pyjsparserdata.py')
-rw-r--r--doc/_extensions/pyjsparser/pyjsparserdata.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/doc/_extensions/pyjsparser/pyjsparserdata.py b/doc/_extensions/pyjsparser/pyjsparserdata.py
index 6ca6dbc47cc..5db295a34b5 100644
--- a/doc/_extensions/pyjsparser/pyjsparserdata.py
+++ b/doc/_extensions/pyjsparser/pyjsparserdata.py
@@ -23,12 +23,6 @@ import sys
import unicodedata
from collections import defaultdict
-PY3 = sys.version_info >= (3,0)
-
-if PY3:
- unichr = chr
- xrange = range
- unicode = str
token = {
'BooleanLiteral': 1,
@@ -221,7 +215,7 @@ LS = u'\u2028'
PS = u'\u2029'
U_CATEGORIES = defaultdict(list)
-for c in map(unichr, range(sys.maxunicode + 1)):
+for c in map(chr, range(sys.maxunicode + 1)):
U_CATEGORIES[unicodedata.category(c)].append(c)
UNICODE_LETTER = set(U_CATEGORIES['Lu']+U_CATEGORIES['Ll']+
U_CATEGORIES['Lt']+U_CATEGORIES['Lm']+
@@ -242,33 +236,33 @@ WHITE_SPACE = set((0x20, 0x09, 0x0B, 0x0C, 0xA0, 0x1680,
LINE_TERMINATORS = set((0x0A, 0x0D, 0x2028, 0x2029))
def isIdentifierStart(ch):
- return (ch if isinstance(ch, unicode) else unichr(ch)) in IDENTIFIER_START
+ return (ch if isinstance(ch, str) else chr(ch)) in IDENTIFIER_START
def isIdentifierPart(ch):
- return (ch if isinstance(ch, unicode) else unichr(ch)) in IDENTIFIER_PART
+ return (ch if isinstance(ch, str) else chr(ch)) in IDENTIFIER_PART
def isWhiteSpace(ch):
- return (ord(ch) if isinstance(ch, unicode) else ch) in WHITE_SPACE
+ return (ord(ch) if isinstance(ch, str) else ch) in WHITE_SPACE
def isLineTerminator(ch):
- return (ord(ch) if isinstance(ch, unicode) else ch) in LINE_TERMINATORS
+ return (ord(ch) if isinstance(ch, str) else ch) in LINE_TERMINATORS
OCTAL = set(('0', '1', '2', '3', '4', '5', '6', '7'))
DEC = set(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))
HEX = set('0123456789abcdefABCDEF')
-HEX_CONV = dict(('0123456789abcdef'[n],n) for n in xrange(16))
+HEX_CONV = dict(('0123456789abcdef'[n],n) for n in range(16))
for i,e in enumerate('ABCDEF', 10):
HEX_CONV[e] = i
def isDecimalDigit(ch):
- return (ch if isinstance(ch, unicode) else unichr(ch)) in DEC
+ return (ch if isinstance(ch, str) else chr(ch)) in DEC
def isHexDigit(ch):
- return (ch if isinstance(ch, unicode) else unichr(ch)) in HEX
+ return (ch if isinstance(ch, str) else chr(ch)) in HEX
def isOctalDigit(ch):
- return (ch if isinstance(ch, unicode) else unichr(ch)) in OCTAL
+ return (ch if isinstance(ch, str) else chr(ch)) in OCTAL
def isFutureReservedWord(w):
return w in ('enum', 'export', 'import', 'super')