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

Function decistmt

Lib/test/test_tokenize.py:1245–1258  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

1243
1244
1245def decistmt(s):
1246 result = []
1247 g = tokenize.tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string
1248 for toknum, tokval, _, _, _ in g:
1249 if toknum == tokenize.NUMBER and '.' in tokval: # replace NUMBER tokens
1250 result.extend([
1251 (tokenize.NAME, 'Decimal'),
1252 (tokenize.OP, '('),
1253 (tokenize.STRING, repr(tokval)),
1254 (tokenize.OP, ')')
1255 ])
1256 else:
1257 result.append((toknum, tokval))
1258 return tokenize.untokenize(result).decode('utf-8').strip()
1259
1260class TestMisc(TestCase):
1261

Callers 1

test_decistmtMethod · 0.85

Calls 7

BytesIOClass · 0.90
untokenizeMethod · 0.80
encodeMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45
stripMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…