Formatter
This class provides functionality for parsing and formatting strings based on specific format specifiers. It processes input strings by mapping identified placeholders to internal methods while enforcing type-specific constraints, such as preventing time-related specifiers on date objects.
Attributes
| Attribute | Type | Description |
|---|---|---|
| data | object | The underlying object, such as a date or time instance, used to resolve format specifiers during the string construction process. |
Methods
format()
@classmethod
def format(
formatstr: string
) - > string
Parses a format string and replaces placeholders with corresponding attribute values from the instance. This method validates that date objects do not use time-related specifiers and handles escaped characters within the input string.
Parameters
| Name | Type | Description |
|---|---|---|
| formatstr | string | The template string containing format specifiers and escaped characters to be processed. |
Returns
| Type | Description |
|---|---|
string | The fully interpolated string with all format specifiers replaced by their evaluated values. |