Skip to content

Commit

Permalink
💥 Remove write capabilities
Browse files Browse the repository at this point in the history
This is until we can solve #137
  • Loading branch information
klieret committed Oct 11, 2023
1 parent a8ae093 commit 20f6476
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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`:
Expand Down
14 changes: 14 additions & 0 deletions ankipandas/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/klieret/AnkiPandas/issues/137/>`_.
Help in fixing this issue would be greatly appreciated!
.. danger::
The switches ``modify``, ``add`` and ``delete`` will run additional
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions ankipandas/test/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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)
2 changes: 1 addition & 1 deletion ankipandas/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.14
0.3.15

0 comments on commit 20f6476

Please sign in to comment.