Skip to content

Commit

Permalink
Fix issue 142
Browse files Browse the repository at this point in the history
Stvad#142
Lots of deprecated items when starting anki with crowdanki
  • Loading branch information
evandrocoan committed Nov 24, 2021
1 parent 789e2ff commit 209802c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion representation/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def serialization_dict(self):
def get_media_file_list(self, data_from_models=True, include_children=True):
media = set()
for note in self.notes:
for media_file in self.collection.media.filesInStr(note.anki_object.mid, note.anki_object.joinedFields()):
anki_object = note.anki_object
join_fields = anki_object.joined_fields if hasattr(anki_object, 'joined_fields') else anki_object.joinedFields
for media_file in self.collection.media.filesInStr(anki_object.mid, join_fields()):
media.add(media_file)

if include_children:
Expand Down
4 changes: 3 additions & 1 deletion representation/deck_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def __init__(self, anki_deck_config=None):

@classmethod
def from_collection(cls, collection, deck_config_id):
anki_dict = collection.decks.getConf(deck_config_id)
decks = collection.decks
get_conf = decks.get_conf if hasattr(decks, 'get_conf') else decks.getConf
anki_dict = get_conf(deck_config_id)
deck_config = DeckConfig(anki_dict)
deck_config._update_fields()

Expand Down
6 changes: 4 additions & 2 deletions representation/deck_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@


def from_collection(collection, name, deck_metadata=None, is_child=False) -> Deck:
anki_dict = collection.decks.byName(name)
decks = collection.decks
by_name = decks.by_name if hasattr(decks, 'by_name') else decks.byName
anki_dict = by_name(name)

if AnkiDeck(anki_dict).is_dynamic:
return None
Expand All @@ -20,7 +22,7 @@ def from_collection(collection, name, deck_metadata=None, is_child=False) -> Dec

deck.notes = Note.get_notes_from_collection(collection, deck.anki_dict["id"], deck.metadata.models)

direct_children = [child_name for child_name, _ in collection.decks.children(deck.anki_dict["id"])
direct_children = [child_name for child_name, _ in decks.children(deck.anki_dict["id"])
if Deck.DECK_NAME_DELIMITER
not in child_name[len(name) + len(Deck.DECK_NAME_DELIMITER):]]

Expand Down

0 comments on commit 209802c

Please # to comment.