MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / OrPredicate

Class OrPredicate

lib/sqlalchemy/testing/exclusions.py:373–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372
373class OrPredicate(Predicate):
374 def __init__(self, predicates, description=None):
375 self.predicates = predicates
376 self.description = description
377
378 def __call__(self, config):
379 for pred in self.predicates:
380 if pred(config):
381 return True
382 return False
383
384 def _eval_str(self, config, negate=False):
385 if negate:
386 conjunction = " and "
387 else:
388 conjunction = " or "
389 return conjunction.join(
390 p._as_string(config, negate=negate) for p in self.predicates
391 )
392
393 def _negation_str(self, config):
394 if self.description is not None:
395 return "Not " + self._format_description(config)
396 else:
397 return self._eval_str(config, negate=True)
398
399 def _as_string(self, config, negate=False):
400 if negate:
401 return self._negation_str(config)
402 else:
403 if self.description is not None:
404 return self._format_description(config)
405 else:
406 return self._eval_str(config)
407
408
409_as_predicate = Predicate.as_predicate

Callers 5

as_predicateMethod · 0.85
db_specFunction · 0.85
only_onFunction · 0.85
againstFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected