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)
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
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)
def after(field, year, month=None, day=None): return -Search.DateTester(field, Fields.Date((year, month, day)))
def before(field, year, month=None, day=None): return Search.DateTester(field, Fields.Date((year, month, day)))
def any_has(value): return Search.AnyTester(value)
def has_key(value): return Search.KeyTester(value)
def has(field, value): return Search.Tester(field, value)