From 20f6476a9101e925083f04e00023d29e05c00d2c Mon Sep 17 00:00:00 2001 From: Kilian Lieret Date: Wed, 11 Oct 2023 14:54:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20Remove=20write=20capabilities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is until we can solve #137 --- CHANGELOG.md | 8 ++++++++ README.md | 14 +++++++++++--- ankipandas/collection.py | 14 ++++++++++++++ ankipandas/test/test_collection.py | 10 +++++----- ankipandas/version.txt | 2 +- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b0dd87..96d6786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.3.15 -- 2023-10-11 + +### Removed + +- `Collection.write` now raises a `NotImplementedError` because + https://github.com/klieret/AnkiPandas/issues/137 has so far not been + resolved and has caused numerous problems. + ## 0.3.14 -- 2023-05-14 ### Fixed diff --git a/README.md b/README.md index 3fc1a4e..3593a4e 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ your Anki flashcards. or switch to the even more versatile [seaborn](https://seaborn.pydata.org/) (statistical analysis) or [matplotlib](https://matplotlib.org/) libraries -- **Manipulate & adding notes and cards**: Apply fast bulk operations to the table (e.g. add +- **Manipulate**: Apply fast bulk operations to the table (e.g. add tags, change decks, set field contents, suspend cards, \...) or - iterate over the table and perform these manipulations step by step. **This is still in alpha/beta! Proceed with care and please report bugs!** (but ankipandas will always create a backup of your database before changing something). + iterate over the table and perform these manipulations step by step. + **⚠️ This functionality is currently disabled until [#137](https://github.com/klieret/AnkiPandas/issues/137) has been resolved! ⚠️** - **Import and Export**: Pandas can export to (and import from) csv, MS Excel, HTML, JSON, \... ([io documentation](https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html)) @@ -161,7 +162,14 @@ notes.query("model=='MnemoticModel' and 'Mnemotic'==''") ## 🛠️ Manipulations -**Please be careful and test this well!** Ankipandas will create a backup of your database before writing, so you can always restore the previous state. Please make sure that everything is working before continuing to use Anki normally! +> **Danger** +> Writing the database has currently been disabled until +> [#137](https://github.com/klieret/AnkiPandas/issues/137) has been resolved. +> Help is much appreviated! + +> **Warning** +> **Please be careful and test this well!** +> Ankipandas will create a backup of your database before writing, so you can always restore the previous state. Please make sure that everything is working before continuing to use Anki normally! Add the `difficult-japanese` and `marked` tag to all notes that contain the tags `Japanese` and `leech`: diff --git a/ankipandas/collection.py b/ankipandas/collection.py index d888418..d039153 100644 --- a/ankipandas/collection.py +++ b/ankipandas/collection.py @@ -251,10 +251,17 @@ def write( add=False, delete=False, backup_folder: PurePath | str | None = None, + _override_exception=False, ): """Creates a backup of the database and then writes back the new data. + .. danger:: + + The write capabilities of ``AnkiPandas`` have currently been disabled + because of `#137 `_. + Help in fixing this issue would be greatly appreciated! + .. danger:: The switches ``modify``, ``add`` and ``delete`` will run additional @@ -280,6 +287,13 @@ def write( Returns: None """ + if not _override_exception: + raise NotImplementedError( + "The write capabilities of AnkiPandas have currently been disabled" + " because of https://github.com/klieret/AnkiPandas/issues/137/. " + "Help in fixing this issue would be greatly appreciated!" + ) + if not modify and not add and not delete: log.warning( "Please set modify=True, add=True or delete=True, you're" diff --git a/ankipandas/test/test_collection.py b/ankipandas/test/test_collection.py index bf2050a..be33c5c 100644 --- a/ankipandas/test/test_collection.py +++ b/ankipandas/test/test_collection.py @@ -63,7 +63,7 @@ def test_read_write_identical_trivial(db_path, tmpdir): (pathlib.Path(str(tmpdir)) / "backups").mkdir() col = Collection(db_path) _init_all_tables(col) - col.write(modify=True, delete=True, add=True) + col.write(modify=True, delete=True, add=True, _override_exception=True) col_rel = Collection(db_path) assert col.notes.equals(col_rel.notes) assert col.cards.equals(col_rel.cards) @@ -84,7 +84,7 @@ def test_write_raises_delete(db_path, tmpdir): ] for case in cases: with pytest.raises(ValueError, match=".*would be deleted.*"): - col.write(**case, delete=False) + col.write(**case, delete=False, _override_exception=True) @parameterized_paths() @@ -101,7 +101,7 @@ def test_write_raises_modified(db_path, tmpdir): ] for case in cases: with pytest.raises(ValueError, match=".*would be modified.*"): - col.write(**case, modify=False) + col.write(**case, modify=False, _override_exception=True) @parameterized_paths() @@ -118,7 +118,7 @@ def test_write_raises_added(db_path, tmpdir): ] for case in cases: with pytest.raises(ValueError, match=".*would be modified.*"): - col.write(**case, add=False) + col.write(**case, add=False, _override_exception=True) @parameterized_paths() @@ -128,4 +128,4 @@ def test_write_added(db_path, tmpdir): col = Collection(db_path) _init_all_tables(col) col.notes.add_note("Basic", ["test", "back"], inplace=True) - col.write(add=True) + col.write(add=True, _override_exception=True) diff --git a/ankipandas/version.txt b/ankipandas/version.txt index 0b69c00..9e29e10 100644 --- a/ankipandas/version.txt +++ b/ankipandas/version.txt @@ -1 +1 @@ -0.3.14 +0.3.15