/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/shellcomplete.py

  • Committer: Vincent Ladeuil
  • Date: 2010-07-07 11:21:19 UTC
  • mto: (5193.7.1 unify-confs)
  • mto: This revision was merged to the branch mainline in revision 5349.
  • Revision ID: v.ladeuil+lp@free.fr-20100707112119-jwyh312df41w6l0o
Revert previous change as I can't reproduce the related problem anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import sys
18
18
 
19
19
 
20
 
def shellcomplete(context=None, outfile=None):
 
20
def shellcomplete(context=None, outfile = None):
21
21
    if outfile is None:
22
22
        outfile = sys.stdout
23
23
    if context is None:
24
 
        shellcomplete_commands(outfile=outfile)
 
24
        shellcomplete_commands(outfile = outfile)
25
25
    else:
26
 
        shellcomplete_on_command(context, outfile=outfile)
 
26
        shellcomplete_on_command(context, outfile = outfile)
27
27
 
28
28
 
29
29
def shellcomplete_on_command(cmdname, outfile=None):
33
33
        outfile = sys.stdout
34
34
 
35
35
    from inspect import getdoc
36
 
    from . import commands
 
36
    import commands
37
37
    cmdobj = commands.get_cmd_object(cmdname)
38
38
 
39
39
    doc = getdoc(cmdobj)
40
40
    if doc is None:
41
 
        raise NotImplementedError(
42
 
            "sorry, no detailed shellcomplete yet for %r" % cmdname)
 
41
        raise NotImplementedError("sorry, no detailed shellcomplete yet for %r" % cmdname)
43
42
 
44
43
    shellcomplete_on_options(cmdobj.options().values(), outfile=outfile)
45
44
    for aname in cmdobj.takes_args:
51
50
        short_name = opt.short_name()
52
51
        if short_name:
53
52
            outfile.write('"(--%s -%s)"{--%s,-%s}\n'
54
 
                          % (opt.name, short_name, opt.name, short_name))
 
53
                    % (opt.name, short_name, opt.name, short_name))
55
54
        else:
56
55
            outfile.write('--%s\n' % opt.name)
57
56
 
58
57
 
59
 
def shellcomplete_commands(outfile=None):
 
58
def shellcomplete_commands(outfile = None):
60
59
    """List all commands"""
61
 
    from . import commands
 
60
    import inspect
 
61
    import commands
62
62
    from inspect import getdoc
63
63
 
64
64
    commands.install_bzr_command_hooks()