Skip to content

Commit 4823703

Browse files
neumondgsnedders
authored andcommitted
Scripting parameter for parse.py (html5lib#1)
1 parent 7f2fe00 commit 4823703

File tree

2 files changed

+10
-43
lines changed

2 files changed

+10
-43
lines changed

.pytest.expect

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -293,43 +293,6 @@ u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::cEleme
293293
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::cElementTree::parser::void-namespace': FAIL
294294
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::lxml::parser::namespaced': FAIL
295295
u'html5lib/tests/testdata/tree-construction/namespace-sensitivity.dat::0::lxml::parser::void-namespace': FAIL
296-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::DOM::parser::namespaced': FAIL
297-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::DOM::parser::void-namespace': FAIL
298-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::ElementTree::parser::namespaced': FAIL
299-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::ElementTree::parser::void-namespace': FAIL
300-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::cElementTree::parser::namespaced': FAIL
301-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::cElementTree::parser::void-namespace': FAIL
302-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::lxml::parser::namespaced': FAIL
303-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::10::lxml::parser::void-namespace': FAIL
304-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::DOM::parser::namespaced': FAIL
305-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::DOM::parser::void-namespace': FAIL
306-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::ElementTree::parser::namespaced': FAIL
307-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::ElementTree::parser::void-namespace': FAIL
308-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::cElementTree::parser::namespaced': FAIL
309-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::cElementTree::parser::void-namespace': FAIL
310-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::lxml::parser::namespaced': FAIL
311-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::16::lxml::parser::void-namespace': FAIL
312-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::DOM::parser::namespaced': FAIL
313-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::DOM::parser::void-namespace': FAIL
314-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::DOM::treewalker': FAIL
315-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::ElementTree::parser::namespaced': FAIL
316-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::ElementTree::parser::void-namespace': FAIL
317-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::ElementTree::treewalker': FAIL
318-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::cElementTree::parser::namespaced': FAIL
319-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::cElementTree::parser::void-namespace': FAIL
320-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::cElementTree::treewalker': FAIL
321-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::genshi::treewalker': FAIL
322-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::lxml::parser::namespaced': FAIL
323-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::lxml::parser::void-namespace': FAIL
324-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::17::lxml::treewalker': FAIL
325-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::DOM::parser::namespaced': FAIL
326-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::DOM::parser::void-namespace': FAIL
327-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::ElementTree::parser::namespaced': FAIL
328-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::ElementTree::parser::void-namespace': FAIL
329-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::cElementTree::parser::namespaced': FAIL
330-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::cElementTree::parser::void-namespace': FAIL
331-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::lxml::parser::namespaced': FAIL
332-
u'html5lib/tests/testdata/tree-construction/noscript01.dat::9::lxml::parser::void-namespace': FAIL
333296
u'html5lib/tests/testdata/tree-construction/ruby.dat::0::DOM::parser::namespaced': FAIL
334297
u'html5lib/tests/testdata/tree-construction/ruby.dat::0::DOM::parser::void-namespace': FAIL
335298
u'html5lib/tests/testdata/tree-construction/ruby.dat::0::ElementTree::parser::namespaced': FAIL

parse.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ def parse():
6565
if opts.profile:
6666
import cProfile
6767
import pstats
68-
cProfile.runctx("run(parseMethod, f, encoding)", None,
68+
cProfile.runctx("run(parseMethod, f, encoding, scripting)", None,
6969
{"run": run,
7070
"parseMethod": parseMethod,
7171
"f": f,
72-
"encoding": encoding},
72+
"encoding": encoding,
73+
"scripting": opts.scripting},
7374
"stats.prof")
7475
# XXX - We should use a temp file here
7576
stats = pstats.Stats('stats.prof')
@@ -79,7 +80,7 @@ def parse():
7980
elif opts.time:
8081
import time
8182
t0 = time.time()
82-
document = run(parseMethod, f, encoding)
83+
document = run(parseMethod, f, encoding, opts.scripting)
8384
t1 = time.time()
8485
if document:
8586
printOutput(p, document, opts)
@@ -88,13 +89,13 @@ def parse():
8889
else:
8990
sys.stderr.write("\n\nRun took: %fs"%(t1-t0))
9091
else:
91-
document = run(parseMethod, f, encoding)
92+
document = run(parseMethod, f, encoding, opts.scripting)
9293
if document:
9394
printOutput(p, document, opts)
9495

95-
def run(parseMethod, f, encoding):
96+
def run(parseMethod, f, encoding, scripting):
9697
try:
97-
document = parseMethod(f, encoding=encoding)
98+
document = parseMethod(f, encoding=encoding, scripting=scripting)
9899
except:
99100
document = None
100101
traceback.print_exc()
@@ -168,6 +169,9 @@ def getOptParser():
168169
parser.add_option("-f", "--fragment", action="store_true", default=False,
169170
dest="fragment", help="Parse as a fragment")
170171

172+
parser.add_option("-s", "--scripting", action="store_true", default=False,
173+
dest="scripting", help="Handle noscript tags as if scripting was enabled")
174+
171175
parser.add_option("", "--tree", action="store_true", default=False,
172176
dest="tree", help="Output as debug tree")
173177

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy