fairyfly.typing module

Collection of methods for type input checking.

fairyfly.typing.clean_string(value, input_name='')[source]

Clean a string so that it is valid as a filepath.

This will strip out spaces and special characters and raise an error if the string is has more than 100 characters. If the input has no valid characters after stripping out illegal ones, a randomly-generated UUID will be returned.

fairyfly.typing.float_in_range(value, mi=-inf, ma=inf, input_name='')[source]

Check a float value to be between minimum and maximum.

fairyfly.typing.float_in_range_excl(value, mi=-inf, ma=inf, input_name='')[source]

Check a float value to be greater than minimum and less than maximum.

fairyfly.typing.float_in_range_excl_incl(value, mi=-inf, ma=inf, input_name='')[source]

Check a float value to be greater than minimum and less than/equal to maximum.

fairyfly.typing.float_in_range_incl_excl(value, mi=-inf, ma=inf, input_name='')[source]

Check a float value to be greater than/equal to minimum and less than maximum.

fairyfly.typing.float_positive(value, input_name='')[source]

Check a float value to be positive.

fairyfly.typing.int_in_range(value, mi=-inf, ma=inf, input_name='')[source]

Check an integer value to be between minimum and maximum.

fairyfly.typing.int_positive(value, input_name='')[source]

Check if an integer value is positive.

fairyfly.typing.invalid_dict_error(invalid_dict, error)[source]

Raise a ValueError for an invalid dictionary that failed to serialize.

This error message will include the identifier (and display_name) if they are present within the invalid_dict, making it easier for ens users to find the invalid object within large objects like Models.

Parameters:
  • invalid_dict – A dictionary of an invalid fairyfly object that failed to serialize.

  • error

fairyfly.typing.list_with_length(value, length=3, item_type=<class 'float'>, input_name='')[source]

Try to create a list with a certain value.

fairyfly.typing.therm_id_from_uuid(value)[source]

Convert a valid_uuid into a format that THERM will accept.

fairyfly.typing.tuple_with_length(value, length=3, item_type=<class 'float'>, input_name='')[source]

Try to create a tuple with a certain value.

fairyfly.typing.uuid_from_therm_id(value)[source]

Convert a UUID from THERM into a valid_uuid format with 32 characters.

fairyfly.typing.valid_uuid(value, input_name='')[source]

Check that a string is a UUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Note that this is slightly different than the UUIDs used in THERM, which have 4 fewer values for a 8-4-4-12 structure instead of a 8-4-4-4-12 structure. The therm_id_from_uuid method can be used to convert an input here into a format acceptable for THERM.