Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
ce051272
Commit
ce051272
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
ddef99ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
sax.py
...Lib/site-packages/pip/_vendor/html5lib/treedapters/sax.py
+50
-0
No files found.
stbi/Lib/site-packages/pip/_vendor/html5lib/treedapters/sax.py
0 → 100644
View file @
ce051272
from
__future__
import
absolute_import
,
division
,
unicode_literals
from
xml.sax.xmlreader
import
AttributesNSImpl
from
..constants
import
adjustForeignAttributes
,
unadjustForeignAttributes
prefix_mapping
=
{}
for
prefix
,
localName
,
namespace
in
adjustForeignAttributes
.
values
():
if
prefix
is
not
None
:
prefix_mapping
[
prefix
]
=
namespace
def
to_sax
(
walker
,
handler
):
"""Call SAX-like content handler based on treewalker walker
:arg walker: the treewalker to use to walk the tree to convert it
:arg handler: SAX handler to use
"""
handler
.
startDocument
()
for
prefix
,
namespace
in
prefix_mapping
.
items
():
handler
.
startPrefixMapping
(
prefix
,
namespace
)
for
token
in
walker
:
type
=
token
[
"type"
]
if
type
==
"Doctype"
:
continue
elif
type
in
(
"StartTag"
,
"EmptyTag"
):
attrs
=
AttributesNSImpl
(
token
[
"data"
],
unadjustForeignAttributes
)
handler
.
startElementNS
((
token
[
"namespace"
],
token
[
"name"
]),
token
[
"name"
],
attrs
)
if
type
==
"EmptyTag"
:
handler
.
endElementNS
((
token
[
"namespace"
],
token
[
"name"
]),
token
[
"name"
])
elif
type
==
"EndTag"
:
handler
.
endElementNS
((
token
[
"namespace"
],
token
[
"name"
]),
token
[
"name"
])
elif
type
in
(
"Characters"
,
"SpaceCharacters"
):
handler
.
characters
(
token
[
"data"
])
elif
type
==
"Comment"
:
pass
else
:
assert
False
,
"Unknown token type"
for
prefix
,
namespace
in
prefix_mapping
.
items
():
handler
.
endPrefixMapping
(
prefix
)
handler
.
endDocument
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment