mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
fstring wip
This commit is contained in:
parent
34f8f858f1
commit
1c403904e5
7 changed files with 11 additions and 15 deletions
|
@ -82,7 +82,7 @@ class DayOne(Journal.Journal):
|
|||
def editable_str(self):
|
||||
"""Turns the journal into a string of entries that can be edited
|
||||
manually and later be parsed with eslf.parse_editable_str."""
|
||||
return "\n".join(["# {0}\n{1}".format(e.uuid, str(e)) for e in self.entries])
|
||||
return "\n".join([f"# {e.uuid}\n{str(e)}" for e in self.entries])
|
||||
|
||||
def parse_editable_str(self, edited):
|
||||
"""Parses the output of self.editable_str and updates its entries."""
|
||||
|
|
|
@ -23,7 +23,7 @@ class Tag:
|
|||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return "<Tag '{}'>".format(self.name)
|
||||
return f"<Tag '{self.name}'>"
|
||||
|
||||
|
||||
class Journal:
|
||||
|
|
|
@ -144,7 +144,7 @@ def run(manual_args=None):
|
|||
try:
|
||||
config = install.load_or_install_jrnl()
|
||||
except UserAbort as err:
|
||||
print("\n{}".format(err), file=sys.stderr)
|
||||
print(f"\n{err}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if args.ls:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -125,7 +125,7 @@ def get_text_from_editor(config, template=""):
|
|||
|
||||
def colorize(string):
|
||||
"""Returns the string wrapped in cyan ANSI escape"""
|
||||
return u"\033[36m{}\033[39m".format(string)
|
||||
return f"\033[36m{string}\033[39m"
|
||||
|
||||
|
||||
def slugify(string):
|
||||
|
|
Loading…
Add table
Reference in a new issue