from core_10x.code_samples.person import Person
from core_10x.exec_control import CACHE_ONLY
from core_10x.trait_filter import BETWEEN, NE, OR, f

if __name__ == '__main__':
    with CACHE_ONLY():
        p = Person(first_name = 'Sasha', last_name = 'Davidovich')

    r = OR(
        f(age=BETWEEN(50, 70), first_name=NE('Sasha')),
        f(age=17)
    )

    print(r.prefix_notation())
    print(r.eval(p))

    name = 'IBM Book'
    query = f(OR(f(book1_name = name), f(book2_name = name)))
    print(query.prefix_notation())
