###############################################################################
#
#   Copyright: (c) 2015 Carlo Sbraccia
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
###############################################################################

from calendar import SATURDAY, SUNDAY

__all__ = ["HolidayCalendar"]


###############################################################################
class HolidayCalendar(object):
    """
    Store holidays and provide testing methods.
    """
    # -------------------------------------------------------------------------
    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    # -------------------------------------------------------------------------
    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    # -------------------------------------------------------------------------
    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            # --- saturday and sundays are always recurring holidays
            return True
        return False

    # -------------------------------------------------------------------------
    def __deepcopy__(self, memo):
        clone = self.__class__.__new__(self.__class__)
        clone.holidays = self.holidays.copy()
        memo[id(self)] = clone
        return clone

2d5f2b639ed3e57f57683c8d7d6d5b089a27d30c
<mask token>


class HolidayCalendar(object):
    <mask token>

    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            return True
        return False
    <mask token>

<mask token>


class HolidayCalendar(object):
    <mask token>

    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            return True
        return False

    def __deepcopy__(self, memo):
        clone = self.__class__.__new__(self.__class__)
        clone.holidays = self.holidays.copy()
        memo[id(self)] = clone
        return clone

<mask token>
__all__ = ['HolidayCalendar']


class HolidayCalendar(object):
    """
    Store holidays and provide testing methods.
    """

    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            return True
        return False

    def __deepcopy__(self, memo):
        clone = self.__class__.__new__(self.__class__)
        clone.holidays = self.holidays.copy()
        memo[id(self)] = clone
        return clone

from calendar import SATURDAY, SUNDAY
__all__ = ['HolidayCalendar']


class HolidayCalendar(object):
    """
    Store holidays and provide testing methods.
    """

    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            return True
        return False

    def __deepcopy__(self, memo):
        clone = self.__class__.__new__(self.__class__)
        clone.holidays = self.holidays.copy()
        memo[id(self)] = clone
        return clone

###############################################################################
#
#   Copyright: (c) 2015 Carlo Sbraccia
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
###############################################################################

from calendar import SATURDAY, SUNDAY

__all__ = ["HolidayCalendar"]


###############################################################################
class HolidayCalendar(object):
    """
    Store holidays and provide testing methods.
    """
    # -------------------------------------------------------------------------
    def __init__(self, holidays=None):
        if holidays is None:
            self.holidays = set()
        else:
            self.holidays = set(holidays)

    # -------------------------------------------------------------------------
    def add(self, holidays):
        for holiday in holidays:
            self.holidays.add(holiday)

    # -------------------------------------------------------------------------
    def is_holiday(self, d):
        if d in self.holidays:
            return True
        elif d.weekday() in (SATURDAY, SUNDAY):
            # --- saturday and sundays are always recurring holidays
            return True
        return False

    # -------------------------------------------------------------------------
    def __deepcopy__(self, memo):
        clone = self.__class__.__new__(self.__class__)
        clone.holidays = self.holidays.copy()
        memo[id(self)] = clone
        return clone
