project_config.reporters.base module

Base reporters.

class project_config.reporters.base.BaseColorReporter(*args: Any, colors: Optional[dict[str, str]] = None, **kwargs: Any)[source]

Bases: BaseFormattedReporter

Base reporter with colorized output.

_abc_impl = <_abc._abc_data object>
_normalize_colors(colors: dict[str, str]) dict[str, str][source]
format_config_key(config_key: str) str[source]

Configuration data key formatter, for example ‘style’.

format_config_value(config_value: str) str[source]

Configuration data value formatter, for example ‘style’ urls.

format_definition(definition: str) str[source]

Definition formatter.

format_error_message(error_message: str) str[source]

Error message formatter.

format_file(fname: str) str[source]

File name formatter.

format_fixed(output: str) str[source]

File name formatter.

format_hint(hint: str) str[source]

Hint formatter.

format_key(key: str) str[source]

Serialized key formatter.

format_metachar(metachar: str) str[source]

Meta characters string formatter.

class project_config.reporters.base.BaseFormattedReporter(rootdir: str, fmt: Optional[str] = None, only_hints: bool = False)[source]

Bases: BaseReporter, ABC

Reporter that requires formatted fields.

_abc_impl = <_abc._abc_data object>
abstract format_config_key(config_key: str) str[source]

Configuration data key formatter, for example ‘style’.

abstract format_config_value(config_value: str) str[source]

Configuration data value formatter, for example ‘style’ urls.

abstract format_definition(definition: str) str[source]

Definition formatter.

abstract format_error_message(error_message: str) str[source]

Error message formatter.

abstract format_file(fname: str) str[source]

File name formatter.

abstract format_fixed(output: str) str[source]

File name formatter.

abstract format_hint(hint: str) str[source]

Hint formatter.

abstract format_key(key: str) str[source]

Serialized key formatter.

abstract format_metachar(metachar: str) str[source]

Meta characters string formatter.

class project_config.reporters.base.BaseNoopFormattedReporter(rootdir: str, fmt: Optional[str] = None, only_hints: bool = False)[source]

Bases: BaseFormattedReporter

Reporter that requires formatted fields without format.

_abc_impl = <_abc._abc_data object>
format_config_key(config_key: str) str[source]

Configuration data key formatter, for example ‘style’.

format_config_value(config_value: str) str[source]

Configuration data value formatter, for example ‘style’ urls.

format_definition(definition: str) str[source]

Definition formatter.

format_error_message(error_message: str) str[source]

Error message formatter.

format_file(fname: str) str[source]

File name formatter.

format_fixed(output: str) str[source]

File name formatter.

format_hint(hint: str) str[source]

Hint formatter.

format_key(key: str) str[source]

Serialized key formatter.

format_metachar(metachar: str) str[source]

Meta characters string formatter.

class project_config.reporters.base.BaseReporter(rootdir: str, fmt: Optional[str] = None, only_hints: bool = False)[source]

Bases: ABC

Base reporter from which all reporters inherit.

_abc_impl = <_abc._abc_data object>
data: dict[str, Any]
errors: FilesErrors
exception_class

alias of ProjectConfigCheckFailed

format
generate_data_report(_data_key: str, _data: dict[str, Any]) str[source]

Generate data report for configuration or styles.

This method should be implemented by inherited reporters.

Parameters:
  • data_key (str) – Configuration for which the data will be generated. Could be either "config" or "style".

  • data (dict) – Data to report.

abstract generate_errors_report() str[source]

Generate check errors report.

This method must be implemented by inherited reporters.

only_hints
raise_errors(errors_report: Optional[str] = None) None[source]

Raise errors failure if no success.

Raise the correspondent exception class for the reporter if the reporter has reported any error.

report_error(error: ErrorDict) None[source]

Report an error.

Parameters:

error (dict) – Error to report.

rootdir
property success: bool

Return if the reporter has not reported errors.

Returns:

True if no errors reported, False otherwise.

Return type:

bool

exception project_config.reporters.base.InvalidColors(errors: list[str])[source]

Bases: ProjectConfigException

Invalid not supported colors in colored formatter.

project_config.reporters.base.bold_color(value: str, color: str) str[source]

Colorize a string with bold formatting using colored library.

Parameters:
  • value (str) – Value to colorize.

  • color (str) – Color to use for the formatting.

Returns:

Colorized string.

Return type:

str

project_config.reporters.base.colored_color_exists(color: str) bool[source]

Check if a color exists in the colored library.

Parameters:

color (str) – Color to check.

Returns:

True if the color exists, False otherwise.

Return type:

bool

project_config.reporters.base.self_format_noop(_self: type, v: str) str[source]

Formatter that returns the value without formatting.