summaryrefslogtreecommitdiff
path: root/Lib/mimetypes.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-02-09 09:44:47 +0000
committerEric S. Raymond <esr@thyrsus.com>2001-02-09 09:44:47 +0000
commitdf3cbe8f6f1aabf26990a156c921a494a4d0d65e (patch)
tree0f4a125c4fa34b6d492654e7e2c25c037e7c8de9 /Lib/mimetypes.py
parenta27cf43e685ee85d719214d8e49b92b5279a6179 (diff)
downloadcpython-df3cbe8f6f1aabf26990a156c921a494a4d0d65e.tar.gz
String method conversion. Added a trivial main to test it with.
Diffstat (limited to 'Lib/mimetypes.py')
-rw-r--r--Lib/mimetypes.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index 444184bc4b..c4d1860bbe 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -23,7 +23,6 @@ read_mime_types(file) -- parse one file, return a dictionary or None
"""
-import string
import posixpath
import urllib
@@ -64,11 +63,11 @@ def guess_type(url):
# data := *urlchar
# parameter := attribute "=" value
# type/subtype defaults to "text/plain"
- comma = string.find(url, ',')
+ comma = url.find(',')
if comma < 0:
# bad data URL
return None, None
- semi = string.find(url, ';', 0, comma)
+ semi = url.find(';', 0, comma)
if semi >= 0:
type = url[:semi]
else:
@@ -86,8 +85,8 @@ def guess_type(url):
encoding = None
if types_map.has_key(ext):
return types_map[ext], encoding
- elif types_map.has_key(string.lower(ext)):
- return types_map[string.lower(ext)], encoding
+ elif types_map.has_key(ext.lower()):
+ return types_map[ext.lower()], encoding
else:
return None, encoding
@@ -103,7 +102,7 @@ def guess_extension(type):
global inited
if not inited:
init()
- type = string.lower(type)
+ type = type.lower()
for ext, stype in types_map.items():
if type == stype:
return ext
@@ -127,7 +126,7 @@ def read_mime_types(file):
while 1:
line = f.readline()
if not line: break
- words = string.split(line)
+ words = line.split()
for i in range(len(words)):
if words[i][0] == '#':
del words[i:]
@@ -237,3 +236,7 @@ types_map = {
'.xwd': 'image/x-xwindowdump',
'.zip': 'application/zip',
}
+
+if __name__ == '__main__':
+ import sys
+ print guess_type(sys.argv[1])