-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import from disk not working #154
Comments
Thanks for the bug report! I think that the issue is linked to #127 (the underlying cause is that the deck config UUID is unnecessarily attached to the deck (within Anki) by CrowdAnki, and can become stale). You can check by inspecting your If you have direct access to a python interpreter then you could also try this code (for diagnosis)#!/usr/bin/env python3
import json
def get_deck_config_uuids(deck):
uuids = [deck["deck_config_uuid"]]
for child in deck.get("children"):
uuids += get_deck_config_uuids(child)
return uuids
with open("deck.json") as f:
anki_deck = json.load(f)
available_deck_config_uuids = set(
[deck_conf["crowdanki_uuid"] for deck_conf in anki_deck["deck_configurations"]]
)
used_deck_config_uuids = set(get_deck_config_uuids(anki_deck))
all_used_deck_configs_are_defined = used_deck_config_uuids.issubset(
available_deck_config_uuids
)
if all_used_deck_configs_are_defined:
print("The deck.json is OK — there are no undefined 'deck_config_uuid's.")
else:
print("The deck.json is not OK — the following 'deck_config_uuid's. are not defined:")
for s in used_deck_config_uuids - available_deck_config_uuids:
print(s)
You could fix the issue in the Sorry! I should get around to finally getting a release fully ready (this is fixed in |
Thanks for your help, spot on as always. I really appreciate the extensive support you provide! What you point out seems to be the issue. When replacing the uuid from the error massage, it resolves the conflict for that specific uuid. A new one comes up, tho. Could you ellaborate on how to use the python interpreter? For editing the deck.json I use sublime text if that's of interest (I could use any program on windows). I'd like to check how many uuids I'd have to replace. Also, is there an ETA for the update to fix this issue? Depending on that I might save myself the effort of going through countless uuids and just wait it out instead 😅 Unless there is a effiecient and smart way of using the uuid list from your script to replace all of them at once via search and replace or a similar function. Maybe you have some thoughts on that aswell. :) |
Probably ~ two weeks (no promises).
If you have python itself directly installed then you could run the script from python, from the directory containing Regular expressionI think that sublime text (like most text editors) has regular expression find-and-replace, so you could replace the regular expression (This won't match anything other than the deck config UUIDs.) Potential disadvantagesIf you care about which sub-deck has which deck configuration ("deck configurations"/"deck options" control the number of new cards per day, the graduating interval, the easy interval, the starting "ease" etc.), then this approach has the disadvantage of making all the deck configurations the same. Also, with the regexp search, all |
I just tried importing an updated version of deck. To resolve duplicated uuids of notes, I ran the script posted by aplaice here. On import, it asked to change every notetype, whoch shouldn't be the case, right? Not all of them, if any, were modified. After importing, the following error occured. None of the cards was updated or altered in any way.
Debug info:
Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-11-29 19:19:30
Caught exception:
Traceback (most recent call last):
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\anki\ui\action_vendor.py", line 31, in
lambda: AnkiJsonImporter.import_deck(self.window.col, self.directory_vendor))
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\importer\anki_importer.py", line 114, in import_deck
AnkiJsonImporter.import_deck_from_path(collection, Path(directory_path))
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\importer\anki_importer.py", line 103, in import_deck_from_path
if importer.load_deck(directory_path):
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\importer\anki_importer.py", line 41, in load_deck
deck.save_to_collection(self.collection, import_config=import_config)
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\representation\deck.py", line 131, in save_to_collection
self.save_decks_and_notes(collection=collection,
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\representation\deck.py", line 147, in save_decks_and_notes
child.save_decks_and_notes(collection=collection,
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\representation\deck.py", line 144, in save_decks_and_notes
full_name = self._save_deck(collection, parent_name)
File "C:\Users\Jonas\AppData\Roaming\Anki2\addons21\1788670778\representation\deck.py", line 173, in _save_deck
self.anki_dict["conf"] = self.metadata.deck_configs[self.deck_config_uuid].anki_dict["id"]
KeyError: 'd83c6288-3349-11ec-b6d3-287fcffa08a1'
Maybe someone can figure out the issue. Perhaps this is also in any way helpful for further development. :)
The text was updated successfully, but these errors were encountered: