| | #!/usr/bin/env python |
---|
| | # nohtml.py |
---|
| | # nohtml.py - Filter To Remove HTML Attachments From Email |
---|
| | # Copyright (c) 2003 TundraWare Inc. All Rights Reserved. |
---|
| | # For Updates See: http://www.tundraware.com/Software/nohtml |
---|
| | |
---|
| | |
---|
| | #------------------- Nothing Below Here Should Need Changing ------------------# |
---|
| | |
---|
| | # Program Information |
---|
| | |
---|
| | PROGNAME = "nohtml" |
---|
| | RCSID = "$Id: nohtml.py,v 1.1 2003/05/05 21:32:41 tundra Exp $" |
---|
| | RCSID = "$Id: nohtml.py,v 1.10 2003/05/05 21:56:35 tundra Exp $" |
---|
| | VERSION = RCSID.split()[2] |
---|
| | |
---|
| | # Copyright Information |
---|
| | |
---|
| |
---|
| | COPYRIGHT = "Copyright %s %s %s %s. " % (CPRT, DATE, OWNER, RIGHTS) |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Variables User Might Change # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | #------------------- Nothing Below Here Should Need Changing ------------------# |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Imports # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | import getopt |
---|
| |
---|
| | import sys |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Aliases & Redefinitions # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Constants & Literals # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Constants |
---|
| | ##### |
---|
| | |
---|
| | FALSE = 0 == 1 # Booleans |
---|
| | TRUE = not FALSE |
---|
| | |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Literals |
---|
| | ##### |
---|
| | |
---|
| | |
---|
| | lCONFFILE = os.path.join(os.getenv("HOME"), "." + PROGNAME + "rc") # conf file |
---|
| | |
---|
| | STARTHTML1 = "Content-Type:".lower() |
---|
| | STARTHTML2 = "text/html".lower() |
---|
| | ENDHTML = "</HTML>".lower() |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Prompts, & Application Strings # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Error Messages |
---|
| | ##### |
---|
| | |
---|
| | eERROR = "ERROR" |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Informational Messages |
---|
| | ##### |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Usage Prompts |
---|
| |
---|
| | " -v print detailed version information", |
---|
| | ] |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Prompts |
---|
| | ##### |
---|
| | |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Global Variables & Data Structures # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | #--------------------------- Code Begins Here ---------------------------------# |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Object Base Class Definitions # |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| |
---|
| | #----------------------------------------------------------# |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Print An Error Message |
---|
| | ##### |
---|
| | |
---|
| | def errmsg(emsg): |
---|
| | print PROGNAME + " " + VERSION + " " + eERROR + ": " + emsg |
---|
| | |
---|
| | # End of 'errmsg()' |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Print Usage Information |
---|
| | ##### |
---|
| | |
---|
| | def Usage(): |
---|
| | for line in uTable: |
---|
| | print line |
---|
| | |
---|
| | # End of 'Usage()' |
---|
| | |
---|
| | |
---|
| | |
---|
| | #----------------------------------------------------------# |
---|
| | # Program Entry Point # |
---|
| | #----------------------------------------------------------# |
---|
| |
---|
| | if opt == "-v": |
---|
| | print RCSID |
---|
| | sys.exit(0) |
---|
| | |
---|
| | PASS = True |
---|
| | |
---|
| | for line in sys.stdin.readlines(): |
---|
| | |
---|
| | lline = line.lower() |
---|
| | |
---|
| | if lline.count(STARTHTML1) and lline.count(STARTHTML2): |
---|
| | PASS = False |
---|
| | |
---|
| | if PASS: |
---|
| | sys.stdout.write(line) |
---|
| | |
---|
| | if lline.count(ENDHTML): |
---|
| | DONE = True |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | |