MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _splitdict

Function _splitdict

tools/python-3.11.9-amd64/Lib/tkinter/__init__.py:124–145  ·  view source on GitHub ↗

Return a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements.

(tk, v, cut_minus=True, conv=None)

Source from the content-addressed store, hash-verified

122
123
124def _splitdict(tk, v, cut_minus=True, conv=None):
125 """Return a properly formatted dict built from Tcl list pairs.
126
127 If cut_minus is True, the supposed '-' prefix will be removed from
128 keys. If conv is specified, it is used to convert values.
129
130 Tcl list is expected to contain an even number of elements.
131 """
132 t = tk.splitlist(v)
133 if len(t) % 2:
134 raise RuntimeError('Tcl list representing a dict is expected '
135 'to contain an even number of elements')
136 it = iter(t)
137 dict = {}
138 for key, value in zip(it, it):
139 key = str(key)
140 if cut_minus and key[0] == '-':
141 key = key[1:]
142 if conv:
143 value = conv(value)
144 dict[key] = value
145 return dict
146
147class _VersionInfoType(collections.namedtuple('_VersionInfoType',
148 ('major', 'minor', 'micro', 'releaselevel', 'serial'))):

Callers 7

_val_or_dictFunction · 0.90
mapMethod · 0.90
setMethod · 0.90
_grid_configureMethod · 0.85
pack_infoMethod · 0.85
place_infoMethod · 0.85
grid_infoMethod · 0.85

Calls 1

strFunction · 0.85

Tested by

no test coverage detected