MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _unsugar_count_from

Function _unsugar_count_from

lib/sqlalchemy/ext/orderinglist.py:231–246  ·  view source on GitHub ↗

Builds counting functions from keyword arguments. Keyword argument filter, prepares a simple ``ordering_func`` from a ``count_from`` argument, otherwise passes ``ordering_func`` on unchanged.

(**kw: Any)

Source from the content-addressed store, hash-verified

229
230
231def _unsugar_count_from(**kw: Any) -> Dict[str, Any]:
232 """Builds counting functions from keyword arguments.
233
234 Keyword argument filter, prepares a simple ``ordering_func`` from a
235 ``count_from`` argument, otherwise passes ``ordering_func`` on unchanged.
236 """
237
238 count_from = kw.pop("count_from", None)
239 if kw.get("ordering_func", None) is None and count_from is not None:
240 if count_from == 0:
241 kw["ordering_func"] = count_from_0
242 elif count_from == 1:
243 kw["ordering_func"] = count_from_1
244 else:
245 kw["ordering_func"] = count_from_n_factory(count_from)
246 return kw
247
248
249class OrderingList(List[_T]):

Callers 1

ordering_listFunction · 0.85

Calls 3

count_from_n_factoryFunction · 0.85
popMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected