Python Virtual File System: A spike test
Mike C. Fletcher
mcfletch at rogers.com
Wed Jun 12 05:06:47 EDT 2002
Purpose:
A class for representing file system paths which supports both
method-based operations, and abstraction through object encapsulation to
eventually allow for Virtual File System operations (for instance,
transparently accessing the contents of zip files).
Status:
An initial implementation (spike test) exploring the viability of the
approach. Implementation provides:
equality testing
parent/child/ancestor/descendent retrieval/testing
filesystem-role testing (file/dir/root)
root retrieval and root comparisons
"walking" (callback-based recursive iteration)
listing (returning Paths which include their parent directory)
fragment determination (i.e. c:\\temp\\test -> "c:\\", "temp", "test"
recursive directory-tree removal (including files)
open( ) method for path specifiers
The current implementation is a sub-class of str which provides a number
of new methods (and overrides some built-in methods) to provide the
above functionality.
Future:
If there is interest, I am planning on creating a new SourceForge
project with the eventual goal of creating a virtual file system package
with a consistent interface to most of the major file-and-directory
systems (zip files, FTP sites, local file systems) and hooks for adding
new systems.
Of course, it would be considerably better for such a project if the
standard library returned Path objects, rather than simple strings, but
I'm not particularly interested in trying to get the project accepted
into the core at the moment (after all, this is just a test).
Request:
If you're interested in working on such a project (or even using it),
let me know, so I can decide whether to devote any more resources to it.
You can find the module here:
http://members.rogers.com/mcfletch/programming/filepath.py
Enjoy yourselves,
Mike
_______________________________________
Mike C. Fletcher
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list