Coverage for lobster/tools/trlc/instruction.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.10.5, created at 2025-08-27 13:02 +0000

1from enum import Enum, auto 

2from dataclasses import dataclass 

3 

4 

5class InstructionType(Enum): 

6 CONSTANT_TEXT = auto() 

7 FIELD = auto() 

8 

9 

10@dataclass 

11class Instruction: 

12 """Specification how to convert a TRLC tuple field to string""" 

13 typ: InstructionType 

14 value: str 

15 

16 

17# pylint: disable=invalid-name 

18# The below functions use the CamelCase style instead of snake_case, so that the 

19# look and feel for the developer is that of using a class constructor, because the 

20# functions are essentially just wrappers around the constructor of the Instruction 

21# class. 

22 

23def ConstantInstruction(value: str) -> Instruction: 

24 """Convenience function for constant text.""" 

25 return Instruction(InstructionType.CONSTANT_TEXT, value) 

26 

27 

28def FieldInstruction(value: str) -> Instruction: 

29 """Convenience function for field.""" 

30 return Instruction(InstructionType.FIELD, value)