
from rbuild import pluginapi
from rbuild.pluginapi import command


class ListImageTypesCommand(command.ListCommand):
    help = "List image types"
    resource = "imagetypes"
    listFields = ("description", "name")


class ImageTypes(pluginapi.Plugin):
    name = 'imagetypes'

    def initialize(self):
        for command, subcommand, commandClass in (
                ('list', 'imagetypes', ListImageTypesCommand),
                ):
            cmd = self.handle.Commands.getCommandClass(command)
            cmd.registerSubCommand(subcommand, commandClass)

    def list(self):
        rb = self.handle.facade.rbuilder
        return [type for type in rb.getImageTypes() if type.name]


from rbuild import pluginapi
from rbuild.pluginapi import command


class ListImageTypesCommand(command.ListCommand):
    help = "List image types"
    resource = "imagetypes"
    listFields = ("name", "description")


class ImageTypes(pluginapi.Plugin):
    name = 'imagetypes'

    def initialize(self):
        for command, subcommand, commandClass in (
                ('list', 'imagetypes', ListImageTypesCommand),
                ):
            cmd = self.handle.Commands.getCommandClass(command)
            cmd.registerSubCommand(subcommand, commandClass)

    def list(self):
        rb = self.handle.facade.rbuilder
        return [type for type in rb.getImageTypes() if type.name]

Swap order of name and description when listing image types
Swap order of name and description when listing image types

Uses the same order as target types, which puts the most important information,
the name, in front.

Refs APPENG-3419

  
  from rbuild import pluginapi
  from rbuild.pluginapi import command
  
  
  class ListImageTypesCommand(command.ListCommand):
      help = "List image types"
      resource = "imagetypes"
-     listFields = ("description", "name")
+     listFields = ("name", "description")
  
  
  class ImageTypes(pluginapi.Plugin):
      name = 'imagetypes'
  
      def initialize(self):
          for command, subcommand, commandClass in (
                  ('list', 'imagetypes', ListImageTypesCommand),
                  ):
              cmd = self.handle.Commands.getCommandClass(command)
              cmd.registerSubCommand(subcommand, commandClass)
  
      def list(self):
          rb = self.handle.facade.rbuilder
          return [type for type in rb.getImageTypes() if type.name]
  
Swap order of name and description when listing image types
## Code Before:

from rbuild import pluginapi
from rbuild.pluginapi import command


class ListImageTypesCommand(command.ListCommand):
    help = "List image types"
    resource = "imagetypes"
    listFields = ("description", "name")


class ImageTypes(pluginapi.Plugin):
    name = 'imagetypes'

    def initialize(self):
        for command, subcommand, commandClass in (
                ('list', 'imagetypes', ListImageTypesCommand),
                ):
            cmd = self.handle.Commands.getCommandClass(command)
            cmd.registerSubCommand(subcommand, commandClass)

    def list(self):
        rb = self.handle.facade.rbuilder
        return [type for type in rb.getImageTypes() if type.name]

## Instruction:
Swap order of name and description when listing image types
## Code After:

from rbuild import pluginapi
from rbuild.pluginapi import command


class ListImageTypesCommand(command.ListCommand):
    help = "List image types"
    resource = "imagetypes"
    listFields = ("name", "description")


class ImageTypes(pluginapi.Plugin):
    name = 'imagetypes'

    def initialize(self):
        for command, subcommand, commandClass in (
                ('list', 'imagetypes', ListImageTypesCommand),
                ):
            cmd = self.handle.Commands.getCommandClass(command)
            cmd.registerSubCommand(subcommand, commandClass)

    def list(self):
        rb = self.handle.facade.rbuilder
        return [type for type in rb.getImageTypes() if type.name]
