mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
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.
This commit is contained in:
parent
244e761fbf
commit
698da02d3b
1 changed files with 17 additions and 17 deletions
|
@ -20,17 +20,6 @@ Functions:
|
||||||
|
|
||||||
init([files]) -- parse a list of files, default knownfiles
|
init([files]) -- parse a list of files, default knownfiles
|
||||||
read_mime_types(file) -- parse one file, return a dictionary or None
|
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
|
import os
|
||||||
|
@ -399,16 +388,27 @@ common_types = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def usage(code, msg=''):
|
|
||||||
print __doc__
|
|
||||||
if msg: print msg
|
|
||||||
sys.exit(code)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
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:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'hle',
|
opts, args = getopt.getopt(sys.argv[1:], 'hle',
|
||||||
['help', 'lenient', 'extension'])
|
['help', 'lenient', 'extension'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue