diff --git a/CHANGELOG.md b/CHANGELOG.md index c2be5a9..85e502e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Make it possible to add a tag from the Tag Browser * Add a statistics dialog with heatmap + * Remove export to .txt (just use .md) # 0.3 diff --git a/README.md b/README.md index b904f20..c8ffec2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ There is deliberately no network connectivity or syncing intended. * Transparent integrity checking of the database when it opens * Automatic locking of the app after a period of inactivity (default 15 min) * Rekey the database (change the password) - * Export the database to json, txt, html, csv, markdown or .sql (for sqlite3) + * Export the database to json, html, csv, markdown or .sql (for sqlite3) * Backup the database to encrypted SQLCipher format (which can then be loaded back in to a Bouquin) * Dark and light themes * Automatically generate checkboxes when typing 'TODO' diff --git a/bouquin/db.py b/bouquin/db.py index 07dec13..7fd521c 100644 --- a/bouquin/db.py +++ b/bouquin/db.py @@ -356,21 +356,6 @@ class DBManager: writer.writerow(["date", "content"]) # header writer.writerows(entries) - def export_txt( - self, - entries: Sequence[Entry], - file_path: str, - separator: str = "\n\n— — — — —\n\n", - ) -> None: - """ - Strip the the latest version of the pages to a text file. - """ - with open(file_path, "w", encoding="utf-8") as f: - for i, (d, c) in enumerate(entries): - f.write(f"{d}\n{c}\n") - if i < len(entries) - 1: - f.write(separator) - def export_html( self, entries: Sequence[Entry], file_path: str, title: str = "Bouquin export" ) -> None: diff --git a/bouquin/main_window.py b/bouquin/main_window.py index 2054e3c..c499a13 100644 --- a/bouquin/main_window.py +++ b/bouquin/main_window.py @@ -1179,7 +1179,6 @@ class MainWindow(QMainWindow): return False filters = ( - "Text (*.txt);;" "JSON (*.json);;" "CSV (*.csv);;" "HTML (*.html);;" @@ -1195,22 +1194,19 @@ class MainWindow(QMainWindow): return # user cancelled default_ext = { - "Text (*.txt)": ".txt", "JSON (*.json)": ".json", "CSV (*.csv)": ".csv", "HTML (*.html)": ".html", "Markdown (*.md)": ".md", "SQL (*.sql)": ".sql", - }.get(selected_filter, ".txt") + }.get(selected_filter, ".md") if not Path(filename).suffix: filename += default_ext try: entries = self.db.get_all_entries() - if selected_filter.startswith("Text"): - self.db.export_txt(entries, filename) - elif selected_filter.startswith("JSON"): + if selected_filter.startswith("JSON"): self.db.export_json(entries, filename) elif selected_filter.startswith("CSV"): self.db.export_csv(entries, filename) diff --git a/tests/test_db.py b/tests/test_db.py index fb3445f..dd2d55b 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -75,10 +75,6 @@ def test_get_all_entries_and_export(fresh_db, tmp_path): fresh_db.export_csv(entries, str(csv_path)) assert csv_path.exists() and list(csv.reader(open(csv_path))) - txt_path = tmp_path / "export.txt" - fresh_db.export_txt(entries, str(txt_path)) - assert txt_path.exists() and txt_path.read_text().strip() - md_path = tmp_path / "export.md" fresh_db.export_markdown(entries, str(md_path)) md_text = md_path.read_text() diff --git a/tests/test_main_window.py b/tests/test_main_window.py index 9c83b11..8ce5564 100644 --- a/tests/test_main_window.py +++ b/tests/test_main_window.py @@ -744,7 +744,6 @@ def test_on_insert_image_calls_editor_insert( @pytest.mark.parametrize( "filter_label, method", [ - ("Text (*.txt)", "export_txt"), ("JSON (*.json)", "export_json"), ("CSV (*.csv)", "export_csv"), ("HTML (*.html)", "export_html"), @@ -1172,7 +1171,7 @@ def test_export_cancel_then_empty_filename( monkeypatch.setattr( mwmod.QFileDialog, "getSaveFileName", - staticmethod(lambda *a, **k: ("", "Text (*.txt)")), + staticmethod(lambda *a, **k: ("", "Markdown (*.md)")), raising=False, ) w._export() # returns early at filename check