HelenFoster / JSentenceHighlighter

6 stars 1 forks source link

Anki 2.1 Compatibility #2

Closed gajewsk2 closed 4 years ago

gajewsk2 commented 5 years ago

Would it be possible to get this moved over to anki 2.1 soon? Love this add-on

MrPiethon commented 5 years ago

I am also wondering the same thing. Please and thank you! (would a $5 coffee gift incentive work? :) )

HelenFoster commented 5 years ago

I'm planning to, though reluctant to promise anything considering the story up to this point.

HelenFoster commented 5 years ago

Right, you can use it now. I still need to rewrite the config before it goes to AnkiWeb.

gajewsk2 commented 5 years ago

I fixed the error below by: with open(conf.deinflectionFile, encoding="utf8") as f: notice the encoding bit.

After that everything worked as expected.


An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.5 Python 3.6.1 Qt 5.9.2 PyQt 5.9
Platform: Windows 10
Flags: frz=True ao=True sv=1

Caught exception:
  File "C:\Users\Micah\AppData\Roaming\Anki2\addons21\jsentencehighlighter\__init__.py", line 32, in highlightSelected
    highlightSentences(browser.selectedNotes())
  File "C:\Users\Micah\AppData\Roaming\Anki2\addons21\jsentencehighlighter\__init__.py", line 20, in highlightSentences
    run.highlightSentences(nids)
  File "C:\Users\Micah\AppData\Roaming\Anki2\addons21\jsentencehighlighter\run.py", line 61, in highlightSentences
    wordFinder = core.WordFinder(conf)
  File "C:\Users\Micah\AppData\Roaming\Anki2\addons21\jsentencehighlighter\core.py", line 23, in __init__
    srcdic = json.load(f)
  File "json\__init__.py", line 296, in load
  File "C:\Users\dae\AppData\Local\Programs\Python\Python36-32\lib\encodings\cp1252.py", line 23, in decode
<class 'UnicodeDecodeError'>: 'charmap' codec can't decode byte 0x81 in position 49: character maps to <undefined>```
HelenFoster commented 5 years ago

Thanks for the report. encoding isn't backwards-compatible, so does this fix the problem for you?

with open(conf.deinflectionFile, "rb") as f:

HelenFoster commented 5 years ago

Some testing on Windows suggests the above is how it is, so I've pushed it like that.

MrPiethon commented 5 years ago

Seems to work perfectly on windows. Nice job :)