[Spambayes-checkins] spambayes/Outlook2000/sandbox dump_props.py,
1.7, 1.8
Mark Hammond
mhammond at users.sourceforge.net
Wed Jul 23 00:12:24 EDT 2003
Update of /cvsroot/spambayes/spambayes/Outlook2000/sandbox
In directory sc8-pr-cvs1:/tmp/cvs-serv31825
Modified Files:
dump_props.py
Log Message:
Allow '-l' to fetch huge properties (just to prove we could)
Index: dump_props.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/sandbox/dump_props.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** dump_props.py 23 Nov 2002 02:57:46 -0000 1.7
--- dump_props.py 23 Jul 2003 06:12:21 -0000 1.8
***************
*** 27,35 ****
else:
name = tag
! ret.append((name, val))
return ret
! def DumpItemProps(item, shorten):
! for prop_name, prop_val in GetAllProperties(item):
prop_repr = repr(prop_val)
if shorten:
--- 27,54 ----
else:
name = tag
! ret.append((name, tag, val))
return ret
! def GetLargeProperty(item, prop_tag):
! prop_tag = PROP_TAG(PT_BINARY, PROP_ID(prop_tag))
! stream = item.OpenProperty(prop_tag,
! pythoncom.IID_IStream,
! 0, 0)
! chunks = []
! while 1:
! chunk = stream.Read(4096)
! if not chunk:
! break
! chunks.append(chunk)
! return "".join(chunks)
!
! def DumpItemProps(item, shorten, get_large_props):
! for prop_name, prop_tag, prop_val in GetAllProperties(item):
! if get_large_props and \
! PROP_TYPE(prop_tag)==PT_ERROR and \
! prop_val in [mapi.MAPI_E_NOT_ENOUGH_MEMORY,'MAPI_E_NOT_ENOUGH_MEMORY']:
! # Use magic to get a large property.
! prop_val = GetLargeProperty(item, prop_tag)
!
prop_repr = repr(prop_val)
if shorten:
***************
*** 37,45 ****
print "%-20s: %s" % (prop_name, prop_repr)
! def DumpProps(driver, mapi_folder, subject, include_attach, shorten):
hr, data = mapi_folder.GetProps( (PR_DISPLAY_NAME_A,), 0)
name = data[0][1]
for item in driver.GetItemsWithValue(mapi_folder, PR_SUBJECT_A, subject):
! DumpItemProps(item, shorten)
if include_attach:
print
--- 56,64 ----
print "%-20s: %s" % (prop_name, prop_repr)
! def DumpProps(driver, mapi_folder, subject, include_attach, shorten, get_large):
hr, data = mapi_folder.GetProps( (PR_DISPLAY_NAME_A,), 0)
name = data[0][1]
for item in driver.GetItemsWithValue(mapi_folder, PR_SUBJECT_A, subject):
! DumpItemProps(item, shorten, get_large)
if include_attach:
print
***************
*** 50,54 ****
print "Dumping attachment (PR_ATTACH_NUM=%d)" % (attach_num,)
attach = item.OpenAttach(attach_num, None, mapi.MAPI_DEFERRED_ERRORS)
! DumpItemProps(attach, shorten)
def usage(driver):
--- 69,73 ----
print "Dumping attachment (PR_ATTACH_NUM=%d)" % (attach_num,)
attach = item.OpenAttach(attach_num, None, mapi.MAPI_DEFERRED_ERRORS)
! DumpItemProps(attach, shorten, get_large)
def usage(driver):
***************
*** 59,62 ****
--- 78,82 ----
-s - Shorten long property values.
-a - Include attachments
+ -l - Get the data for very large properties
-n - Show top-level folder names and exit
***************
*** 74,78 ****
import getopt
try:
! opts, args = getopt.getopt(sys.argv[1:], "af:sn")
except getopt.error, e:
print e
--- 94,98 ----
import getopt
try:
! opts, args = getopt.getopt(sys.argv[1:], "af:snl")
except getopt.error, e:
print e
***************
*** 83,86 ****
--- 103,107 ----
shorten = False
+ get_large_props = False
include_attach = False
for opt, opt_val in opts:
***************
*** 91,94 ****
--- 112,117 ----
elif opt == "-a":
include_attach = True
+ elif opt == "-l":
+ get_large_props = True
elif opt == "-n":
driver.DumpTopLevelFolders()
***************
*** 114,118 ****
sys.exit(1)
! DumpProps(driver, folder, subject, include_attach, shorten)
if __name__=='__main__':
--- 137,141 ----
sys.exit(1)
! DumpProps(driver, folder, subject, include_attach, shorten, get_large_props)
if __name__=='__main__':
More information about the Spambayes-checkins
mailing list