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

Method _from_str

Tools/c-analyzer/c_parser/info.py:971–998  ·  view source on GitHub ↗
(cls, text)

Source from the content-addressed store, hash-verified

969
970 @classmethod
971 def _from_str(cls, text):
972 orig = text
973 inline, sep, text = text.partition('|')
974 if not sep:
975 text = inline
976 inline = None
977
978 isforward = False
979 if text.endswith(';'):
980 text = text[:-1]
981 isforward = True
982 elif text.endswith('{}'):
983 text = text[:-2]
984
985 index = text.rindex('(')
986 if index < 0:
987 raise ValueError(f'bad signature text {orig!r}')
988 params = text[index:]
989 while params.count('(') <= params.count(')'):
990 index = text.rindex('(', 0, index)
991 if index < 0:
992 raise ValueError(f'bad signature text {orig!r}')
993 params = text[index:]
994 text = text[:index]
995
996 returntype = VarType._from_str(text.rstrip())
997
998 return cls(params, returntype, inline, isforward)
999
1000 def __str__(self):
1001 parts = []

Callers

nothing calls this directly

Calls 7

clsClass · 0.50
partitionMethod · 0.45
endswithMethod · 0.45
rindexMethod · 0.45
countMethod · 0.45
_from_strMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected