When generating template based filenames replace multiple spaces with a single space

This commit is contained in:
Kovid Goyal 2010-08-05 12:05:54 -06:00
parent 314f8fefd4
commit 43b51ed334

View File

@ -99,7 +99,8 @@ def preprocess_template(template):
def safe_format(x, format_args):
try:
return x.format(**format_args).strip()
ans = x.format(**format_args).strip()
return re.sub(r'\s+', ' ', ans)
except IndexError: # Thrown if user used [] and index is out of bounds
pass
except AttributeError: # Thrown if user used a non existing attribute