Skip to content

Commit e074e70

Browse files
authored
Merge pull request #768 from jmchilton/py3_quick
Try enabling more Python 3 testing.
2 parents dedeb65 + 215bcb5 commit e074e70

File tree

10 files changed

+29
-35
lines changed

10 files changed

+29
-35
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ env:
77
- TOX_ENV=py27-lint-readme
88
- TOX_ENV=py27-lint-docs
99
- TOX_ENV=py27-quick
10+
- TOX_ENV=py34-quick
1011
- TOX_ENV=py27
1112
- TOX_ENV=py34
1213
- TOX_ENV=py27-lint-docstrings

planemo/bioconda_scripts/bioconductor_skeleton.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
https://github.com/bioconda/bioconda-recipes/blob/master/scripts/bioconductor/bioconductor_skeleton.py
44
(written by Ryan Dale github: daler)
55
"""
6+
from __future__ import print_function
67

78
import configparser
89
import hashlib
@@ -12,14 +13,13 @@
1213
import shutil
1314
import tarfile
1415
import tempfile
15-
import urlparse
1616
from collections import OrderedDict
1717
from textwrap import dedent
1818

1919
import bs4
2020
import pyaml
2121
import requests
22-
22+
from six.moves.urllib.parse import urljoin
2323

2424
logging.basicConfig(level=logging.INFO, format='[bioconductor_skeleton.py %(asctime)s]: %(message)s')
2525
logger = logging.getLogger()
@@ -135,7 +135,7 @@ def f(href):
135135
# build the actual URL based on the identified package name and the
136136
# relative URL from the source. Here we're just hard-coding
137137
# '../src/contrib' based on the structure of the bioconductor site.
138-
return os.path.join(urlparse.urljoin(self.url, '../src/contrib'), s[0])
138+
return os.path.join(urljoin(self.url, '../src/contrib'), s[0])
139139

140140
@property
141141
def tarball_url(self):
@@ -197,8 +197,8 @@ def description(self):
197197
e = c['top']
198198

199199
# Glue together newlines
200-
for k in e.keys():
201-
e[k] = e[k].replace('\n', ' ')
200+
for k, v in e.items():
201+
e[k] = v.replace('\n', ' ')
202202

203203
return dict(e)
204204

planemo/database/postgres.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import subprocess
44

5+
from galaxy.util import unicodify
6+
57
from planemo.io import communicate
68
from .interface import DatabaseSource
79

@@ -20,7 +22,7 @@ def __init__(self, **kwds):
2022
def list_databases(self):
2123
"""Use `psql --list` to generate a list of identifiers."""
2224
command_builder = self._psql_command_builder("--list")
23-
stdout = self._communicate(command_builder)
25+
stdout = unicodify(self._communicate(command_builder))
2426
output_lines = stdout.splitlines()
2527
identifiers = []
2628
for line in output_lines:

planemo/git.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""Utilities for interacting with git using planemo abstractions."""
2+
from __future__ import absolute_import
3+
24
import os
35
import subprocess
46

5-
from six import text_type
7+
from galaxy.util import unicodify
68

79
from planemo import io
810

@@ -81,7 +83,7 @@ def diff(ctx, directory, range):
8183
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
8284
universal_newlines=True
8385
)
84-
return [l.strip() for l in text_type(stdout).splitlines() if l]
86+
return [l.strip() for l in unicodify(stdout).splitlines() if l]
8587

8688

8789
def clone(*args, **kwds):
@@ -103,7 +105,7 @@ def rev(ctx, directory):
103105
stdout, _ = io.communicate(
104106
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
105107
)
106-
return text_type(stdout).strip()
108+
return unicodify(stdout).strip()
107109

108110

109111
def is_rev_dirty(ctx, directory):
@@ -117,8 +119,8 @@ def rev_if_git(ctx, directory):
117119
"""Determine git revision (or ``None``)."""
118120
try:
119121
the_rev = rev(ctx, directory)
120-
is_dirtry = is_rev_dirty(ctx, directory)
121-
if is_dirtry:
122+
is_dirty = is_rev_dirty(ctx, directory)
123+
if is_dirty:
122124
the_rev += "-dirty"
123125
return the_rev
124126
except RuntimeError:

planemo/io.py

+5-13
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def shell(cmds, **kwds):
5151
def info(message, *args):
5252
if args:
5353
message = message % args
54-
_echo(click.style(message, bold=True, fg='green'))
54+
click.echo(click.style(message, bold=True, fg='green'))
5555

5656

5757
def can_write_to_path(path, **kwds):
@@ -64,20 +64,13 @@ def can_write_to_path(path, **kwds):
6464
def error(message, *args):
6565
if args:
6666
message = message % args
67-
_echo(click.style(message, bold=True, fg='red'), err=True)
67+
click.echo(click.style(message, bold=True, fg='red'), err=True)
6868

6969

7070
def warn(message, *args):
7171
if args:
7272
message = message % args
73-
_echo(click.style(message, fg='red'), err=True)
74-
75-
76-
def _echo(message, err=False):
77-
if sys.version_info[0] == 2:
78-
click.echo(message, err=err)
79-
else:
80-
print(message)
73+
click.echo(click.style(message, fg='red'), err=True)
8174

8275

8376
def shell_join(*args):
@@ -133,7 +126,7 @@ def find_matching_directories(path, pattern, recursive):
133126

134127
@contextlib.contextmanager
135128
def real_io():
136-
"""Ensure stdout and stderr have ``fileno`` attributes.
129+
"""Ensure stdout and stderr have supported ``fileno()`` method.
137130
138131
nosetests replaces these streams with :class:`StringIO` objects
139132
that may not work the same in every situtation - :func:`subprocess.Popen`
@@ -142,9 +135,8 @@ def real_io():
142135
original_stdout = sys.stdout
143136
original_stderr = sys.stderr
144137
try:
145-
if not hasattr(sys.stdout, "fileno"):
138+
if commands.redirecting_io(sys=sys):
146139
sys.stdout = sys.__stdout__
147-
if not hasattr(sys.stderr, "fileno"):
148140
sys.stderr = sys.__stderr__
149141
yield
150142
finally:

planemo/reports/xunit_handler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ def handle_report_xunit_kwd(kwds, collected_data):
55
if kwds.get('report_xunit', False):
66
with open(kwds['report_xunit'], 'w') as handle:
77
handle.write(template_data(
8-
collected_data, template_name='xunit.tpl')
9-
.encode('ascii', 'xmlcharrefreplace'))
8+
collected_data, template_name='xunit.tpl'))

planemo/tool_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def _build_galaxy(**kwds):
300300
# process raw cite urls
301301
cite_urls = kwds.get("cite_url", [])
302302
del kwds["cite_url"]
303-
citations = map(UrlCitation, cite_urls)
303+
citations = list(map(UrlCitation, cite_urls))
304304
kwds["bibtex_citations"] = citations
305305

306306
# handle requirements and containers

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jinja2
1111
glob2
1212
virtualenv
1313
lxml
14-
gxformat2>=0.1.1
14+
gxformat2>=0.2.0
1515
ephemeris>=0.2.0
16-
galaxy-lib>=17.9.8
16+
galaxy-lib>=17.9.12
1717
html5lib>=0.9999999,!=0.99999999,!=0.999999999,!=1.0b10,!=1.0b09
1818
cwltool==1.0.20170828135420

tests/test_io.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""Test utilities from :module:`planemo.io`."""
22
import tempfile
33

4-
from .test_utils import (
5-
assert_equal,
6-
io,
7-
)
4+
from planemo import io
5+
from .test_utils import assert_equal
86

97

108
def test_io_capture():
@@ -40,7 +38,7 @@ def assert_filtered_is(paths, expected, **kwds):
4038
assert_filtered_is(["/a/c"], [], exclude=["/a"])
4139
assert_filtered_is(["/b"], ["/b"], exclude=["/a"])
4240
assert_filtered_is(["/a/b/c"], [], exclude=["c"])
43-
with tempfile.NamedTemporaryFile() as tmp:
41+
with tempfile.NamedTemporaryFile(mode='w+') as tmp:
4442
tmp.write("#exclude c\n\nc\n")
4543
tmp.flush()
4644
assert_filtered_is(["/a/b/c", "/a/b/d"], ["/a/b/d"], exclude_from=[tmp.name])

tests/test_shed_upload.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_upload_from_git(self):
138138
"git add .",
139139
"git commit -m 'initial commit'"
140140
]))
141-
rev = git.rev(None, "single_tool").decode("UTF-8")
141+
rev = git.rev(None, "single_tool")
142142
upload_command = [
143143
"shed_update", "--force_repository_creation",
144144
"git+single_tool/.git"

0 commit comments

Comments
 (0)