def create_component(nexus_wrapper: NexusWrapper, component_group: h5py.Group) -> Component: if (nexus_wrapper.get_attribute_value( component_group, CommonAttrs.NX_CLASS) == CHOPPER_CLASS_NAME): return Component(nexus_wrapper, component_group, ChopperShape(nexus_wrapper, component_group)) if (nexus_wrapper.get_attribute_value( component_group, CommonAttrs.NX_CLASS) in PIXEL_COMPONENT_TYPES and "pixel_shape" in component_group): return Component(nexus_wrapper, component_group, PixelShape(nexus_wrapper, component_group)) return Component(nexus_wrapper, component_group)
def test_GIVEN_group_with_bytes_attribute_WHEN_getting_attribute_value_THEN_returns_value_as_str( ): wrapper = NexusWrapper(filename="test_attr_as_str") test_group = wrapper.nexus_file.create_group("test_group") attr_value = b"test_attr_value" attr_name = "test_attr" test_group.attrs[attr_name] = attr_value attr_value_as_str = attr_value.decode("utf-8") assert wrapper.get_attribute_value(test_group, attr_name) == attr_value_as_str