Package picasa3meta :: Module thumbindex :: Class ThumbIndex
[hide private]
[frames] | no frames]

Class ThumbIndex

source code

object --+
         |
        ThumbIndex


Read the Picasa3 thumbindex.db file, verify the magic byte and save 
all entries into the name[] and pathIndex[] lists
        
If a files has been removed from Picasa3 that thumbindex entry will not be 
reused.  Requesting that entry will return a null file/path name.  

Requesting the index of a file that does not exist (or has been deleted)
will return -1 (0xffffffff)

usage: 
        from picasa3meta import thumbindex
        
        db = thumbindex.ThumbIndex("/path/to/Picasa3/db3/thumbindex.db")

        # find index of image.jpg data in Picasa3 imagedata_xxx.pmp files
        pmpIndex = db.indexOfFile("/full/path/to/Picasa3/image.jpg")

        # find the basename of the image file at pmpIndex
        imageName = db.imageName(pmpIndex)

        # find the path of the image file at pmpIndex
        imagePath = db.imagePath(pmpIndex)

        # return the full path/file name of the image file at pmpIndex
        imageFullName = db.imageFullName(pmpIndex)

        # assuming pmp is a pmpinfo object for the imagedata table, retrieve
        # the database entry for a file
        index = db.indexOfFile("/full/path/to/file.jpg")
        for col, val in pmp.getEntry(index):
                print "column %s is %s"%(col,val)

The thumbindex.db file format is:

        |magic byte |# entries  |null terminated path/file |    
        |40 46 66 66|xx xx xx xx|ascii ................. 00|    

        |26 bytes unknown                                  |
        |xx xx xx xx xx xx ............................. xx|    

        |index      |repeat from 'null terminated path/file' above ...
        |xx xx xx xx|   

        The index is the index into the array for the entry of the parent 
        directory of the file, or 0xffffffff if this entry is a directory.

        If the file path/filename length is 0 then this file or path has been 
        deleted.        Just set the index to 0xffffffff so that it is ignored.

Instance Methods [hide private]
 
__init__(self, thumbindex)
Open file "thumbindex", verify the magic byte (0x40466666), and then read all entries into name[], pathIndex[] arrays.
source code
 
indexOfFile(self, findMe)
Find the index into the imagedata_xxx.pmp files for an image file.
source code
 
imagePath(self, what)
Find the path of the file at entry 'what'.
source code
 
imageName(self, what)
Find the basename of the file at entry 'what'.
source code
 
imageFullName(self, what)
Find the full path name of the file/directory at entry 'what'.
source code
 
dump(self, what)
diagnostic dump of the entry at 'what'
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, thumbindex)
(Constructor)

source code 

Open file "thumbindex", verify the magic byte (0x40466666), and then read all entries into name[], pathIndex[] arrays.

Overrides: object.__init__

indexOfFile(self, findMe)

source code 

Find the index into the imagedata_xxx.pmp files for an image file. Returns -1 if the image file is not found.

imagePath(self, what)

source code 

Find the path of the file at entry 'what'.

If entry 'what' is a directory itself or is an image that has been removed, just return an empty string. An exception will be thrown if you ask for an entry > number of entries in thumbindex.db (self.entries)

imageName(self, what)

source code 

Find the basename of the file at entry 'what'.

An exception will be thrown if you ask for an entry > number of entries in thumbindex.db (self.entries)

imageFullName(self, what)

source code 

Find the full path name of the file/directory at entry 'what'.

An exception will be thrown if you ask for an entry > number of entries in thumbindex.db (self.entries)