Movatterモバイル変換


[0]ホーム

URL:


Up one LevelPython Library ReferenceContentsModule IndexIndex

11.11dircache -- Cached directory listings

Thedircache module defines a function for reading directory listingusing a cache, and cache invalidation using themtime of the directory.Additionally, it defines a function to annotate directories by appendinga slash.

Thedircache module defines the following functions:

reset()
Resets the directory cache.

listdir(path)
Return a directory listing ofpath, as gotten fromos.listdir(). Note that unlesspath changes, further calltolistdir() will not re-read the directory structure.

Note that the list returned should be regarded as read-only. (Perhapsa future version should change it to return a tuple?)

opendir(path)
Same aslistdir(). Defined for backwards compatibility.

annotate(head, list)
Assumelist is a list of paths relative tohead, and append,in place, a "/" to each path which points to a directory.

>>> import dircache>>> a = dircache.listdir('/')>>> a = a[:] # Copy the return value so we can change 'a'>>> a['bin', 'boot', 'cdrom', 'dev', 'etc', 'floppy', 'home', 'initrd', 'lib', 'lost+found', 'mnt', 'proc', 'root', 'sbin', 'tmp', 'usr', 'var', 'vmlinuz']>>> dircache.annotate('/', a)>>> a['bin/', 'boot/', 'cdrom/', 'dev/', 'etc/', 'floppy/', 'home/', 'initrd/', 'lib/', 'lost+found/', 'mnt/', 'proc/', 'root/', 'sbin/', 'tmp/', 'usr/', 'var/', 'vmlinuz']


Up one LevelPython Library ReferenceContentsModule IndexIndex

Release 2.5.2, documentation updated on 21st February, 2008.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2025 Movatter.jp