#1489 Drop usage of kobo.plugins
Merged 3 years ago by lsedlar. Opened 3 years ago by lsedlar.
lsedlar/pungi drop-kobo-plugins  into  master

@@ -45,20 +45,14 @@ 

  

  def get_gather_source(name):

      import pungi.phases.gather.sources

-     from .source import GatherSourceContainer

  

-     GatherSourceContainer.register_module(pungi.phases.gather.sources)

-     container = GatherSourceContainer()

-     return container["GatherSource%s" % name]

+     return pungi.phases.gather.sources.ALL_SOURCES[name.lower()]

  

  

  def get_gather_method(name):

      import pungi.phases.gather.methods

-     from .method import GatherMethodContainer

  

-     GatherMethodContainer.register_module(pungi.phases.gather.methods)

-     container = GatherMethodContainer()

-     return container["GatherMethod%s" % name]

+     return pungi.phases.gather.methods.ALL_METHODS[name.lower()]

  

  

  class GatherPhase(PhaseBase):

file modified
+1 -10
@@ -14,15 +14,6 @@ 

  # along with this program; if not, see <https://gnu.org/licenses/>.

  

  

- import kobo.plugins

- 

- 

- class GatherMethodBase(kobo.plugins.Plugin):

+ class GatherMethodBase(object):

      def __init__(self, compose):

          self.compose = compose

- 

- 

- class GatherMethodContainer(kobo.plugins.PluginContainer):

-     @classmethod

-     def normalize_name(cls, name):

-         return name.lower()

@@ -0,0 +1,24 @@ 

+ # -*- coding: utf-8 -*-

+ 

+ 

+ # This program is free software; you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation; version 2 of the License.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU Library General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, see <https://gnu.org/licenses/>.

+ 

+ from .method_deps import GatherMethodDeps

+ from .method_nodeps import GatherMethodNodeps

+ from .method_hybrid import GatherMethodHybrid

+ 

+ ALL_METHODS = {

+     "deps": GatherMethodDeps,

+     "nodeps": GatherMethodNodeps,

+     "hybrid": GatherMethodHybrid,

+ }

@@ -31,8 +31,6 @@ 

  

  

  class GatherMethodDeps(pungi.phases.gather.method.GatherMethodBase):

-     enabled = True

- 

      def __call__(

          self,

          arch,

@@ -60,8 +60,6 @@ 

  

  

  class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase):

-     enabled = True

- 

      def __init__(self, *args, **kwargs):

          super(GatherMethodHybrid, self).__init__(*args, **kwargs)

          self.package_maps = {}

@@ -28,8 +28,6 @@ 

  

  

  class GatherMethodNodeps(pungi.phases.gather.method.GatherMethodBase):

-     enabled = True

- 

      def __call__(self, arch, variant, *args, **kwargs):

          fname = "gather-nodeps-%s" % variant.uid

          if self.source_name:

file modified
+1 -10
@@ -14,15 +14,6 @@ 

  # along with this program; if not, see <https://gnu.org/licenses/>.

  

  

- import kobo.plugins

- 

- 

- class GatherSourceBase(kobo.plugins.Plugin):

+ class GatherSourceBase(object):

      def __init__(self, compose):

          self.compose = compose

- 

- 

- class GatherSourceContainer(kobo.plugins.PluginContainer):

-     @classmethod

-     def normalize_name(cls, name):

-         return name.lower()

@@ -0,0 +1,26 @@ 

+ # -*- coding: utf-8 -*-

+ 

+ 

+ # This program is free software; you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation; version 2 of the License.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU Library General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, see <https://gnu.org/licenses/>.

+ 

+ from .source_comps import GatherSourceComps

+ from .source_json import GatherSourceJson

+ from .source_module import GatherSourceModule

+ from .source_none import GatherSourceNone

+ 

+ ALL_SOURCES = {

+     "comps": GatherSourceComps,

+     "json": GatherSourceJson,

+     "module": GatherSourceModule,

+     "none": GatherSourceNone,

+ }

@@ -30,8 +30,6 @@ 

  

  

  class GatherSourceComps(pungi.phases.gather.source.GatherSourceBase):

-     enabled = True

- 

      def __call__(self, arch, variant):

          groups = set()

          if not self.compose.conf.get("comps_file"):

@@ -37,8 +37,6 @@ 

  

  

  class GatherSourceJson(pungi.phases.gather.source.GatherSourceBase):

-     enabled = True

- 

      def __call__(self, arch, variant):

          json_path = self.compose.conf.get("gather_source_mapping")

          if not json_path:

@@ -26,8 +26,6 @@ 

  

  

  class GatherSourceModule(pungi.phases.gather.source.GatherSourceBase):

-     enabled = True

- 

      def __call__(self, arch, variant):

          groups = set()

          packages = set()

@@ -29,7 +29,5 @@ 

  

  

  class GatherSourceNone(pungi.phases.gather.source.GatherSourceBase):

-     enabled = True

- 

      def __call__(self, arch, variant):

          return set(), set()

@@ -29,13 +29,10 @@ 

          self.path_prefix = None

  

      def run(self):

-         pkgset_source = "PkgsetSource%s" % self.compose.conf["pkgset_source"]

-         from .source import PkgsetSourceContainer

          from . import sources

  

-         PkgsetSourceContainer.register_module(sources)

-         container = PkgsetSourceContainer()

-         SourceClass = container[pkgset_source]

+         SourceClass = sources.ALL_SOURCES[self.compose.conf["pkgset_source"].lower()]

+ 

          self.package_sets, self.path_prefix = SourceClass(self.compose)()

  

      def validate(self):

file modified
+1 -10
@@ -14,15 +14,6 @@ 

  # along with this program; if not, see <https://gnu.org/licenses/>.

  

  

- import kobo.plugins

- 

- 

- class PkgsetSourceBase(kobo.plugins.Plugin):

+ class PkgsetSourceBase(object):

      def __init__(self, compose):

          self.compose = compose

- 

- 

- class PkgsetSourceContainer(kobo.plugins.PluginContainer):

-     @classmethod

-     def normalize_name(cls, name):

-         return name.lower()

@@ -0,0 +1,22 @@ 

+ # -*- coding: utf-8 -*-

+ 

+ 

+ # This program is free software; you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation; version 2 of the License.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU Library General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, see <https://gnu.org/licenses/>.

+ 

+ from .source_koji import PkgsetSourceKoji

+ from .source_repos import PkgsetSourceRepos

+ 

+ ALL_SOURCES = {

+     "koji": PkgsetSourceKoji,

+     "repos": PkgsetSourceRepos,

+ }

@@ -184,8 +184,6 @@ 

  

  

  class PkgsetSourceKoji(pungi.phases.pkgset.source.PkgsetSourceBase):

-     enabled = True

- 

      def __call__(self):

          compose = self.compose

          koji_profile = compose.conf["koji_profile"]

@@ -31,8 +31,6 @@ 

  

  

  class PkgsetSourceRepos(pungi.phases.pkgset.source.PkgsetSourceBase):

-     enabled = True

- 

      def __call__(self):

          package_sets, path_prefix = get_pkgset_from_repos(self.compose)

          return (package_sets, path_prefix)