From a31eb9628acefe8c117ff3487085244d48c6ca00 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Mon, 11 May 2015 11:55:46 -0600 Subject: [PATCH] [YAML Export] style improvements --- jrnl/plugins/yaml_exporter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 1442adcc..cc1500dc 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -17,7 +17,8 @@ class YAMLExporter(TextExporter): def export_entry(cls, entry, to_multifile=True): """Returns a markdown representation of a single entry, with YAML front matter.""" if to_multifile is False: - print("{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format("\033[31m", "\033[0m", file=sys.stderr)) + print("{}ERROR{}: YAML export must be to individual files. Please \ + specify a directory to export to.".format(ERROR_COLOR, RESET_COLOR, file=sys.stderr)) return date_str = entry.date.strftime(entry.journal.config['timeformat']) @@ -28,12 +29,12 @@ class YAMLExporter(TextExporter): # see also Entry.Entry.rag_regex multi_tag_regex = re.compile(r'(?u)^\s*([{tags}][-+*#/\w]+\s*)+$'.format(tags=tagsymbols), re.UNICODE) - '''Increase heading levels in body text''' + """Increase heading levels in body text""" newbody = '' heading = '#' previous_line = '' warn_on_heading_level = False - for line in entry.body.splitlines(True): + for line in body.splitlines(True): if re.match(r"#+ ", line): """ATX style headings""" newbody = newbody + previous_line + heading + line @@ -57,7 +58,8 @@ class YAMLExporter(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("{}WARNING{}: Headings increased past H6 on export - {} {}" \ + .format(WARNING_COLOR, RESET_COLOR, date_str, entry.title), file=sys.stderr) dayone_attributes = '' if hasattr(entry, "uuid"): @@ -79,5 +81,6 @@ class YAMLExporter(TextExporter): @classmethod def export_journal(cls, journal): """Returns an error, as YAML export requires a directory as a target.""" - print("{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format(ERROR_COLOR, RESET_COLOR), file=sys.stderr) + print("{}ERROR{}: YAML export must be to individual files. \ + Please specify a directory to export to.".format(ERROR_COLOR, RESET_COLOR), file=sys.stderr) return