summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcmdtest2
-rw-r--r--setup.py8
-rwxr-xr-xyarn22
-rw-r--r--yarnlib/mdparser.py11
4 files changed, 21 insertions, 22 deletions
diff --git a/cmdtest b/cmdtest
index 1d60900..5a3f445 100755
--- a/cmdtest
+++ b/cmdtest
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2011 Lars Wirzenius
#
# This program is free software: you can redistribute it and/or modify
diff --git a/setup.py b/setup.py
index 9ba00a2..1c11194 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
# Copyright (C) 2011 Lars Wirzenius <liw@liw.fi>
#
# This program is free software; you can redistribute it and/or modify
@@ -43,13 +43,13 @@ class GenerateManpage(build):
def run(self):
build.run(self)
- print 'building manpages'
+ print('building manpages')
cmds = ['cmdtest']
if markdown_version:
cmds.append('yarn')
for x in cmds:
with open('%s.1' % x, 'w') as f:
- subprocess.check_call(['python', x,
+ subprocess.check_call(['python3', x,
'--generate-manpage=%s.1.in' % x,
'--output=%s.1' % x], stdout=f)
@@ -76,7 +76,7 @@ class Check(Command):
def run(self):
if markdown_version:
subprocess.check_call(
- ['python', '-m', 'CoverageTestRunner',
+ ['python3', '-m', 'CoverageTestRunner',
'--ignore-missing-from', 'without-tests'])
if os.path.exists('.coverage'):
os.remove('.coverage')
diff --git a/yarn b/yarn
index d67c115..4b4db34 100755
--- a/yarn
+++ b/yarn
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2013 Lars Wirzenius
#
# This program is free software: you can redistribute it and/or modify
@@ -116,8 +116,6 @@ class YarnRunner(cliapp.Application):
self._write(sys.stderr, msg)
def _write(self, output, msg):
- if isinstance(msg, unicode):
- msg = msg.encode(locale.getpreferredencoding())
output.write(msg)
output.flush()
@@ -332,7 +330,7 @@ class YarnRunner(cliapp.Application):
started = time.time()
self.info(0, 'Running scenario %s' % scenario.name)
- self.ts['scenario_name'] = scenario.name.encode('utf-8')
+ self.ts['scenario_name'] = scenario.name
self.ts.flush()
self.scenarios_run += 1
@@ -450,7 +448,7 @@ class YarnRunner(cliapp.Application):
self.info(1, 'Running step "%s %s"' % (step.what, step.text))
self.ts['current_step'] = step
- self.ts['step_name'] = '%s %s' % (step.what, step.text.encode('utf8'))
+ self.ts['step_name'] = '%s %s' % (step.what, step.text)
self.ts.flush()
self.steps_run += 1
@@ -461,7 +459,7 @@ class YarnRunner(cliapp.Application):
env['SRCDIR'] = os.getcwd()
env['HOME'] = self.homedir(datadir)
for i, match in enumerate(m.groups('')):
- env['MATCH_%d' % (i+1)] = match.encode('utf-8')
+ env['MATCH_%d' % (i+1)] = match
self.add_srcdir_to_pythonpath(env, env['SRCDIR'])
if self.settings['cd-datadir']:
@@ -487,11 +485,11 @@ class YarnRunner(cliapp.Application):
logging.debug('Exit code: %d' % exit)
if stdout:
- logging.debug('Standard output:\n%s' % self.indent(stdout))
+ logging.debug('Standard output:\n%s' % self.indent(stdout.decode()))
else:
logging.debug('Standard output: empty')
if stderr:
- logging.debug('Standard error:\n%s' % self.indent(stderr))
+ logging.debug('Standard error:\n%s' % self.indent(stderr.decode()))
else:
logging.debug('Standard error: empty')
@@ -500,9 +498,9 @@ class YarnRunner(cliapp.Application):
self.error('step "%s %s" failed,' % (step.what, step.text))
self.error('with exit code %d:' % exit)
self.error('Standard output from shell command:\n%s' %
- self.indent(stdout))
+ self.indent(stdout.decode()))
self.error('Standard error from shell command:\n%s' %
- self.indent(stderr))
+ self.indent(stderr.decode()))
self.remember_step_timing(
'%s %s' % (step.what, step.text), time.time() - started)
@@ -541,7 +539,9 @@ class YarnRunner(cliapp.Application):
exit, out, err = cliapp.runcmd_unchecked(
['cp', '-ax', datadir, snapshot])
if exit != 0:
- logging.warning('Snapshot copy failed:\n%s\n%s' % (out, err))
+ logging.warning(
+ 'Snapshot copy failed:\n%s\n%s' %
+ (out.decode(), err.decode ()))
def nice(self, name):
# Quote a scenario or step name so it forms a nice filename.
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)