comparison python/test.py @ 196:ffd1503a7530

build proper python rpm subpackage
author Carl Byington <carl@five-ten-sg.com>
date Wed, 22 Apr 2009 13:52:18 -0700
parents 320cfcba8058
children 268458c79e9b
comparison
equal deleted inserted replaced
195:320cfcba8058 196:ffd1503a7530
1 import _libpst, sys 1 import _libpst, sys
2
3 print _libpst.__dict__
4 exit
5
6 ft = _libpst.FILETIME()
7 ft.dwLowDateTime = 0
8 ft.dwHighDateTime = 1
9
2 10
3 for i in range(1,len(sys.argv)): 11 for i in range(1,len(sys.argv)):
4 print "try file %s" % (sys.argv[i]) 12 print "try file %s" % (sys.argv[i])
5 pst = _libpst.pst(sys.argv[i]) 13 pst = _libpst.pst(sys.argv[i])
6 topf = pst.pst_getTopOfFolders() 14 topf = pst.pst_getTopOfFolders()
15
16 print pst.pst_rfc2425_datetime_format(ft)
17 print pst.pst_rfc2445_datetime_format(ft)
7 18
8 while (topf): 19 while (topf):
9 #print "topf d_id is %d\n" % (topf.d_id) 20 #print "topf d_id is %d\n" % (topf.d_id)
10 item = pst.pst_parse_item(topf, None) 21 item = pst.pst_parse_item(topf, None)
11 if (item): 22 if (item):
12 if (item.type == 1): 23 if (item.type == 1):
13 em = item.email 24 em = item.email
14 if (em): 25 if (em):
26 print "default charset %s" % (pst.pst_default_charset(item))
27 ft = em.arrival_date
28 if (ft):
29 print "message arrived at %s" % (pst.pst_rfc2425_datetime_format(ft))
15 if (em.messageid.str): 30 if (em.messageid.str):
16 print "message id is |%s|" % (em.messageid.str) 31 print "message id is |%s|" % (em.messageid.str)
17 subj = item.subject; 32 subj = item.subject;
18 if (subj.str): 33 if (subj and subj.str):
34 was = subj.is_utf8;
35 pst.pst_convert_utf8(item, subj)
36 now = subj.is_utf8;
37 if (was != now):
38 print "subject was converted to utf8"
19 print "subject is %s" % (subj.str) 39 print "subject is %s" % (subj.str)
20 body = item.body 40 body = item.body
21 #if (body.str): 41 #if (body.str):
22 # print "message body is %s" % (body.str) 42 # print "message body is %s" % (body.str)
23 att = item.attach 43 att = item.attach
25 attid = att.i_id 45 attid = att.i_id
26 print "attachment id %d" % (attid) 46 print "attachment id %d" % (attid)
27 att1 = att.filename1 47 att1 = att.filename1
28 att2 = att.filename2 48 att2 = att.filename2
29 print "attachment file name %s %s" % (att1.str, att2.str) 49 print "attachment file name %s %s" % (att1.str, att2.str)
30 attdata = pst.pst_attach_to_mem(att) 50 if (0):
31 if (attdata): 51 attdata = pst.pst_attach_to_mem(att)
32 print "data size %d" % (len(attdata)) 52 if (attdata):
53 print "data size %d" % (len(attdata))
54 if (0):
55 f = pst.ppst_open_file(att2.str, 'w')
56 if (f):
57 si = pst.pst_attach_to_file_base64(att, f)
58 pst.ppst_close_file(f)
59 print "wrote %d bytes in %s" % (si, att2.str)
60 if (1):
61 f = pst.ppst_open_file(att2.str, 'w')
62 if (f):
63 si = pst.pst_attach_to_file(att, f)
64 pst.ppst_close_file(f)
65 print "wrote %d bytes in %s" % (si, att2.str)
33 att = att.next 66 att = att.next
67 pst.pst_freeItem(item)
34 topf = pst.pst_getNextDptr(topf) 68 topf = pst.pst_getNextDptr(topf)
35 print "done" 69 print "done"
36 70