<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def path(self, which=None):
 """Return the path to the current entity. Return the path to base entities of this entity's type if: * ``which`` is ``'base'``, or * ``which`` is ``None`` and instance attribute ``id`` is unset. Return the path to this exact entity if instance attribute ``id`` is set and: * ``which`` is ``'self'``, or * ``which`` is ``None``. Raise :class:`NoSuchPathError` otherwise. Child classes may choose to extend this method, especially if a child entity offers more than the two URLs supported by default. If extended, then the extending class should check for custom parameters before calling ``super``:: def path(self, which):
 if which == 'custom': return urljoin(…) super(ChildEntity, self).__init__(which) This will allow the extending method to accept a custom parameter without accidentally raising a :class:`NoSuchPathError`. :param which: A string. Optional. Valid arguments are 'self' and 'base'. :return: A string. A fully qualified URL. :raises nailgun.entity_mixins.NoSuchPathError: If no path can be built. """

        # It is OK that member ``self._meta`` is not found. Subclasses are
        # required to set that attribute if they wish to use this method.
        #
        # Beware of leading and trailing slashes:
        #
        #     urljoin('example.com', 'foo') => 'foo'
        #     urljoin('example.com/', 'foo') => 'example.com/foo'
        #     urljoin('example.com', '/foo') => '/foo'
        #     urljoin('example.com/', '/foo') => '/foo'
        #
        base = urljoin(
            self._server_config.url + '/',
            self._meta['api_path']  # pylint:disable=no-member
        )
        if which == 'base' or (which is None and not hasattr(self, 'id')):
            return base
        elif (which == 'self' or which is None) and hasattr(self, 'id'):
            return urljoin(base + '/', str(self.id))  # pylint:disable=E1101
        raise NoSuchPathError