summaryrefslogtreecommitdiff
path: root/yarnlib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-11-28 10:11:12 +0200
committerLars Wirzenius <liw@liw.fi>2019-11-28 10:36:11 +0200
commit3d999b0948b07b0ba2213f7904b241725e682c16 (patch)
treefd979530aee951f2a82c30a1a871daafc8a35d95 /yarnlib
parent335478a004afc442820862c188f7378595a6b8bb (diff)
downloadcmdtest-3d999b0948b07b0ba2213f7904b241725e682c16.tar.gz
Change: port to Python3
Diffstat (limited to 'yarnlib')
-rw-r--r--yarnlib/mdparser.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/yarnlib/mdparser.py b/yarnlib/mdparser.py
index 67851ec..9adf057 100644
--- a/yarnlib/mdparser.py
+++ b/yarnlib/mdparser.py
@@ -17,9 +17,9 @@
import logging
-import HTMLParser
+import html.parser
import markdown
-import StringIO
+import io
from markdown.treeprocessors import Treeprocessor
@@ -41,7 +41,7 @@ class GatherCodeBlocks(Treeprocessor):
self.blocks = blocks
def run(self, root):
- h = HTMLParser.HTMLParser()
+ h = html.parser.HTMLParser()
for child in root.getchildren():
if child.tag == 'pre':
code = child.find('code')
@@ -68,13 +68,12 @@ class MarkdownParser(object):
def parse_string(self, text):
ext = ParseScenarioTestBlocks()
- f = StringIO.StringIO()
+ f = io.StringIO()
markdown.markdown(text, output=f, extensions=[ext])
self.blocks.extend(ext.blocks)
return ext.blocks
def parse_file(self, filename): # pragma: no cover
with open(filename) as f:
- binary = f.read()
- text = binary.decode('utf-8')
+ text = f.read()
return self.parse_string(text)