diff options
author | Guido van Rossum <guido@python.org> | 1998-10-17 18:09:27 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-17 18:09:27 (GMT) |
commit | d54fb7ae9b2032155cb321bf5e9b5dac9983bfa5 (patch) | |
tree | 5dff43d3fd5e64f2e5ea81e416a35334c4c1cc1e /Lib/dos-8x3 | |
parent | f3dcafecd3827aa5c6a99c807c3300ec8f65f650 (diff) | |
download | cpython-d54fb7ae9b2032155cb321bf5e9b5dac9983bfa5.zip cpython-d54fb7ae9b2032155cb321bf5e9b5dac9983bfa5.tar.gz cpython-d54fb7ae9b2032155cb321bf5e9b5dac9983bfa5.tar.bz2 |
The usual
Diffstat (limited to 'Lib/dos-8x3')
-rw-r--r-- | Lib/dos-8x3/mimetype.py | 21 | ||||
-rwxr-xr-x | Lib/dos-8x3/py_compi.py | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/Lib/dos-8x3/mimetype.py b/Lib/dos-8x3/mimetype.py index b35d0ff..3d6510e 100644 --- a/Lib/dos-8x3/mimetype.py +++ b/Lib/dos-8x3/mimetype.py @@ -25,6 +25,7 @@ read_mime_types(file) -- parse one file, return a dictionary or None import string import posixpath +import urllib knownfiles = [ "/usr/local/etc/httpd/conf/mime.types", @@ -53,6 +54,26 @@ def guess_type(url): """ if not inited: init() + scheme, url = urllib.splittype(url) + if scheme == 'data': + # syntax of data URLs: + # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data + # mediatype := [ type "/" subtype ] *( ";" parameter ) + # data := *urlchar + # parameter := attribute "=" value + # type/subtype defaults to "text/plain" + comma = string.find(url, ',') + if comma < 0: + # bad data URL + return None, None + semi = string.find(url, ';', 0, comma) + if semi >= 0: + type = url[:semi] + else: + type = url[:comma] + if '=' in type or '/' not in type: + type = 'text/plain' + return type, None # never compressed, so encoding is None base, ext = posixpath.splitext(url) while suffix_map.has_key(ext): base, ext = posixpath.splitext(base + suffix_map[ext]) diff --git a/Lib/dos-8x3/py_compi.py b/Lib/dos-8x3/py_compi.py index a6d03d7..e1d0d70 100755 --- a/Lib/dos-8x3/py_compi.py +++ b/Lib/dos-8x3/py_compi.py @@ -44,7 +44,7 @@ def compile(file, cfile=None, dfile=None): import os, marshal, __builtin__ f = open(file) try: - timestamp = os.fstat(file.fileno()) + timestamp = long(os.fstat(f.fileno())[8]) except AttributeError: timestamp = long(os.stat(file)[8]) codestring = f.read() |