Skip to content

Commit d4e83b7

Browse files
Merge pull request #49 from antgonza/Python2.7
Python 2.7
2 parents 690362a + 1a6f268 commit d4e83b7

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

.github/workflows/qiita-ci.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ jobs:
99
main:
1010
runs-on: ubuntu-latest
1111

12+
strategy:
13+
matrix:
14+
python-version: ["2.7", "3.9"]
15+
1216
services:
1317
postgres:
1418
# Docker Hub image
@@ -73,7 +77,7 @@ jobs:
7377
- name: Install Qiita plugins
7478
shell: bash -l {0}
7579
run: |
76-
conda create --yes -n qiita_client python=3.9 pip nose flake8 coverage
80+
conda create --yes -n qiita_client python=${{ matrix.python-version }} pip nose flake8 coverage
7781
conda activate qiita_client
7882
7983
pip --quiet install .

qiita_client/qiita_client.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import pandas as pd
1313
from json import dumps
1414
from random import randint
15-
from itertools import zip_longest
15+
16+
try:
17+
from itertools import zip_longest
18+
except ImportError:
19+
from itertools import izip_longest as zip_longest
20+
1621
from os.path import basename
1722

1823
from .exceptions import (QiitaClientError, NotFoundError, BadRequestError,
@@ -590,8 +595,9 @@ def artifact_and_preparation_files(self, artifact_id,
590595

591596
if artifact_info['analysis'] is not None:
592597
raise RuntimeError(
593-
f'Artifact {artifact_id} is an analysis artifact, this method '
594-
'is meant to work with artifacts linked to a preparation.')
598+
'Artifact ' + str(artifact_id) + ' is an analysis artifact, '
599+
'this method is meant to work with artifacts linked to '
600+
'a preparation.')
595601

596602
prep_info = self.get('/qiita_db/prep_template/%s/'
597603
% artifact_info['prep_information'][0])
@@ -615,8 +621,9 @@ def _process_files_per_sample_fastq(self, files, prep_info,
615621
revs = sorted(
616622
files['raw_reverse_seqs'], key=lambda x: x['filepath'])
617623
if len(fwds) != len(revs):
618-
raise ValueError(f'The fwd ({len(fwds)}) and rev ({len(revs)})'
619-
' files should be of the same length')
624+
raise ValueError('The fwd (' + str(len(fwds)) + ') and rev ('
625+
+ str(len(revs)) + ') files should be of the '
626+
'same length')
620627

621628
run_prefixes = prep_info['run_prefix'].to_dict()
622629

@@ -635,15 +642,15 @@ def _process_files_per_sample_fastq(self, files, prep_info,
635642
run_prefix = rp
636643
sample_name = sn
637644
elif fwd_fn.startswith(rp) and run_prefix is not None:
638-
raise ValueError(
639-
f'Multiple run prefixes match this fwd read: {fwd_fn}')
645+
raise ValueError('Multiple run prefixes match this fwd '
646+
'read: %s' % fwd_fn)
640647

641648
if run_prefix is None:
642649
raise ValueError(
643-
f'No run prefix matching this fwd read: {fwd_fn}')
650+
'No run prefix matching this fwd read: %s' % fwd_fn)
644651
if run_prefix in used_prefixes:
645652
raise ValueError(
646-
f'Run prefix matches multiple fwd reads: {run_prefix}')
653+
'Run prefix matches multiple fwd reads: %s' % run_prefix)
647654
used_prefixes.append(run_prefix)
648655

649656
if rev is not None:
@@ -655,7 +662,7 @@ def _process_files_per_sample_fastq(self, files, prep_info,
655662
if not rev_fn.startswith(run_prefix):
656663
raise ValueError(
657664
'Reverse read does not match run prefix. run_prefix: '
658-
f'{run_prefix}; files: {fwd_fn} / {rev_fn}')
665+
'%s; files: %s / %s') % (run_prefix, fwd_fn, rev_fn)
659666

660667
used_prefixes.append(run_prefix)
661668

qiita_client/tests/test_qiita_client.py

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def setUp(self):
101101
CLIENT_SECRET, server_cert=self.server_cert)
102102
self.clean_up_files = []
103103

104+
# making assertRaisesRegex compatible with Python 2.7 and 3.9
105+
if not hasattr(self, 'assertRaisesRegex'):
106+
setattr(self, 'assertRaisesRegex', self.assertRaisesRegexp)
107+
104108
def tearDown(self):
105109
for fp in self.clean_up_files:
106110
if exists(fp):

0 commit comments

Comments
 (0)