Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3bedc5

Browse files
committed
Fix#112: fix parse.py to work with default args and XML serialisation.
This is the result of fallout from the removal of simpletree!
1 parentf04b07b commite3bedc5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎parse.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
fromhtml5lib.tokenizerimportHTMLTokenizer
1414
fromhtml5libimporttreebuilders,serializer,treewalkers
1515
fromhtml5libimportconstants
16+
fromhtml5libimportutils
1617

1718
defparse():
1819
optParser=getOptParser()
@@ -108,7 +109,14 @@ def printOutput(parser, document, opts):
108109

109110
ifdocumentisnotNone:
110111
ifopts.xml:
111-
sys.stdout.write(document.toxml("utf-8"))
112+
tb=opts.treebuilder.lower()
113+
iftb=="dom":
114+
document.writexml(sys.stdout,encoding="utf-8")
115+
eliftb=="lxml":
116+
importlxml.etree
117+
sys.stdout.write(lxml.etree.tostring(document))
118+
eliftb=="etree":
119+
sys.stdout.write(utils.default_etree.tostring(document))
112120
elifopts.tree:
113121
ifnothasattr(document,'__getitem__'):
114122
document= [document]
@@ -152,7 +160,7 @@ def getOptParser():
152160
help="Time the run using time.time (may not be accurate on all platforms, especially for short runs)")
153161

154162
parser.add_option("-b","--treebuilder",action="store",type="string",
155-
dest="treebuilder",default="simpleTree")
163+
dest="treebuilder",default="etree")
156164

157165
parser.add_option("-e","--error",action="store_true",default=False,
158166
dest="error",help="Print a list of parse errors")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp