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

Function normalize_selection

Tools/c-analyzer/c_common/scriptutil.py:116–140  ·  view source on GitHub ↗
(selected: str, *, possible=None)

Source from the content-addressed store, hash-verified

114
115
116def normalize_selection(selected: str, *, possible=None):
117 if selected in (None, True, False):
118 return selected
119 elif isinstance(selected, str):
120 selected = [selected]
121 elif not selected:
122 return ()
123
124 unsupported = []
125 _selected = set()
126 for item in selected:
127 if not item:
128 continue
129 for value in item.strip().replace(',', ' ').split():
130 if not value:
131 continue
132 # XXX Handle subtraction (leading "-").
133 if possible and value not in possible and value != 'all':
134 unsupported.append(value)
135 _selected.add(value)
136 if unsupported:
137 raise UnsupportedSelectionError(unsupported, tuple(possible))
138 if 'all' in _selected:
139 return True
140 return frozenset(selected)
141
142
143##################################

Callers 1

process_argsFunction · 0.85

Calls 7

setFunction · 0.85
splitMethod · 0.45
replaceMethod · 0.45
stripMethod · 0.45
appendMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…