[Python-checkins] CVS: python/dist/src/Lib mimetypes.py,1.20,1.21

Fred L. Drake fdrake@users.sourceforge.net
Wed, 05 Dec 2001 07:58:31 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv6563/Lib

Modified Files:
	mimetypes.py 
Log Message:
Separate the script portion from the library portion; everything that
pertains to the script is now in the if __name__ == "__main__" block.
This is in response to a commenton python-dev from Neal Norwitz.


Index: mimetypes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mimetypes.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** mimetypes.py	2001/10/25 21:49:18	1.20
--- mimetypes.py	2001/12/05 15:58:29	1.21
***************
*** 21,35 ****
  init([files]) -- parse a list of files, default knownfiles
  read_mime_types(file) -- parse one file, return a dictionary or None
- 
- When run as a script, the following command line options are recognized:
- 
- Usage: mimetypes.py [options] type
- Options:
-     --help / -h       -- print this message and exit
-     --lenient / -l    -- additionally search of some common, but non-standard
-                          types.
-     --extension / -e  -- guess extension instead of type
- 
- More than one type argument may be given.
  """
  
--- 21,24 ----
***************
*** 400,412 ****
  
  
- def usage(code, msg=''):
-     print __doc__
-     if msg: print msg
-     sys.exit(code)
- 
- 
  if __name__ == '__main__':
      import sys
      import getopt
  
      try:
--- 389,412 ----
  
  
  if __name__ == '__main__':
      import sys
      import getopt
+ 
+     USAGE = """\
+ Usage: mimetypes.py [options] type
+ 
+ Options:
+     --help / -h       -- print this message and exit
+     --lenient / -l    -- additionally search of some common, but non-standard
+                          types.
+     --extension / -e  -- guess extension instead of type
+ 
+ More than one type argument may be given.
+ """
+ 
+     def usage(code, msg=''):
+         print USAGE
+         if msg: print msg
+         sys.exit(code)
  
      try: