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

Method _parse

Tools/c-analyzer/c_common/tables.py:299–328  ·  view source on GitHub ↗
(cls, specstr)

Source from the content-addressed store, hash-verified

297
298 @classmethod
299 def _parse(cls, specstr):
300 m = cls.REGEX.match(specstr)
301 if not m:
302 return None
303 (label, field,
304 align, width1,
305 width2, fmt,
306 ) = m.groups()
307 if not label:
308 label = field
309 if fmt:
310 assert not align and not width1, (specstr,)
311 _parsed = _parse_fmt(fmt)
312 if not _parsed:
313 raise NotImplementedError
314 elif width2:
315 width, _ = _parsed
316 if width != int(width2):
317 raise NotImplementedError(specstr)
318 elif width2:
319 fmt = width2
320 width = int(width2)
321 else:
322 assert not fmt, (fmt, specstr)
323 if align:
324 width = int(width1) if width1 else len(label)
325 fmt = f'{align}{width}'
326 else:
327 width = None
328 return field, label, fmt, width
329
330 @classmethod
331 def _normalize(cls, spec):

Callers 3

from_rawMethod · 0.45
parseMethod · 0.45
_normalizeMethod · 0.45

Calls 3

_parse_fmtFunction · 0.85
matchMethod · 0.45
groupsMethod · 0.45

Tested by

no test coverage detected