ioos / pyoos

A Python library for collecting Met/Ocean observations
GNU Lesser General Public License v3.0
33 stars 33 forks source link

Python 3 #52

Closed ocefpaf closed 8 years ago

ocefpaf commented 8 years ago

@kwilcox and @daf this PR is incomplete because I could not figure out how to fix the error below.

tests/parsers/test_ioos_get_observation.py::SweIoosTest::test_o_and_m_get_observation FAILED

=================================== FAILURES ===================================
___________________ SweIoosTest.test_o_and_m_get_observation ___________________
self = <test_ioos_get_observation.SweIoosTest testMethod=test_o_and_m_get_observation>
    def test_o_and_m_get_observation(self):
        data = open(resource_file(os.path.join('ioos_swe', 'OM-GetObservation.xml')), "rb").read()

>       d = IoosGetObservation(data)
tests/parsers/test_ioos_get_observation.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cls = <class 'pyoos.parsers.ioos.get_observation.IoosGetObservation'>
element = b'<?xml version="1.0" encoding="UTF-8"?>\r\n<!-- Template Document for a generic (independant of feature type) Get Obs...A different feature type may be returned in this member -->\r\n  </om:member>\r\n  \r\n</om:ObservationCollection>\r\n'
    def __new__(cls, element):
        if isinstance(element, bytes):
            root = etree.fromstring(element)
        else:
            root = element

        if hasattr(root, 'getroot'):
            root = root.getroot()

        XLINK_NS = ns.get_namespace("xlink")
        GML_NS = [ns.get_versioned_namespace('gml', '3.1.1')]
        version = None
        for g in GML_NS:
            try:
                version = testXMLValue(root.find("{%s}metaDataProperty[@{%s}title='ioosTemplateVersion']/{%s}version" % (g, XLINK_NS, g)))
                break
            except:
                continue

        if version == "1.0":
            from pyoos.parsers.ioos.one.get_observation import GetObservation as GO10
>           return super(IoosGetObservation, cls).__new__(GO10, element=root)
E           TypeError: object() takes no parameters
pyoos/parsers/ioos/get_observation.py:32: TypeError
ocefpaf commented 8 years ago

@kwilcox I found this and decided to give it another shot. Can you review it? Not sure is passing the tests is enough here.

ocefpaf commented 8 years ago

@daf, @lukecampbell, and @kwilcox this is ready for another round of review.

PS0: pyoos and cc-plugin-glider are the last modules holding the IOOS stack to Python 2.7. PS1: cc-plugin-glider seems to be a low hanging fruit: https://github.com/ioos/cc-plugin-glider/issues/7

lukecampbell commented 8 years ago

This looks very thorough to me, @daf do you have any follow ups?

lukecampbell commented 8 years ago

Thanks @ocefpaf good work!