Skip to content

Commit

Permalink
fixes for python 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Mar 14, 2017
1 parent e1f8a3a commit 63d813b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ features or changes that you can implement yourself.
(sbmlutils)$ pip install -e .

9. When you are done making changes, check that your changes pass pep8
and the tests with tox for your local Python version::
and the tests with tox for your local Python version::

(sbmlutils)$ tox -e pep8

Expand Down
4 changes: 2 additions & 2 deletions sbmlutils/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ def annotations_from_file(file_path, delimiter='\t'):
def annotations_from_csv(csvfile, delimiter='\t'):
""" Read annotations from csv in annotation data structure. """
res = []
f = open(csvfile, 'rb')
f = open(csvfile, 'rt')
reader = csv.reader(f, delimiter=delimiter, quoting=csv.QUOTE_NONE)

# first line is headers line
headers = reader.next()
headers = next(reader)
logger.info('Headers: {}'.format(headers))

# read entries
Expand Down
8 changes: 4 additions & 4 deletions sbmlutils/formating.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def annotation_to_html(cls, item):
:param item: SBO item
"""
items = []
for kcv in xrange(item.getNumCVTerms()):
for kcv in range(item.getNumCVTerms()):
cv = item.getCVTerm(kcv)
q_type = cv.getQualifierType()
if q_type == 0:
Expand All @@ -25,7 +25,7 @@ def annotation_to_html(cls, item):
qualifier = annotation.BiologicalQualifierType[cv.getBiologicalQualifierType()]
items.append(''.join(['<b>', qualifier, '</b>']))

for k in xrange(cv.getNumResources()):
for k in range(cv.getNumResources()):
uri = cv.getResourceURI(k)
tokens = uri.split('/')
resource_id = tokens[-1]
Expand Down Expand Up @@ -86,7 +86,7 @@ def modelHistoryToString(mhistory):
return ""
items = []
items.append('<b>Creator</b>')
for kc in xrange(mhistory.getNumCreators()):
for kc in range(mhistory.getNumCreators()):
cdata = []
c = mhistory.getCreator(kc)
if c.isSetGivenName():
Expand All @@ -100,7 +100,7 @@ def modelHistoryToString(mhistory):
items.append(", ".join(cdata))
if mhistory.isSetCreatedDate():
items.append('<b>Created:</b> ' + dateToString(mhistory.getCreatedDate()))
for km in xrange(mhistory.getNumModifiedDates()):
for km in range(mhistory.getNumModifiedDates()):
items.append('<b>Modified:</b> ' + dateToString(mhistory.getModifiedDate(km)))
items.append('<br />')
return "<br />".join(items)
Expand Down
5 changes: 3 additions & 2 deletions sbmlutils/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import print_function, division
from six import iteritems
import os
import logging
import warnings
Expand Down Expand Up @@ -32,7 +33,7 @@ def create_merged_doc(model_paths):
comp_doc = doc.getPlugin("comp")
comp_model = model.getPlugin("comp")

for emd_id, path in model_paths.iteritems():
for emd_id, path in iteritems(model_paths):
# create ExternalModelDefinitions
emd = comp.create_ExternalModelDefinition(comp_doc, emd_id, source=path)
# add submodel which references the external model definitions
Expand All @@ -50,7 +51,7 @@ def merge_models(model_paths, validate=True):
"""
# necessary to convert models to SBML L3V1, unfortunately many biomodels/models
# only L2V?, so additional step necessary
for mid, path in model_paths.iteritems():
for mid, path in iteritems(model_paths):
if not os.path.exists(path):
logging.error('Path for SBML file does not exist: {}'.format(path))

Expand Down
2 changes: 1 addition & 1 deletion sbmlutils/report/templates/macros_helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% macro notes(item) %}
{% if item.isSetNotes() %}
{{ item.notes_string.decode('utf-8') }}
{{ item.getNotesString }}
{% endif %}
{% endmacro %}

Expand Down
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Test with

[tox]
envlist = py27, py35, py36
envlist = pep8, py27, py35, py36

[testenv]
deps=
pytest
pytest-benchmark
commands=
pytest
# nosetests
# avoids import errors of 'nosetests' in virtualenv

[testenv:pep8]
skip_install = True
deps =
pep8
commands =
pep8 --show-source sbmlutils

0 comments on commit 63d813b

Please sign in to comment.