Example #1
0
def search(w):
    finds = Word.select().where(Word.title == w)
    if finds:
        find = finds[0]
        return find.pron, find.brief, find.full
    else:
        return search_iciba(w)
Example #2
0
def get_data_of_day(fr, to):
    return Word.select().\
        where(~Word.last_modify.is_null()).\
        where(Word.last_modify.year>=fr.year).\
        where(Word.last_modify.month>=fr.month).\
        where(Word.last_modify.day>=to.day).\
        where(Word.last_modify.year<=to.year).\
        where(Word.last_modify.month<=to.month).\
        where(Word.last_modify.day<=to.day)
Example #3
0
def get_data_of_day(fr, to):
    # frr = datetime.datetime.combine(fr, datetime.time.min)
    # too = datetime.datetime.combine(fr, datetime.time.max)
    return Word.select().where(~Word.last_modify.is_null()).\
        where(Word.last_modify.year>=fr.year).\
        where(Word.last_modify.month>=fr.month).\
        where(Word.last_modify.day>=to.day).\
        where(Word.last_modify.year<=to.year).\
        where(Word.last_modify.month<=to.month).\
        where(Word.last_modify.day<=to.day)
Example #4
0
def task_for_today():
    ws = get_data_of_day(datetime.date.today(), datetime.date.today())

    if ws.count() > 30:
        print('==== review today ({}) ===='.format(ws.count()))
        ws = ws.order_by(fn.random())
        print_ws(ws, False)
    else:
        print('==== new today ====')
        ws = Word.select().where(Word.last_modify.is_null()).\
            order_by(((Word.count-0.8) * Word.id).desc(), Word.id.desc()).\
            limit(65)
        print_ws(ws, True)
Example #5
0
def task_for_review():
    cr = (1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 15)
    cr = [
        datetime.datetime.now().date() - datetime.timedelta(days=i) for i in cr
    ]
    cr = [i.year * 10000 + i.month * 100 + i.day for i in cr]

    # how does peewee support |(col1, col2) << ((a,b), (c,d))| ?
    ws = Word.select().\
            where(~Word.last_modify.is_null()). \
            where((Word.last_modify.year*10000+Word.last_modify.month*100+Word.last_modify.day) << cr).\
            order_by(Word.last_modify.desc(), fn.random())

    print_ws(ws, False)
Example #6
0
 def update_detail(self):
     sels = self.tv.selection()
     if sels:
         text = self.tv.item(sels[0], 'text')
         ws = Word.select().where(Word.title == text)
         if ws:
             w = ws[0]
             detail = w.full
             if not detail:
                 detail = w.brief
             # self.detail['text'] = detail
             self.detail.config(state=tkinter.NORMAL)
             self.detail.delete(1.0, tkinter.END)
             self.detail.insert(tkinter.END, detail)
             self.detail.config(state=tkinter.DISABLED)
Example #7
0
def task_from_prehistory():
    print('==== from prehistory ====')
    ws = Word.select().where(Word.last_modify.is_null()).\
        order_by(((Word.count-0.8) * Word.id).desc(), Word.id.desc()).\
        limit(65)
    return ws