From f57076633a961f88de84156eb4f14e37d3b8cf62 Mon Sep 17 00:00:00 2001 From: Lee Kamentsky Date: Tue, 13 Oct 2015 09:21:34 -0400 Subject: [PATCH] Fixes #37 + test - the default xml was misformatted --- bioformats/omexml.py | 16 ++++++++++------ bioformats/tests/test_omexml.py | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/bioformats/omexml.py b/bioformats/omexml.py index 2bd5171..10a31d2 100644 --- a/bioformats/omexml.py +++ b/bioformats/omexml.py @@ -32,11 +32,11 @@ def xsd_now(): NS_RE = r"http://www.openmicroscopy.org/Schemas/(?P.*)/[0-9/-]" default_xml = """ - + xsi:schemaLocation="{ns_ome_default} {ns_ome_default}/ome.xsd"> - %(DEFAULT_NOW)s + {DEFAULT_NOW} - - -""".format(ns_ome_default=NS_DEFAULT.format(ns_key='ome'), ns_sa_default=NS_DEFAULT.format(ns_key='sa')) + +""".format( + ns_ome_default=NS_DEFAULT.format(ns_key='OME'), + ns_sa_default=NS_DEFAULT.format(ns_key='sa'), + ns_binary_file=NS_DEFAULT.format(ns_key="BinaryFile"), + DEFAULT_NOW=DEFAULT_NOW) # # These are the OME-XML pixel types - not all supported by subimager diff --git a/bioformats/tests/test_omexml.py b/bioformats/tests/test_omexml.py index f466785..39156ba 100644 --- a/bioformats/tests/test_omexml.py +++ b/bioformats/tests/test_omexml.py @@ -11,9 +11,11 @@ import datetime import os +import re import unittest import urllib import xml.dom +import xml.etree.ElementTree import bioformats.omexml as O @@ -32,6 +34,22 @@ def test_00_00_init(self): self.assertEquals(o.root_node.tag, O.qn(o.get_ns("ome"), "OME")) self.assertEquals(o.image_count, 1) + def test_00_01_ns_binary_file(self): + # regression test of issue #37 + o = O.OMEXML() + xmlstr = o.to_xml() + tree = xml.etree.ElementTree.fromstring(xmlstr) + bfelements = tree.findall(".//*[@BigEndian]") + self.assertEqual(len(bfelements), 1) + # + # Try to find BinData with the namespace, + # http://www.openmicroscopy.org/Schemas/BinaryFile/YYYY-MM + # + match = re.match( + "\\{http://www.openmicroscopy.org/Schemas/BinaryFile/" + "\\d{4}-\\d{2}\\}BinData", bfelements[0].tag) + self.assertTrue(match is not None) + def test_01_01_read(self): for xml in (self.GROUPFILES_XML, TIFF_XML): o = O.OMEXML(xml)