1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-22 15:56:27 +00:00

Added new option --dont-mangle-from to turn off From_ mangling.

This commit is contained in:
Nikolaus Schulz 2006-10-12 21:14:04 +00:00
parent 6198341eef
commit b682b26398
3 changed files with 37 additions and 8 deletions

View file

@ -3,7 +3,7 @@
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
.\" Please send any bug reports, improvements, comments, patches,
.\" etc. to Steve Cheng <steve@ggi-project.org>.
.TH "ARCHIVEMAIL" "1" "29 September 2006" "SP" ""
.TH "ARCHIVEMAIL" "1" "12 October 2006" "SP" ""
.SH NAME
archivemail \- archive and compress your old email
@ -177,6 +177,13 @@ message has been read. \fBarchivemail\fR determines if a
been read by looking at the filename. If the filename contains an 'S' after
\fI:2,\fR then it assumes the message has been read.
.TP
\fB --dont-mangle-from\fR
Do not mangle lines in message bodies beginning with "From ". Since mail user
agents may interpret such lines as message separators, by default
\fBarchivemail\fR mangles them by prepending a '>' to these lines (that is,
the resulting mailbox is in \fBMBOXO\fR-format). See \fBmbox\fR(5) for more
information.
.TP
\fB --delete\fR
Delete rather than archive old mail. Use this option with caution!
.TP

View file

@ -157,6 +157,7 @@ class Options:
output_dir = None
pwfile = None
preserve_unread = 0
mangle_from = 1
quiet = 0
read_buffer_size = 8192
script_name = os.path.basename(sys.argv[0])
@ -179,7 +180,7 @@ class Options:
opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uv',
["date=", "days=", "delete", "dry-run", "help",
"include-flagged", "no-compress", "output-dir=",
"filter-append=", "pwfile=",
"filter-append=", "pwfile=", "dont-mangle-from",
"preserve-unread", "quiet", "size=", "suffix=",
"verbose", "version", "warn-duplicate"])
except getopt.error, msg:
@ -225,6 +226,8 @@ class Options:
self.min_size = string.atoi(a)
if o in ('-u', '--preserve-unread'):
self.preserve_unread = 1
if o == '--dont-mangle-from':
self.mangle_from = 0
if o in ('-v', '--verbose'):
self.verbose = 1
if o in ('-V', '--version'):
@ -337,14 +340,15 @@ class Mbox(mailbox.UnixMailbox):
assert(options.read_buffer_size > 0)
linebuf = ""
while 1:
chunk = msg.fp.read(options.read_buffer_size)
# Be careful not to break pattern matching
splitindex = chunk.rfind(os.linesep)
body = linebuf + chunk[:splitindex]
linebuf = chunk[splitindex:]
body = msg.fp.read(options.read_buffer_size)
if options.mangle_from:
# Be careful not to break pattern matching
splitindex = body.rfind(os.linesep)
nicebody = linebuf + body[:splitindex]
linebuf = body[splitindex:]
body = from_re.sub('>From ', nicebody)
if not body:
break
body = from_re.sub('>From ', body)
self.mbox_file.write(body)
self.mbox_file.write(os.linesep)
@ -610,6 +614,7 @@ Options are as follows:
-S, --size=NUM only archive messages NUM bytes or larger
-n, --dry-run don't write to anything - just show what would be done
-u, --preserve-unread never archive unread messages
--dont-mangle-from do not mangle From_ in message bodies
--delete delete rather than archive old mail (use with caution!)
--include-flagged messages flagged important can also be archived
--no-compress do not compress archives with gzip

View file

@ -27,6 +27,10 @@
<!ENTITY crontab "<CiteRefEntry>
<RefEntryTitle><Command/crontab/</RefEntryTitle>
<ManVolNum/5/</CiteRefEntry>">
<!ENTITY mbox "<CiteRefEntry>
<RefEntryTitle><Command/mbox/</RefEntryTitle>
<ManVolNum/5/</CiteRefEntry>">
]>
<RefEntry>
@ -242,6 +246,19 @@ been read by looking at the filename. If the filename contains an 'S' after
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--dont-mangle-from</Option>
</Term>
<ListItem><Para>
Do not mangle lines in message bodies beginning with "From ". Since mail user
agents may interpret such lines as message separators, by default
<command/archivemail/ mangles them by prepending a '>' to these lines (that is,
the resulting mailbox is in <application/MBOXO/-format). See &mbox; for more
information.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--delete</Option>