Update of /cvsroot/happydoc/HappyDoc3/happydoclib
In directory sc8-pr-cvs1:/tmp/cvs-serv15545/happydoclib
Modified Files:
appclass.py packagetree.py
Log Message:
Initialize extra mimetypes in the application, instead of the
PackageTree module.
Add an option so the user can specify a filename extension-to-mimetype
mapping.
Index: appclass.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/appclass.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** appclass.py 28 Dec 2002 16:40:46 -0000 1.9
--- appclass.py 18 Jan 2003 14:35:24 -0000 1.10
***************
*** 54,64 ****
# Import system modules
#
- import os
import glob
import sys
- import types
import string
- import re
import traceback
#
--- 54,65 ----
# Import system modules
#
import glob
+ import mimetypes
+ import os
+ import re
import sys
import string
import traceback
+ import types
#
***************
*** 127,130 ****
--- 128,140 ----
self.addIgnoreDirectoryPattern('trace.txt')
+ #
+ # Initialize extensions for mimetypes that we know about but which are
+ # not standard.
+ #
+ self.addMimetype('stx', 'text/x-structured')
+ return
+
+ def addMimetype(self, extension, mimetypeSpec):
+ mimetypes.types_map['.%s' % extension] = mimetypeSpec
return
***************
*** 205,208 ****
--- 215,234 ----
## self.author_name = authorNameAndEmail
## return
+
+ def optionHandler_mimetype(self, extensionAndMimetype):
+ """Specify a filename extension and mimetype mapping.
+
+ This is useful if input files are named in a way that the
+ Python mimetypes module cannot determine their mimetype
+ automatically.
+
+ For example::
+
+ """
+ parts = extensionAndMimetype.split('=')
+ if len(parts) != 2:
+ raise ValueError('Could not understand "%s". Use --mimetype "ext=mimetype"' % extensionAndMimetype)
+ self.addMimetype(parts[0], parts[1])
+ return
def optionHandler_d(self, outputDirectory):
Index: packagetree.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/packagetree.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** packagetree.py 1 Jan 2003 13:47:22 -0000 1.2
--- packagetree.py 18 Jan 2003 14:35:24 -0000 1.3
***************
*** 77,86 ****
TRACE_LEVEL=2
- #
- # Initialize extensions for mimetypes that we know about but which are
- # not standard.
- #
- mimetypes.types_map['.stx'] = 'text/x-structured'
-
class PackageTree(UserDict.UserDict):
"""Tree of package information.
--- 77,80 ----
|