コード例 #1
0
class PathCompleter(Completer):
    def __init__(self):
        super(PathCompleter, self).__init__()

    def completions(self, text, cwd):
        expanded = path_expanduser(text)
        fullpath = FilePath(expanded, cwd)
        try:
            isdir = stat.S_ISDIR(os.stat(fullpath).st_mode)
        except OSError, e:
            isdir = False
        fs = Filesystem.getInstance()
        if isdir and fullpath.endswith('/'):
            for fpath in iterd_sorted(fullpath, fpath=True):
                yield _mkfile_completion(text, fpath)
            return
        (src_dpath, src_prefix) = os.path.split(fullpath)
        try:
            for fpath in iterd_sorted(src_dpath, fpath=True):
                fname = unix_basename(fpath)
                if fname.startswith(src_prefix):
                    try:
                        yield _mkfile_completion(text, fpath)
                    except OSError, e:
                        pass
        except OSError, e:
            pass
コード例 #2
0
 def completions(self, text, cwd, context=None):
     bc = BuiltinCompleter()
     for completion in bc.completions(text, cwd, context=context):
         yield completion
     aliases = AliasRegistry.getInstance()
     for alias in aliases:
         compl = self._match(alias.name, text, alias)
         if compl: yield compl
     textpath = FilePath(text, cwd)
     expanded_textpath = path_expanduser(textpath)
     (text_dpath, text_prefix) = os.path.split(expanded_textpath)
     if text.find('/') >= 0 or text.startswith('.' + os.sep):
         pc = PathCompleter()
         for completion in pc.completions(text, cwd):
             fobj = completion.target
             if fobj.is_directory or fobj.is_executable:
                 yield completion
     else:
         fs = Filesystem.getInstance()
         for dpath in fs.get_path_generator():
             if not os.access(dpath, os.X_OK):
                 continue
             for fpath in iterd_sorted(dpath):
                 fname = unix_basename(fpath)
                 if not fname.startswith(text_prefix):
                     continue
                 fobj = fs.get_file_sync(fpath)
                 if fobj.is_executable:
                     yield _mkfile_completion(text, fpath, fobj)
コード例 #3
0
ファイル: completion.py プロジェクト: sandeep-datta/hotwire
 def completions(self, text, cwd, context=None):
     bc = BuiltinCompleter()
     for completion in bc.completions(text, cwd, context=context):
         yield completion
     aliases = AliasRegistry.getInstance()
     for alias in aliases:
         compl = self._match(alias.name, text, alias)
         if compl: yield compl
     textpath = FilePath(text, cwd)
     expanded_textpath = path_expanduser(textpath)
     (text_dpath, text_prefix) = os.path.split(expanded_textpath)             
     if text.find('/') >= 0 or text.startswith('.' + os.sep):
         pc = PathCompleter()
         for completion in pc.completions(text, cwd):
             fobj = completion.target
             if fobj.is_directory or fobj.is_executable:
                 yield completion
     else:
         fs = Filesystem.getInstance()           
         for dpath in fs.get_path_generator():
             if not os.access(dpath, os.X_OK):
                 continue
             for fpath in iterd_sorted(dpath):
                 fname = unix_basename(fpath)
                 if not fname.startswith(text_prefix):
                     continue
                 fobj = fs.get_file_sync(fpath)
                 if fobj.is_executable:
                     yield _mkfile_completion(text, fpath, fobj)
コード例 #4
0
ファイル: completion.py プロジェクト: sandeep-datta/hotwire
 def completions(self, text, cwd):
     expanded = path_expanduser(text)        
     fullpath = FilePath(expanded, cwd)
     try:
         isdir = stat.S_ISDIR(os.stat(fullpath).st_mode)
     except OSError as e:
         isdir = False
     fs = Filesystem.getInstance()
     if isdir and fullpath.endswith('/'):
         for fpath in iterd_sorted(fullpath, fpath=True):
             yield _mkfile_completion(text, fpath)
         return
     (src_dpath, src_prefix) = os.path.split(fullpath)
     try:
         for fpath in iterd_sorted(src_dpath, fpath=True):
             fname = unix_basename(fpath)
             if fname.startswith(src_prefix):
                 try:
                     yield _mkfile_completion(text, fpath)
                 except OSError as e:
                     pass
     except OSError as e:
         pass
コード例 #5
0
ファイル: fs.py プロジェクト: EmilyDirsh/hotwire-shell
 def ls_dir(self, dir, show_all):
     for x in iterd_sorted(dir):
         fobj = self.get_file_sync(x)
         if show_all or (not fobj.hidden):  
             yield fobj
コード例 #6
0
ファイル: fs.py プロジェクト: zaxebo1/hotwire-shell
 def ls_dir(self, dir, show_all):
     for x in iterd_sorted(dir):
         fobj = self.get_file_sync(x)
         if show_all or (not fobj.hidden):
             yield fobj