def get_date_and_shop(session): d = shared.get_answer( 'Data zakupów DD-MM-YYYY', date.today().strftime('%d-%m-%Y'), '^[0-4][0-9]-[0-1][0-9]-[0-9]{4}' ) sklep = shared.choice('Wybierz sklep', session, m.Sklep, shared.enter_new(m.Sklep, session)) return datetime.strptime(d, '%d-%m-%Y'), sklep
'Wybierz podkategorię: ', session, m.Podkategoria, shared.enter_new(m.Podkategoria, kategoria), query_processor = lambda x: x.filter(m.Podkategoria.kategoria_id == kategoria.id) ) produkt = shared.choice( 'Wybierz produkt: ', session, m.Produkt, shared.enter_new(m.Produkt, podkategoria), query_processor = lambda x: x.filter(m.Produkt.podkategoria_id == podkategoria.id).order_by(m.Produkt.nazwa) ) cena = shared.get_answer( 'Cena: ', None, '[0-9]{0,5}(\.|,)[0-9]{0,2}' ) cena = string.replace(cena, ',', '.') ilosc = shared.get_answer( 'Ilosc', '1', '([1-9][0-9]*)?(\.|,)?[0-9]*' ) ilosc = string.replace(ilosc, ',', '.') zakup = m.Zakup(data, sklep, produkt, Decimal(cena), Decimal(ilosc)) session.add(zakup) moar = shared.get_answer( 'Dalej?', 't', 't|n'