Ejemplo n.º 1
0
def has_type(value):
    the_type = Types.get_entry(string.lower(value), 0)

    if the_type is None:
        raise TypeError, "no such entry type"

    return Search.TypeTester(the_type)
Ejemplo n.º 2
0
def _split_req(req):
    test = None

    list = map(string.strip, string.split(req, '|'))
    if len(list) > 1:
        for e in list:
            if test == None:
                test = _split_req(e)
            else:
                test = test | _split_req(e)
        return test

    list = map(string.strip, string.split(req, '&'))
    if len(list) > 1:
        for e in list:
            if test == None:
                test = _split_req(e)
            else:
                test = test & _split_req(e)
        return test

    list = map(string.strip, string.split(req, '!='))
    if len(list) > 2:
        raise SyntaxError, 'invalid test'

    if len(list) == 2:
        return -Search.Tester(string.lower(string.strip(list[0])),
                              string.strip(list[1]))

    list = map(string.strip, string.split(req, '='))
    if len(list) > 2:
        raise SyntaxError, 'invalid test'

    if len(list) == 2:
        return Search.Tester(string.lower(string.strip(list[0])),
                             string.strip(list[1]))

    for e in Types.SearchedFields:
        if test == None:
            test = Search.Tester(string.lower(e), string.strip(list[0]))
        else:
            test = test | Search.Tester(string.lower(e), string.strip(list[0]))

    return test
Ejemplo n.º 3
0
    def simple_search(self, w, *arg):
        q = w.get_text().strip()
        if q:
            try:
                test = SearchCls.AnyTester(q.encode('latin-1'))
            except UnicodeEncodeError:
                Utils.error_dialog_s(_("your search text must contain\nlatin-1 characters only"))
                return
        else:
            test = None

        self.limit_view(q, test)
Ejemplo n.º 4
0
def after(field, year, month=None, day=None):
    return -Search.DateTester(field, Fields.Date((year, month, day)))
Ejemplo n.º 5
0
def before(field, year, month=None, day=None):
    return Search.DateTester(field, Fields.Date((year, month, day)))
Ejemplo n.º 6
0
def any_has(value):
    return Search.AnyTester(value)
Ejemplo n.º 7
0
def has_key(value):
    return Search.KeyTester(value)
Ejemplo n.º 8
0
def has(field, value):
    return Search.Tester(field, value)