Fix format_string_contains_key()
AttributeError occured if no parsable field was found in the specified pattern. Reported in #84.
This commit is contained in:
parent
a7f89e4327
commit
90a1b73d21
@ -130,7 +130,7 @@ def mediaid_to_shortcode(mediaid: int) -> str:
|
|||||||
def format_string_contains_key(format_string: str, key: str) -> bool:
|
def format_string_contains_key(format_string: str, key: str) -> bool:
|
||||||
# pylint:disable=unused-variable
|
# pylint:disable=unused-variable
|
||||||
for literal_text, field_name, format_spec, conversion in string.Formatter().parse(format_string):
|
for literal_text, field_name, format_spec, conversion in string.Formatter().parse(format_string):
|
||||||
if field_name == key or field_name.startswith(key + '.'):
|
if field_name and (field_name == key or field_name.startswith(key + '.')):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user