Esempio n. 1
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)
Esempio n. 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)
Esempio n. 3
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)
Esempio n. 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)
Esempio n. 5
0
 def validate_backend(self, key, value):
     if value not in BACKEND_PLUGINS.get_plugin_names():
         raise ValueError('Backend "{}" is not supported.'.format(value))
     return value
Esempio n. 6
0
 def validate_backend(self, key, value):
     if value not in BACKEND_PLUGINS.get_plugin_names():
         raise ValueError('Backend "{}" is not supported.'.format(value))
     return value