Get the corresponding TimePeriod from the value.

        Example values: 'all', 'hour', 'day', 'week', or 'month'.

def get_time_period(value):
        """Get the corresponding TimePeriod from the value.

        Example values: 'all', 'hour', 'day', 'week', or 'month'.
        """
        for time_period in TimePeriod:
            if time_period.period == value:
                return time_period
        raise ValueError('{} is not a valid TimePeriod'.format(value))