diff --git a/.travis.yml b/.travis.yml index 37dab626..8219d49a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ cache: git: depth: false + autocrlf: false before_install: - date diff --git a/CHANGELOG.md b/CHANGELOG.md index de50e8c7..e4dbdba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Implemented enhancements:** +- Update YAML exporter to handle Dayone format [\#773](https://github.com/jrnl-org/jrnl/pull/773) ([MinchinWeb](https://github.com/MinchinWeb)) - Full text search \(case insensitive\) with "-contains" [\#740](https://github.com/jrnl-org/jrnl/pull/740) ([empireshades](https://github.com/empireshades)) - Reduce startup time by 55% [\#719](https://github.com/jrnl-org/jrnl/pull/719) ([maebert](https://github.com/maebert)) - Refactor password logic to prevent accidental password leakage [\#708](https://github.com/jrnl-org/jrnl/pull/708) ([pspeter](https://github.com/pspeter)) @@ -18,6 +19,7 @@ **Build:** +- Fix all skipped tests on Travis Windows builds by preserving newlines [\#823](https://github.com/jrnl-org/jrnl/pull/823) ([micahellison](https://github.com/micahellison)) - Change PyPI auth method in build pipeline [\#807](https://github.com/jrnl-org/jrnl/pull/807) ([wren](https://github.com/wren)) - Automagically update the changelog you see before your very eyes! [\#806](https://github.com/jrnl-org/jrnl/pull/806) ([wren](https://github.com/wren)) - Update Black version and lock file to fix builds on develop branch [\#784](https://github.com/jrnl-org/jrnl/pull/784) ([wren](https://github.com/wren)) diff --git a/features/dayone_regressions.feature b/features/dayone_regressions.feature index f6098ba6..62c8cc24 100644 --- a/features/dayone_regressions.feature +++ b/features/dayone_regressions.feature @@ -24,7 +24,6 @@ Feature: Zapped Dayone bugs stay dead! | I'm feeling sore because I forgot to stretch. """ - @skip_win Scenario: Opening an folder that's not a DayOne folder gives a nice error message Given we use the config "empty_folder.yaml" When we run "jrnl Herro" diff --git a/features/encryption.feature b/features/encryption.feature index 081a208f..787fa850 100644 --- a/features/encryption.feature +++ b/features/encryption.feature @@ -12,7 +12,6 @@ Then we should see the message "Journal decrypted" And the journal should have 2 entries - @skip_win Scenario: Encrypting a journal Given we use the config "basic.yaml" When we run "jrnl --encrypt" and enter @@ -27,7 +26,6 @@ Then the output should contain "Password" And the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Mistyping your password Given we use the config "basic.yaml" When we run "jrnl --encrypt" and enter @@ -45,7 +43,6 @@ Then the output should contain "Password" And the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Storing a password in Keychain Given we use the config "multiple.yaml" When we run "jrnl simple --encrypt" and enter diff --git a/features/upgrade.feature b/features/upgrade.feature index b2c569c7..ef597d4f 100644 --- a/features/upgrade.feature +++ b/features/upgrade.feature @@ -1,6 +1,5 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x - @skip_win Scenario: Upgrade and parse journals with square brackets Given we use the config "upgrade_from_195.json" When we run "jrnl -9" and enter "Y" @@ -12,7 +11,6 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x """ Then the journal should have 2 entries - @skip_win Scenario: Upgrading a journal encrypted with jrnl 1.x Given we use the config "encrypted_old.json" When we run "jrnl -n 1" and enter @@ -24,7 +22,6 @@ Feature: Upgrading Journals from 1.x.x to 2.x.x Then the output should contain "Password" and the output should contain "2013-06-10 15:40 Life is good" - @skip_win Scenario: Upgrade and parse journals with little endian date format Given we use the config "upgrade_from_195_little_endian_dates.json" When we run "jrnl -9" and enter "Y" diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index b0177b39..430b68f7 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -19,11 +19,10 @@ class YAMLExporter(TextExporter): """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, + "{}ERROR{}: YAML export must be to individual files. Please \ + specify a directory to export to.".format( + ERROR_COLOR, RESET_COLOR, file=sys.stderr + ) ) return @@ -33,16 +32,14 @@ class YAMLExporter(TextExporter): tagsymbols = entry.journal.config["tagsymbols"] # see also Entry.Entry.rag_regex - multi_tag_regex = re.compile( - r"(?u)^\s*([{tags}][-+*#/\w]+\s*)+$".format(tags=tagsymbols) - ) + multi_tag_regex = re.compile(fr"(?u)^\s*([{tagsymbols}][-+*#/\w]+\s*)+$") """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 @@ -80,9 +77,32 @@ class YAMLExporter(TextExporter): dayone_attributes = "" if hasattr(entry, "uuid"): dayone_attributes += "uuid: " + entry.uuid + "\n" - # TODO: copy over pictures, if present - # source directory is entry.journal.config['journal'] - # output directory is...? + if ( + hasattr(entry, "creator_device_agent") + or hasattr(entry, "creator_generation_date") + or hasattr(entry, "creator_host_name") + or hasattr(entry, "creator_os_agent") + or hasattr(entry, "creator_software_agent") + ): + dayone_attributes += "creator:\n" + if hasattr(entry, "creator_device_agent"): + dayone_attributes += f" device agent: {entry.creator_device_agent}\n" + if hasattr(entry, "creator_generation_date"): + dayone_attributes += " generation date: {}\n".format( + str(entry.creator_generation_date) + ) + if hasattr(entry, "creator_host_name"): + dayone_attributes += f" host name: {entry.creator_host_name}\n" + if hasattr(entry, "creator_os_agent"): + dayone_attributes += f" os agent: {entry.creator_os_agent}\n" + if hasattr(entry, "creator_software_agent"): + dayone_attributes += ( + f" software agent: {entry.creator_software_agent}\n" + ) + + # TODO: copy over pictures, if present + # source directory is entry.journal.config['journal'] + # output directory is...? return "title: {title}\ndate: {date}\nstared: {stared}\ntags: {tags}\n{dayone} {body} {space}".format( date=date_str,