Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: dircache.py
"""Read and cache directory listings.
[0] Fix | Delete
[1] Fix | Delete
The listdir() routine returns a sorted list of the files in a directory,
[2] Fix | Delete
using a cache to avoid reading the directory more often than necessary.
[3] Fix | Delete
The annotate() routine appends slashes to directories."""
[4] Fix | Delete
from warnings import warnpy3k
[5] Fix | Delete
warnpy3k("the dircache module has been removed in Python 3.0", stacklevel=2)
[6] Fix | Delete
del warnpy3k
[7] Fix | Delete
[8] Fix | Delete
import os
[9] Fix | Delete
[10] Fix | Delete
__all__ = ["listdir", "opendir", "annotate", "reset"]
[11] Fix | Delete
[12] Fix | Delete
cache = {}
[13] Fix | Delete
[14] Fix | Delete
def reset():
[15] Fix | Delete
"""Reset the cache completely."""
[16] Fix | Delete
global cache
[17] Fix | Delete
cache = {}
[18] Fix | Delete
[19] Fix | Delete
def listdir(path):
[20] Fix | Delete
"""List directory contents, using cache."""
[21] Fix | Delete
try:
[22] Fix | Delete
cached_mtime, list = cache[path]
[23] Fix | Delete
del cache[path]
[24] Fix | Delete
except KeyError:
[25] Fix | Delete
cached_mtime, list = -1, []
[26] Fix | Delete
mtime = os.stat(path).st_mtime
[27] Fix | Delete
if mtime != cached_mtime:
[28] Fix | Delete
list = os.listdir(path)
[29] Fix | Delete
list.sort()
[30] Fix | Delete
cache[path] = mtime, list
[31] Fix | Delete
return list
[32] Fix | Delete
[33] Fix | Delete
opendir = listdir # XXX backward compatibility
[34] Fix | Delete
[35] Fix | Delete
def annotate(head, list):
[36] Fix | Delete
"""Add '/' suffixes to directories."""
[37] Fix | Delete
for i in range(len(list)):
[38] Fix | Delete
if os.path.isdir(os.path.join(head, list[i])):
[39] Fix | Delete
list[i] = list[i] + '/'
[40] Fix | Delete
[41] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function