[Spambayes-checkins] spambayes/scripts sb_filter.py,1.4,1.5
Skip Montanaro
montanaro at users.sourceforge.net
Wed Nov 12 09:34:52 EST 2003
Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv17926
Modified Files:
sb_filter.py
Log Message:
Allow multiple types of mailboxes to be processed using mboxutils.getmbox.
If any mailbox files are given on the command line, the output is always a
Unix-style mailbox containing From_ lines.
Index: sb_filter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_filter.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sb_filter.py 15 Oct 2003 05:02:08 -0000 1.4
--- sb_filter.py 12 Nov 2003 14:34:50 -0000 1.5
***************
*** 15,21 ****
##
! """Usage: %(program)s [OPTION]...
! [OPTION] is one of:
-h
show usage and exit
--- 15,21 ----
##
! """Usage: %(program)s [options] [filenames]
! Options can one or more of:
-h
show usage and exit
***************
*** 46,49 ****
--- 46,73 ----
All options marked with '*' operate on stdin. Only those processing options
marked with '+' send a modified message to stdout.
+
+ If no filenames are given on the command line, standard input will be
+ processed as a single message. If one or more filenames are given on the
+ command line, each will be processed according to the following rules:
+
+ * If the filename is '-', standard input will be processed as a single
+ message (may only be usefully given once).
+
+ * If the filename starts with '+' it will be processed as an MH folder.
+
+ * If the filename is a directory and it contains a subdirectory named
+ 'cur', it will be processed as a Maildir.
+
+ * If the filename is a directory and it contains a subdirectory named
+ 'Mail', it will be processed as an MH Mailbox.
+
+ * If the filename is a directory and not a Maildir nor an MH Mailbox, it
+ will be processed as a Mailbox directory consisting of just .txt and
+ .lorien files.
+
+ * Otherwise, the filename is treated as a Unix-style mailbox (messages
+ begin on a line starting with 'From ').
+
+ Output is always to standard output as a Unix-style mailbox.
"""
***************
*** 195,202 ****
actions = [h.filter]
! msg = mboxutils.get_message(sys.stdin)
! for action in actions:
! action(msg)
! sys.stdout.write(msg.as_string(unixfrom=(msg.get_unixfrom() is not None)))
if __name__ == "__main__":
--- 219,234 ----
actions = [h.filter]
! if not args:
! args = ["-"]
! for fname in args:
! mbox = mboxutils.getmbox(fname)
! for msg in mbox:
! for action in actions:
! action(msg)
! if args == ["-"]:
! unixfrom = msg.get_unixfrom() is not None
! else:
! unixfrom = True
! sys.stdout.write(msg.as_string(unixfrom=unixfrom))
if __name__ == "__main__":
More information about the Spambayes-checkins
mailing list