Skip to content

Instantly share code, notes, and snippets.

@katipogluMustafa
Last active November 16, 2020 08:34
Show Gist options
  • Save katipogluMustafa/5e37b4848aedfb3ef9e261db89f92df9 to your computer and use it in GitHub Desktop.
Save katipogluMustafa/5e37b4848aedfb3ef9e261db89f92df9 to your computer and use it in GitHub Desktop.
from constraints.interval import Interval, TimebinInterval, MaxLimitInterval
class TimeConstraint:
def is_valid_timebin(interval: Interval):
return TimeConstraint.__is_expected_class(interval, TimebinInterval) and interval.is_valid()
def is_valid_max_limit(interval: Interval):
return TimeConstraint.__is_expected_class(interval, MaxLimitInterval) and interval.is_valid()
def __is_expected_class(interval: Interval, target_class: type):
if interval is None:
return False
if not isinstance(interval, target_class):
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment