def usage(code=0, errormsg=''):
version(0)
sys.stdout.write("""\
-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 header:param] [--remove-params=header] [-beit mask] [-o output_file] [input_file [output_file]]
+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 header:param] [-beit mask] [-o output_file] [input_file [output_file]]
""" % me)
if errormsg:
sys.stderr.write(errormsg + '\n')
for header in header_list:
del msg[header]
- for header in gopts.remove_all_params:
- value = msg[header]
- if value is None: # No such header
- continue
- if ';' not in value: # There are no parameters
- continue
- del msg[header] # Delete all such headers
- # Get the value without parameters and set it back
- msg[header] = value.split(';')[0].strip()
+ #for header in gopts.remove_all_params:
+ # value = msg[header]
+ # if value is None: # No such header
+ # continue
+ # if ';' not in value: # There are no parameters
+ # continue
+ # del msg[header] # Delete all such headers
+ # # Get the value without parameters and set it back
+ # msg[header] = value.split(';')[0].strip()
for header, param in gopts.remove_header_params:
msg.del_param(param, header)
remove_headers = []
# A list of headers parameters to remove
remove_header_params = []
- # A list of headers to be stripped of all parameters
- remove_all_params = []
totext_mask = [] # A list of content-types to decode
binary_mask = [] # A list to pass through
try:
options, arguments = getopt(sys.argv[1:],
'hVcCDPH:f:d:p:r:R:b:e:i:t:o:',
- ['help', 'version', 'host=', 'remove-params='])
+ ['help', 'version', 'host='])
except GetoptError:
usage(1)
gopts.remove_headers.append(value)
elif option == '-R':
gopts.remove_header_params.append(value.split(':', 1))
- elif option == '--remove-params':
- gopts.remove_all_params.append(value)
elif option == '-t':
gopts.totext_mask.append(value)
elif option == '-b':
test_file msg_15.txt msg_15-2.txt -i text/html
test_file msg_22.txt msg_22-1.txt -r content-id
test_file msg_29.txt msg_29-1.txt -R Content-Type:title
-test_file msg_18.txt msg_18-1.txt --remove-params=X-Foobar-Spoink-Defrobnit
test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:name,filename
test_file msg_22.txt msg_22.txt -P -p \*:name,filename
test_file msg_22.txt msg_22.txt -P -p Content-Type,Content-Disposition:\*
test_file msg_22.txt msg_22.txt -P -p '*,-Content-Id:*,-x-mac-type'
test_file msg_16.txt msg_16-1.txt -r Received,List-Help,List-Post,List-Subscribe,List-Id,List-Unsubscribe,List-Archive
test_file msg_16.txt msg_16-2.txt -r \*,-mime-version,-content-type
+#test_file msg_18.txt msg_18-1.txt --remove-params=X-Foobar-Spoink-Defrobnit
if [ "$RC" -eq 0 ]; then
echo "All tests passed!"