Skip to content
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

Add deck and note options. #12

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge 'upstream/master' into options.
  • Loading branch information
holocronweaver committed Sep 1, 2017
commit 8286fbc331999050fb10fe4adbaa7472f89f1ca2
4 changes: 2 additions & 2 deletions genanki/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def reps_left_til_grad(self, value):


class Card:
def __init__(self, ord_, options=None):
self.ord = ord_
def __init__(self, ord, options=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this options object, you can't directly set properties on the Card. For example, you can't do my_card.type = 1, you have to do my_card.options.type = 1, which seems like an unnecessary level of indirection and doesn't mesh with how other objects (Notes and Decks) work. Can you make these direct properties of Card and get rid of the CardOptions class?

To achieve what you're trying to do with CardOptions, you can write a helper function (in your own code) like

def set_card_attributes(card, attrs):
    for a in attr:
        setattr(card, a, attrs[a])

and then write code like

my_attrs = {'type': 2, 'due': 1234}
for note in notes:
    for card in note.cards:
        set_card_attributes(card, my_attrs)

self.ord = ord
self.options = options or CardOptions()

def write_to_db(self, cursor, now_ts, deck_id, note_id):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.