From 3d999b0948b07b0ba2213f7904b241725e682c16 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 28 Nov 2019 10:11:12 +0200 Subject: Change: port to Python3 --- yarnlib/mdparser.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'yarnlib') 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) -- cgit v1.2.1