Logo Search packages:      
Sourcecode: ranger version File versions  Download package

def ranger::fsobject::directory::Directory::load_bit_by_bit (   self )
Returns a generator which load a part of the directory
in each iteration.

Definition at line 166 of file directory.py.

                               :
            """
            Returns a generator which load a part of the directory
            in each iteration.
            """

            self.loading = True
            self.load_if_outdated()

            try:
                  if self.runnable:
                        yield
                        mypath = self.path

                        self.mount_path = mount_path(mypath)

                        hidden_filter = not self.settings.show_hidden \
                                    and self.settings.hidden_filter
                        filenames = [mypath + (mypath == '/' and fname or '/' + fname)\
                                    for fname in os.listdir(mypath) if accept_file(
                                          fname, mypath, hidden_filter, self.filter)]
                        yield

                        self.load_content_mtime = os.stat(mypath).st_mtime

                        marked_paths = [obj.path for obj in self.marked_items]

                        files = []
                        disk_usage = 0
                        for name in filenames:
                              try:
                                    file_lstat = os_lstat(name)
                                    if file_lstat.st_mode & 0o170000 == 0o120000:
                                          file_stat = os_stat(name)
                                    else:
                                          file_stat = file_lstat
                                    stats = (file_stat, file_lstat)
                                    is_a_dir = file_stat.st_mode & 0o170000 == 0o040000
                              except:
                                    stats = None
                                    is_a_dir = False
                              if is_a_dir:
                                    try:
                                          item = self.fm.env.get_directory(name)
                                          item.load_if_outdated()
                                    except:
                                          item = Directory(name, preload=stats,
                                                      path_is_abs=True)
                                          item.load()
                              else:
                                    item = File(name, preload=stats, path_is_abs=True)
                                    item.load()
                                    disk_usage += item.size
                              files.append(item)
                              yield
                        self.disk_usage = disk_usage

                        self.filenames = filenames
                        self.files = files

                        self._clear_marked_items()
                        for item in self.files:
                              if item.path in marked_paths:
                                    item._mark(True)
                                    self.marked_items.append(item)
                              else:
                                    item._mark(False)

                        self.sort()

                        if files:
                              if self.pointed_obj is not None:
                                    self.sync_index()
                              else:
                                    self.move(to=0)
                  else:
                        self.filenames = None
                        self.files = None

                  self.cycle_list = None
                  self.content_loaded = True
                  self.last_update_time = time()
                  self.correct_pointer()

            finally:
                  self.loading = False


Generated by  Doxygen 1.6.0   Back to index