Mercurial > libpst
comparison python/test.py @ 299:1ddc61fd6189
fix pst_binary in python interface
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Sun, 14 Aug 2011 19:58:47 -0700 |
parents | 268458c79e9b |
children |
comparison
equal
deleted
inserted
replaced
298:201464dd356e | 299:1ddc61fd6189 |
---|---|
5 ft.dwHighDateTime = 1 | 5 ft.dwHighDateTime = 1 |
6 | 6 |
7 | 7 |
8 for i in range(1,len(sys.argv)): | 8 for i in range(1,len(sys.argv)): |
9 print "try file %s" % (sys.argv[i]) | 9 print "try file %s" % (sys.argv[i]) |
10 pst = _libpst.pst(sys.argv[i]) | 10 pst = _libpst.pst(sys.argv[i], "") |
11 topf = pst.pst_getTopOfFolders() | 11 topf = pst.pst_getTopOfFolders() |
12 | 12 |
13 print pst.pst_rfc2425_datetime_format(ft) | 13 print pst.pst_rfc2425_datetime_format(ft) |
14 print pst.pst_rfc2445_datetime_format(ft) | 14 print pst.pst_rfc2445_datetime_format(ft) |
15 | 15 |
25 if (ft): | 25 if (ft): |
26 print "message arrived at %s" % (pst.pst_rfc2425_datetime_format(ft)) | 26 print "message arrived at %s" % (pst.pst_rfc2425_datetime_format(ft)) |
27 if (em.messageid.str): | 27 if (em.messageid.str): |
28 print "message id is <%s>" % (em.messageid.str) | 28 print "message id is <%s>" % (em.messageid.str) |
29 subj = item.subject; | 29 subj = item.subject; |
30 rtf = em.rtf_compressed; | |
31 if rtf and (len(rtf) > 0): print "rtf compressed size", len(rtf) | |
30 if (subj and subj.str): | 32 if (subj and subj.str): |
31 was = subj.is_utf8; | 33 was = subj.is_utf8; |
32 pst.pst_convert_utf8(item, subj) | 34 pst.pst_convert_utf8(item, subj) |
33 now = subj.is_utf8; | 35 now = subj.is_utf8; |
34 if (was != now): | 36 if (was != now): |
36 print "subject is %s" % (subj.str) | 38 print "subject is %s" % (subj.str) |
37 body = item.body | 39 body = item.body |
38 #if (body.str): | 40 #if (body.str): |
39 # print "message body is %s" % (body.str) | 41 # print "message body is %s" % (body.str) |
40 att = item.attach | 42 att = item.attach |
43 att = None | |
41 while (att): | 44 while (att): |
42 attid = att.i_id | 45 attid = att.i_id |
43 print "attachment id %d" % (attid) | 46 att1 = att.filename1 |
44 att1 = att.filename1 | 47 att2 = att.filename2 |
45 att2 = att.filename2 | 48 print "attachment id %d file name short '%s' long '%s'" % (attid, att1.str, att2.str) |
46 print "attachment file name short '%s' long '%s'" % (att1.str, att2.str) | 49 if (1): |
47 if (0): | |
48 attdata = pst.pst_attach_to_mem(att) | 50 attdata = pst.pst_attach_to_mem(att) |
49 if (attdata): | 51 if (attdata): |
50 print "data size %d" % (len(attdata)) | 52 print "data size %d" % (len(attdata)) |
51 if (0): | 53 if (0): |
52 f = pst.ppst_open_file(att2.str, 'w') | 54 f = pst.ppst_open_file(att2.str, 'w') |
53 if (f): | 55 if (f): |
54 si = pst.pst_attach_to_file_base64(att, f) | 56 si = pst.pst_attach_to_file_base64(att, f) |
55 pst.ppst_close_file(f) | 57 pst.ppst_close_file(f) |
56 print "wrote %d bytes in %s" % (si, att2.str) | 58 print "wrote %d bytes in %s" % (si, att2.str) |
57 if (1): | 59 if (0): |
58 f = pst.ppst_open_file(att2.str, 'w') | 60 f = pst.ppst_open_file(att2.str, 'w') |
59 if (f): | 61 if (f): |
60 si = pst.pst_attach_to_file(att, f) | 62 si = pst.pst_attach_to_file(att, f) |
61 pst.ppst_close_file(f) | 63 pst.ppst_close_file(f) |
62 print "wrote %d bytes in %s" % (si, att2.str) | 64 print "wrote %d bytes in %s" % (si, att2.str) |