serialtools.database_config module

class serialtools.database_config.DatabaseCreator

Bases: object

endianness

A setting without a default value which requires the user to explicitly set a value in the config file or pass it as command line argument.

You can use is_value_valid() in order to check whether this config has a value or not.

If you try to use the value before it has been set: If you try to access the config as instance attribute (object.config) a TypeError is thrown. Otherwise (config.value) None is returned.

get(*, require_signals: bool = True, config_id: ConfigId | None = None) Database
load_file(fn: str, *, config_id: ConfigId | None = None) Database
word_length_in_bits

A setting which can have different values for different objects.

This class implements the descriptor protocol to return one of the values in values depending on a config_id attribute of the owning object if an instance of this class is accessed as an instance attribute. If there is no value for the config_id in values value is returned instead. If the owning instance does not have a config_id attribute an AttributeError is raised.

In the config file a group can be opened with [config-id]. Then all following set commands set the value for the specified config id.

class serialtools.database_config.LoggingCallback(*, logger: ~logging.Logger = <RootLogger root (WARNING)>, levels: ~collections.abc.Mapping[~confattr.configfile.NotificationLevel, int] = {})

Bases: object

class serialtools.database_config.Message(config_file: ConfigFile)

Bases: ConfigFileArgparseCommand

init_parser(parser: ArgumentParser) None
Parameters:

parser – The parser to add arguments to. This is the same object like parser.

This is an abstract method which must be implemented by subclasses. Use ArgumentParser.add_argument() to add arguments to parser.

message: db.MessageSpec | None = None
run_parsed(args: Namespace) None

This is an abstract method which must be implemented by subclasses.

class serialtools.database_config.Param(config_file: ConfigFile)

Bases: ConfigFileArgparseCommand

Define a parameter that can be used in the message command.

defined_parameters: dict[str, db.ByteSpec] = {}
init_parser(parser: ArgumentParser) None
Parameters:

parser – The parser to add arguments to. This is the same object like parser.

This is an abstract method which must be implemented by subclasses. Use ArgumentParser.add_argument() to add arguments to parser.

parse_allowed_values(allowed_values: str | None, length: int | str | None) Sequence[bytes] | None
run_parsed(args: Namespace) None

This is an abstract method which must be implemented by subclasses.

class serialtools.database_config.Signal(config_file: ConfigFile)

Bases: ConfigFileArgparseCommand

init_parser(parser: ArgumentParser) None
Parameters:

parser – The parser to add arguments to. This is the same object like parser.

This is an abstract method which must be implemented by subclasses. Use ArgumentParser.add_argument() to add arguments to parser.

run_parsed(args: Namespace) None

This is an abstract method which must be implemented by subclasses.

signals: list[db.Signal] = []
serialtools.database_config.get_database(*, require_signals: bool = True, config_id: ConfigId | None = None) Database
serialtools.database_config.integer(val: str) int
serialtools.database_config.load_file(fn: str, *, config_id: ConfigId | None = None) Database