Skip to content

Feature Request: Enum Support #6

Description

@ModernMAK
class ChunkType(Enum):
    Folder = "FOLD"
    Data = "DATA"


    @classmethod
    def parse(cls, value: Union[str, bytes]) -> ChunkType:
        if isinstance(value, bytes):
            try:
                _ = value.decode("ascii")
            except UnicodeDecodeError:
                raise ChunkTypeError(value)
            value = _
        try:
            return ChunkType(value)
        except ValueError:
            raise ChunkTypeError(value)

See: https://github.com/ModernMAK/Relic-Game-Tool/blob/f65a07d6ad744b5ca5407b36fedf64f19502ead8/src/relic/chunky/chunk/header.py#L14-L29

Good candidate is DataClassPackable

Something like EnumStruct to differentiate it from DataStruct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions