comparison python/test.py @ 195:320cfcba8058

add python module interface to the shared library for easy scripting. the shared library must never write to stdout or stderr. fix pst_attach_to_mem so the caller does not need to initialize the buffer pointer.
author Carl Byington <carl@five-ten-sg.com>
date Mon, 20 Apr 2009 19:39:26 -0700
parents
children ffd1503a7530
comparison
equal deleted inserted replaced
194:885b47107036 195:320cfcba8058
1 import _libpst, sys
2
3 for i in range(1,len(sys.argv)):
4 print "try file %s" % (sys.argv[i])
5 pst = _libpst.pst(sys.argv[i])
6 topf = pst.pst_getTopOfFolders()
7
8 while (topf):
9 #print "topf d_id is %d\n" % (topf.d_id)
10 item = pst.pst_parse_item(topf, None)
11 if (item):
12 if (item.type == 1):
13 em = item.email
14 if (em):
15 if (em.messageid.str):
16 print "message id is |%s|" % (em.messageid.str)
17 subj = item.subject;
18 if (subj.str):
19 print "subject is %s" % (subj.str)
20 body = item.body
21 #if (body.str):
22 # print "message body is %s" % (body.str)
23 att = item.attach
24 while (att):
25 attid = att.i_id
26 print "attachment id %d" % (attid)
27 att1 = att.filename1
28 att2 = att.filename2
29 print "attachment file name %s %s" % (att1.str, att2.str)
30 attdata = pst.pst_attach_to_mem(att)
31 if (attdata):
32 print "data size %d" % (len(attdata))
33 att = att.next
34 topf = pst.pst_getNextDptr(topf)
35 print "done"
36