diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-11-28 10:38:02 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-11-28 10:38:02 +0200 |
commit | e8b8d90d18408b222a05950257daccbddd7d6926 (patch) | |
tree | c1d999c1fd0016c9982cca8707f2b4f687e70bce /yarnlib | |
parent | 335478a004afc442820862c188f7378595a6b8bb (diff) | |
parent | 24960b9bd1e53e970b9a9796c268ce58cd5eff93 (diff) | |
download | cmdtest-e8b8d90d18408b222a05950257daccbddd7d6926.tar.gz |
Change: port to Python3, drop Python2 support
This is a combination of changes made by Richard Ipsum <richardipsum@vx21.xyz>
and Antonio Terceiro <terceiro@debian.org> to port cmdtest and yarn to
Python3. They both provided patches for Python3 support, and I merged the
changes. The actual work was done by Richard and Antonio.
Diffstat (limited to 'yarnlib')
-rw-r--r-- | yarnlib/mdparser.py | 11 |
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) |