Skip to content

models

Classes:

Name Description
Action

Action input interface of the inputs section of Control.

AircraftKwargs

Represent the keyword arguments expected by the Aircraft class.

ApacheAllDrawModesKwargs

Keyword arguments for Apache all draw modes.

ApacheDrawModeKwargs

Keyword arguments for Apache draw mode.

ApacheEufdMode

Apache EUFD Mode.

Asset

Representation of an asset with metadata information.

BiosValueInt

Value of BIOS Integer Buffer.

BiosValueStr

Value of BIOS String Buffer.

Color

A superset of HTML 4.0 color names used in CSS 1.

Control

Control section of the BIOS model.

ControlDepiction

Represent the depiction of a control.

ControlKeyData

Describes input data for cockpit controller.

CycleButton

Map BIOS key string with iterator to keep a current value.

DcsBiosPlaneData

DcsBios plane data model.

DeviceRowsNumber

Represent the number of rows for different types of devices.

Direction

Direction of iteration.

DllSdk

DLL SDK.

FixedStep

FixedStep input interface of the inputs section of Control.

FontsConfig

Fonts configuration for LcdInfo.

Gkey

Logitech G-Key.

GuiPlaneInputRequest

Represents a GUI plane input request.

GuiTab

Describe GUI mani window tabs.

Input

Input base class of the inputs section of Control.

IntBuffArgs

Arguments of BIOS Integer Buffer.

LcdButton

LCD Buttons.

LcdInfo

LCD info.

LcdMode

LCD Mode.

LcdSize

LCD dimensions.

LcdType

LCD Type.

LedConstants

LED constants.

LogitechDeviceModel

Logitech Device model.

MouseButton

Representation of a mouse button.

MsgBoxTypes

Message box types.

Output

Output base class of the outputs section of Control.

OutputInt

Integer output interface of the outputs section of Control.

OutputStr

String output interface of the outputs a section of Control.

Release

Representation of a software release.

RequestModel

Represent a request model for handling different input button states and their respective BIOS actions.

RequestType

Internal request types.

SetState

SetState input interface of the inputs section of Control.

SetString

SetString input interface of the inputs section of Control.

StrBuffArgs

Arguments of BIOS String Buffer.

SystemData

Stores system and application-related information.

VariableStep

VariableStep input interface of the inputs section of Control.

ZigZagIterator

An iterator that moves within a range in an oscillating pattern.

Action

Bases: Input

Action input interface of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

validate_interface

Validate.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
172
173
174
175
176
177
178
179
180
181
182
@field_validator('interface')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'action':
        raise ValueError("Invalid value for 'interface'. Only 'action' is allowed.")
    return value

AircraftKwargs

Bases: TypedDict

Represent the keyword arguments expected by the Aircraft class.

ApacheAllDrawModesKwargs

Bases: ApacheDrawModeKwargs

Keyword arguments for Apache all draw modes.

ApacheDrawModeKwargs

Bases: TypedDict

Keyword arguments for Apache draw mode.

ApacheEufdMode

Bases: Enum

Apache EUFD Mode.

Asset

Bases: BaseModel

Representation of an asset with metadata information.

This class is used to encapsulate details about an asset such as its URL, name, label, content type, size and download location. It also provides functionality to validate the asset's properties against specific criteria.

Methods:

Name Description
get_asset_with_name

Retrieve the asset if its name matches the specified file extension and contains the given file name.

get_asset_with_name

get_asset_with_name(
    extension: str = "", file_name: str = ""
) -> Asset | None

Retrieve the asset if its name matches the specified file extension and contains the given file name.

This method checks if the name of the asset ends with the provided file extension and if the given file name is a substring of the asset's name.

Parameters:

Name Type Description Default

extension

str

The file extension to check for.

''

file_name

str

The specific file name to look for within the asset's name.

''

Returns:

Type Description
Asset | None

The Asset instance if the name matches, otherwise None.

Source code in src/dcspy/models.py
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
def get_asset_with_name(self, extension: str = '', file_name: str = '') -> Asset | None:
    """
    Retrieve the asset if its name matches the specified file extension and contains the given file name.

    This method checks if the name of the asset ends with the provided file extension and if the given file name is a substring of the asset's name.

    :param extension: The file extension to check for.
    :param file_name: The specific file name to look for within the asset's name.
    :return: The Asset instance if the name matches, otherwise None.
    """
    if self.name.endswith(extension) and file_name in self.name:
        return self
    return None

BiosValueInt

Bases: BaseModel

Value of BIOS Integer Buffer.

BiosValueStr

Bases: BaseModel

Value of BIOS String Buffer.

Color

Bases: Enum

A superset of HTML 4.0 color names used in CSS 1.

Control

Bases: BaseModel

Control section of the BIOS model.

Methods:

Name Description
make_empty

Make an empty Control object with default values assigned to its attributes.

Attributes:

Name Type Description
input ControlKeyData

Extract inputs data.

output BiosValueInt | BiosValueStr

Extract outputs data.

input property

Extract inputs data.

Returns:

Type Description
ControlKeyData

ControlKeyData

output property

Extract outputs data.

Returns:

Type Description
BiosValueInt | BiosValueStr

Union[BiosValueInt, BiosValueStr]

make_empty classmethod

make_empty() -> Control

Make an empty Control object with default values assigned to its attributes.

Returns:

Type Description
Control

Control an object with empty values.

Source code in src/dcspy/models.py
483
484
485
486
487
488
489
490
@classmethod
def make_empty(cls) -> Control:
    """
    Make an empty Control object with default values assigned to its attributes.

    :return: Control an object with empty values.
    """
    return cls(api_variant='', category='', control_type='', description='', identifier='', inputs=[], outputs=[])

ControlDepiction

Bases: BaseModel

Represent the depiction of a control.

ControlKeyData

ControlKeyData(
    name: str,
    description: str,
    max_value: int,
    suggested_step: int = 1,
)

Describes input data for cockpit controller.

Define a type of input for a cockpit controller.

Parameters:

Name Type Description Default

name

str

Name of the input

required

description

str

Short description

required

max_value

int

Max value (zero-based)

required

suggested_step

int

One (1) by default

1

Methods:

Name Description
from_control

Construct an object based on Control BIOS Model.

Attributes:

Name Type Description
depiction ControlDepiction

Return the depiction of the control.

has_action bool

Check if an input has an action input.

has_fixed_step bool

Check if input has fixed step input.

has_set_state bool

Check if input has set state input.

has_set_string bool

Check if input has set string input.

has_variable_step bool

Check if an input has a variable step input.

input_len int

Get a length of input dictionary.

is_push_button bool

Check if the controller is a push button type.

one_input bool

Check if an input has only one input dict.

Source code in src/dcspy/models.py
288
289
290
291
292
293
294
295
296
297
298
299
300
301
def __init__(self, name: str, description: str, max_value: int, suggested_step: int = 1) -> None:
    """
    Define a type of input for a cockpit controller.

    :param name: Name of the input
    :param description: Short description
    :param max_value: Max value (zero-based)
    :param suggested_step: One (1) by default
    """
    self.name = name
    self.description = description
    self.max_value = max_value
    self.suggested_step = suggested_step
    self.list_dict: list[Inputs] = []

depiction property

depiction: ControlDepiction

Return the depiction of the control.

Returns:

Type Description
ControlDepiction

ControlDepiction object representing the control's name and description.

has_action property

has_action: bool

Check if an input has an action input.

Returns:

Type Description
bool

True if ControlKeyData has action input, False otherwise

has_fixed_step property

has_fixed_step: bool

Check if input has fixed step input.

Returns:

Type Description
bool

True if ControlKeyData has fixed step input, False otherwise

has_set_state property

has_set_state: bool

Check if input has set state input.

Returns:

Type Description
bool

True if ControlKeyData has set state input, False otherwise

has_set_string property

has_set_string: bool

Check if input has set string input.

Returns:

Type Description
bool

True if ControlKeyData has set string input, False otherwise

has_variable_step property

has_variable_step: bool

Check if an input has a variable step input.

Returns:

Type Description
bool

True if ControlKeyData has variable step input, False otherwise

input_len property

input_len: int

Get a length of input dictionary.

Returns:

Type Description
int

Number of inputs as integer

is_push_button property

is_push_button: bool

Check if the controller is a push button type.

Returns:

Type Description
bool

True if a controller is a push button type, False otherwise

one_input property

one_input: bool

Check if an input has only one input dict.

Returns:

Type Description
bool

True if ControlKeyData has only one input, False otherwise

from_control classmethod

from_control(ctrl: Control) -> ControlKeyData

Construct an object based on Control BIOS Model.

Parameters:

Name Type Description Default

ctrl

Control

Control BIOS model

required

Returns:

Type Description
ControlKeyData

ControlKeyData instance

Source code in src/dcspy/models.py
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
@classmethod
def from_control(cls, /, ctrl: Control) -> ControlKeyData:
    """
    Construct an object based on Control BIOS Model.

    :param ctrl: Control BIOS model
    :return: ControlKeyData instance
    """
    try:
        max_value = cls._get_max_value(ctrl.inputs)
        suggested_step: int = max(d.get('suggested_step', 1) for d in ctrl.inputs)  # type: ignore[type-var, assignment]
    except ValueError:
        max_value = 0
        suggested_step = 0
    instance = cls(name=ctrl.identifier, description=ctrl.description, max_value=max_value, suggested_step=suggested_step)
    instance.list_dict = ctrl.inputs
    return instance

CycleButton

Bases: BaseModel

Map BIOS key string with iterator to keep a current value.

Methods:

Name Description
from_request

Convert a request string to a CycleButton instance by extracting the necessary details from the request's components.

from_request classmethod

from_request(req: str) -> CycleButton

Convert a request string to a CycleButton instance by extracting the necessary details from the request's components.

The request is expected to follow a predefined structure where its components are separated by spaces.

Parameters:

Name Type Description Default

req

str

A string a request expected to contain control_name, an underscore, step, and max_value, separated by spaces.

required

Returns:

Type Description
CycleButton

Instance of CycleButton based on extracted data.

Source code in src/dcspy/models.py
544
545
546
547
548
549
550
551
552
553
554
555
556
@classmethod
def from_request(cls, /, req: str) -> CycleButton:
    """
    Convert a request string to a `CycleButton` instance by extracting the necessary details from the request's components.

    The request is expected to follow a predefined structure where its components
    are separated by spaces.

    :param req: A string a request expected to contain `control_name`, an underscore, `step`, and `max_value`, separated by spaces.
    :return: Instance of `CycleButton` based on extracted data.
    """
    selector, _, step, max_value = req.split(' ')
    return CycleButton(ctrl_name=selector, step=int(step), max_value=int(max_value))

DcsBiosPlaneData

Bases: RootModel

DcsBios plane data model.

Methods:

Name Description
get_ctrl

Get Control from DCS-BIOS with name.

get_inputs

Get dict with all not empty inputs for plane.

get_ctrl

get_ctrl(ctrl_name: str) -> Control

Get Control from DCS-BIOS with name.

Parameters:

Name Type Description Default

ctrl_name

str

Control name

required

Returns:

Type Description
Control

Control instance

Source code in src/dcspy/models.py
501
502
503
504
505
506
507
508
509
510
511
512
def get_ctrl(self, ctrl_name: str) -> Control:
    """
    Get Control from DCS-BIOS with name.

    :param ctrl_name: Control name
    :return: Control instance
    """
    for controllers in self.root.values():
        for ctrl, data in controllers.items():
            if ctrl == ctrl_name:
                return Control.model_validate(data)
    return Control.make_empty()

get_inputs

get_inputs() -> dict[str, dict[str, ControlKeyData]]

Get dict with all not empty inputs for plane.

Inputs are grouped in original sections.

Returns:

Type Description
dict[str, dict[str, ControlKeyData]]

Dict with sections and ControlKeyData models.

Source code in src/dcspy/models.py
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
def get_inputs(self) -> dict[str, dict[str, ControlKeyData]]:
    """
    Get dict with all not empty inputs for plane.

    Inputs are grouped in original sections.

    :return: Dict with sections and ControlKeyData models.
    """
    ctrl_key: dict[str, dict[str, ControlKeyData]] = {}

    for section, controllers in self.root.items():
        ctrl_key[section] = {}
        for ctrl, data in controllers.items():
            ctrl_input = Control.model_validate(data).input
            if ctrl_input and not ctrl_input.has_set_string:
                ctrl_key[section][ctrl] = ctrl_input
        if not ctrl_key[section]:
            del ctrl_key[section]
    return ctrl_key

DeviceRowsNumber

Bases: BaseModel

Represent the number of rows for different types of devices.

Attributes:

Name Type Description
total int

Get the total number of rows.

total property

total: int

Get the total number of rows.

Returns:

Type Description
int

The total count of rows as an integer.

Direction

Bases: IntEnum

Direction of iteration.

DllSdk

Bases: BaseModel

DLL SDK.

Methods:

Name Description
get_path

Return the path of the DLL file based on the provided library type.

Attributes:

Name Type Description
header str

Load the header content of the DLL.

header property

header: str

Load the header content of the DLL.

Returns:

Type Description
str

The header content as a string.

get_path

get_path() -> str

Return the path of the DLL file based on the provided library type.

Returns:

Type Description
str

The path of the DLL file as a string.

Source code in src/dcspy/models.py
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
def get_path(self) -> str:
    """
    Return the path of the DLL file based on the provided library type.

    :return: The path of the DLL file as a string.
    """
    arch = 'x64' if all([architecture()[0] == '64bit', maxsize > 2 ** 32, sizeof(c_void_p) > 4]) else 'x86'
    try:
        prog_files = environ['PROGRAMW6432']
    except KeyError:
        prog_files = environ['PROGRAMFILES']
    dll_path = f'{prog_files}\\Logitech Gaming Software\\SDK\\{self.directory}\\{arch}\\Logitech{self.name.capitalize()}.dll'
    return dll_path

FixedStep

Bases: Input

FixedStep input interface of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

validate_interface

Validate.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
117
118
119
120
121
122
123
124
125
126
127
@field_validator('interface')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'fixed_step':
        raise ValueError("Invalid value for 'interface'. Only 'fixed_step' is allowed.")
    return value

FontsConfig

Bases: BaseModel

Fonts configuration for LcdInfo.

Gkey

Bases: BaseModel

Logitech G-Key.

Methods:

Name Description
from_yaml

Construct Gkey from YAML string.

generate

Generate a sequence of G-Keys.

from_yaml classmethod

from_yaml(yaml_str: str) -> Gkey

Construct Gkey from YAML string.

Parameters:

Name Type Description Default

yaml_str

str

G-Key string, example: G2_M1

required

Returns:

Type Description
Gkey

Gkey instance

Source code in src/dcspy/models.py
748
749
750
751
752
753
754
755
756
757
758
759
@classmethod
def from_yaml(cls, /, yaml_str: str) -> Gkey:
    """
    Construct Gkey from YAML string.

    :param yaml_str: G-Key string, example: G2_M1
    :return: Gkey instance
    """
    match = search(r'G(\d+)_M(\d+)', yaml_str)
    if match:
        return cls(**{k: int(i) for k, i in zip(('key', 'mode'), match.groups())})
    raise ValueError(f'Invalid Gkey format: {yaml_str}. Expected: G<i>_M<j>')

generate staticmethod

generate(key: int, mode: int) -> Sequence[Gkey]

Generate a sequence of G-Keys.

Parameters:

Name Type Description Default

key

int

Number of keys

required

mode

int

Number of modes

required

Returns:

Type Description
Sequence[Gkey]

sequence of Gkey instances

Source code in src/dcspy/models.py
761
762
763
764
765
766
767
768
769
770
@staticmethod
def generate(key: int, mode: int) -> Sequence[Gkey]:
    """
    Generate a sequence of G-Keys.

    :param key: Number of keys
    :param mode: Number of modes
    :return: sequence of Gkey instances
    """
    return tuple(Gkey(key=k, mode=m) for k in range(1, key + 1) for m in range(1, mode + 1))

GuiPlaneInputRequest

Bases: BaseModel

Represents a GUI plane input request.

This class is used to construct and manage input requests originating from a graphical interface, such as radio buttons or other control widgets, that interact with plane systems. It allows for structured generation of requests based on provided parameters or configurations and provides utility methods to convert data into request objects.

Methods:

Name Description
from_control_key

Create an instance of GuiPlaneInputRequest based on provided control key data, a request type and optional custom value.

from_plane_gkeys

Create a dictionary mapping unique plane keys to GuiPlaneInputRequest objects, based on input configuration data.

make_empty

Create an empty GuiPlaneInputRequest object with default values assigned to its attributes.

from_control_key classmethod

Create an instance of GuiPlaneInputRequest based on provided control key data, a request type and optional custom value.

The method generates a request string for the GUI widget interface determined by the specified request type (rb_iface) using information from the ControlKeyData object (ctrl_key). If a custom value is provided, it incorporates the value into the generated request for certain request types.

Parameters:

Name Type Description Default

ctrl_key

ControlKeyData

A ControlKeyData is an object used to specify the control key's attributes, such as its name, suggested step, and maximum value.

required

rb_iface

str

A string that represents the requested widget interface type, options include types such as 'rb_action', 'rb_fixed_step_inc', etc.

required

custom_value

str

An optional string used to provide a custom value for specific request types ('rb_custom' or 'rb_set_state').

''

Returns:

Type Description
GuiPlaneInputRequest

A GuiPlaneInputRequest object initialized with the identifier, generated request string and the specified widget interface type.

Source code in src/dcspy/models.py
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
@classmethod
def from_control_key(cls, ctrl_key: ControlKeyData, rb_iface: str, custom_value: str = '') -> GuiPlaneInputRequest:
    """
    Create an instance of GuiPlaneInputRequest based on provided control key data, a request type and optional custom value.

    The method generates a request string for the GUI widget interface determined by the specified request type (rb_iface)
    using information from the ControlKeyData object (ctrl_key).
    If a custom value is provided, it incorporates the value into the generated request for certain request types.

    :param ctrl_key: A ControlKeyData is an object used to specify the control key's attributes, such as its name, suggested step, and maximum value.
    :param rb_iface: A string that represents the requested widget interface type, options include types such as 'rb_action', 'rb_fixed_step_inc', etc.
    :param custom_value: An optional string used to provide a custom value for specific request types ('rb_custom' or 'rb_set_state').
    :return: A GuiPlaneInputRequest object initialized with the identifier, generated request string and the specified widget interface type.
    """
    rb_iface_request = {
        'rb_action': f'{ctrl_key.name} TOGGLE',
        'rb_fixed_step_inc': f'{ctrl_key.name} INC',
        'rb_fixed_step_dec': f'{ctrl_key.name} DEC',
        'rb_cycle': f'{ctrl_key.name} CYCLE {ctrl_key.suggested_step} {ctrl_key.max_value}',
        'rb_custom': f'{ctrl_key.name} {RequestType.CUSTOM.value} {custom_value}',
        'rb_push_button': f'{ctrl_key.name} {RequestType.PUSH_BUTTON.value}',
        'rb_variable_step_plus': f'{ctrl_key.name} +{ctrl_key.suggested_step}',
        'rb_variable_step_minus': f'{ctrl_key.name} -{ctrl_key.suggested_step}',
        'rb_set_state': f'{ctrl_key.name} {custom_value}',
    }
    return cls(identifier=ctrl_key.name, request=rb_iface_request[rb_iface], widget_iface=rb_iface)

from_plane_gkeys classmethod

from_plane_gkeys(
    plane_gkeys: dict[str, str],
) -> dict[str, GuiPlaneInputRequest]

Create a dictionary mapping unique plane keys to GuiPlaneInputRequest objects, based on input configuration data.

The method processes each key-value pair where the value contains a request type and determines the appropriate widget interface based on specified keywords. A mapping dictionary is used to identify widget interfaces corresponding to request types.

Parameters:

Name Type Description Default

plane_gkeys

dict[str, str]

A dictionary where each key is a plane identifier (string) and the value is a space-separated string of configuration data that includes a request type.

required

Returns:

Type Description
dict[str, GuiPlaneInputRequest]

A dictionary mapping each plane identifier (string) to a GuiPlaneInputRequest instance.

Source code in src/dcspy/models.py
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
@classmethod
def from_plane_gkeys(cls, /, plane_gkeys: dict[str, str]) -> dict[str, GuiPlaneInputRequest]:
    """
    Create a dictionary mapping unique plane keys to `GuiPlaneInputRequest` objects, based on input configuration data.

    The method processes each key-value pair where the value contains a request type and determines the appropriate widget
    interface based on specified keywords.
    A mapping dictionary is used to identify widget interfaces corresponding to request types.

    :param plane_gkeys: A dictionary where each key is a plane identifier (string) and the value is
                        a space-separated string of configuration data that includes a request type.
    :return: A dictionary mapping each plane identifier (string) to a `GuiPlaneInputRequest` instance.
    """
    input_reqs = {}
    req_keyword_rb_iface = {
        RequestType.CUSTOM.value: 'rb_custom',
        RequestType.PUSH_BUTTON.value: 'rb_push_button',
        'TOGGLE': 'rb_action',
        'INC': 'rb_fixed_step_inc',
        'DEC': 'rb_fixed_step_dec',
        'CYCLE': 'rb_cycle',
        '+': 'rb_variable_step_plus',
        '-': 'rb_variable_step_minus',
        ' ': 'rb_set_state',
    }

    for gkey, data in plane_gkeys.items():
        try:
            iface = next(rb_iface for req_suffix, rb_iface in req_keyword_rb_iface.items() if req_suffix in data)
        except StopIteration:
            data = ''
            iface = ''
        input_reqs[gkey] = GuiPlaneInputRequest(identifier=data.split(' ')[0], request=data, widget_iface=iface)
    return input_reqs

make_empty classmethod

make_empty() -> GuiPlaneInputRequest

Create an empty GuiPlaneInputRequest object with default values assigned to its attributes.

Returns:

Type Description
GuiPlaneInputRequest

An instance of GuiPlaneInputRequest with default empty values

Source code in src/dcspy/models.py
639
640
641
642
643
644
645
646
@classmethod
def make_empty(cls) -> GuiPlaneInputRequest:
    """
    Create an empty GuiPlaneInputRequest object with default values assigned to its attributes.

    :return: An instance of GuiPlaneInputRequest with default empty values
    """
    return cls(identifier='', request='', widget_iface='')

GuiTab

Bases: IntEnum

Describe GUI mani window tabs.

Input

Bases: BaseModel

Input base class of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

IntBuffArgs

Bases: BaseModel

Arguments of BIOS Integer Buffer.

LcdButton

Bases: Enum

LCD Buttons.

LcdInfo

Bases: BaseModel

LCD info.

Methods:

Name Description
set_fonts

Set fonts configuration.

set_fonts

set_fonts(fonts: FontsConfig) -> None

Set fonts configuration.

Parameters:

Name Type Description Default

fonts

FontsConfig

fonts configuration

required
Source code in src/dcspy/models.py
824
825
826
827
828
829
830
831
832
833
834
835
836
def set_fonts(self, fonts: FontsConfig) -> None:
    """
    Set fonts configuration.

    :param fonts: fonts configuration
    """
    self.font_xs = ImageFont.truetype(fonts.name, fonts.small)
    self.font_s = ImageFont.truetype(fonts.name, fonts.medium)
    self.font_l = ImageFont.truetype(fonts.name, fonts.large)
    self.font_ded = None
    if fonts.ded_font:
        path_falcon_ded = Path(__file__) / '..' / 'resources' / 'falconded.ttf'
        self.font_ded = ImageFont.truetype(str(path_falcon_ded.resolve()), 25)

LcdMode

Bases: Enum

LCD Mode.

LcdSize

Bases: Enum

LCD dimensions.

LcdType

Bases: Enum

LCD Type.

LedConstants

Bases: Enum

LED constants.

LogitechDeviceModel

Bases: BaseModel

Logitech Device model.

It describes all capabilities of any Logitech device.

Methods:

Name Description
get_key_at

Get the keys at the specified row and column in the table layout.

Attributes:

Name Type Description
cols int

Get the number of columns required.

g_keys Sequence[Gkey]

Generate a sequence of G-Keys.

lcd_name str

Get the LCD name in lower case.

mouse_keys Sequence[MouseButton]

Generate a sequence of MouseButtons.

rows DeviceRowsNumber

Get the number of rows for each key category.

cols property

cols: int

Get the number of columns required.

Returns:

Type Description
int

The number of columns required.

g_keys property

g_keys: Sequence[Gkey]

Generate a sequence of G-Keys.

Returns:

Type Description
Sequence[Gkey]

A sequence of G-Keys.

lcd_name property

lcd_name: str

Get the LCD name in lower case.

Returns:

Type Description
str

The name of the LCD as a lowercase string.

mouse_keys property

mouse_keys: Sequence[MouseButton]

Generate a sequence of MouseButtons.

Returns:

Type Description
Sequence[MouseButton]

A sequence of MouseButtons.

rows property

Get the number of rows for each key category.

Returns:

Type Description
DeviceRowsNumber

A DeviceRowsNumber with the number of rows for each category.

get_key_at

get_key_at(row: int, col: int) -> AnyButton | None

Get the keys at the specified row and column in the table layout.

Parameters:

Name Type Description Default

row

int

The row index (zero-based).

required

col

int

The column index (zero-based).

required

Returns:

Type Description
AnyButton | None

The key at the specified row and column, if it exists, otherwise None.

Source code in src/dcspy/models.py
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
def get_key_at(self, row: int, col: int) -> AnyButton | None:
    """
    Get the keys at the specified row and column in the table layout.

    :param row: The row index (zero-based).
    :param col: The column index (zero-based).
    :return: The key at the specified row and column, if it exists, otherwise None.
    """
    try:
        g_keys = [[Gkey(key=r, mode=c) for c in range(1, self.no_g_modes + 1)] for r in range(1, self.no_g_keys + 1)]
        lcd_buttons = []
        mouse_buttons = []

        if self.lcd_keys:
            lcd_buttons = [[lcd_key] + [None] * (self.no_g_modes - 1) for lcd_key in self.lcd_keys]
        if len(self.mouse_keys) > 1:
            mouse_buttons = [[mouse_key] + [None] * (self.no_g_modes - 1) for mouse_key in self.mouse_keys]

        table_layout = g_keys + lcd_buttons + mouse_buttons
        return table_layout[row][col]
    except IndexError:
        return None

MouseButton

Bases: BaseModel

Representation of a mouse button.

Provides functionality for working with mouse buttons, including conversion to string, boolean evaluation, hashing and constructing instances from YAML strings. Supports generating sequences of mouse buttons within a specified range.

Methods:

Name Description
from_yaml

Create a MouseButton object from a YAML string representation.

generate

Generate a sequence of MouseButton objects based on the provided range.

from_yaml classmethod

from_yaml(yaml_str: str) -> MouseButton

Create a MouseButton object from a YAML string representation.

This method parses a given YAML string to extract the button number encoded in the format M_<i> (such as M_1, M_2, etc.) and generates a MouseButton instance for the corresponding button. If the format does not conform to expectations and parsing fails, a ValueError is raised.

Parameters:

Name Type Description Default

yaml_str

str

The YAML string representing the mouse button in the format M_<i>.

required

Returns:

Type Description
MouseButton

A MouseButton instance derived from the specified YAML string.

Raises:

Type Description
ValueError

If the provided YAML string does not match the expected format M_<i>.

Source code in src/dcspy/models.py
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
@classmethod
def from_yaml(cls, /, yaml_str: str) -> MouseButton:
    """
    Create a MouseButton object from a YAML string representation.

    This method parses a given YAML string to extract the button number
    encoded in the format `M_<i>` (such as `M_1`, `M_2`, etc.) and generates
    a MouseButton instance for the corresponding button.
    If the format does not conform to expectations and parsing fails, a ValueError is raised.

    :param yaml_str: The YAML string representing the mouse button in the format `M_<i>`.
    :return: A MouseButton instance derived from the specified YAML string.
    :raises ValueError: If the provided YAML string does not match the expected format `M_<i>`.
    """
    match = search(r'M_(\d+)', yaml_str)
    if match:
        return cls(button=int(match.group(1)))
    raise ValueError(f'Invalid MouseButton format: {yaml_str}. Expected: M_<i>')

generate staticmethod

Generate a sequence of MouseButton objects based on the provided range.

This utility creates MouseButton instances for each integer value within the inclusive range defined by the button_range tuple.

Parameters:

Name Type Description Default

button_range

tuple[int, int]

A tuple of two integers, representing the start and end of the range (inclusive) for generating MouseButton objects.

required

Returns:

Type Description
Sequence[MouseButton]

A tuple containing instantiated MouseButton objects for each value in the specified range.

Source code in src/dcspy/models.py
717
718
719
720
721
722
723
724
725
726
727
728
@staticmethod
def generate(button_range: tuple[int, int]) -> Sequence[MouseButton]:
    """
    Generate a sequence of MouseButton objects based on the provided range.

    This utility creates MouseButton instances for each integer value within
    the inclusive range defined by the ``button_range`` tuple.

    :param button_range: A tuple of two integers, representing the start and end of the range (inclusive) for generating MouseButton objects.
    :return: A tuple containing instantiated MouseButton objects for each value in the specified range.
    """
    return tuple(MouseButton(button=m) for m in range(button_range[0], button_range[1] + 1))

MsgBoxTypes

Bases: Enum

Message box types.

Output

Bases: BaseModel

Output base class of the outputs section of Control.

OutputInt

Bases: Output

Integer output interface of the outputs section of Control.

Methods:

Name Description
validate_interface

Validate.

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
237
238
239
240
241
242
243
244
245
246
247
@field_validator('type')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'integer':
        raise ValueError("Invalid value for 'interface'. Only 'integer' is allowed.")
    return value

OutputStr

Bases: Output

String output interface of the outputs a section of Control.

Methods:

Name Description
validate_interface

Validate.

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
217
218
219
220
221
222
223
224
225
226
227
@field_validator('type')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'string':
        raise ValueError("Invalid value for 'interface'. Only 'string' is allowed.")
    return value

Release

Bases: BaseModel

Representation of a software release.

The Release class provides detailed information about a specific release of a software project, including metadata such as URLs, tags, names, and dates. It also includes functionality to determine whether a release is the latest and to retrieve downloadable assets.

Methods:

Name Description
download_url

Download the URL of a specific asset that matches the given file name and extension.

get_asset

Retrieve the asset if its name matches the specified file extension and contains the given file name.

is_latest

Determine if the provided version is the latest compared to the instance's version.

verify

Verify the integrity of a local file by comparing its checksums with the expected checksum.

Attributes:

Name Type Description
published str

Convert and format the published_at attribute into a human-readable date string in the format 'DD Month YYYY'.

version Version

The version property retrieves the software version as a version.Version object.

published property

published: str

Convert and format the published_at attribute into a human-readable date string in the format 'DD Month YYYY'.

Returns:

Type Description
str

The formatted publication date string.

version property

version: Version

The version property retrieves the software version as a version.Version object.

The version data is parsed from the tag_name attribute, which is expected to be in a format compatible with packaging.version.

Returns:

Type Description
Version

Parsed Version object representing the software version.

download_url

download_url(
    extension: str = "", file_name: str = ""
) -> str

Download the URL of a specific asset that matches the given file name and extension.

This method iterates through the list of assets, applying the criteria specified by the extension and file_name parameters to identify the correct asset. If no asset matches the provided criteria, an empty string is returned.

Parameters:

Name Type Description Default

extension

str

The file extension to search for, defaults to an empty string if not specified.

''

file_name

str

The file name to search for defaults to an empty string if not specified.

''

Returns:

Type Description
str

The download URL of the asset if a match is found, otherwise an empty string.

Source code in src/dcspy/models.py
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
def download_url(self, extension: str = '', file_name: str = '') -> str:
    """
    Download the URL of a specific asset that matches the given file name and extension.

    This method iterates through the list of assets, applying the criteria specified by
    the `extension` and `file_name` parameters to identify the correct asset.
    If no asset matches the provided criteria, an empty string is returned.

    :param extension: The file extension to search for, defaults to an empty string if not specified.
    :param file_name: The file name to search for defaults to an empty string if not specified.
    :return: The download URL of the asset if a match is found, otherwise an empty string.
    """
    asset = self.get_asset(extension=extension, file_name=file_name)
    if asset is not None:
        return asset.browser_download_url
    return ''

get_asset

get_asset(
    extension: str = "", file_name: str = ""
) -> Asset | None

Retrieve the asset if its name matches the specified file extension and contains the given file name.

This method checks if the name of the asset ends with the provided file extension and if the given file name is a substring of the asset's name.

Parameters:

Name Type Description Default

extension

str

The file extension to check for.

''

file_name

str

The specific file name to look for within the asset's name.

''

Returns:

Type Description
Asset | None

The Asset instance if the name matches, otherwise None.

Source code in src/dcspy/models.py
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
def get_asset(self, extension: str = '', file_name: str = '') -> Asset | None:
    """
    Retrieve the asset if its name matches the specified file extension and contains the given file name.

    This method checks if the name of the asset ends with the provided file extension and if the given file name is a substring of the asset's name.

    :param extension: The file extension to check for.
    :param file_name: The specific file name to look for within the asset's name.
    :return: The Asset instance if the name matches, otherwise None.
    """
    try:
        asset = next(asset for asset in self.assets if asset.get_asset_with_name(extension=extension, file_name=file_name) is not None)
    except StopIteration:
        asset = None
    return asset

is_latest

is_latest(current_ver: str | Version) -> bool

Determine if the provided version is the latest compared to the instance's version.

This method compares the version of the current object with a given version to check if the current version is equal to or earlier than the given version.

Parameters:

Name Type Description Default

current_ver

str | Version

The version to compare against, it can be provided as a string or as a version.Version object.

required

Returns:

Type Description
bool

Returns True if the current version is less than or equal to the provided version (indicating it is the latest), False otherwise.

Source code in src/dcspy/models.py
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
def is_latest(self, current_ver: str | version.Version) -> bool:
    """
    Determine if the provided version is the latest compared to the instance's version.

    This method compares the version of the current object with a given version to check
    if the current version is equal to or earlier than the given version.

    :param current_ver: The version to compare against, it can be provided as a string or as a version.Version object.
    :return: Returns True if the current version is less than or equal to the provided version (indicating it is the latest), False otherwise.
    """
    if isinstance(current_ver, str):
        current_ver = version.parse(current_ver)
    return self.version <= current_ver

verify

verify(
    local_file: Path,
    temp_digest=Path(gettempdir())
    / f"DIGESTS_{strftime('%Y%m%d_%H%M%S')}",
) -> tuple[bool, dict[str, bool]]

Verify the integrity of a local file by comparing its checksums with the expected checksum.

It returns True if the checksums match, indicating that the file is intact and unaltered; otherwise, it returns False.

Parameters:

Name Type Description Default

local_file

Path

The path to the local file whose integrity is to be verified.

required

temp_digest

Temporary file to store the digest in the local file.

Path(gettempdir()) / f'DIGESTS_{strftime('%Y%m%d_%H%M%S')}'

Returns:

Type Description
tuple[bool, dict[str, bool]]

True if the computed checksum matches the expected checksum, False otherwise.

Source code in src/dcspy/models.py
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
def verify(self, local_file: Path,
           temp_digest = Path(gettempdir()) / f'DIGESTS_{datetime.now().strftime("%Y%m%d_%H%M%S")}') -> tuple[bool, dict[str, bool]]:
    """
    Verify the integrity of a local file by comparing its checksums with the expected checksum.

    It returns True if the checksums match, indicating that the file is intact and unaltered; otherwise, it returns False.

    :param local_file: The path to the local file whose integrity is to be verified.
    :param temp_digest: Temporary file to store the digest in the local file.
    :return: True if the computed checksum matches the expected checksum, False otherwise.
    """
    from dcspy.utils import download_file, verify_hashes

    url = self.download_url(extension='', file_name='DIGESTS')
    download_file(url=url, save_path=temp_digest)
    result = verify_hashes(file_path=local_file, digest_file=temp_digest)
    return result

RequestModel

Bases: BaseModel

Represent a request model for handling different input button states and their respective BIOS actions.

This class is designed to manage various types of input requests, including cycle, custom and push-button requests. It provides functionality to validate input data, generate requests in byte format, and interpret requests based on specific conditions. It also supports creating empty request models and handling interactions with BIOS configuration via designated callable functions.

Methods:

Name Description
bytes_requests

Generate and returns a list of byte strings based on a specific request input.

from_request

Create an instance of the RequestModel class using a specific request string.

make_empty

Create an empty instance of RequestModel with default values for its attributes.

validate_interface

Validate the provided interface name ensuring it consists only of uppercase letters, digits or underscores.

Attributes:

Name Type Description
is_custom bool

Check if the request is of type custom.

is_cycle bool

Check if the instance has a valid cycle.

is_push_button bool

Identify if the request is a push-button type.

is_custom property

is_custom: bool

Check if the request is of type custom.

This property evaluates whether the raw_request attribute of the object contains a custom request type, based on the predefined RequestType.CUSTOM value.

Returns:

Type Description
bool

Boolean indicating if the request is of type custom.

is_cycle property

is_cycle: bool

Check if the instance has a valid cycle.

This property checks the internal state of the instance to determine whether a valid cycle exists. A cycle is represented by the presence of a truthy value in the cycle attribute.

Returns:

Type Description
bool

Returns True if a valid cycle exists, otherwise False.

is_push_button property

is_push_button: bool

Identify if the request is a push-button type.

This property checks if the raw_request contains a specific value indicating a push-button request type and returns a boolean result accordingly.

Returns:

Type Description
bool

True if the request is of type push-button, else False

bytes_requests

bytes_requests(key_down: int | None = None) -> list[bytes]

Generate and returns a list of byte strings based on a specific request input.

The method generates a string request using the provided argument key_down. It then splits the generated string request using the | delimiter and converts each segment into a byte string.

Parameters:

Name Type Description Default

key_down

int | None

Accepts an integer representing the key value or None for default behavior.

None

Returns:

Type Description
list[bytes]

A list containing byte strings derived from the generated request.

Source code in src/dcspy/models.py
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
def bytes_requests(self, key_down: int | None = None) -> list[bytes]:
    """
    Generate and returns a list of byte strings based on a specific request input.

    The method generates a string request using the provided argument `key_down`.
    It then splits the generated string request using the `|` delimiter and converts each segment into a byte string.

    :param key_down: Accepts an integer representing the key value or None for default behavior.
    :return: A list containing byte strings derived from the generated request.
    """
    request = self._generate_request_based_on_case(key_down)
    return [bytes(req, 'utf-8') for req in request.split('|')]

from_request classmethod

from_request(
    key: AnyButton,
    request: str,
    get_bios_fn: Callable[[str], BiosValue],
) -> RequestModel

Create an instance of the RequestModel class using a specific request string.

This method processes the provided request string to extract necessary information, such as control name and cycle details. It initializes a CycleButton instance using the request information if applicable. The function then returns a RequestModel instance, contains the parsed data and additional state information.

Parameters:

Name Type Description Default

key

AnyButton

The key representing the AnyButton instance tied to the request.

required

request

str

The raw request string providing all request details.

required

get_bios_fn

Callable[[str], BiosValue]

A callable function that retrieves BIOS values, function takes a string input (BIOS key) and returns a corresponding BiosValue object.

required

Returns:

Type Description
RequestModel

A new instance of RequestModel contains data parsed from the provided request string and supporting parameters.

Source code in src/dcspy/models.py
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
@classmethod
def from_request(cls, key: AnyButton, request: str, get_bios_fn: Callable[[str], BiosValue]) -> RequestModel:
    """
    Create an instance of the RequestModel class using a specific request string.

    This method processes the provided request string to extract necessary
    information, such as control name and cycle details.
    It initializes a CycleButton instance using the request information if applicable.
    The function then returns a RequestModel instance, contains the parsed data and additional state information.

    :param key: The key representing the `AnyButton` instance tied to the request.
    :param request: The raw request string providing all request details.
    :param get_bios_fn: A callable function that retrieves BIOS values, function takes
                        a string input (BIOS key) and returns a corresponding `BiosValue` object.
    :return: A new instance of `RequestModel` contains data parsed from the provided request string and supporting parameters.
    """
    cycle_button = CycleButton(ctrl_name='', step=0, max_value=0)
    if RequestType.CYCLE.value in request:
        cycle_button = CycleButton.from_request(request)
    ctrl_name = request.split(' ')[0]
    return RequestModel(ctrl_name=ctrl_name, raw_request=request, get_bios_fn=get_bios_fn, cycle=cycle_button, key=key)

make_empty classmethod

make_empty(key: AnyButton) -> RequestModel

Create an empty instance of RequestModel with default values for its attributes.

Parameters:

Name Type Description Default

key

AnyButton

Represents the key parameter, which will be used as a button object type for the RequestModel instance.

required

Returns:

Type Description
RequestModel

A new instance of RequestModel initialized with default attribute values and the provided key parameter.

Source code in src/dcspy/models.py
1312
1313
1314
1315
1316
1317
1318
1319
1320
@classmethod
def make_empty(cls, key: AnyButton) -> RequestModel:
    """
    Create an empty instance of RequestModel with default values for its attributes.

    :param key: Represents the key parameter, which will be used as a button object type for the RequestModel instance.
    :return: A new instance of RequestModel initialized with default attribute values and the provided key parameter.
    """
    return cls(ctrl_name='EMPTY', raw_request='', get_bios_fn=int, cycle=CycleButton(ctrl_name='', step=0, max_value=0), key=key)

validate_interface

validate_interface(value: str) -> str

Validate the provided interface name ensuring it consists only of uppercase letters, digits or underscores.

This validator enforces strict naming conventions for control names, rejecting any value that contains invalid characters or is an empty string.

Parameters:

Name Type Description Default

value

str

The interface name to validate.

required

Returns:

Type Description
str

The validated interface name if it passes all checks.

Raises:

Type Description
ValueError

If the given value is an empty string or contains characters other than uppercase letters (A-Z), digits (0-9), or underscores (_).

Source code in src/dcspy/models.py
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
@field_validator('ctrl_name')
def validate_interface(cls, value: str) -> str:
    """
    Validate the provided interface name ensuring it consists only of uppercase letters, digits or underscores.

    This validator enforces strict naming conventions for control names, rejecting any value that contains invalid characters or is an empty string.

    :param value: The interface name to validate.
    :return: The validated interface name if it passes all checks.
    :raises ValueError: If the given value is an empty string or contains characters other than uppercase letters (A-Z), digits (0-9), or underscores (_).
    """
    if not value or not all(ch.isupper() or ch == '_' or ch.isdigit() for ch in value):
        raise ValueError("Invalid value for 'ctrl_name'. Only A-Z, 0-9 and _ are allowed.")
    return value

RequestType

Bases: Enum

Internal request types.

SetState

Bases: Input

SetState input interface of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

validate_interface

Validate.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
154
155
156
157
158
159
160
161
162
163
164
@field_validator('interface')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'set_state':
        raise ValueError("Invalid value for 'interface'. Only 'set_state' is allowed.")
    return value

SetString

Bases: Input

SetString input interface of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

validate_interface

Validate.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
189
190
191
192
193
194
195
196
197
198
199
@field_validator('interface')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'set_string':
        raise ValueError("Invalid value for 'interface'. Only 'set_string' is allowed.")
    return value

StrBuffArgs

Bases: BaseModel

Arguments of BIOS String Buffer.

SystemData

Bases: BaseModel

Stores system and application-related information.

Attributes:

Name Type Description
sha str

Provides a property to retrieve the SHA part of the DCS-BIOS repo.

sha property

sha: str

Provides a property to retrieve the SHA part of the DCS-BIOS repo.

Returns:

Type Description
str

The extracted SHA value from the dcs_bios_ver string.

VariableStep

Bases: Input

VariableStep input interface of the inputs section of Control.

Methods:

Name Description
get

Access an attribute and get default when is not available.

validate_interface

Validate.

get

get(attribute: str, default=None) -> Any | None

Access an attribute and get default when is not available.

Parameters:

Name Type Description Default

attribute

str
required

default

None

Returns:

Type Description
Any | None
Source code in src/dcspy/models.py
102
103
104
105
106
107
108
109
110
def get(self, attribute: str, default=None) -> Any | None:
    """
    Access an attribute and get default when is not available.

    :param attribute:
    :param default:
    :return:
    """
    return self.model_dump().get(attribute, default)

validate_interface

validate_interface(value: str) -> str

Validate.

Parameters:

Name Type Description Default

value

str
required

Returns:

Type Description
str
Source code in src/dcspy/models.py
136
137
138
139
140
141
142
143
144
145
146
@field_validator('interface')
def validate_interface(cls, value: str) -> str:
    """
    Validate.

    :param value:
    :return:
    """
    if value != 'variable_step':
        raise ValueError("Invalid value for 'interface'. Only 'variable_step' is allowed.")
    return value

ZigZagIterator

ZigZagIterator(current: int, max_val: int, step: int = 1)

An iterator that moves within a range in an oscillating pattern.

The iterator starts at a given current value, progresses or retreats based on the defined step size and changes a direction upon reaching the boundaries of the range (max_val and 0). This allows for oscillating behavior within the specified limits. The class also provides access to its current direction of iteration.

Represent a simple iterator with a defined range and step increment.

The iterator maintains a current value, a maximum limit, and adjusts its progression based on the specified step. It also tracks the direction of iteration internally.

Parameters:

Name Type Description Default

current

int

The starting point of the iterator.

required

max_val

int

The upper limit of the iterator range.

required

step

int

The increment value for each iteration, defaults to 1.

1

Attributes:

Name Type Description
direction Direction

Represent the direction of an iterator or entity within a defined context.

Source code in src/dcspy/models.py
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
def __init__(self, current: int, max_val: int, step: int = 1) -> None:
    """
    Represent a simple iterator with a defined range and step increment.

    The iterator maintains a current value, a maximum limit, and adjusts
    its progression based on the specified step.
    It also tracks the direction of iteration internally.

    :param current: The starting point of the iterator.
    :param max_val: The upper limit of the iterator range.
    :param step: The increment value for each iteration, defaults to 1.
    """
    self.current = current
    self.step = step
    self.max_val = max_val
    self._direction = Direction.FORWARD

direction property writable

direction: Direction

Represent the direction of an iterator or entity within a defined context.

This property retrieves the current direction of the iterator.

Returns:

Type Description
Direction

The current direction of the iterator.