Saltar a contenido

Args Module

Args

Class to handle command line arguments.

Source code in devices\raspberry_pi_5\src\args\__init__.py
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
class Args:
    """
    Class to handle command line arguments.
    """

    # Prefix for command line arguments
    PREFIX = '--'

    def __init__(self, parser: ArgumentParser):
        """
        Initialize the Args class with an ArgumentParser instance.

        Args:
            parser (ArgumentParser): The argument parser instance.
        """
        # Check the type of parser
        is_instance(parser, ArgumentParser)
        self.__parser = parser

        # Initialize the args dictionary
        self.__args: dict[str, Any] = {}

    @staticmethod
    def check_yolo_version(yolo_version: str) -> None:
        """
        Check the validity of YOLO version.

        Args:
            yolo_version (str): Version of the YOLO model.
        Raises:
            ValueError: If the YOLO version is not valid.
        """
        if yolo_version not in VERSIONS:
            mapped_yolo_versions = add_single_quotes_to_list_elements(VERSIONS)
            raise ValueError(
                f"Invalid yolo version: {yolo_version}. Must be one of the following: {', '.join(mapped_yolo_versions)}."
            )

    @staticmethod
    def check_model_name(model_name: str) -> None:
        """
        Check the validity of model name.

        Args:
            model_name (str): Name of the YOLO model.
        Raises:
            ValueError: If the model name is not valid.
        """
        if model_name not in MODELS_NAME:
            mapped_yolo_models_name = add_single_quotes_to_list_elements(
                MODELS_NAME
            )
            raise ValueError(
                f"Invalid model name: {model_name}. Must be one of the following: {', '.join(mapped_yolo_models_name)}."
            )

    @classmethod
    def _get_attribute_name(
        cls,
        flag: FlagProtocol,
        disabled: bool = False
    ) -> str:
        """
        Get the attribute name.

        Args:
            flag (FlagProtocol): The flag to get the attribute name for.
            disabled (bool): If True, the attribute will be prefixed with 'no-' to indicate it is disabled.
        Returns:
            str: The attribute name with the prefix.
        """
        if not disabled:
            return f'{cls.PREFIX}{flag.parsed_name}'
        return f'{cls.PREFIX}no-{flag.parsed_name}'

    def _parse_args_as_dict(self):
        """
        Parse the arguments and return them as a dictionary.
        """
        # Parse the arguments
        args = self.__parser.parse_args()

        # Get the arguments as a dictionary
        self.__args = vars(args)

    def _get_attribute_from_args_dict(self, flag: FlagProtocol) -> Any:
        """
        Get the attribute name from the args dictionary.

        Args:
            flag (FlagProtocol): The flag to get the attribute name for.
        Returns:
            Any: The value of the attribute from the args.
        Raises:
            KeyError: If the attribute is not found in the args dictionary.
        """
        # Check if the args have been parsed
        parsed = False
        if not self.__args:
            parsed = True
            self._parse_args_as_dict()

        # Substitute whitespaces with underscores
        attribute = flag.parsed_name.replace(' ', '_')

        # Substitute dashes with underscores
        attribute = attribute.replace('-', '_')

        # Check if the attribute exists in the args dictionary
        if attribute not in self.__args and not parsed:
            # If the attribute does not exist, parse the args again
            self._parse_args_as_dict()

        if attribute not in self.__args:
            raise KeyError(
                f"Attribute '{attribute}' not found as an argument in the parser."
            )
        return self.__args[attribute]

    def _add_boolean_argument(
        self,
        flag: FlagProtocol,
        default: bool = False
    ) -> None:
        """
        Add a boolean argument to the parser.

        Args:
            flag (FlagProtocol): The flag to be added.
            default (bool): Default value for the boolean argument.
        """
        # Add the boolean argument to the parser
        name = flag.parsed_name
        self.__parser.add_argument(
            self._get_attribute_name(flag, disabled=True),
            dest=name,
            action="store_false",
            help=f"Set {name.lower()} flag as 'False'"
        )
        self.__parser.add_argument(
            self._get_attribute_name(flag),
            dest=name,
            action="store_true",
            help=f"Set {name.lower()} flag as 'True'"
        )
        self.__parser.set_defaults(**{name: default})

    def _add_non_boolean_argument(
        self,
        flag: FlagProtocol,
        type: Callable[[str], Any] | FileType | str,
        default: Optional[Any] = None,
        required: bool = False,
        choices: Optional[List[Any]] = None,
        help: Optional[str] = None,
        nargs: Optional[str] = None
    ) -> None:
        """
        Add a non-boolean argument to the parser.

        Args:
            flag (FlagProtocol): The flag to be added.
            type (Callable[[str], Any] | FileType | str): The type of the argument.
            default (Optional[Any]): Default value for the argument.
            required (bool): If True, the argument is required.
            choices (Optional[List[Any]]): List of valid choices for the argument.
            help (Optional[str]): Help text for the argument.
            nargs (Optional[str]): Number of arguments expected.
        """
        # Add the non-boolean argument to the parser
        name = flag.parsed_name
        self.__parser.add_argument(
            self._get_attribute_name(flag),
            dest=name,
            type=type,
            default=default,
            required=required,
            choices=choices,
            nargs=nargs,
            help=f"Set {name.lower()} argument" if not help else help
        )

    def add_debug_argument(
        self,
        default: bool = False
    ) -> None:
        """
        Add debug argument to the parser.

        Args:
            default (bool): Default value for the debug argument. Defaults to False.
        """
        self._add_boolean_argument(Flag.DEBUG, default=default)

    def get_debug(self) -> bool:
        """
        Get the debug argument from the parser.

        Returns:
            bool: The value of the debug argument.
        """
        return self._get_attribute_from_args_dict(Flag.DEBUG)

    def add_server_argument(
        self,
        default: bool = False
    ) -> None:
        """
        Add server argument to the parser.

        Args:
            default (bool): Default value for the server argument.
        """
        self._add_boolean_argument(Flag.SERVER, default)

    def get_server(self):
        """
        Get the server argument from the parser.

        Returns:
            bool: The value of the server argument.
        """
        return self._get_attribute_from_args_dict(Flag.SERVER)

    def add_serial_argument(
        self,
        default: bool = False
    ) -> None:
        """
        Add serial argument to the parser.

        Args:
            default (bool): Default value for the serial argument.
        """
        self._add_boolean_argument(Flag.SERIAL, default)

    def get_serial(self) -> bool:
        """
        Get the serial argument from the parser.

        Returns:
            bool: The value of the serial argument.
        """
        return self._get_attribute_from_args_dict(Flag.SERIAL)

    def add_ip_argument(
        self,
        default: str = '0.0.0.0'
    ) -> None:
        """
        Add IP argument to the parser.

        Args:
            default (str): Default IP address for the server.
        """
        self._add_non_boolean_argument(
            Flag.IP,
            type=str,
            default=default,
            help="Set the IP address for the server"
        )

    def get_ip(self) -> str:
        """
        Get the IP argument from the parser.

        Returns:
            str: The value of the IP argument.
        """
        return self._get_attribute_from_args_dict(Flag.IP)

    def add_port_argument(
        self,
        default: int = 8765
    ) -> None:
        """
        Add port argument to the parser.

        Args:
            default (int): Default port number for the server.
        """
        self._add_non_boolean_argument(
            Flag.PORT,
            type=int,
            default=default,
            choices=[*range(1, 65536)],
            help="Set the port number for the server"
        )

    def get_port(self) -> int:
        """
        Get the port argument from the parser.

        Returns:
            int: The value of the port argument.
        """
        return self._get_attribute_from_args_dict(Flag.PORT)

    def add_yolo_input_model_argument(self) -> None:
        """
        Add YOLO input model argument to the parser.
        """
        self._add_non_boolean_argument(
            Flag.INPUT_MODEL,
            type=str,
            required=True,
            help='YOLO input model',
            choices=MODELS_NAME
        )

    def get_yolo_input_model(self) -> str:
        """
        Get the YOLO input model argument from the parser.

        Returns:
            str: The value of the YOLO input model argument.
        """
        return self._get_attribute_from_args_dict(Flag.INPUT_MODEL)

    def add_yolo_version_argument(self) -> None:
        """
        Add YOLO version argument to the parser.
        """
        self._add_non_boolean_argument(
            Flag.VERSION,
            type=str,
            required=True,
            help='YOLO model version',
            choices=VERSIONS
        )

    def get_yolo_version(self) -> str:
        """
        Get the YOLO version argument from the parser.

        Returns:
            str: The value of the YOLO version argument.
        """
        return self._get_attribute_from_args_dict(Flag.VERSION)

    def add_movement_argument(
        self,
        default: bool = True
    ) -> None:
        """
        Add movement argument to the parser.

        Args:
            default (bool): Default value for the movement argument.
        """
        self._add_boolean_argument(Flag.MOVEMENT, default=default)

    def get_movement(self) -> bool:
        """
        Get the movement argument from the parser.

        Returns:
            bool: The value of the movement argument.
        """
        return self._get_attribute_from_args_dict(Flag.MOVEMENT)

    def add_rplidar_is_upside_down_argument(
        self,
        default: bool = False
    ) -> None:
        """
        Add RPLidar upside down argument to the parser.

        Args:
            default (bool): Default value for the RPLidar upside down argument.
        """
        self._add_boolean_argument(Flag.RPLIDAR_IS_UPSIDE_DOWN, default=default)

    def get_rplidar_is_upside_down(self) -> bool:
        """
        Get the RPLidar upside down argument from the parser.

        Returns:
            bool: The value of the RPLidar upside down argument.
        """
        return self._get_attribute_from_args_dict(Flag.RPLIDAR_IS_UPSIDE_DOWN)

    def add_rplidar_angle_rotation_argument(
        self,
        default: float = 0.0
    ) -> None:
        """
        Add RPLidar angle rotation argument to the parser.

        Args:
            default (float): Default value for the RPLidar angle rotation
            argument.
        """
        self._add_non_boolean_argument(
            Flag.RPLIDAR_ANGLE_ROTATION,
            type=float,
            default=default,
            help='RPLidar angle rotation in degrees'
        )

    def get_rplidar_angle_rotation(self) -> float:
        """
        Get the RPLidar angle rotation argument from the parser.

        Returns:
            float: The value of the RPLidar angle rotation argument.
        """
        return self._get_attribute_from_args_dict(Flag.RPLIDAR_ANGLE_ROTATION)

__init__(parser)

Initialize the Args class with an ArgumentParser instance.

Parameters:

Name Type Description Default
parser ArgumentParser

The argument parser instance.

required
Source code in devices\raspberry_pi_5\src\args\__init__.py
18
19
20
21
22
23
24
25
26
27
28
29
30
def __init__(self, parser: ArgumentParser):
    """
    Initialize the Args class with an ArgumentParser instance.

    Args:
        parser (ArgumentParser): The argument parser instance.
    """
    # Check the type of parser
    is_instance(parser, ArgumentParser)
    self.__parser = parser

    # Initialize the args dictionary
    self.__args: dict[str, Any] = {}

add_debug_argument(default=False)

Add debug argument to the parser.

Parameters:

Name Type Description Default
default bool

Default value for the debug argument. Defaults to False.

False
Source code in devices\raspberry_pi_5\src\args\__init__.py
192
193
194
195
196
197
198
199
200
201
202
def add_debug_argument(
    self,
    default: bool = False
) -> None:
    """
    Add debug argument to the parser.

    Args:
        default (bool): Default value for the debug argument. Defaults to False.
    """
    self._add_boolean_argument(Flag.DEBUG, default=default)

add_ip_argument(default='0.0.0.0')

Add IP argument to the parser.

Parameters:

Name Type Description Default
default str

Default IP address for the server.

'0.0.0.0'
Source code in devices\raspberry_pi_5\src\args\__init__.py
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
def add_ip_argument(
    self,
    default: str = '0.0.0.0'
) -> None:
    """
    Add IP argument to the parser.

    Args:
        default (str): Default IP address for the server.
    """
    self._add_non_boolean_argument(
        Flag.IP,
        type=str,
        default=default,
        help="Set the IP address for the server"
    )

add_movement_argument(default=True)

Add movement argument to the parser.

Parameters:

Name Type Description Default
default bool

Default value for the movement argument.

True
Source code in devices\raspberry_pi_5\src\args\__init__.py
350
351
352
353
354
355
356
357
358
359
360
def add_movement_argument(
    self,
    default: bool = True
) -> None:
    """
    Add movement argument to the parser.

    Args:
        default (bool): Default value for the movement argument.
    """
    self._add_boolean_argument(Flag.MOVEMENT, default=default)

add_port_argument(default=8765)

Add port argument to the parser.

Parameters:

Name Type Description Default
default int

Default port number for the server.

8765
Source code in devices\raspberry_pi_5\src\args\__init__.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
def add_port_argument(
    self,
    default: int = 8765
) -> None:
    """
    Add port argument to the parser.

    Args:
        default (int): Default port number for the server.
    """
    self._add_non_boolean_argument(
        Flag.PORT,
        type=int,
        default=default,
        choices=[*range(1, 65536)],
        help="Set the port number for the server"
    )

add_rplidar_angle_rotation_argument(default=0.0)

Add RPLidar angle rotation argument to the parser.

Parameters:

Name Type Description Default
default float

Default value for the RPLidar angle rotation

0.0
Source code in devices\raspberry_pi_5\src\args\__init__.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
def add_rplidar_angle_rotation_argument(
    self,
    default: float = 0.0
) -> None:
    """
    Add RPLidar angle rotation argument to the parser.

    Args:
        default (float): Default value for the RPLidar angle rotation
        argument.
    """
    self._add_non_boolean_argument(
        Flag.RPLIDAR_ANGLE_ROTATION,
        type=float,
        default=default,
        help='RPLidar angle rotation in degrees'
    )

add_rplidar_is_upside_down_argument(default=False)

Add RPLidar upside down argument to the parser.

Parameters:

Name Type Description Default
default bool

Default value for the RPLidar upside down argument.

False
Source code in devices\raspberry_pi_5\src\args\__init__.py
371
372
373
374
375
376
377
378
379
380
381
def add_rplidar_is_upside_down_argument(
    self,
    default: bool = False
) -> None:
    """
    Add RPLidar upside down argument to the parser.

    Args:
        default (bool): Default value for the RPLidar upside down argument.
    """
    self._add_boolean_argument(Flag.RPLIDAR_IS_UPSIDE_DOWN, default=default)

add_serial_argument(default=False)

Add serial argument to the parser.

Parameters:

Name Type Description Default
default bool

Default value for the serial argument.

False
Source code in devices\raspberry_pi_5\src\args\__init__.py
234
235
236
237
238
239
240
241
242
243
244
def add_serial_argument(
    self,
    default: bool = False
) -> None:
    """
    Add serial argument to the parser.

    Args:
        default (bool): Default value for the serial argument.
    """
    self._add_boolean_argument(Flag.SERIAL, default)

add_server_argument(default=False)

Add server argument to the parser.

Parameters:

Name Type Description Default
default bool

Default value for the server argument.

False
Source code in devices\raspberry_pi_5\src\args\__init__.py
213
214
215
216
217
218
219
220
221
222
223
def add_server_argument(
    self,
    default: bool = False
) -> None:
    """
    Add server argument to the parser.

    Args:
        default (bool): Default value for the server argument.
    """
    self._add_boolean_argument(Flag.SERVER, default)

add_yolo_input_model_argument()

Add YOLO input model argument to the parser.

Source code in devices\raspberry_pi_5\src\args\__init__.py
308
309
310
311
312
313
314
315
316
317
318
def add_yolo_input_model_argument(self) -> None:
    """
    Add YOLO input model argument to the parser.
    """
    self._add_non_boolean_argument(
        Flag.INPUT_MODEL,
        type=str,
        required=True,
        help='YOLO input model',
        choices=MODELS_NAME
    )

add_yolo_version_argument()

Add YOLO version argument to the parser.

Source code in devices\raspberry_pi_5\src\args\__init__.py
329
330
331
332
333
334
335
336
337
338
339
def add_yolo_version_argument(self) -> None:
    """
    Add YOLO version argument to the parser.
    """
    self._add_non_boolean_argument(
        Flag.VERSION,
        type=str,
        required=True,
        help='YOLO model version',
        choices=VERSIONS
    )

check_model_name(model_name) staticmethod

Check the validity of model name.

Parameters:

Name Type Description Default
model_name str

Name of the YOLO model.

required

Raises:
ValueError: If the model name is not valid.

Source code in devices\raspberry_pi_5\src\args\__init__.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@staticmethod
def check_model_name(model_name: str) -> None:
    """
    Check the validity of model name.

    Args:
        model_name (str): Name of the YOLO model.
    Raises:
        ValueError: If the model name is not valid.
    """
    if model_name not in MODELS_NAME:
        mapped_yolo_models_name = add_single_quotes_to_list_elements(
            MODELS_NAME
        )
        raise ValueError(
            f"Invalid model name: {model_name}. Must be one of the following: {', '.join(mapped_yolo_models_name)}."
        )

check_yolo_version(yolo_version) staticmethod

Check the validity of YOLO version.

Parameters:

Name Type Description Default
yolo_version str

Version of the YOLO model.

required

Raises:
ValueError: If the YOLO version is not valid.

Source code in devices\raspberry_pi_5\src\args\__init__.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@staticmethod
def check_yolo_version(yolo_version: str) -> None:
    """
    Check the validity of YOLO version.

    Args:
        yolo_version (str): Version of the YOLO model.
    Raises:
        ValueError: If the YOLO version is not valid.
    """
    if yolo_version not in VERSIONS:
        mapped_yolo_versions = add_single_quotes_to_list_elements(VERSIONS)
        raise ValueError(
            f"Invalid yolo version: {yolo_version}. Must be one of the following: {', '.join(mapped_yolo_versions)}."
        )

get_debug()

Get the debug argument from the parser.

Returns:

Name Type Description
bool bool

The value of the debug argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
204
205
206
207
208
209
210
211
def get_debug(self) -> bool:
    """
    Get the debug argument from the parser.

    Returns:
        bool: The value of the debug argument.
    """
    return self._get_attribute_from_args_dict(Flag.DEBUG)

get_ip()

Get the IP argument from the parser.

Returns:

Name Type Description
str str

The value of the IP argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
272
273
274
275
276
277
278
279
def get_ip(self) -> str:
    """
    Get the IP argument from the parser.

    Returns:
        str: The value of the IP argument.
    """
    return self._get_attribute_from_args_dict(Flag.IP)

get_movement()

Get the movement argument from the parser.

Returns:

Name Type Description
bool bool

The value of the movement argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
362
363
364
365
366
367
368
369
def get_movement(self) -> bool:
    """
    Get the movement argument from the parser.

    Returns:
        bool: The value of the movement argument.
    """
    return self._get_attribute_from_args_dict(Flag.MOVEMENT)

get_port()

Get the port argument from the parser.

Returns:

Name Type Description
int int

The value of the port argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
299
300
301
302
303
304
305
306
def get_port(self) -> int:
    """
    Get the port argument from the parser.

    Returns:
        int: The value of the port argument.
    """
    return self._get_attribute_from_args_dict(Flag.PORT)

get_rplidar_angle_rotation()

Get the RPLidar angle rotation argument from the parser.

Returns:

Name Type Description
float float

The value of the RPLidar angle rotation argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
410
411
412
413
414
415
416
417
def get_rplidar_angle_rotation(self) -> float:
    """
    Get the RPLidar angle rotation argument from the parser.

    Returns:
        float: The value of the RPLidar angle rotation argument.
    """
    return self._get_attribute_from_args_dict(Flag.RPLIDAR_ANGLE_ROTATION)

get_rplidar_is_upside_down()

Get the RPLidar upside down argument from the parser.

Returns:

Name Type Description
bool bool

The value of the RPLidar upside down argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
383
384
385
386
387
388
389
390
def get_rplidar_is_upside_down(self) -> bool:
    """
    Get the RPLidar upside down argument from the parser.

    Returns:
        bool: The value of the RPLidar upside down argument.
    """
    return self._get_attribute_from_args_dict(Flag.RPLIDAR_IS_UPSIDE_DOWN)

get_serial()

Get the serial argument from the parser.

Returns:

Name Type Description
bool bool

The value of the serial argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
246
247
248
249
250
251
252
253
def get_serial(self) -> bool:
    """
    Get the serial argument from the parser.

    Returns:
        bool: The value of the serial argument.
    """
    return self._get_attribute_from_args_dict(Flag.SERIAL)

get_server()

Get the server argument from the parser.

Returns:

Name Type Description
bool

The value of the server argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
225
226
227
228
229
230
231
232
def get_server(self):
    """
    Get the server argument from the parser.

    Returns:
        bool: The value of the server argument.
    """
    return self._get_attribute_from_args_dict(Flag.SERVER)

get_yolo_input_model()

Get the YOLO input model argument from the parser.

Returns:

Name Type Description
str str

The value of the YOLO input model argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
320
321
322
323
324
325
326
327
def get_yolo_input_model(self) -> str:
    """
    Get the YOLO input model argument from the parser.

    Returns:
        str: The value of the YOLO input model argument.
    """
    return self._get_attribute_from_args_dict(Flag.INPUT_MODEL)

get_yolo_version()

Get the YOLO version argument from the parser.

Returns:

Name Type Description
str str

The value of the YOLO version argument.

Source code in devices\raspberry_pi_5\src\args\__init__.py
341
342
343
344
345
346
347
348
def get_yolo_version(self) -> str:
    """
    Get the YOLO version argument from the parser.

    Returns:
        str: The value of the YOLO version argument.
    """
    return self._get_attribute_from_args_dict(Flag.VERSION)

enums

Flag

Bases: Enum

Enum to represent command line flags.

Source code in devices\raspberry_pi_5\src\args\enums.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@unique
class Flag(Enum):
    """
    Enum to represent command line flags.
    """

    DEBUG = 1
    INPUT_MODEL = 2
    VERSION = 3
    SERVER = 4
    SERIAL = 5
    IP = 6
    PORT = 7
    MOVEMENT = 8
    RPLIDAR_IS_UPSIDE_DOWN = 9
    RPLIDAR_ANGLE_ROTATION = 10

    @property
    def parsed_name(self) -> str:
        """
        Get the flag name in lowercase.

        Returns:
            str: The flag name in lowercase.
        """
        return self.name.lower()

parsed_name property

Get the flag name in lowercase.

Returns:

Name Type Description
str str

The flag name in lowercase.

protocols

FlagProtocol

Bases: Protocol

Protocol for flag classes.

Source code in devices\raspberry_pi_5\src\args\protocols.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class FlagProtocol(Protocol):
    """
    Protocol for flag classes.
    """

    @property
    def parsed_name(self) -> str:
        """
        Get the parsed name of the flag.
        """
        pass

parsed_name property

Get the parsed name of the flag.