Remove export to txt, the .md markdown is really the same
This commit is contained in:
parent
7ef79c495b
commit
97e723ce34
6 changed files with 5 additions and 28 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue