From 451c28d881dc30420bf2c535634918b003ccb003 Mon Sep 17 00:00:00 2001 From: neumond Date: Sun, 8 May 2016 01:23:40 +0300 Subject: [PATCH] Scripting parameter for parse.py --- parse.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/parse.py b/parse.py index b9bea288..2245060a 100755 --- a/parse.py +++ b/parse.py @@ -65,11 +65,12 @@ def parse(): if opts.profile: import cProfile import pstats - cProfile.runctx("run(parseMethod, f, encoding)", None, + cProfile.runctx("run(parseMethod, f, encoding, scripting)", None, {"run": run, "parseMethod": parseMethod, "f": f, - "encoding": encoding}, + "encoding": encoding, + "scripting": opts.scripting}, "stats.prof") # XXX - We should use a temp file here stats = pstats.Stats('stats.prof') @@ -79,7 +80,7 @@ def parse(): elif opts.time: import time t0 = time.time() - document = run(parseMethod, f, encoding) + document = run(parseMethod, f, encoding, opts.scripting) t1 = time.time() if document: printOutput(p, document, opts) @@ -88,13 +89,13 @@ def parse(): else: sys.stderr.write("\n\nRun took: %fs"%(t1-t0)) else: - document = run(parseMethod, f, encoding) + document = run(parseMethod, f, encoding, opts.scripting) if document: printOutput(p, document, opts) -def run(parseMethod, f, encoding): +def run(parseMethod, f, encoding, scripting): try: - document = parseMethod(f, encoding=encoding) + document = parseMethod(f, encoding=encoding, scripting=scripting) except: document = None traceback.print_exc() @@ -168,6 +169,9 @@ def getOptParser(): parser.add_option("-f", "--fragment", action="store_true", default=False, dest="fragment", help="Parse as a fragment") + parser.add_option("-s", "--scripting", action="store_true", default=False, + dest="scripting", help="Handle noscript tags as if scripting was enabled") + parser.add_option("", "--tree", action="store_true", default=False, dest="tree", help="Output as debug tree")