70 """A string formatter that implements format most equivalent to the str.format, but does not replace keys,
83 def get_value(self, key, args, kwds):
84 """Retrieves the value that corresponds to the key from either the positional or
85 the keyword arguments given to format
87 Overrides the standard lookup such that missing keys in the keyword arguments or
88 transformed in a NoReplacementField signal object.
91 if isinstance(key, str):
95 return NoReplacementField(key)
97 return super().get_value(key, args, kwds)
99 def convert_field(self, value, conversion):
100 """Applies the conversion to the value.
102 Overrides the standard method such that a potential conversion is attached to the NoReplacementField
105 if isinstance(value, NoReplacementField):
106 conversion = conversion or None
107 value.conversion = conversion
110 return super().convert_field(value, conversion)
112 def format_field(self, value, format_spec):
113 """Applies the conversion to the value.
115 Overrides the standard method such that a potential format_spec is attached to the NoReplacementField.
116 Than composes the replacement_field specification to be inserted in the formatted string.
117 The outcome should be equivalent to the unformatted string for missing keys.
120 if isinstance(value, NoReplacementField):
121 format_spec = format_spec or None
122 value.format_spec = format_spec
123 return value.compose()
125 return super().format_field(value, format_spec)