Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
dircache Namespace Reference

Functions

def reset
 
def listdir
 
def annotate
 

Variables

list __all__ = ["listdir", "opendir", "annotate", "reset"]
 
dictionary cache = {}
 
 opendir = listdir
 

Detailed Description

Read and cache directory listings.

The listdir() routine returns a sorted list of the files in a directory,
using a cache to avoid reading the directory more often than necessary.
The annotate() routine appends slashes to directories.

Function Documentation

def dircache.annotate (   head,
  list 
)
Add '/' suffixes to directories.

Definition at line 40 of file dircache.py.

40 
41 def annotate(head, list):
42  """Add '/' suffixes to directories."""
43  for i in range(len(list)):
44  if os.path.isdir(os.path.join(head, list[i])):
45  list[i] = list[i] + '/'
def dircache.listdir (   path)
List directory contents, using cache.

Definition at line 18 of file dircache.py.

18 
19 def listdir(path):
20  """List directory contents, using cache."""
21  try:
22  cached_mtime, list = cache[path]
23  del cache[path]
24  except KeyError:
25  cached_mtime, list = -1, []
26  try:
27  mtime = os.stat(path)[8]
28  except os.error:
29  return []
30  if mtime != cached_mtime:
31  try:
32  list = os.listdir(path)
33  except os.error:
34  return []
35  list.sort()
36  cache[path] = mtime, list
37  return list
def dircache.reset ( )
Reset the cache completely.

Definition at line 13 of file dircache.py.

13 
14 def reset():
15  """Reset the cache completely."""
16  global cache
17  cache = {}

Variable Documentation

list __all__ = ["listdir", "opendir", "annotate", "reset"]

Definition at line 9 of file dircache.py.

dictionary cache = {}

Definition at line 11 of file dircache.py.

opendir = listdir

Definition at line 38 of file dircache.py.