Skip to content

Commit

Permalink
Compatibility with Py2
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Dec 1, 2016
1 parent b941599 commit a3099db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions MyCapytain/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,12 @@ def xmlparser(xml, objectify=True):
doclose = None
if isinstance(xml, (etree._Element, ObjectifiedElement, etree._ElementTree)):
return xml
elif isinstance(xml, IOBase):
pass
elif isinstance(xml, basestring):
xml = StringIO(xml)
doclose = True
else:

elif not isinstance(xml, IOBase):
raise TypeError("Unsupported type of resource {}".format(type(xml)))

if objectify:
parsed = etree.parse(xml).getroot()
else:
Expand Down
5 changes: 5 additions & 0 deletions tests/resources/commonTests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from six import text_type as str

import warnings
from unittest import TestCase

import MyCapytain.errors
from MyCapytain.common.reference import Reference, URN, Citation
from MyCapytain.common.utils import Mimetypes
from MyCapytain.resources.texts.locals.tei import Text
from io import open


class CapitainsXmlTextTest(TestCase):
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/proto/test_text.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from six import text_type as str

import unittest

from MyCapytain.resources.prototypes.text import *
import MyCapytain.common.reference
import MyCapytain.common.metadata


class TestProtoResource(unittest.TestCase):
""" Test for resource, mother class of Text and Passage """
def test_init(self):
Expand Down

0 comments on commit a3099db

Please sign in to comment.