]> granicus.if.org Git - python/commitdiff
The usual
authorGuido van Rossum <guido@python.org>
Sat, 17 Oct 1998 18:09:27 +0000 (18:09 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 17 Oct 1998 18:09:27 +0000 (18:09 +0000)
Lib/dos-8x3/mimetype.py
Lib/dos-8x3/py_compi.py

index b35d0ff84bd0610c031d266cd470699331ec2915..3d6510e23d026948269a306caded7ade0c07c7bc 100644 (file)
@@ -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])
index a6d03d7b3eedf72a354d06358f2d6fee608a72e2..e1d0d70babeee1976bc44995b0df5b972a9b33dc 100755 (executable)
@@ -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()