def buildEntry(self, filename, path, pathFilename=None, isDir=False, isMovie=False, mediaType=None): png = None fileSize = "" fileAttrib = "" lastModified = "" realPath = "" res = [] # info if not isDir: if self.showFiles: fileInfo = os_lstat(pathFilename) fileAttrib = oct(stat_stat.S_IMODE(fileInfo.st_mode)) lastModified = strftime("%d.%m.%Y %H:%M:%S", localtime(fileInfo.st_mtime)) fileSize = prettySize(getSize(pathFilename)) isLink = stat_stat.S_ISLNK(fileInfo.st_mode) if os_path.islink(pathFilename): realPath = " >> %s" % (os_path.realpath(pathFilename)) elif path is not None and filename not in ( '<%s>' % (_("List of Storage Devices")), '<%s>' % (_("Parent Directory"))): try: fileInfo = os_lstat(path) fileAttrib = oct(stat_stat.S_IMODE(fileInfo.st_mode)) if os_path.islink(path[:-1]): realPath = " >> %s" % (os_path.realpath(path[:-1])) except OSError: print("OSError occured") # icons if isDir: png = LoadPixmap(cached=True, path="%s/dir.png" % (self.iconSet)) else: extension = filename.split('.') extension = extension[-1].lower() if EXTENSIONS.has_key(extension): png = LoadPixmap("%s/%s.png" % (self.iconSet, EXTENSIONS[extension])) elif isMovie: png = LoadPixmap("%s/movie.png" % (self.iconSet)) if self.showDetails: res.extend( (filename, path, pathFilename, isDir, isMovie, mediaType, png, fileSize, lastModified, fileAttrib, realPath)) else: res.extend( (filename, path, pathFilename, isDir, isMovie, mediaType, png)) return res
def byDateFunc(self, a, b): try: stat1 = os_lstat(self.current_directory + a[0]) stat2 = os_lstat(self.current_directory + b[0]) except: return 0 if self.sortType == self.SORT_DATE_DESC: return cmp(b[3], a[3]) or cmp(stat2.st_ctime, stat1.st_ctime) else: return cmp(b[3], a[3]) or cmp(stat1.st_ctime, stat2.st_ctime)
def _checkPathForChanges(oldStatCache, statCache, oldDirCache, dirCache, checked_locations, path, recursive, depth=0, linked_paths=None): #print "_checkPathForChanges: %s" % (path) # We use realpath to ensure we don't do a second stat or listdir for the same # path. changes = {} modified = False oldFileStat = None try: try: lstat = os_lstat(path) except Exception, e: log.debug("polling _checkPathForChanges unable to lstat [%r] - %s", path, e) raise #if S_ISLNK(lstat.st_mode): if (lstat.st_mode & 0170000) == S_IFLNK: # Taken from stat module realpath = os_path_realpath(path) # linked_paths is used to ensure we don't go in a cyclic loop for symlinks if not linked_paths: linked_paths = {} if path != realpath: # It's a link #log.debug("Link: %s to %s", path, realpath) all_links_here = linked_paths.get(realpath, []) # We do not support cyclical paths, check if any have been found for linkpath in all_links_here: if len(path) >= len(linkpath): largerpath = path smallerpath = linkpath else: largerpath = linkpath smallerpath = path if largerpath.find(smallerpath) == 0: #print "Found cyclical path: %s to %s" % (path, realpath) #log.info("Found cyclical symlink path: %s to %s", path, realpath) return {} # It's okay, but we add this link to the known symlink list all_links_here.append(path) linked_paths[realpath] = all_links_here st = os_stat(path) else: realpath = path st = lstat
def _checkPathForChanges( oldStatCache, statCache, oldDirCache, dirCache, checked_locations, path, recursive, depth=0, linked_paths=None ): # print "_checkPathForChanges: %s" % (path) # We use realpath to ensure we don't do a second stat or listdir for the same # path. changes = {} modified = False oldFileStat = None try: try: lstat = os_lstat(path) except Exception, e: log.debug("polling _checkPathForChanges unable to lstat [%r] - %s", path, e) raise # if S_ISLNK(lstat.st_mode): if (lstat.st_mode & 0170000) == S_IFLNK: # Taken from stat module realpath = os_path_realpath(path) # linked_paths is used to ensure we don't go in a cyclic loop for symlinks if not linked_paths: linked_paths = {} if path != realpath: # It's a link # log.debug("Link: %s to %s", path, realpath) all_links_here = linked_paths.get(realpath, []) # We do not support cyclical paths, check if any have been found for linkpath in all_links_here: if len(path) >= len(linkpath): largerpath = path smallerpath = linkpath else: largerpath = linkpath smallerpath = path if largerpath.find(smallerpath) == 0: # print "Found cyclical path: %s to %s" % (path, realpath) # log.info("Found cyclical symlink path: %s to %s", path, realpath) return {} # It's okay, but we add this link to the known symlink list all_links_here.append(path) linked_paths[realpath] = all_links_here st = os_stat(path) else: realpath = path st = lstat
def load_bit_by_bit(self): """An iterator that loads a part on every next() call Returns a generator which load a part of the directory in each iteration. """ self.loading = True self.percent = 0 self.load_if_outdated() basename_is_rel_to = self.path if self.flat else None try: # pylint: disable=too-many-nested-blocks if self.runnable: yield mypath = self.path self.mount_path = mount_path(mypath) def ignore_files(): directory = expanduser("~") files = [] for filename in os.listdir(directory): if filename.startswith( "ranger_") and filename.endswith(".txt"): with open(os.path.join(directory, filename), 'r') as f: files += f.read().strip().split("\n") return list(set(files)) if self.flat: filelist = [] for dirpath, dirnames, filenames in walklevel( mypath, self.flat): dirlist = [ os.path.join("/", dirpath, d) for d in dirnames if self.flat == -1 or (dirpath.count(os.path.sep) - mypath.count(os.path.sep)) <= self.flat ] filelist += dirlist filelist += [ os.path.join("/", dirpath, f) for f in filenames ] filenames = filelist filenames = [ f for f in filenames if not f in ignore_files() ] self.load_content_mtime = mtimelevel(mypath, self.flat) else: filelist = os.listdir(mypath) filenames = [ mypath + (mypath == '/' and fname or '/' + fname) for fname in filelist ] filenames = [ f for f in filenames if not f in ignore_files() ] self.load_content_mtime = os.stat(mypath).st_mtime if self.cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". if self.content_loaded: if self.fm.settings.autoupdate_cumulative_size: self.look_up_cumulative_size() else: self.infostring = ' %s' % human_readable( self.size, separator='? ') else: self.infostring = ' %s' % human_readable(self.size) else: self.size = len(filelist) self.infostring = ' %d' % self.size if self.is_link: self.infostring = '->' + self.infostring yield marked_paths = [obj.path for obj in self.marked_items] files = [] disk_usage = 0 has_vcschild = False 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 except OSError: file_lstat = None file_stat = None if file_lstat and file_stat: stats = (file_stat, file_lstat) is_a_dir = file_stat.st_mode & 0o170000 == 0o040000 else: stats = None is_a_dir = False if is_a_dir: item = self.fm.get_directory( name, preload=stats, path_is_abs=True, basename_is_rel_to=basename_is_rel_to) item.load_if_outdated() if self.flat: item.relative_path = os.path.relpath( item.path, self.path) else: item.relative_path = item.basename item.relative_path_lower = item.relative_path.lower() if item.vcs and item.vcs.track: if item.vcs.is_root_pointer: has_vcschild = True else: item.vcsstatus = \ item.vcs.rootvcs.status_subpath( # pylint: disable=no-member os.path.join(self.realpath, item.basename), is_directory=True, ) else: item = File(name, preload=stats, path_is_abs=True, basename_is_rel_to=basename_is_rel_to) item.load() disk_usage += item.size if self.vcs and self.vcs.track: item.vcsstatus = \ self.vcs.rootvcs.status_subpath( # pylint: disable=no-member os.path.join(self.realpath, item.basename)) files.append(item) self.percent = 100 * len(files) // len(filenames) yield self.has_vcschild = has_vcschild self.disk_usage = disk_usage self.filenames = filenames self.files_all = files self._clear_marked_items() for item in self.files_all: if item.path in marked_paths: item.mark_set(True) self.marked_items.append(item) else: item.mark_set(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_all = None self.files = None self.cycle_list = None self.content_loaded = True self.last_update_time = time() self.correct_pointer() finally: self.loading = False self.fm.signal_emit("finished_loading_dir", directory=self) if self.vcs: self.fm.ui.vcsthread.process(self)
def load_bit_by_bit(self): """An iterator that loads a part on every next() call Returns a generator which load a part of the directory in each iteration. """ self.loading = True self.percent = 0 self.load_if_outdated() basename_is_rel_to = self.path if self.flat else None try: if self.runnable: yield mypath = self.path self.mount_path = mount_path(mypath) if self.flat: filelist = [] for dirpath, dirnames, filenames in walklevel( mypath, self.flat): dirlist = [ os.path.join("/", dirpath, d) for d in dirnames if self.flat == -1 or dirpath.count(os.path.sep) - mypath.count(os.path.sep) <= self.flat ] filelist += dirlist filelist += [ os.path.join("/", dirpath, f) for f in filenames ] filenames = filelist self.load_content_mtime = mtimelevel(mypath, self.flat) else: filelist = os.listdir(mypath) filenames = [ mypath + (mypath == '/' and fname or '/' + fname) for fname in filelist ] self.load_content_mtime = os.stat(mypath).st_mtime if self._cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". if self.content_loaded: if self.fm.settings.autoupdate_cumulative_size: self.look_up_cumulative_size() else: self.infostring = ' %s' % human_readable( self.size, separator='? ') else: self.infostring = ' %s' % human_readable(self.size) else: self.size = len(filelist) self.infostring = ' %d' % self.size if self.is_link: self.infostring = '->' + self.infostring yield marked_paths = [obj.path for obj in self.marked_items] files = [] disk_usage = 0 if self.settings.vcs_aware: self.has_vcschild = False self.load_vcs(None) 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: if self.flat: item = Directory( name, preload=stats, path_is_abs=True, basename_is_rel_to=basename_is_rel_to) item.load() else: try: item = self.fm.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, basename_is_rel_to=basename_is_rel_to) item.load() disk_usage += item.size # Load vcs data if self.settings.vcs_aware: item.load_vcs(self) if item.vcs_enabled: self.has_vcschild = True files.append(item) self.percent = 100 * len(files) // len(filenames) yield self.disk_usage = disk_usage self.vcs_outdated = False self.filenames = filenames self.files_all = files self._clear_marked_items() for item in self.files_all: 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_all = None self.files = None self.cycle_list = None self.content_loaded = True self.last_update_time = time() self.correct_pointer() finally: self.loading = False self.fm.signal_emit("finished_loading_dir", directory=self)
def load_bit_by_bit(self): """An iterator that loads a part on every next() call Returns a generator which load a part of the directory in each iteration. """ self.loading = True self.percent = 0 self.load_if_outdated() basename_is_rel_to = self.path if self.flat else None try: # pylint: disable=too-many-nested-blocks if self.runnable: yield mypath = self.path self.mount_path = mount_path(mypath) if self.flat: filelist = [] for dirpath, dirnames, filenames in walklevel(mypath, self.flat): dirlist = [ os.path.join("/", dirpath, d) for d in dirnames if self.flat == -1 or (dirpath.count(os.path.sep) - mypath.count(os.path.sep)) <= self.flat ] filelist += dirlist filelist += [os.path.join("/", dirpath, f) for f in filenames] filenames = filelist self.load_content_mtime = mtimelevel(mypath, self.flat) else: filelist = os.listdir(mypath) filenames = [mypath + (mypath == '/' and fname or '/' + fname) for fname in filelist] self.load_content_mtime = os.stat(mypath).st_mtime if self.cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". if self.content_loaded: if self.fm.settings.autoupdate_cumulative_size: self.look_up_cumulative_size() else: self.infostring = ' %s' % human_readable( self.size, separator='? ') else: self.infostring = ' %s' % human_readable(self.size) else: self.size = len(filelist) self.infostring = ' %d' % self.size if self.is_link: self.infostring = '->' + self.infostring yield marked_paths = [obj.path for obj in self.marked_items] files = [] disk_usage = 0 has_vcschild = False 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 except OSError: file_lstat = None file_stat = None if file_lstat and file_stat: stats = (file_stat, file_lstat) is_a_dir = file_stat.st_mode & 0o170000 == 0o040000 else: stats = None is_a_dir = False if is_a_dir: item = self.fm.get_directory(name, preload=stats, path_is_abs=True, basename_is_rel_to=basename_is_rel_to) item.load_if_outdated() if self.flat: item.relative_path = os.path.relpath(item.path, self.path) else: item.relative_path = item.basename item.relative_path_lower = item.relative_path.lower() if item.vcs and item.vcs.track: if item.vcs.is_root_pointer: has_vcschild = True else: item.vcsstatus = \ item.vcs.rootvcs.status_subpath( # pylint: disable=no-member os.path.join(self.realpath, item.basename), is_directory=True, ) else: item = File(name, preload=stats, path_is_abs=True, basename_is_rel_to=basename_is_rel_to) item.load() disk_usage += item.size if self.vcs and self.vcs.track: item.vcsstatus = \ self.vcs.rootvcs.status_subpath( # pylint: disable=no-member os.path.join(self.realpath, item.basename)) files.append(item) self.percent = 100 * len(files) // len(filenames) yield self.has_vcschild = has_vcschild self.disk_usage = disk_usage self.filenames = filenames self.files_all = files self._clear_marked_items() for item in self.files_all: if item.path in marked_paths: item.mark_set(True) self.marked_items.append(item) else: item.mark_set(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_all = None self.files = None self.cycle_list = None self.content_loaded = True self.last_update_time = time() self.correct_pointer() finally: self.loading = False self.fm.signal_emit("finished_loading_dir", directory=self) if self.vcs: self.fm.ui.vcsthread.process(self)
def load_bit_by_bit(self): """ 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, 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
def load_bit_by_bit(self): """An iterator that loads a part on every next() call Returns a generator which load a part of the directory in each iteration. """ self.loading = True self.percent = 0 self.load_if_outdated() try: if self.runnable: yield mypath = self.path self.mount_path = mount_path(mypath) filelist = os.listdir(mypath) if self._cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". if self.content_loaded: if self.fm.settings.autoupdate_cumulative_size: self.look_up_cumulative_size() else: self.infostring = ' %s' % human_readable( self.size, separator='? ') else: self.infostring = ' %s' % human_readable(self.size) else: self.size = len(filelist) self.infostring = ' %d' % self.size if self.is_link: self.infostring = '->' + self.infostring filenames = [mypath + (mypath == '/' and fname or '/' + fname) for fname in filelist] yield self.load_content_mtime = os.stat(mypath).st_mtime marked_paths = [obj.path for obj in self.marked_items] files = [] disk_usage = 0 if self.settings.vcs_aware: self.has_vcschild = False self.load_vcs(None) 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.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 # Load vcs data if self.settings.vcs_aware: item.load_vcs(self) if item.vcs_enabled: self.has_vcschild = True files.append(item) self.percent = 100 * len(files) // len(filenames) yield self.disk_usage = disk_usage self.vcs_outdated = False self.filenames = filenames self.files_all = files self._clear_marked_items() for item in self.files_all: 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_all = None self.files = None self.cycle_list = None self.content_loaded = True self.last_update_time = time() self.correct_pointer() finally: self.loading = False self.fm.signal_emit("finished_loading_dir", directory=self)
def load_bit_by_bit(self): """ 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
def load_bit_by_bit(self): """ Returns a generator which load a part of the directory in each iteration. """ self.loading = True self.percent = 0 self.load_if_outdated() try: if self.runnable: yield mypath = self.path self.mount_path = mount_path(mypath) if not self.settings.show_hidden and self.settings.hidden_filter: # COMPAT # hidden_filter used to be a regex, not a string. If an # old config is used, we don't need to re.compile it. if hasattr(self.settings.hidden_filter, 'search'): hidden_filter = self.settings.hidden_filter else: hidden_filter = re.compile(self.settings.hidden_filter) else: hidden_filter = None filelist = os.listdir(mypath) if self._cumulative_size_calculated: # If self.content_loaded is true, this is not the first # time loading. So I can't really be sure if the # size has changed and I'll add a "?". if self.content_loaded: if self.fm.settings.autoupdate_cumulative_size: self.look_up_cumulative_size() else: self.infostring = ' %s' % human_readable( self.size, separator='? ') else: self.infostring = ' %s' % human_readable(self.size) else: self.size = len(filelist) self.infostring = ' %d' % self.size if self.is_link: self.infostring = '->' + self.infostring filenames = [mypath + (mypath == '/' and fname or '/' + fname)\ for fname in filelist 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.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) self.percent = 100 * len(files) // len(filenames) 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 self.fm.signal_emit("finished_loading_dir", directory=self)
def changeDirectory(self, directory, select=None): self.list = [] # if we are just entering from the list of mount points: if self.current_directory is None: if directory and self.showMountpoints: self.current_mountpoint = self.getMountpointLink(directory) else: self.current_mountpoint = None self.current_directory = directory directories = [] files = [] if directory is None and self.showMountpoints: # present available mountpoints for p in harddiskmanager.getMountedPartitions(): path = os_path.join(p.mountpoint, "") if path not in self.inhibitMounts and not self.inParentDirs( path, self.inhibitDirs): self.list.append( (p.description, path, None, True, False, None)) files = [] directories = [] elif directory is None: files = [] directories = [] else: if os_path.exists(directory): try: files = listdir(directory) except: files = [] files.sort() tmpfiles = files[:] for x in tmpfiles: if os_path.isdir(directory + x): directories.append(directory + x + "/") files.remove(x) if directory is not None and self.showDirectories and not self.isTop: if directory == self.current_mountpoint and self.showMountpoints: self.list.append(("<%s>" % (_("List of Storage Devices")), None, None, True, False, None)) elif (directory != "/") and not (self.inhibitMounts and self.getMountpoint(directory) in self.inhibitMounts): self.list.append(("<%s>" % (_("Parent Directory")), '/'.join(directory.split('/')[:-2]) + '/', None, True, False, None)) if self.showDirectories: for x in directories: if not (self.inhibitMounts and self.getMountpoint(x) in self.inhibitMounts) and not self.inParentDirs( x, self.inhibitDirs): name = x.split('/')[-2] self.list.append((name, x, None, True, False, None)) if self.showFiles: for x in files: path = directory + x name = x if (self.matchingPattern is None) or re_compile( self.matchingPattern).search(path): nx = None if (config.plugins.DreamExplorer.useMediaFilter.value == "on"): nx = self.getTSInfo(path) if nx is not None: name = nx extension = None extensionPos = name.rfind('.') if extensionPos != -1: extension = name[extensionPos + 1:].lower() mediaType = EXTENSIONS.get(extension) if nx is None: fileInfo = os_lstat(path) lastModified = strftime("%d.%m.%Y %H:%M:%S", localtime(fileInfo.st_mtime)) self.list.append( (name, directory, path, False, False, mediaType)) else: extname = name + " [" + self.getTSLength(path) + "]" self.list.append( (extname, directory, path, False, True, mediaType)) # let's sort the list to retain the last selection after directory change self.sortList() self.l.setList(self.list) if select is not None: i = 0 self.moveToIndex(0) for x in self.list: p = x[1] if isinstance(p, eServiceReference): p = p.getPath() if p == select: self.moveToIndex(i) break i += 1