Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Static Private Attributes
Bio.Index._ShelveIndex Class Reference
Collaboration diagram for Bio.Index._ShelveIndex:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__

Public Attributes

 data

Static Private Attributes

int __version = 2
string __version_key = '__version'

Detailed Description

An index file wrapped around shelve.

Definition at line 22 of file Index.py.


Constructor & Destructor Documentation

def Bio.Index._ShelveIndex.__init__ (   self,
  indexname,
  truncate = None 
)

Definition at line 34 of file Index.py.

00034 
00035     def __init__(self, indexname, truncate=None):
00036         dict.__init__(self)
00037         try:
00038             if truncate:
00039                 # In python 1.52 and before, dumbdbm (under shelve)
00040                 # doesn't clear the old database.
00041                 files = [indexname + '.dir',
00042                          indexname + '.dat',
00043                          indexname + '.bak'
00044                          ]
00045                 for file in files:
00046                     if os.path.exists(file):
00047                         os.unlink(file)
00048                 raise Exception("open a new shelf")
00049             self.data = shelve.open(indexname, flag='r')
00050         except:
00051             # No database exists.
00052             self.data = shelve.open(indexname, flag='n')
00053             self.data[self.__version_key] = self.__version
00054         else:
00055             # Check to make sure the database is the correct version.
00056             version = self.data.get(self.__version_key, None)
00057             if version is None:
00058                 raise IOError("Unrecognized index format")
00059             elif version != self.__version:
00060                 raise IOError("Version %s doesn't match my version %s" \
00061                               % (version, self.__version))
            

Here is the caller graph for this function:

Definition at line 62 of file Index.py.

00062 
00063     def __del__(self):
00064         if self.__dict__.has_key('data'):
00065             self.data.close()


Member Data Documentation

int Bio.Index._ShelveIndex.__version = 2 [static, private]

Definition at line 31 of file Index.py.

string Bio.Index._ShelveIndex.__version_key = '__version' [static, private]

Definition at line 32 of file Index.py.

Definition at line 48 of file Index.py.


The documentation for this class was generated from the following file: