toml_formatter package
Package to run the Destination Earth on Demand Extremes system.
- class GeneralConstants[source]
Bases:
objectGeneral package-related constants.
- PACKAGE_DIRECTORY = PosixPath('/home/runner/work/toml-formatter/toml-formatter/toml_formatter')
- PACKAGE_NAME = 'toml_formatter'
- VERSION = '0.1.0'
Submodules
toml_formatter.argparse_wrapper module
Wrappers for argparse functionality.
toml_formatter.commands_functions module
Implement the package’s commands.
toml_formatter.formatter module
Code related to TOML formatting.
- class FormattedToml(raw_data: Sequence[str], formatter_options: FormatterOptions = FormatterOptions(line_length=90, indentation=2, section_order_overrides=(), loglevel='INFO'))[source]
Bases:
objectClass to help format the contents of a TOML file.
- classmethod from_file(path: Path | str, **kwargs)[source]
Return a class instance with info read from file located at path.
- classmethod from_string(toml_string: str, **kwargs)[source]
Return a class instance with info retrieved from toml_string.
- property indentation: int
Return the indentation applied for each scope level change.
- property sections: Tuple[_FormattedTomlFileSection]
Return the sections present in the file.
toml_formatter.formatter_options module
Registration and validation of options passed to the formatter.
- pydantic model FormatterOptions[source]
Bases:
BaseModelModel for the formatter’s configuration options.
Show JSON schema
{ "title": "FormatterOptions", "description": "Model for the formatter's configuration options.", "type": "object", "properties": { "line_length": { "default": 90, "exclusiveMinimum": 0, "title": "Line Length", "type": "integer" }, "indentation": { "default": 2, "minimum": 0, "title": "Indentation", "type": "integer" }, "section_order_overrides": { "default": [], "items": { "type": "string" }, "title": "Section Order Overrides", "type": "array" }, "loglevel": { "default": "INFO", "enum": [ "INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL" ], "title": "Loglevel", "type": "string" } } }
- Fields:
- field indentation: int = 2
- Constraints:
ge = 0
- field line_length: int = 90
- Constraints:
gt = 0
- field loglevel: Literal['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'] = 'INFO'
- field section_order_overrides: tuple[str, ...] = ()
toml_formatter.logs module
Logging-related classes, functions and definitions.
- class LogDefaults[source]
Bases:
objectDefaults used for the logging system.
- DIRECTORY = PosixPath('/home/runner/.logs/toml_formatter')
- LEVEL = 'INFO'
- LOGLEVEL_ENVVAR = 'TOML_FORMATTER_LOGLEVEL'
- RETENTION_TIME = '1 week'
- SINKS = {'console': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, 'logfile': PosixPath('/home/runner/.logs/toml_formatter/toml_formatter_{time}.log')}
- class LogFormatter(datetime: str = '<green>{time:YYYY-MM-DD HH:mm:ss}</green>', level: str = '<level>{level: <8}</level>', code_location: str = '<cyan>@{name}</cyan>:<cyan>{function}</cyan> <cyan><{file.path}</cyan>:<cyan>{line}>:</cyan>', message: str = '<level>{message}</level>')[source]
Bases:
objectHelper class to setup logging without poluting the module’s main scope.
- code_location: str = '<cyan>@{name}</cyan>:<cyan>{function}</cyan> <cyan><{file.path}</cyan>:<cyan>{line}>:</cyan>'
- datetime: str = '<green>{time:YYYY-MM-DD HH:mm:ss}</green>'
- format_string(loglevel: str)[source]
Return the appropriate fmt string according to log level and fmt opts.
- level: str = '<level>{level: <8}</level>'
- message: str = '<level>{message}</level>'