From c2587c76f1b416cdbecb979e54941933246bf856 Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Tue, 16 Feb 2021 20:14:16 -0600 Subject: starting over --- lib/dircache.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'lib/dircache.py') diff --git a/lib/dircache.py b/lib/dircache.py index c14db3e..b40f76e 100644 --- a/lib/dircache.py +++ b/lib/dircache.py @@ -10,27 +10,27 @@ import path cache = {} def listdir(path): # List directory contents, using cache - try: - cached_mtime, list = cache[path] - del cache[path] - except RuntimeError: - cached_mtime, list = -1, [] - try: - mtime = posix.stat(path)[8] - except posix.error: - return [] - if mtime <> cached_mtime: - try: - list = posix.listdir(path) - except posix.error: - return [] - list.sort() - cache[path] = mtime, list - return list + try: + cached_mtime, list = cache[path] + del cache[path] + except RuntimeError: + cached_mtime, list = -1, [] + try: + mtime = posix.stat(path)[8] + except posix.error: + return [] + if mtime <> cached_mtime: + try: + list = posix.listdir(path) + except posix.error: + return [] + list.sort() + cache[path] = mtime, list + return list opendir = listdir # XXX backward compatibility def annotate(head, list): # Add '/' suffixes to directories - for i in range(len(list)): - if path.isdir(path.cat(head, list[i])): - list[i] = list[i] + '/' + for i in range(len(list)): + if path.isdir(path.cat(head, list[i])): + list[i] = list[i] + '/' -- cgit v1.2.3