MCPcopy
hub / github.com/SirVer/ultisnips / _split_conditional

Function _split_conditional

pythonx/UltiSnips/text_objects/transformation.py:28–49  ·  view source on GitHub ↗

Split the given conditional 'string' into its arguments.

(string)

Source from the content-addressed store, hash-verified

26
27
28def _split_conditional(string):
29 """Split the given conditional 'string' into its arguments."""
30 bracks_open = 0
31 args = []
32 carg = ""
33 escaped = False
34 for _idx, char in enumerate(string):
35 if char == "(":
36 if not escaped:
37 bracks_open += 1
38 elif char == ")":
39 if not escaped:
40 bracks_open -= 1
41 elif char == ":" and not bracks_open and not escaped:
42 args.append(carg)
43 carg = ""
44 escaped = False
45 continue
46 carg += char
47 escaped = not escaped if char == "\\" else False
48 args.append(carg)
49 return args
50
51
52def _replace_conditional(match, string):

Callers 1

_replace_conditionalFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected