#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) Wolfgang Rohdewald <wolfgang@rohdewald.de>
# See LICENSE for details.

"""
This implements :class:`gpxity.backends.ServerDirectory`
"""


from .directory import Directory

__all__ = ['ServerDirectory']

class ServerDirectory(Directory):
    """Like :class:`Directory` but the activity ids are different: Just a number.
    A new id is generated by adding 1 to the highest existing id.

    The symbolic links per YYYY/MM use the title of the activity as link name.

    """

    # pylint: disable=abstract-method

    skip_test = False

    def _set_new_id(self, activity):
        """gives the activity a unique id"""
        try:
            activity.id_in_backend = str(max(int(x) for x in self._list_gpx()) + 1)
        except ValueError:
            activity.id_in_backend = '1'

ServerDirectory._define_support() # pylint: disable=protected-access
