Closed 4SoG closed 5 years ago
I'll look into this. Hope I'll finde some time next week.
I know that there's also https://github.com/vgck/merge-notes if you need something right now.
But I'd be happy if you could test my fix (if I find the problem anytime soon).
I might also update this addon to anki 2.1 (is issue #3)...
Thank you, klieret. I'd had a look at the other merge addons but yours provides much more control over the merging results and seems perfect for my needs. I'll be glad to help with testing the fix.
I forgot to provide the contents of the log file before, here it is:
SyncFields:DEBUG:Setting up menu. SyncFields:DEBUG:Found 2 notes with tag_from MERGE_FROM SyncFields:DEBUG:Found 1 notes with tag_to MERGE_TO SyncFields:DEBUG:looping to build db SyncFields:DEBUG:Statistics: ok: zero_from: zero_to: many_from: answer many_to:
This is with the following settings:
self.strip_html = False
self.strip_html_permanently = False
self.dry = True
When I tried with the default settings, i.e.:
self.strip_html = True
self.strip_html_permanently = True
self.dry = False
I got a slightly different error:
Traceback (most recent call last): File "aqt\webview.py", line 152, in _linkHandler File "aqt\toolbar.py", line 74, in _linkHandler File "aqt\toolbar.py", line 91, in _browseLinkHandler File "aqt\main.py", line 709, in onBrowse File "aqt__init.py", line 61, in open File "aqt\browser.py", line 362, in init__ File "aqt\browser.py", line 441, in setupMenus File "anki\hooks.py", line 26, in runHook File "C:\Users\4SoG\AppData\Roaming\Anki2\addons\merge_notes_files\merge_notes.py", line 111, in setup_menu self.dry)) File "C:\Users\4SoG\AppData\Roaming\Anki2\addons\merge_notes_files\merge_notes.py", line 144, in loop expr = strip_html(expr).strip() TypeError: 'bool' object is not callable
and the following log:
SyncFields:DEBUG:Setting up menu. SyncFields:DEBUG:Found 2 notes with tag_from MERGE_FROM SyncFields:DEBUG:Found 1 notes with tag_to MERGE_TO SyncFields:DEBUG:Stripping HTML from match field from all notes SyncFields:DEBUG:looping to build db
Btw, am I right assuming that replacing
self.match_field = u"Expression"
with
self.match_field = u"Answer"
(since the field I want to compare is called "Answer") would require changing
expr = note["Expression"]
with
expr = note["Answer"]
in lines 142 and 149?
For the time being, I have renamed the "Answer" field in my test notes to "Expression" but I'd rather keep the former name.
You're definitely right about the Expression
field. That's an obvious bug and I've just pushed the fix (the two lines you mentioned should just take self.match_field
as well).
Ok I think I got both problems with the last two commits (but I haven't tested it yet...).
Thanks for the quick response! I've tested the current version and now the menu item in the card browser gets created without issues. But, it doesn't seem to work. I've tried with
self.dry = True
and
self.dry = False
but in both cases there was no reaction at all (no error messages either) and the notes haven't been merged.
Here's the current log:
SyncFields:DEBUG:Setting up menu. SyncFields:DEBUG:Found 2 notes with tag_from MERGE_FROM SyncFields:DEBUG:Found 1 notes with tag_to MERGE_TO SyncFields:DEBUG:looping to build db SyncFields:DEBUG:Statistics: ok: zero_from: zero_to: many_from: answer many_to:
Based on the comment on #3 it should work now.
Looking at the log: You have 2 notes to merge from and 1 to merge to, but it looks like both of the merge from notes have the same matching field as merge to. Thus it would be a many to one merging (2 cards merged into one more card, so 3 in total). This is not supported (yet). Is that intended?
This can also be seen from the statistics: Only the notes shown after 'ok' will be merged.
(and with self.try == True
nothing happens by design, this is if you just want to see the statistics)
Oh, sorry, I thought that setting self.try == True
would show up a window or a tooltip with a list of notes to merge.
As for the issue, it seems the main problem is I misunderstood how the addon works. You are right - when I removed the MERGE_FROM tag from one note, the other two did get merged. Thank you very much for the fix.
And I have to say that this addon is just brilliant. What I like most about it (apart from the fact that it allows you to control which fields to merge and which to keep unchanged) is that it updates an existing note instead of creating a new one.
But, my main purpose was actually to merge multiple (i.e. more than two) notes into one. I am learning Irish and have imported a few vocabulary decks which often have the same words/phrases but different audio, examples, notes etc., so in many cases I have 3-4 notes with the same answer. I would like to keep all that information (especially audio as it's pretty rare to find decks with sound files for Irish, but grammar notes/examples are also important for me) in a single note to reduce workload.
Do you think you could implement this feature?
Once more, thank you very much for your assistance and supporting the addon.
Yeah, there's so much to be improved. The statistics should definitely appear as a popup and also prompt for confirmation or something. This really started as a quick and dirty one time solution for me, so I didn't put in much work back then.
As for merging multiple notes, I just opened #5, so let's discuss there and will close this issue.
Hi,
First of all, thanks for providing the addon. Unfortunately, I keep getting the following error when I try to open the card browser with this addon installed:
Traceback (most recent call last): File "aqt\webview.py", line 152, in _linkHandler File "aqt\toolbar.py", line 74, in _linkHandler File "aqt\toolbar.py", line 91, in _browseLinkHandler File "aqt\main.py", line 709, in onBrowse File "aqt__init.py", line 61, in open File "aqt\browser.py", line 362, in init__ File "aqt\browser.py", line 441, in setupMenus File "anki\hooks.py", line 26, in runHook File "C:\Users\4SoG\AppData\Roaming\Anki2\addons\merge_notes_files\merge_notes.py", line 111, in setup_menu self.dry)) TypeError: arguments did not match any overloaded call: QObject.connect(QObject, SIGNAL(), QObject, SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 3 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), callable, Qt.ConnectionType=Qt.AutoConnection): argument 3 has unexpected type 'NoneType' QObject.connect(QObject, SIGNAL(), SLOT(), Qt.ConnectionType=Qt.AutoConnection): argument 3 has unexpected type 'NoneType'
I am running Anki Version 2.0.52 Qt 4.7.4 PyQt 4.8.6 on Windows 10 Version 1809 (OS Build 17763.615) 32 bit. Have tried disabling all the other addons but it didn't help.
I would be very grateful for your assistance with making the addon work.