klieret / anki-merge-notes

Anki plugin to merge notes.
GNU Affero General Public License v3.0
6 stars 0 forks source link

TypeError: <lambda>() takes exactly 1 argument (0 given) #1

Closed nicolasmaia closed 7 years ago

nicolasmaia commented 7 years ago

Database checked, that's not the issue. Running Anki version 2.0.42 Qt 4.8.1 PyQt 4.9.1 on GNU/Linux.

I think the docs aren't too clear on one point: should I manually tag every duplicate card? I manually tagged two cards to test the addon, adding to_notes and from_notes. When I tried merging, I got the error message in the title.

The cards have exactly the same fields. I didn't modify the source on the first run; got the error. I then tried adding some fields like Reading and Hint that were not in the source, this way:

        u'Onyomi': "from"
        u'Reading': "to"
        u'Hint': "to"
        u'Sound': "merge_ft"

When I restarted Anki, however, I got the following error message:

Traceback (most recent call last):
  File "aqt/addons.py", line 41, in loadAddons
  File "/home/pizzaiolo/Documentos/Anki/addons/merge_notes.py", line 4, in <module>
    import merge_notes_files.run
  File "/home/pizzaiolo/Documentos/Anki/addons/merge_notes_files/run.py", line 5, in <module>
    from .merge_notes import MergeNotes
  File "/home/pizzaiolo/Documentos/Anki/addons/merge_notes_files/merge_notes.py", line 52
    u'Reading': "to"
              ^
SyntaxError: invalid syntax

For reference, my cards are not kanji, and their fields are Reading, Hint, Expression and Sound.

What can I try?

klieret commented 7 years ago

Hi! Thanks for your interest in that snippet.

So just so that I understand this correctly: You have your 4 fields: Reading, Hint, Expression, Sound, right? So the modified part should read

self.field_merge_modes = {
            u'Reading': "from",
            u'Hint': "to",
            u'Expression': "to",
           u'Sound': "merge_fr",
}

Note that all the other fields are deleted. Also note that there are commas ',' behind every line! I am pretty sure you forgot them, this seems to be your error message after you started Anki: Python complains because there's no comma behind u'Reading': "to".

klieret commented 7 years ago

As for the error complaining about the lambda. This seems to be an issue with line 104 in merge_notes.py. I am looking into it.

klieret commented 7 years ago

The new commit should fix the bug. So please redownload/clone the repository, do your changes again (don't forget the commas) and that should do it.

If you still get this error (or the other one), could you please include

  1. the full error message (like you did with the TypeError)
  2. the log merge_notes_logging.log which should be in the same folder as the addon files

If the issue is fixed, please let me know too!

Cheers, Kilian

klieret commented 7 years ago

Oh and as for the initial question: Yes, you have to tag every single tag (it was written to merge to whole decks, so large scale merging is the usage case). I don't know what exactly you want to, but you can just search for notes and then bulk tag them via the standard Anki interface I think.

nicolasmaia commented 7 years ago

Neat! Thanks a lot. I ended up using https://github.com/vgck/merge-notes, and that worked out for me. That one is more like an atomic blast whereas this one is more fine-grained, so I'll likely have uses for both in the future.

Thanks for taking the time to look through it. If I run into trouble again I'll likely return to this issue, but in the meantime, feel free to close it :)

nicolasmaia commented 7 years ago

Oh, one last thing: I tried installing your addon through AnkiHub (which is neat because it automatically updates addons) but I wasn't able to. Not sure if the problem is on your end or theirs, but if there's something that can be done to have anki-merge-notes compatible with AnkiHub, I think it'd be great.

klieret commented 7 years ago

Oh nice, I didn't find the plugin from vgck when I was looking for something like this a while back ;) Also thanks for the pointer to AnkiHub, I will add that as a feature request for now, but it looks very promising. Maybe I will find time to add that to my anki Addons later.