MCPcopy Index your code
hub / github.com/RustPython/RustPython / _mapdict_values

Function _mapdict_values

Lib/tkinter/ttk.py:58–77  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

56 return _flatten(opts)
57
58def _mapdict_values(items):
59 # each value in mapdict is expected to be a sequence, where each item
60 # is another sequence containing a state (or several) and a value
61 # E.g. (script=False):
62 # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]
63 # returns:
64 # ['active selected', 'grey', 'focus', [1, 2, 3, 4]]
65 opt_val = []
66 for *state, val in items:
67 if len(state) == 1:
68 # if it is empty (something that evaluates to False), then
69 # format it to Tcl code to denote the "normal" state
70 state = state[0] or ''
71 else:
72 # group multiple states
73 state = ' '.join(state) # raise TypeError if not str
74 opt_val.append(state)
75 if val is not None:
76 opt_val.append(val)
77 return opt_val
78
79def _format_mapdict(mapdict, script=False):
80 """Formats mapdict to pass it to tk.call.

Callers 2

_format_mapdictFunction · 0.85
_format_elemcreateFunction · 0.85

Calls 3

lenFunction · 0.85
joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected