fstring wip

This commit is contained in:
Peter Schmidbauer 2019-11-01 10:37:12 +01:00
parent 34f8f858f1
commit 1c403904e5
7 changed files with 11 additions and 15 deletions

View file

@ -50,15 +50,11 @@ class MarkdownExporter(TextExporter):
newbody = newbody + previous_line # add very last line
if warn_on_heading_level is True:
print("{}WARNING{}: Headings increased past H6 on export - {} {}".format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr)
print(f"{WARNING_COLOR}WARNING{RESET_COLOR}: "
f"Headings increased past H6 on export - {date_str} {entry.title}",
file=sys.stderr)
return "{md} {date} {title}\n{body} {space}".format(
md=heading,
date=date_str,
title=entry.title,
body=newbody,
space=""
)
return f"{heading} {date_str} {entry.title}\n{newbody} "
@classmethod
def export_journal(cls, journal):

View file

@ -34,7 +34,7 @@ def __exporter_from_file(template_file):
"""Create a template class from a file"""
name = os.path.basename(template_file).replace(".template", "")
template = Template.from_file(template_file)
return type(str("{}Exporter".format(name.title())), (GenericTemplateExporter, ), {
return type(str(f"{name.title(}Exporter")), (GenericTemplateExporter, ), {
"names": [name],
"extension": template.extension,
"template": template

View file

@ -28,9 +28,9 @@ class TextExporter:
try:
with codecs.open(path, "w", "utf-8") as f:
f.write(cls.export_journal(journal))
return "[Journal exported to {0}]".format(path)
return f"[Journal exported to {path}]"
except IOError as e:
return "[{2}ERROR{3}: {0} {1}]".format(e.filename, e.strerror, ERROR_COLOR, RESET_COLOR)
return f"[{ERROR_COLOR}ERROR{RESET_COLOR}: {e.filename} {e.strerror}]"
@classmethod
def make_filename(cls, entry):