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

Method _normalize

Tools/c-analyzer/c_common/tables.py:331–366  ·  view source on GitHub ↗
(cls, spec)

Source from the content-addressed store, hash-verified

329
330 @classmethod
331 def _normalize(cls, spec):
332 if len(spec) == 1:
333 raw, = spec
334 raise NotImplementedError
335 return _resolve_column(raw)
336
337 if len(spec) == 4:
338 label, field, width, fmt = spec
339 if width:
340 if not fmt:
341 fmt = str(width)
342 elif _parse_fmt(fmt)[0] != width:
343 raise ValueError(f'width mismatch in {spec}')
344 elif len(raw) == 3:
345 label, field, fmt = spec
346 if not field:
347 label, field = None, label
348 elif not isinstance(field, str) or not field.isidentifier():
349 # XXX This doesn't seem right...
350 fmt = f'{field}:{fmt}' if fmt else field
351 label, field = None, label
352 elif len(raw) == 2:
353 label = None
354 field, fmt = raw
355 if not field:
356 field, fmt = fmt, None
357 elif not field.isidentifier() or fmt.isidentifier():
358 label, field = field, fmt
359 else:
360 raise NotImplementedError
361
362 fmt = f':{fmt}' if fmt else ''
363 if label:
364 return cls._parse(f'[{label}]{field}{fmt}')
365 else:
366 return cls._parse(f'{field}{fmt}')
367
368 @property
369 def width(self):

Callers 1

from_rawMethod · 0.45

Calls 4

strFunction · 0.85
_parse_fmtFunction · 0.85
isidentifierMethod · 0.80
_parseMethod · 0.45

Tested by

no test coverage detected