[Zope3-checkins] CVS: Zope3/src/zope/app - content_types.py:1.4

Fred L. Drake, Jr. fred at zope.com
Tue Aug 19 11:15:49 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app
In directory cvs.zope.org:/tmp/cvs-serv21546

Modified Files:
	content_types.py 
Log Message:
- guess_content_type():  simplify logic; text_type() will never return
  a false value, so we don't have to handle that case
- normalized whitespace


=== Zope3/src/zope/app/content_types.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/content_types.py:1.3	Sat Jan  4 09:08:08 2003
+++ Zope3/src/zope/app/content_types.py	Tue Aug 19 10:15:43 2003
@@ -15,11 +15,11 @@
 
 import re, mimetypes
 
-find_binary=re.compile('[\0-\7]').search
+find_binary = re.compile('[\0-\7]').search
 
 def text_type(s):
     # Yuk. See if we can figure out the type by content.
-    s=s.strip()
+    s = s.strip()
     if (s[:6].lower() == '<html>' or s.find('</') > 0):
         return 'text/html'
 
@@ -33,7 +33,7 @@
 
 # This gives us a hook to add content types that
 # aren't currently listed in the mimetypes module.
-_addtypes=(
+_addtypes = (
     ('.mp3', 'audio/mpeg'),
     ('.ra', 'audio/x-pn-realaudio'),
     ('.pdf', 'application/pdf'),
@@ -87,14 +87,14 @@
             if find_binary(body) is not None:
                 type = default or 'application/octet-stream'
             else:
-                type = (default or text_type(body)
-                      or 'text/x-unknown-content-type')
+                type = default or text_type(body)
         else:
             type = default or 'text/x-unknown-content-type'
 
     return type.lower(), enc and enc.lower() or None
 
-if __name__=='__main__':
-    items=mimetypes.types_map.items()
+if __name__ == '__main__':
+    items = mimetypes.types_map.items()
     items.sort()
-    for item in items: print "%s:\t%s" % item
+    for item in items:
+        print "%s:\t%s" % item




More information about the Zope3-Checkins mailing list