diff options
| author | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
|---|---|---|
| committer | Skip Montanaro <[email protected]> | 2021-02-16 20:14:16 -0600 |
| commit | c2587c76f1b416cdbecb979e54941933246bf856 (patch) | |
| tree | bb61ee9128075ce22af4eafa232f13c2e5a07896 /lib/dircache.py | |
| parent | d90761a005b24018ae237bf551515772a1de656f (diff) | |
| download | python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.tar.xz python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.zip | |
starting over
Diffstat (limited to 'lib/dircache.py')
| -rw-r--r-- | lib/dircache.py | 40 |
1 files changed, 20 insertions, 20 deletions
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] + '/' |
