Package corebio :: Package utils :: Class FileIndex
[frames | no frames]

Type FileIndex

object --+
         |
        FileIndex

Known Subclasses:
Raf

Line based random access to a file. Quickly turn a file into a read-only
database.

Attr:
- indexfile -- The file to be indexed. Can be set to None and latter
            replaced with a new file handle, for exampel, if you need to
            close and latter reopen the file. 

Bugs:
    User must set the indexedfile to None before pickling this class.

Method Summary
  __init__(self, indexedfile, linekey, parser)
Args: - indexedfile -- The file to index - linekey -- An optional function.
  __contains__(self, item)
  __getitem__(self, item)
  __iter__(self)
  __len__(self)
  seek(self, item)
Seek the indexfile to the position of item.
  tell(self, item)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name...
  __getattribute__(...)
x.__getattribute__('name') <==> x.name...
  __hash__(x)
x.__hash__() <==> hash(x)...
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle...
  __reduce_ex__(...)
helper for pickle...
  __repr__(x)
x.__repr__() <==> repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value...
  __str__(x)
x.__str__() <==> str(x)...

Class Variable Summary
list __slots__ = ['indexedfile', '_parser', '_positions', '_k...
member_descriptor indexedfile = <member 'indexedfile' of 'FileIndex' objec...

Method Details

__init__(self, indexedfile, linekey=None, parser=None)
(Constructor)

Args:
- indexedfile -- The file to index
- linekey -- An optional function. keyofline() will be passed each line
    of the file in turn and should return a string to index the line, 
    or None. If keyofline() is supplied, then only lines that generate  
    keys are indexed.
- parser -- An optional parser. A function that reads from a file handle
    positioned at the start of a record and returns an object.
Overrides:
__builtin__.object.__init__

seek(self, item)

Seek the indexfile to the position of item.

Class Variable Details

__slots__

Type:
list
Value:
['indexedfile', '_parser', '_positions', '_keys', '_key_dict']         

indexedfile

Type:
member_descriptor
Value:
<member 'indexedfile' of 'FileIndex' objects>                          

Generated by Epydoc 2.1 on http://epydoc.sf.net