Example #1
0
        ch = sys.stdin.read(1)
    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
    return ch


client = MongoClient('localhost', 27017)
db = client.jiyi

parser = ArgumentParser(description='Add audio files to your collections.')
parser.add_argument('-c', '--collection', type=str, required=True, help='The name of the collection')
args = parser.parse_args()

col = db[args.collection]

cards = [Card.from_dict(**d) for d in col.find({'next_rep': {'$lt': datetime.now()}, 'suspended': {'$eq': False}})]
i = 0
while i < len(cards):
    card = cards[i]

    print(card.text)
    print(OKBLUE + '1-4; [q]uit; [d]elete; [s]uspend; [r]epeat ', end='')
    sys.stdout.flush()
    
    card.play()

    key = getch()
    
    if key == 'q':
        print('q' + ENDC)
        sys.exit(0)