Skip to content

Development

joachimmetz edited this page Oct 2, 2014 · 3 revisions

Python development

Get version

import pypff

pypff.get_version()

Open file

import pypff

pff_file = pypff.file()

pff_file.open("Archive.pst")

pff_file.close()

Note that the explicit call to close is not required.

Open file using a file-like object

import pypff

file_object = open("Archive.pst", "rb")

pff_file = pypff.file()

pff_file.open_file_object(file_object)

pff_file.close()

Note that the explicit call to close is not required.

Items

A pypff.item is the base object for the different kind of items stored in the PFF file.

Get number of items

The number of items can be retrieved by either calling the get_number_of_items() function, e.g.

number_of_items = pff_file.get_number_of_items()

or reading the number_of_items property:

number_of_items = pff_file.number_of_items

The number of recovered items can be obtained by calling the function pff_file.get_number_of_recovered_items() or reading the property pff_file.number_of_recovered_items.

Get an item by index

An item can be retrieved by index:

pff_item = pff_file.get_item(0)

The function will return the most specific item object type. This will either be pypff.item, pypff.folder, pypff.message. Where pypff.item is the base type for the other types.

A recovered item can be retrieved in the same way by using the function pff_file.get_recovered_item().

Iterating over all items

for pff_item in pff_file.items:
    if isinstance(pff_item, pypff.url):
        print pff_item.location

The recovered items can iterated by reading the property pff_file.recovered_items.

Also see

import pypff

help(pypff)
help(pypff.file)
help(pypff.item)
help(pypff.folder)
help(pypff.message)
Clone this wiki locally