FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
html5lib-python/tests/mockParser.py at python3-old · hexagonrecursion/html5lib-python · GitHub
This repository was archived by the owner on May 5, 2023. It is now read-only.
hexagonrecursion
/
html5lib-python
Public archive
forked from
html5lib/html5lib-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
html5lib-python
/
tests
/
mockParser.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (33 loc) · 1.14 KB
Breadcrumbs
html5lib-python
/
tests
/
mockParser.py
Copy path
File metadata and controls
37 lines (33 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import
sys
import
os
if
__name__
==
'__main__'
:
#Allow us to import from the src directory
os
.
chdir
(
os
.
path
.
split
(
os
.
path
.
abspath
(
__file__
))[
0
])
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
pardir
,
"src"
)))
from
tokenizer
import
HTMLTokenizer
class
HTMLParser
(
object
):
""" Fake parser to test tokenizer output """
def
parse
(
self
,
stream
,
output
=
True
):
tokenizer
=
HTMLTokenizer
(
stream
)
for
token
in
tokenizer
:
if
output
:
print
token
if
__name__
==
"__main__"
:
x
=
HTMLParser
()
if
len
(
sys
.
argv
)
>
1
:
if
len
(
sys
.
argv
)
>
2
:
import
hotshot
,
hotshot
.
stats
prof
=
hotshot
.
Profile
(
'stats.prof'
)
prof
.
runcall
(
x
.
parse
,
sys
.
argv
[
1
],
False
)
prof
.
close
()
stats
=
hotshot
.
stats
.
load
(
'stats.prof'
)
stats
.
strip_dirs
()
stats
.
sort_stats
(
'time'
)
stats
.
print_stats
()
else
:
x
.
parse
(
sys
.
argv
[
1
])
else
:
print
"""Usage: python mockParser.py filename [stats]
If stats is specified the hotshots profiler will run and output the
stats instead.
"""
Back
|
FazBrowse Home
|
New Git URL