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

Function _parse_sequence

Lib/idlelib/multicall.py:267–304  ·  view source on GitHub ↗

Get a string which should describe an event sequence. If it is successfully parsed as one, return a tuple containing the state (as an int), the event type (as an index of _types), and the detail - None if none, or a string if there is one. If the parsing is unsuccessful, return None.

(sequence)

Source from the content-addressed store, hash-verified

265_keysym_re = re.compile(r"^\w+$")
266_button_re = re.compile(r"^[1-5]$")
267def _parse_sequence(sequence):
268 """Get a string which should describe an event sequence. If it is
269 successfully parsed as one, return a tuple containing the state (as an int),
270 the event type (as an index of _types), and the detail - None if none, or a
271 string if there is one. If the parsing is unsuccessful, return None.
272 """
273 if not sequence or sequence[0] != '<' or sequence[-1] != '>':
274 return None
275 words = sequence[1:-1].split('-')
276 modifiers = 0
277 while words and words[0] in _modifier_names:
278 modifiers |= 1 << _modifier_names[words[0]]
279 del words[0]
280 if words and words[0] in _type_names:
281 type = _type_names[words[0]]
282 del words[0]
283 else:
284 return None
285 if _binder_classes[type] is _SimpleBinder:
286 if modifiers or words:
287 return None
288 else:
289 detail = None
290 else:
291 # _ComplexBinder
292 if type in [_type_names[s] for s in ("KeyPress", "KeyRelease")]:
293 type_re = _keysym_re
294 else:
295 type_re = _button_re
296
297 if not words:
298 detail = None
299 elif len(words) == 1 and type_re.match(words[0]):
300 detail = words[0]
301 else:
302 return None
303
304 return modifiers, type, detail
305
306def _triplet_to_sequence(triplet):
307 if triplet[2]:

Callers 2

event_addMethod · 0.85
event_deleteMethod · 0.85

Calls 2

splitMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…