#264 unify CLI parsing of multiple architectures
Merged 7 years ago by mikem. Opened 7 years ago by tkopecek.
tkopecek/koji issue206  into  master

file modified
+17 -8
@@ -302,6 +302,14 @@ 

      for child in task.get('children',()):

          print_task_recurse(child,depth+1)

  

+ def parse_arches(arches, to_list=False):

+     """Parse comma or space-separated list of arches and return

+        only space-separated one."""

+     arches = arches.replace(',', ' ').split()

+     if to_list:

+         return arches

+     else:

+         return ' '.join(arches)

  

  class TaskWatcher(object):

  
@@ -631,7 +639,7 @@ 

      usage = _("usage: %prog edit-host hostname ... [options]")

      usage += _("\n(Specify the --help global option for a list of other help options)")

      parser = OptionParser(usage=usage)

-     parser.add_option("--arches", help=_("Space-separated list of supported architectures"))

+     parser.add_option("--arches", help=_("Space or comma-separated list of supported architectures"))

      parser.add_option("--capacity", type="float", help=_("Capacity of this host"))

      parser.add_option("--description", metavar="DESC", help=_("Description of this host"))

      parser.add_option("--comment", help=_("A brief comment about this host"))
@@ -645,6 +653,8 @@ 

      for key, val in subopts.__dict__.items():

          if val is not None:

              vals[key] = val

+     if 'arches' in vals:

+         vals['arches'] = parse_arches(vals['arches'])

  

      session.multicall = True

      for host in args:
@@ -794,7 +804,7 @@ 

              continue

          to_add.append(package)

      if options.extra_arches:

-         opts['extra_arches'] = ' '.join(options.extra_arches.replace(',',' ').split())

+         opts['extra_arches'] = parse_arches(options.extra_arches)

  

      # add the packages

      print "Adding %i packages to tag %s" % (len(to_add), dsttag['name'])
@@ -961,7 +971,7 @@ 

      source = args[1]

      opts = {}

      if build_opts.arch_override:

-         opts['arch_override'] = ' '.join(build_opts.arch_override.replace(',',' ').split())

+         opts['arch_override'] = parse_arches(build_opts.arch_override)

      for key in ('skip_tag', 'scratch', 'repo_id'):

          val = getattr(build_opts, key)

          if val is not None:
@@ -4797,7 +4807,7 @@ 

      if options.parent:

          opts['parent'] = options.parent

      if options.arches:

-         opts['arches'] = ' '.join(options.arches.replace(',',' ').split())

+         opts['arches'] = parse_arches(options.arches)

      if options.maven_support:

          opts['maven_support'] = True

      if options.include_all:
@@ -4836,7 +4846,7 @@ 

      tag = args[0]

      opts = {}

      if options.arches:

-         opts['arches'] = ' '.join(options.arches.replace(',',' ').split())

+         opts['arches'] = parse_arches(options.arches)

      if options.no_perm:

          opts['perm_id'] = None

      elif options.perm:
@@ -6113,8 +6123,7 @@ 

              sys.exit(1)

          callopts['owner'] = user['id']

      if options.arch:

-         arches = options.arch.replace(',',' ').split()

-         callopts['arch'] = arches

+         callopts['arch'] = parse_arches(options.arch, to_list=True)

      if options.method:

          callopts['method'] = options.method

      if options.channel:
@@ -6187,7 +6196,7 @@ 

          parser.error(_("Please specify an archlist, a tag, and at least one package"))

          assert False  # pragma: no cover

      activate_session(session)

-     arches = ' '.join(args[0].replace(',',' ').split())

+     arches = parse_arches(args[0])

      tag = args[1]

      for package in args[2:]:

          #really should implement multicall...

no initial comment

Commit 7f15bcc fixes this pull-request

Pull-Request has been merged by mikem@redhat.com

7 years ago
Metadata