MCPcopy Index your code
hub / github.com/python/cpython / parsecodes

Function parsecodes

Tools/unicode/gencodec.py:46–71  ·  view source on GitHub ↗

Converts code combinations to either a single code integer or a tuple of integers. meta-codes (in angular brackets, e.g. and ) are ignored. Empty codes or illegal ones are returned as None.

(codes, len=len, range=range)

Source from the content-addressed store, hash-verified

44 r'(#.+)?')
45
46def parsecodes(codes, len=len, range=range):
47
48 """ Converts code combinations to either a single code integer
49 or a tuple of integers.
50
51 meta-codes (in angular brackets, e.g. <LR> and <RL>) are
52 ignored.
53
54 Empty codes or illegal ones are returned as None.
55
56 """
57 if not codes:
58 return MISSING_CODE
59 l = codes.split('+')
60 if len(l) == 1:
61 return int(l[0],16)
62 for i in range(len(l)):
63 try:
64 l[i] = int(l[i],16)
65 except ValueError:
66 l[i] = MISSING_CODE
67 l = [x for x in l if x != MISSING_CODE]
68 if len(l) == 1:
69 return l[0]
70 else:
71 return tuple(l)
72
73def readmap(filename):
74

Callers 1

readmapFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…