def test_export_format(self): self.assertEqual(FieldConfig.exportFormat("file.grdecl"), EnkfFieldFileFormatEnum.ECL_GRDECL_FILE) self.assertEqual(FieldConfig.exportFormat("file.xyz.grdecl"), EnkfFieldFileFormatEnum.ECL_GRDECL_FILE) self.assertEqual(FieldConfig.exportFormat("file.roFF"), EnkfFieldFileFormatEnum.RMS_ROFF_FILE) self.assertEqual(FieldConfig.exportFormat("file.xyz.roFF"), EnkfFieldFileFormatEnum.RMS_ROFF_FILE) with self.assertRaises(ValueError): FieldConfig.exportFormat("file.xyz") with self.assertRaises(ValueError): FieldConfig.exportFormat("file.xyz")
def export(self, filename, file_type=None, init_file=None): output_transform = False if file_type is None: try: file_type = FieldConfig.exportFormat(filename) except ValueError: sys.stderr.write( "Sorry - could not infer output format from filename:%s\n" % filename) return False self._export(filename, None, file_type, output_transform, init_file) return True