~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-18 20:37:53 UTC
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: bialix@ukr.net-20060718203753-fa30c2f3cc59316b
don't use curses on win32

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
import readline
22
22
import shlex
23
 
import stat
24
23
import string
25
24
import sys
26
25
 
27
26
from bzrlib.branch import Branch
28
27
from bzrlib.commands import get_cmd_object, get_all_cmds, get_alias
29
28
from bzrlib.errors import BzrError
30
 
from bzrlib.workingtree import WorkingTree
31
29
 
32
30
import terminal
33
31
 
66
64
 
67
65
    def get_completions_or_raise(self):
68
66
        if self.command is None:
69
 
            if '/' in self.text:
70
 
                iter = iter_executables(self.text)
71
 
            else:
72
 
                iter = (c+" " for c in iter_command_names() if
73
 
                        c not in COMPLETION_BLACKLIST)
 
67
            iter = (c+" " for c in iter_command_names() if
 
68
                    c not in COMPLETION_BLACKLIST)
74
69
            return list(filter_completions(iter, self.text))
75
70
        if self.prev_opt is None:
76
71
            completions = self.get_option_completions()
123
118
        if self.tree is not None:
124
119
            try:
125
120
                prompt_data = (self.tree.branch.nick, self.tree.branch.revno(), 
126
 
                               self.tree.relpath('.'))
 
121
                               self.tree.branch.relpath('.'))
127
122
                prompt = " %s:%d/%s" % prompt_data
128
123
            except:
129
124
                prompt = ""
285
280
                yield name
286
281
 
287
282
 
288
 
def iter_executables(path):
289
 
    dirname, partial = os.path.split(path)
290
 
    for filename in os.listdir(dirname):
291
 
        if not filename.startswith(partial):
292
 
            continue
293
 
        fullpath = os.path.join(dirname, filename)
294
 
        mode=os.lstat(fullpath)[stat.ST_MODE]
295
 
        if stat.S_ISREG(mode) and 0111 & mode:
296
 
            yield fullpath + ' '
297
 
 
298
 
 
299
283
def filter_completions(iter, arg):
300
284
    return (c for c in iter if c.startswith(arg))
301
285