Comments (6)
Ah, yes. If you were to quit with :cquit
in Vim, this would work as expected. But I think apy does not properly handle if the notes are not parseable (e.g. if you try to add an empty note, as in this case). I'll fix it. I guess the most natural behaviour would be to issue a warning when a note was not successfully parsed, and then avoid the error.
from apy.
Thanks! I've copied your cli tests! I was not aware of the click.testing
module and I very much like the use of the temporary directories for testing as you've done here. Again, thanks!
Also, I can now reproduce the error and I'll look into a way to fix it!
from apy.
Thanks! I added a similar check for the n_notes
attribute. In principle, I think there might still be a slight bug here, since the empty.md
note is still parsed and we try to add it. It is detected as a dupe and so no notes are actually added.
In any case, I think the point here is not to become perfect. Good is good enough. When I make mistakes, I have found I can still use apy to fix them quite easily with the apy review
function.
I really appreciate your effort, it is very nice to get some help in fixing issues and improving this utility. apy
is already at 95% fully functional for me, but it might have some rough edges especially with regard to other users workflows and similar. As such, it is very nice to get help in fixing these.
from apy.
Ok, I can't quite reproduce this, actually. I think the issue is something else. Not sure exactly how to fix this unlless I can reproduce it, sorry.
Note: You should clean up such notes with e.g. apy review -q added:1
or the Anki browser and delete them, as it seems you might have actually added notes this way.
from apy.
Ok, I can't quite reproduce this, actually. I think the issue is something else. Not sure exactly how to fix this unlless I can reproduce it, sorry.
Have a look at my cli-tests
branch, the test case test_cli_add_from_file
reproduces it for me. I tested using the CLI interface itself because I couldn't reproduce it with the a.add_notes_from_file(filename)
way like in the current test functions. Does this show the problem on your end?
(oh and you'll need to run pytest --ignore=tests/test_decks.py
because that branch doesn't have this change in it)
from apy.
Returning early if n_decks == 0
in add
and add_from_file
seemed to fix it for me:
diff --git a/apy/cli.py b/apy/cli.py
index d6dfcf0..221bc5e 100644
--- a/apy/cli.py
+++ b/apy/cli.py
@@ -76,6 +76,10 @@ def add(tags, model, deck):
decks = [a.col.decks.name(c.did) for n in notes for c in n.n.cards()]
n_notes = len(notes)
n_decks = len(decks)
+
+ if n_decks == 0:
+ click.echo("No notes added")
+ return None
if a.n_decks > 1:
if n_notes == 1:
@@ -108,6 +112,10 @@ def add_from_file(file, tags):
n_notes = len(notes)
n_decks = len(decks)
+ if n_decks == 0:
+ click.echo("No notes added")
+ return None
+
if a.n_decks > 1:
if n_notes == 1:
click.echo(f'Added note to deck: {decks[0]}')
from apy.
Related Issues (20)
- Can we avoid the dependency on aqt? HOT 4
- GitHub actions issue with caching? HOT 6
- type union syntax breaks on 3.9 HOT 1
- Cannot install apy through pipx in Termux as it cannot detect Anki HOT 8
- `markdown_models` equivalent for `apy add-single`? HOT 9
- Usability: Create default config with `base_path` upon installation for convenience HOT 6
- How do I change the default template? HOT 6
- Using $$-style escapes for math HOT 8
- Specify deck for add-from-file HOT 4
- Can apy be used to convert the contents of a markdown file to anki? HOT 2
- Code shows with white background on Anki HOT 15
- Reverse sync? From Anki to markdown file? HOT 3
- Fallback to `$VISUAL` if `$EDITOR` is unset HOT 1
- `apy list` does not list `cid` like README says HOT 14
- Attempt to change model (via review menu) results in crash HOT 7
- Changing a note type will fill in HTML and not markdown (even if it's semantically the same) HOT 3
- `apy review` menu: Option/keybind to go back to the previous card HOT 4
- Question about markdown detection and LaTeX HOT 9
- Help text of `apy list-from-file -h` is formatted wrong on console HOT 2
- Question: Why does `api info` print `Scheduler version: 2` when only v3 is supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apy.