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
|
* Make it possible to add a tag from the Tag Browser
|
||||||
* Add a statistics dialog with heatmap
|
* Add a statistics dialog with heatmap
|
||||||
|
* Remove export to .txt (just use .md)
|
||||||
|
|
||||||
# 0.3
|
# 0.3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ There is deliberately no network connectivity or syncing intended.
|
||||||
* Transparent integrity checking of the database when it opens
|
* Transparent integrity checking of the database when it opens
|
||||||
* Automatic locking of the app after a period of inactivity (default 15 min)
|
* Automatic locking of the app after a period of inactivity (default 15 min)
|
||||||
* Rekey the database (change the password)
|
* 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)
|
* Backup the database to encrypted SQLCipher format (which can then be loaded back in to a Bouquin)
|
||||||
* Dark and light themes
|
* Dark and light themes
|
||||||
* Automatically generate checkboxes when typing 'TODO'
|
* Automatically generate checkboxes when typing 'TODO'
|
||||||
|
|
|
||||||
|
|
@ -356,21 +356,6 @@ class DBManager:
|
||||||
writer.writerow(["date", "content"]) # header
|
writer.writerow(["date", "content"]) # header
|
||||||
writer.writerows(entries)
|
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(
|
def export_html(
|
||||||
self, entries: Sequence[Entry], file_path: str, title: str = "Bouquin export"
|
self, entries: Sequence[Entry], file_path: str, title: str = "Bouquin export"
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -1179,7 +1179,6 @@ class MainWindow(QMainWindow):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
filters = (
|
filters = (
|
||||||
"Text (*.txt);;"
|
|
||||||
"JSON (*.json);;"
|
"JSON (*.json);;"
|
||||||
"CSV (*.csv);;"
|
"CSV (*.csv);;"
|
||||||
"HTML (*.html);;"
|
"HTML (*.html);;"
|
||||||
|
|
@ -1195,22 +1194,19 @@ class MainWindow(QMainWindow):
|
||||||
return # user cancelled
|
return # user cancelled
|
||||||
|
|
||||||
default_ext = {
|
default_ext = {
|
||||||
"Text (*.txt)": ".txt",
|
|
||||||
"JSON (*.json)": ".json",
|
"JSON (*.json)": ".json",
|
||||||
"CSV (*.csv)": ".csv",
|
"CSV (*.csv)": ".csv",
|
||||||
"HTML (*.html)": ".html",
|
"HTML (*.html)": ".html",
|
||||||
"Markdown (*.md)": ".md",
|
"Markdown (*.md)": ".md",
|
||||||
"SQL (*.sql)": ".sql",
|
"SQL (*.sql)": ".sql",
|
||||||
}.get(selected_filter, ".txt")
|
}.get(selected_filter, ".md")
|
||||||
|
|
||||||
if not Path(filename).suffix:
|
if not Path(filename).suffix:
|
||||||
filename += default_ext
|
filename += default_ext
|
||||||
|
|
||||||
try:
|
try:
|
||||||
entries = self.db.get_all_entries()
|
entries = self.db.get_all_entries()
|
||||||
if selected_filter.startswith("Text"):
|
if selected_filter.startswith("JSON"):
|
||||||
self.db.export_txt(entries, filename)
|
|
||||||
elif selected_filter.startswith("JSON"):
|
|
||||||
self.db.export_json(entries, filename)
|
self.db.export_json(entries, filename)
|
||||||
elif selected_filter.startswith("CSV"):
|
elif selected_filter.startswith("CSV"):
|
||||||
self.db.export_csv(entries, filename)
|
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))
|
fresh_db.export_csv(entries, str(csv_path))
|
||||||
assert csv_path.exists() and list(csv.reader(open(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"
|
md_path = tmp_path / "export.md"
|
||||||
fresh_db.export_markdown(entries, str(md_path))
|
fresh_db.export_markdown(entries, str(md_path))
|
||||||
md_text = md_path.read_text()
|
md_text = md_path.read_text()
|
||||||
|
|
|
||||||
|
|
@ -744,7 +744,6 @@ def test_on_insert_image_calls_editor_insert(
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"filter_label, method",
|
"filter_label, method",
|
||||||
[
|
[
|
||||||
("Text (*.txt)", "export_txt"),
|
|
||||||
("JSON (*.json)", "export_json"),
|
("JSON (*.json)", "export_json"),
|
||||||
("CSV (*.csv)", "export_csv"),
|
("CSV (*.csv)", "export_csv"),
|
||||||
("HTML (*.html)", "export_html"),
|
("HTML (*.html)", "export_html"),
|
||||||
|
|
@ -1172,7 +1171,7 @@ def test_export_cancel_then_empty_filename(
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
mwmod.QFileDialog,
|
mwmod.QFileDialog,
|
||||||
"getSaveFileName",
|
"getSaveFileName",
|
||||||
staticmethod(lambda *a, **k: ("", "Text (*.txt)")),
|
staticmethod(lambda *a, **k: ("", "Markdown (*.md)")),
|
||||||
raising=False,
|
raising=False,
|
||||||
)
|
)
|
||||||
w._export() # returns early at filename check
|
w._export() # returns early at filename check
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue