Beispiel #1
0
class OutputFormat(base.StringOptionParameter):
    name = 'output_format'
    default = constants.OutputFormatName.OCGIS
    valid = list(get_converter_map().keys())

    def __init__(self, init_value=None):
        try:
            if isinstance(init_value, six.string_types):
                init_value = init_value.lower()
            # Maintain the old CSV-Shapefile output format key.
            if init_value == 'csv+':
                init_value = constants.OutputFormatName.CSV_SHAPEFILE
            # Maintain the old NumPy key.
            if init_value == 'numpy':
                init_value = constants.OutputFormatName.OCGIS
        except AttributeError:
            # Allow the object to initialized by itself.
            if not isinstance(init_value, self.__class__):
                raise
        super(OutputFormat, self).__init__(init_value=init_value)

    @classmethod
    def iter_possible(cls):
        for element in cls.valid:
            yield element

    def get_converter_class(self):
        return get_converter(self.value)

    def _get_meta_(self):
        ret = 'The output format is "{0}".'.format(self.value)
        return ret
Beispiel #2
0
 def test_get_converter_map(self):
     cmap = get_converter_map()
     self.assertEqual(cmap[constants.OUTPUT_FORMAT_NETCDF_UGRID_2D_FLEXIBLE_MESH],
                      NcUgrid2DFlexibleMeshConverter)
     self.assertEqual(cmap[constants.OUTPUT_FORMAT_METADATA_JSON], MetaJSONConverter)
Beispiel #3
0
 def test_get_converter_map(self):
     cmap = get_converter_map()
     self.assertEqual(cmap[constants.OutputFormatName.METADATA_JSON],
                      MetaJSONConverter)
Beispiel #4
0
 def test_get_converter_map(self):
     cmap = get_converter_map()
     self.assertEqual(cmap[constants.OutputFormatName.METADATA_JSON], MetaJSONConverter)