~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bashcomp.py

Fix Python 2.4 syntax and testtools dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
            opt.add_option(parser, opt.short_name())
214
214
            if isinstance(opt, option.RegistryOption) and opt.enum_switch:
215
215
                enum_switch = '--%s' % optname
216
 
                keys = opt.registry.keys()
217
 
                if enum_switch in optswitches and keys:
218
 
                    optswitches.remove(enum_switch)
219
 
                    for key in keys:
220
 
                        optswitches.append('%s=%s' % (enum_switch, key))
221
 
                    enums.append("%s) optEnums='%s' ;;"
222
 
                                 % (enum_switch, ' '.join(keys)))
 
216
                try:
 
217
                    keys = opt.registry.keys()
 
218
                except ImportError, e:
 
219
                    cases += ("\t\t# ERROR getting registry keys for '--%s':"
 
220
                              + " %s\n") % (optname, str(e).split('\n')[0])
 
221
                else:
 
222
                    if enum_switch in optswitches and keys:
 
223
                        optswitches.remove(enum_switch)
 
224
                        for key in keys:
 
225
                            optswitches.append('%s=%s' % (enum_switch, key))
 
226
                            enums.append("%s) optEnums='%s' ;;"
 
227
                                         % (enum_switch, ' '.join(keys)))
223
228
            switches.extend(optswitches)
224
229
        if 'help' == cmdname or 'help' in cmd.aliases:
225
230
            fixedWords = " ".join(sorted(help_topics.topic_registry.keys()))
253
258
        template = fun
254
259
    else:
255
260
        template = head + fun + tail
 
261
    if debug:
 
262
        perhaps_debug_output = debug_output
 
263
    else:
 
264
        perhaps_debug_output = ''
256
265
    out.write(template % {"cmds": " ".join(cmds),
257
266
                          "cases": cases,
258
267
                          "function_name": function_name,
259
268
                          "version": __version__,
260
269
                          "global_options": global_options,
261
 
                          "debug": debug_output if debug else "",
 
270
                          "debug": perhaps_debug_output,
262
271
                          "bzr_version": bzr_version,
263
272
                          })
264
273