Exemple #1
0
def del_word(keyword):
    if keyword:
        try:
            word = Word.select().where(Word.keyword == keyword).get()
            word.delete_instance()
            print(colored(u'已删除{0}'.format(keyword), 'blue'))
        except Word.DoesNotExist:
            print(colored(u'没有找到{0}'.format(keyword), 'red'))
        config.silent_remove(os.path.join(config.VOICE_DIR, keyword + '.mp3'))
    else:
        count = Word.delete().execute()
        shutil.rmtree(config.VOICE_DIR, ignore_errors=True)
        print(colored(u'共删除{0}个单词'.format(count), 'blue'))
Exemple #2
0
def del_word(keyword):
    if keyword:
        try:
            word = Word.select().where(Word.keyword == keyword).get()
            word.delete_instance()
            print (colored(u"已删除{0}".format(keyword), "blue"))
        except Word.DoesNotExist:
            print (colored(u"没有找到{0}".format(keyword), "red"))
        config.silent_remove(os.path.join(config.VOICE_DIR, keyword + ".mp3"))
    else:
        count = Word.delete().execute()
        shutil.rmtree(config.VOICE_DIR, ignore_errors=True)
        print (colored(u"共删除{0}个单词".format(count), "blue"))
Exemple #3
0
def learn(ctx):
    words = Word.select().where((Word.stage == 0)
                                & (Word.next_review == datetime.today()))
    if not len(words):
        click.echo(f"Your day is clear!")
        return

    for index, word in enumerate(words):
        click.echo(f"{index+1}/{len(words)} {word.en} {word.ch}")
        click.echo("now input this word three times!")
        correct_time = 0
        while correct_time < 3:
            if click.prompt("") == word.en:
                correct_time += 1
                click.echo(f"correct! {correct_time} count!")
            else:
                click.echo(f"Try Again!")
        click.echo("Good work!\n")

    click.echo("You've learned all the words!\n"
               "Now It's time to check how you remember them!\n"
               "Let's go to our first review process!\n")
    ctx.invoke(review, words)
Exemple #4
0
def show_db_list():
    print colored(u'保存在数据库中的单词及查询次数:', 'blue')
    for word in Word.select():
        print colored(word.keyword, 'cyan'), colored(str(word.count), 'green')
Exemple #5
0
def show_db_list():
    print colored(u"保存在数据库中的单词及查询次数:", "blue")
    for word in Word.select():
        print colored(word.keyword, "cyan"), colored(str(word.count), "green")