from Components.config import ConfigInteger class MyAppConfig: # Define an integer configuration option for MyApp OPTION_A = ConfigInteger(default=10, limits=(1, 100)) # Accessing the value of the option print(MyAppConfig.OPTION_A.value)
from Components.config import ConfigInteger class MyAppConfig: # Define an integer configuration option for MyApp OPTION_B = ConfigInteger(default=1, limits=(0, 100)) def set_option_b(self, new_value): # Validate user input for OPTION_B if new_value < 0: raise ValueError("Option value must be greater than or equal to 0.") elif new_value > 100: raise ValueError("Option value must be less than or equal to 100.") else: self.OPTION_B.value = new_value # Setting the value of the option config = MyAppConfig() config.set_option_b(-1) # Raises ValueErrorIn the example above, a configuration option `OPTION_B` is defined for the `MyAppConfig` class with limits of 0 and 100. The `set_option_b()` method is used to validate user input for the option and set its value. If the input is outside the limits, a `ValueError` is raised. The package library for the `Components.config` package is likely `enigma2`. This package is used for developing plugins and extensions for Enigma2-based satellite receivers.