MCPcopy Index your code
hub / github.com/httpie/cli / expect

Function expect

httpie/cli/nested_json/parse.py:46–67  ·  view source on GitHub ↗
(*kinds)

Source from the content-addressed store, hash-verified

44
45 # noinspection PyShadowingNames
46 def expect(*kinds):
47 nonlocal cursor
48 assert kinds
49 if can_advance():
50 token = tokens[cursor]
51 cursor += 1
52 if token.kind in kinds:
53 return token
54 elif tokens:
55 token = tokens[-1]._replace(
56 start=tokens[-1].end + 0,
57 end=tokens[-1].end + 1,
58 )
59 else:
60 token = None
61 if len(kinds) == 1:
62 suffix = kinds[0].to_name()
63 else:
64 suffix = ', '.join(kind.to_name() for kind in kinds[:-1])
65 suffix += ' or ' + kinds[-1].to_name()
66 message = f'Expecting {suffix}'
67 raise NestedJSONSyntaxError(source, token, message)
68
69 # noinspection PyShadowingNames
70 def parse_root():

Callers 2

parse_rootFunction · 0.85
parseFunction · 0.85

Calls 3

can_advanceFunction · 0.85
to_nameMethod · 0.80

Tested by

no test coverage detected