Output os.linesep instead of '\n'.
+Version 2.5.1 (2014-04-??)
+
+ Open all files in binary mode. Output os.linesep instead of '\n'.
+
+
Version 2.5.0 (2014-03-18)
Add option --set-header=header:value to set header's value (only at the top
Version 2.5.0 (2014-03-18)
Add option --set-header=header:value to set header's value (only at the top
-Open all files in binary mode. Output os.linesep instead of '\n'.
-
-
Add option -I to completely skip (remove) subparts -- no headers, no body,
no boundary, nothing.
Add option -I to completely skip (remove) subparts -- no headers, no body,
no boundary, nothing.
Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [--set-param header:param=value] [-Bbeit mask] [--save-headers|body|message mask] [-O dest_dir] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
Usage: %s [-h|--help] [-V|--version] [-cCDP] [-H|--host=hostname] [-f charset] [-d header1[,h2,...]|*[,-h1,...]] [-p header1[,h2,h3,...]:param1[,p2,p3,...]] [-r header1[,h2,...]|*[,-h1,...]] [-R header1[,h2,h3,...]:param1[,p2,p3,...]] [--set-header header:value] [--set-param header:param=value] [-Bbeit mask] [--save-headers|body|message mask] [-O dest_dir] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
- sys.stderr.write(errormsg + '\n')
+ sys.stderr.write(errormsg + os.linesep)
sys.exit(code)
def output_headers(msg):
unix_from = msg.get_unixfrom()
if unix_from:
sys.exit(code)
def output_headers(msg):
unix_from = msg.get_unixfrom()
if unix_from:
- output(unix_from + '\n')
+ output(unix_from + os.linesep)
for key, value in msg.items():
for key, value in msg.items():
- output("%s: %s\n" % (key, value))
- output("\n") # End of headers
+ output("%s: %s%s" % (key, value, os.linesep))
+ output(os.linesep) # End of headers
def recode_if_needed(s, charset):
def recode_if_needed(s, charset):
- file = open(filename, 'w')
- file.write(s)
- file.close()
+ outfile = open(filename, 'wb')
+ outfile.write(s)
+ outfile.close()
pipe = os.popen(command, 'r')
s = pipe.read()
pipe = os.popen(command, 'r')
s = pipe.read()
break
elif content_type in g.ignore_mask:
output_headers(msg)
break
elif content_type in g.ignore_mask:
output_headers(msg)
- output("\nMessage body of type %s skipped.\n" % ctype)
+ output("%sMessage body of type %s skipped.%s" % (os.linesep, ctype, os.linesep))
break
elif content_type in g.error_mask:
break
break
elif content_type in g.error_mask:
break
if msg.preamble: # Preserve the first part, it is probably not a RFC822-message
output(msg.preamble) # Usually it is just a few lines of text (MIME warning)
if msg.preamble is not None:
if msg.preamble: # Preserve the first part, it is probably not a RFC822-message
output(msg.preamble) # Usually it is just a few lines of text (MIME warning)
if msg.preamble is not None:
first_subpart = True
boundary = msg.get_boundary()
first_subpart = True
boundary = msg.get_boundary()
if first_subpart:
first_subpart = False
else:
if first_subpart:
first_subpart = False
else:
- output("\n")
- output("--%s\n" % boundary)
+ output(os.linesep)
+ output("--%s%s" % (boundary, os.linesep))
# Recursively decode all parts of the subpart
decode_message(subpart)
if boundary:
# Recursively decode all parts of the subpart
decode_message(subpart)
if boundary:
- output("\n--%s--\n" % boundary)
+ output("%s--%s--%s" % (os.linesep, boundary, os.linesep))
if msg.epilogue:
output(msg.epilogue)
if msg.epilogue:
output(msg.epilogue)
if create:
os.makedirs(full_dir)
try:
if create:
os.makedirs(full_dir)
try:
- return open(fullpath, 'w')
+ return open(fullpath, 'wb')
except:
if create:
os.removedirs(full_dir)
except:
if create:
os.removedirs(full_dir)