Exemplo n.º 1
0
def cmd_deck(arg):
    """Create or load an active deck.

    Required: Deck name to load, or to create if it does not exist.
    """
    global active_deck
    if not arg:
        raise UsageError('NAME')
    try:
        with open(deck.filename(arg), "rb") as f:
            active_deck = pickle.load(f)
            print('Loaded deck \'' + active_deck.name + '\'.')
    except IOError:
        active_deck = deck.Deck(arg)
        print('Created new deck \'' + active_deck.name + '\'.')
Exemplo n.º 2
0
def cmd_deck(arg):
    """Create or load an active deck.

    Required: Deck name to load, or to create if it does not exist.
    """
    global active_deck
    if not arg:
        raise UsageError('NAME')
    try:
        with open(deck.filename(arg), "rb") as f:
            active_deck = pickle.load(f)
            print('Loaded deck \'' + active_deck.name + '\'.')
    except IOError:
        active_deck = deck.Deck(arg)
        print('Created new deck \'' + active_deck.name + '\'.')
Exemplo n.º 3
0
def cmd_save(arg):
    """Save the active deck."""
    assert_activedeck()
    with open(deck.filename(active_deck.name), "wb") as f:
        pickle.dump(active_deck, f)
    print('Saved deck \'' + active_deck.name + '\'.')
Exemplo n.º 4
0
def cmd_save(arg):
    """Save the active deck."""
    assert_activedeck()
    with open(deck.filename(active_deck.name), "wb") as f:
        pickle.dump(active_deck, f)
    print('Saved deck \'' + active_deck.name + '\'.')