summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-12-05 15:58:29 (GMT)
committerFred Drake <fdrake@acm.org>2001-12-05 15:58:29 (GMT)
commit698da02d3b0ce3364dc4e9bd61a47d73ca4e74a7 (patch)
treee6ff553bcd27708b591f1d6e3ef5bb95accb09af
parent244e761fbf965a87dadb2e6720d1e68acdf4d7d3 (diff)
downloadcpython-698da02d3b0ce3364dc4e9bd61a47d73ca4e74a7.zip
cpython-698da02d3b0ce3364dc4e9bd61a47d73ca4e74a7.tar.gz
cpython-698da02d3b0ce3364dc4e9bd61a47d73ca4e74a7.tar.bz2
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.
-rw-r--r--Lib/mimetypes.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 1cd424a..5a708e3 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -20,17 +20,6 @@ Functions:
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.
"""
import os
@@ -399,16 +388,27 @@ common_types = {
}
-def usage(code, msg=''):
- print __doc__
- if msg: print msg
- sys.exit(code)
-
-
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:
opts, args = getopt.getopt(sys.argv[1:], 'hle',
['help', 'lenient', 'extension'])