Revision f5ce7613

b/autotools/build-bash-completion
1 1
#!/usr/bin/python
2 2
#
3 3

  
4
# Copyright (C) 2009 Google Inc.
4
# Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
319 319

  
320 320
    wrote_opt = False
321 321

  
322
    for (suggest, allnames) in values.iteritems():
322
    for (suggest, allnames) in values.items():
323 323
      longnames = [i for i in allnames if i.startswith("--")]
324 324

  
325 325
      if wrote_opt:
......
551 551

  
552 552
      # Group commands by arguments and options
553 553
      grouped_cmds = {}
554
      for cmd, (_, argdef, optdef, _, _) in commands.iteritems():
554
      for cmd, (_, argdef, optdef, _, _) in commands.items():
555 555
        if not (argdef or optdef):
556 556
          continue
557 557
        grouped_cmds.setdefault((tuple(argdef), tuple(optdef)), set()).add(cmd)
558 558

  
559 559
      # We're doing options and arguments to commands
560 560
      sw.Write("""case "${COMP_WORDS[1]}" in""")
561
      for ((argdef, optdef), cmds) in grouped_cmds.items():
561
      sort_grouped = sorted(grouped_cmds.items(),
562
                            key=lambda (_, y): sorted(y)[0])
563
      for ((argdef, optdef), cmds) in sort_grouped:
562 564
        assert argdef or optdef
563 565
        sw.Write("%s)", "|".join(map(utils.ShellQuote, sorted(cmds))))
564 566
        sw.IncIndent()
......
610 612
  aliases = getattr(module, "aliases", {})
611 613
  if aliases:
612 614
    commands = commands.copy()
613
    for name, target in aliases.iteritems():
615
    for name, target in aliases.items():
614 616
      commands[name] = commands[target]
615 617

  
616 618
  return commands

Also available in: Unified diff