MCPcopy Create free account
hub / github.com/ceph/ceph / parse_funcsig

Function parse_funcsig

src/pybind/ceph_argparse.py:926–967  ·  view source on GitHub ↗

parse a single descriptor (array of strings or dicts) into a dict of function descriptor/validators (objects of CephXXX type) :returns: list of ``argdesc``

(sig: Sequence[Union[str, Dict[str, Any]]])

Source from the content-addressed store, hash-verified

924
925
926def parse_funcsig(sig: Sequence[Union[str, Dict[str, Any]]]) -> List[argdesc]:
927 """
928 parse a single descriptor (array of strings or dicts) into a
929 dict of function descriptor/validators (objects of CephXXX type)
930
931 :returns: list of ``argdesc``
932 """
933 newsig = []
934 argnum = 0
935 for desc in sig:
936 argnum += 1
937 if isinstance(desc, basestring):
938 t = CephPrefix
939 desc = {'type': t, 'name': 'prefix', 'prefix': desc}
940 else:
941 # not a simple string, must be dict
942 if 'type' not in desc:
943 s = 'JSON descriptor {0} has no type'.format(sig)
944 raise JsonFormat(s)
945 # look up type string in our globals() dict; if it's an
946 # object of type `type`, it must be a
947 # locally-defined class. otherwise, we haven't a clue.
948 if desc['type'] in globals():
949 t = globals()[desc['type']]
950 if not isinstance(t, type):
951 s = 'unknown type {0}'.format(desc['type'])
952 raise JsonFormat(s)
953 else:
954 s = 'unknown type {0}'.format(desc['type'])
955 raise JsonFormat(s)
956
957 kwargs = dict()
958 for key, val in desc.items():
959 if key not in ['type', 'name', 'n', 'req', 'positional']:
960 kwargs[key] = val
961 newsig.append(argdesc(t,
962 name=desc.get('name', None),
963 n=desc.get('n', 1),
964 req=desc.get('req', True),
965 positional=desc.get('positional', True),
966 **kwargs))
967 return newsig
968
969
970def parse_json_funcsigs(s: str,

Callers 3

setUpMethod · 0.90
parse_json_funcsigsFunction · 0.85
find_cmd_targetFunction · 0.85

Calls 6

JsonFormatClass · 0.85
argdescClass · 0.85
formatMethod · 0.45
itemsMethod · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by 1

setUpMethod · 0.72