(
part: StringLikePart,
context: &PyFormatContext,
preferred_quote: Quote,
)
| 285 | /// to choose the quotes for a part. |
| 286 | impl QuoteMetadata { |
| 287 | pub(crate) fn from_part( |
| 288 | part: StringLikePart, |
| 289 | context: &PyFormatContext, |
| 290 | preferred_quote: Quote, |
| 291 | ) -> Self { |
| 292 | match part { |
| 293 | StringLikePart::String(_) | StringLikePart::Bytes(_) => { |
| 294 | let text = &context.source()[part.content_range()]; |
| 295 | |
| 296 | Self::from_str(text, part.flags(), preferred_quote) |
| 297 | } |
| 298 | StringLikePart::FString(fstring) => { |
| 299 | let metadata = QuoteMetadata::from_str("", part.flags(), preferred_quote); |
| 300 | |
| 301 | metadata.merge_interpolated_string_elements( |
| 302 | &fstring.elements, |
| 303 | fstring.flags.into(), |
| 304 | context, |
| 305 | preferred_quote, |
| 306 | ) |
| 307 | } |
| 308 | StringLikePart::TString(tstring) => { |
| 309 | let metadata = QuoteMetadata::from_str("", part.flags(), preferred_quote); |
| 310 | |
| 311 | metadata.merge_interpolated_string_elements( |
| 312 | &tstring.elements, |
| 313 | tstring.flags.into(), |
| 314 | context, |
| 315 | preferred_quote, |
| 316 | ) |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | fn from_str(text: &str, flags: AnyStringFlags, preferred_quote: Quote) -> Self { |
| 322 | let kind = if flags.is_raw_string() { |
nothing calls this directly
no test coverage detected