Esempio n. 1
0
 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
Esempio n. 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)
Esempio n. 3
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)
Esempio n. 4
0
 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
Esempio n. 5
0
 def __init__(self):
     self.__bookmarks_path = path_expanduser('~/.gtk-bookmarks')
     try:
         self.__monitor = Filesystem.getInstance().get_monitor(
             self.__bookmarks_path, self.__on_bookmarks_changed)
     except NotImplementedError, e:
         pass
Esempio n. 6
0
 def __init__(self):
     self.__bookmarks_path = path_expanduser('~/.gtk-bookmarks')
     try:
         self.__monitor = Filesystem.getInstance().get_monitor(self.__bookmarks_path, self.__on_bookmarks_changed)
     except NotImplementedError as e:
         pass
     self.__bookmarks = []
     self.__read_bookmarks()
Esempio n. 7
0
 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
Esempio n. 8
0
 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