Commits

Geoffrey Sneddon committed bf926a2

Make Anolis work without profiling when hotshot doesn't exist.

Comments (0)

Files changed (2)

 	parser.add_option("", "--w3c-compat-crazy-substitutions", action="store_true",
 		dest="w3c_compat_crazy_substitutions", help="Do crazy W3C specific substitutions, which may cause unexpected behaviour (i.e., replacing random strings within the document with no special marker).")
 	
-	parser.add_option("", "--profile", action="store_true",
-		dest="profile", help=SUPPRESS_HELP)
+	try:
+		import hotshot
+		import hotshot.stats
+		parser.add_option("", "--profile", action="store_true",
+			dest="profile", help=SUPPRESS_HELP)
+	except ImportError:
+		pass
 	
 	parser.add_option("", "--inject-meta-charset", action="store_true",
 		dest="inject_meta_charset", help=SUPPRESS_HELP)

anolislib/generator.py

 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-import hotshot
-import hotshot.stats
-import os
-import tempfile
-
 import html5lib
 from html5lib import treebuilders, treewalkers, serializer
 import lxml.html
 	
 	# Run the generator, and profile, or not, as the case may be
 	if profile:
+		import hotshot
+		import hotshot.stats
+		import os
+		import tempfile
 		statfile = tempfile.mkstemp()[1]
 		prof = hotshot.Profile(statfile)
 		prof.runcall(process, tree, processes, **kwargs)