예제 #1
0
파일: models.py 프로젝트: odra/anitya
    def get_version_class(self):
        """
        Get the class for the version scheme used by this project.

        This will take into account the defaults set in the ecosystem, backend,
        and globally. The version scheme locations are checked in the following
        order and the first non-null result is returned:

        1. On the project itself in the ``version_scheme`` column.
        2. The project's ecosystem default, if the project is part of one.
        3. The project's backend default, if the backend defines one.
        4. The global default defined in :data:`anitya.lib.versions.GLOBAL_DEFAULT`

        Returns:
            anitya.lib.versions.Version: A ``Version`` sub-class.
        """
        version_scheme = self.version_scheme
        if not version_scheme and self.ecosystem_name:
            ecosystem = ECOSYSTEM_PLUGINS.get_plugin(self.ecosystem_name)
            if ecosystem is None:
                # This project uses its URL as an ecosystem
                version_scheme = DEFAULT_VERSION_SCHEME
            else:
                version_scheme = ecosystem.default_version_scheme
        if not version_scheme and self.backend:
            backend = BACKEND_PLUGINS.get_plugin(self.backend)
            version_scheme = backend.default_version_scheme
        if not version_scheme:
            version_scheme = DEFAULT_VERSION_SCHEME

        return VERSION_PLUGINS.get_plugin(version_scheme)
예제 #2
0
    def get_version_class(self):
        """
        Get the class for the version scheme used by this project.

        This will take into account the defaults set in the ecosystem, backend,
        and globally. The version scheme locations are checked in the following
        order and the first non-null result is returned:

        1. On the project itself in the ``version_scheme`` column.
        2. The project's ecosystem default, if the project is part of one.
        3. The project's backend default, if the backend defines one.
        4. The global default defined in :data:`anitya.lib.versions.GLOBAL_DEFAULT`

        Returns:
            anitya.lib.versions.Version: A ``Version`` sub-class.
        """
        version_scheme = self.version_scheme
        if not version_scheme and self.ecosystem_name:
            ecosystem = ECOSYSTEM_PLUGINS.get_plugin(self.ecosystem_name)
            if ecosystem is None:
                # This project uses its URL as an ecosystem
                version_scheme = DEFAULT_VERSION_SCHEME
            else:
                version_scheme = ecosystem.default_version_scheme
        if not version_scheme and self.backend:
            backend = BACKEND_PLUGINS.get_plugin(self.backend)
            version_scheme = backend.default_version_scheme
        if not version_scheme:
            version_scheme = DEFAULT_VERSION_SCHEME

        return VERSION_PLUGINS.get_plugin(version_scheme)
예제 #3
0
파일: models.py 프로젝트: odra/anitya
    def get_version_url(self):
        ''' Returns full version url, which is used by backend.

        Returns:
            str: Version url or empty string if backend is not specified
        '''
        if not self.backend:
            return ""

        backend = BACKEND_PLUGINS.get_plugin(self.backend)
        return backend.get_version_url(self)
예제 #4
0
    def get_version_url(self):
        """ Returns full version url, which is used by backend.

        Returns:
            str: Version url or empty string if backend is not specified
        """
        if not self.backend:
            return ""

        backend = BACKEND_PLUGINS.get_plugin(self.backend)
        return backend.get_version_url(self)