# Path: fimfarchive/exceptions.py
# class InvalidStoryError(FimfarchiveError):
#     """
#     Story does not exist.
#     """
# 
# Path: fimfarchive/flavors.py
# class UpdateStatus(Flavor):
#     """
#     Indicates if and how a story has changed.
#     """
#     CREATED = ()
#     REVIVED = ()
#     UPDATED = ()
#     DELETED = ()
# 
# Path: fimfarchive/mappers.py
# class StoryDateMapper(Mapper[Optional[Arrow]]):
#     """
#     Returns the latest timestamp in a story, or None.
#     """
# 
#     def __call__(self, story: Story) -> Optional[Arrow]:
#         try:
#             meta = getattr(story, 'meta', None)
#         except InvalidStoryError:
#             return None
# 
#         if not meta:
#             return None
# 
#         dates = {
#             meta.get('date_modified'),
#         }
# 
#         for chapter in meta.get('chapters') or tuple():
#             dates.add(chapter.get('date_modified'))
# 
#         dates.discard(None)
# 
#         if dates:
#             return max(arrow.get(date) for date in dates)
#         else:
#             return None


from fimfarchive.exceptions import InvalidStoryError
from fimfarchive.flavors import UpdateStatus
from fimfarchive.mappers import StoryDateMapper

        Args:
            old: The currently available story.
            new: The potential replacement story.

        Returns:
            Story: One of the two story objects.
        """
        raise NotImplementedError()


class UpdateSelector(Selector):
    """
    Selects the new story if it needs to be updated.

    An `UpdateStatus` flavor is applied to all returned stories. The
    returned story will also be fully fetched. The selector will not
    attempt to fetch data from new stories unless they have changed.
    """

    def __init__(self, date_mapper=None):
        """
        Constructor.

        Args:
            date_mapper: Maps a `Story` to its modification date.
        """
        if date_mapper:
            self.date_mapper = date_mapper
        else:

# Path: fimfarchive/exceptions.py
# class InvalidStoryError(FimfarchiveError):
#     """
#     Story does not exist.
#     """
# 
# Path: fimfarchive/flavors.py
# class UpdateStatus(Flavor):
#     """
#     Indicates if and how a story has changed.
#     """
#     CREATED = ()
#     REVIVED = ()
#     UPDATED = ()
#     DELETED = ()
# 
# Path: fimfarchive/mappers.py
# class StoryDateMapper(Mapper[Optional[Arrow]]):
#     """
#     Returns the latest timestamp in a story, or None.
#     """
# 
#     def __call__(self, story: Story) -> Optional[Arrow]:
#         try:
#             meta = getattr(story, 'meta', None)
#         except InvalidStoryError:
#             return None
# 
#         if not meta:
#             return None
# 
#         dates = {
#             meta.get('date_modified'),
#         }
# 
#         for chapter in meta.get('chapters') or tuple():
#             dates.add(chapter.get('date_modified'))
# 
#         dates.discard(None)
# 
#         if dates:
#             return max(arrow.get(date) for date in dates)
#         else:
#             return None


# Path: fimfarchive/selectors.py
from fimfarchive.exceptions import InvalidStoryError
from fimfarchive.flavors import UpdateStatus
from fimfarchive.mappers import StoryDateMapper


        Args:
            old: The currently available story.
            new: The potential replacement story.

        Returns:
            Story: One of the two story objects.
        """
        raise NotImplementedError()


class UpdateSelector(Selector):
    """
    Selects the new story if it needs to be updated.

    An `UpdateStatus` flavor is applied to all returned stories. The
    returned story will also be fully fetched. The selector will not
    attempt to fetch data from new stories unless they have changed.
    """

    def __init__(self, date_mapper=None):
        """
        Constructor.

        Args:
            date_mapper: Maps a `Story` to its modification date.
        """
        if date_mapper:
            self.date_mapper = date_mapper
        else:

            self.date_mapper = StoryDateMapper()