import HTMLutil
class Directory(UserList) def __cmp__(self, item) def __init__(self, name='root', data=None) string __module__ = 'HTMLutil' def add_object(self, pathlist, object) def ls(self, pad='') def tree(self) # Methods inherited by Directory from UserList def __add__(self, list) def __delitem__(self, i) def __delslice__(self, i, j) def __getitem__(self, i) def __getslice__(self, i, j) def __len__(self) def __mul__(self, n) def __mul__(self, n) def __radd__(self, list) def __repr__(self) def __setitem__(self, i, item) def __setslice__(self, i, j, list) def append(self, item) def count(self, item) def index(self, item) def insert(self, i, item) def pop(self, i=-1) def remove(self, item) def reverse(self) def sort(self, *args)
Instances of this class can be populated with objects at the end of a path list. The path list is a list of strings representing directory names leading to the target value. The data structure can be emitted in a format condusive to processing by HTMLgen.List and friends.
Add a new object into the directory structure.
*pathlist* is a list of strings to be used as directory names leading to the object. If a subdirectory name does not exist one will be created automatically.
*object* can be any python object.
Print an indented representation of the entire directory contents.
Return the Directory object as a list of items and nested lists, aka tree, suitable for use in a HTMLgen.List class.
D = Directory() D.add_object(['path','to','directory'], object) [would be analogous to creating a file "/path/to/directory/object"] ... repeated for any number of objects ... LoL = D.tree() html_list = HTMLgen.List(LoL)
Unlike a file system which requires that a directory to exist before a file can be added; Directory will automatically create new directories in the path as needed.
Copyright © 1996-9 Robin Friedrich
All Rights Reserved
Comments to author: friedrich@pythonpros.com
Generated: Tue Apr 20, 1999