Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def shift_kw( self , ecl_kw , shift , force_active = False):
"""
See usage documentation on iadd_kw().
"""
self.scalar_apply_kw( ecl_kw , shift , {EclDataType.ECL_INT : self._shift_kw_int,
EclDataType.ECL_FLOAT : self._shift_kw_float ,
EclDataType.ECL_DOUBLE : self._shift_kw_double} , force_active)
[1]: It is possible, but not recommended, to pass in None for
@kw, in which case the method will load the first keyword
it finds in the file.
"""
cfile = CFILE(fileH)
if kw:
if len(kw) > 8:
raise TypeError("Sorry keyword:%s is too long, must be eight characters or less." % kw)
if ecl_type is None:
if cls.int_kw_set.__contains__(kw):
ecl_type = EclDataType.ECL_INT
else:
ecl_type = EclDataType.ECL_FLOAT
ecl_type = warn_and_cast_data_type(ecl_type)
if not isinstance(ecl_type, EclDataType):
raise TypeError("Expected EclDataType, was: %s" % type(ecl_type))
if not ecl_type in [EclDataType.ECL_FLOAT, EclDataType.ECL_INT]:
raise ValueError("The type:%s is invalid when loading keyword:%s" % (ecl_type.type_name, kw))
return cls._load_grdecl(cfile, kw, strict, ecl_type)
def warn_and_cast_data_type(data_type):
if isinstance(data_type, EclDataType):
return data_type
if isinstance(data_type, EclTypeEnum):
if not constant_size_data_type(data_type):
raise ValueError("Cannot cast EclTypeEnum (%d) to EclDataType due "
"to non-constant size. Please provide an EclDataType instead.")
dump_type_deprecation_warning()
return EclDataType(data_type)
def warn_and_cast_data_type(data_type):
if isinstance(data_type, EclDataType):
return data_type
if isinstance(data_type, EclTypeEnum):
if not constant_size_data_type(data_type):
raise ValueError("Cannot cast EclTypeEnum (%d) to EclDataType due "
"to non-constant size. Please provide an EclDataType instead.")
dump_type_deprecation_warning()
return EclDataType(data_type)