summaryrefslogtreecommitdiff
path: root/Lib/mimetypes.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-03-26 21:13:24 +0000
committerGuido van Rossum <guido@python.org>1998-03-26 21:13:24 +0000
commit45e2fbc2e70ef28b1f0327207f33dab3a4e825c5 (patch)
tree24cafdb6ffb07170188292a02440935291327cde /Lib/mimetypes.py
parent9ea7024754f0e42d7fc70fd1c8f6f6cfbf7e1cf0 (diff)
downloadcpython-git-45e2fbc2e70ef28b1f0327207f33dab3a4e825c5.tar.gz
Mass check-in after untabifying all files that need it.
Diffstat (limited to 'Lib/mimetypes.py')
-rw-r--r--Lib/mimetypes.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index fd0e1c52c9..296c0ca49e 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -48,49 +48,49 @@ def guess_type(url):
"""
if not inited:
- init()
+ init()
base, ext = posixpath.splitext(url)
while suffix_map.has_key(ext):
- base, ext = posixpath.splitext(base + suffix_map[ext])
+ base, ext = posixpath.splitext(base + suffix_map[ext])
if encodings_map.has_key(ext):
- encoding = encodings_map[ext]
- base, ext = posixpath.splitext(base)
+ encoding = encodings_map[ext]
+ base, ext = posixpath.splitext(base)
else:
- encoding = None
+ encoding = None
if types_map.has_key(ext):
- return types_map[ext], encoding
+ return types_map[ext], encoding
elif types_map.has_key(string.lower(ext)):
- return types_map[string.lower(ext)], encoding
+ return types_map[string.lower(ext)], encoding
else:
- return None, encoding
+ return None, encoding
def init(files=None):
global inited
for file in files or knownfiles:
- s = read_mime_types(file)
- if s:
- for key, value in s.items():
- types_map[key] = value
+ s = read_mime_types(file)
+ if s:
+ for key, value in s.items():
+ types_map[key] = value
inited = 1
def read_mime_types(file):
try:
- f = open(file)
+ f = open(file)
except IOError:
- return None
+ return None
map = {}
while 1:
- line = f.readline()
- if not line: break
- words = string.split(line)
- for i in range(len(words)):
- if words[i][0] == '#':
- del words[i:]
- break
- if not words: continue
- type, suffixes = words[0], words[1:]
- for suff in suffixes:
- map['.'+suff] = type
+ line = f.readline()
+ if not line: break
+ words = string.split(line)
+ for i in range(len(words)):
+ if words[i][0] == '#':
+ del words[i:]
+ break
+ if not words: continue
+ type, suffixes = words[0], words[1:]
+ for suff in suffixes:
+ map['.'+suff] = type
f.close()
return map