コード例 #1
0
 def ExpandPredicate( self, service_key: bytes, predicate: ClientSearch.Predicate, service_strict: bool = False ):
     
     if not service_strict and self._controller.new_options.GetBoolean( 'apply_all_siblings_to_all_services' ):
         
         service_key = CC.COMBINED_TAG_SERVICE_KEY
         
     
     ideal_sibling_predicate = predicate
     other_sibling_predicates = []
     
     if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG:
         
         tag = predicate.GetValue()
         
         ideal_sibling = self.CollapseTag( service_key, tag, service_strict = service_strict )
         
         ideal_sibling_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, ideal_sibling, predicate.IsInclusive() )
         
         other_siblings = set( self.GetAllSiblings( service_key, tag, service_strict = service_strict ) )
         
         other_siblings.discard( tag )
         other_siblings.discard( ideal_sibling )
         
         other_sibling_predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, sibling, predicate.IsInclusive() ) for sibling in other_siblings ]
         
         
     return ( ideal_sibling_predicate, other_sibling_predicates )
コード例 #2
0
    def test_basics(self):
        def test(obj, dupe_obj):

            self.assertEqual(len(list(obj.items())),
                             len(list(dupe_obj.items())))

            for (key, value) in list(obj.items()):

                self.assertEqual(value, dupe_obj[key])

        #

        d = HydrusSerialisable.SerialisableDictionary()

        d[1] = 2
        d[3] = 'test1'

        d['test2'] = 4
        d['test3'] = 5

        d[6] = HydrusSerialisable.SerialisableDictionary(
            {i: 'test' + str(i)
             for i in range(20)})
        d[ClientSearch.Predicate(ClientSearch.PREDICATE_TYPE_TAG,
                                 'test pred 1')] = 56

        d[ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_TAG,
            'test pred 2')] = HydrusSerialisable.SerialisableList([
                ClientSearch.Predicate(ClientSearch.PREDICATE_TYPE_TAG,
                                       'test' + str(i)) for i in range(10)
            ])

        self.assertEqual(len(list(d.keys())), 7)

        for (key, value) in list(d.items()):

            self.assertEqual(d[key], value)

        self._dump_and_load_and_test(d, test)

        #

        db = HydrusSerialisable.SerialisableBytesDictionary()

        db[HydrusData.GenerateKey()] = HydrusData.GenerateKey()
        db[HydrusData.GenerateKey()] = [
            HydrusData.GenerateKey() for i in range(10)
        ]
        db[1] = HydrusData.GenerateKey()
        db[2] = [HydrusData.GenerateKey() for i in range(10)]

        self.assertEqual(len(list(db.keys())), 4)

        for (key, value) in list(db.items()):

            self.assertEqual(db[key], value)

        self._dump_and_load_and_test(db, test)
コード例 #3
0
def filetype_pred_generator( v ):
    
    # v is a list of non-hydrus-standard filetype strings
    
    mimes = ( 1, )
    
    return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, mimes )
コード例 #4
0
ファイル: ClientManagers.py プロジェクト: cutie/hydrus
    def ExpandPredicates(self, service_key, predicates, service_strict=False):

        if not service_strict and self._controller.new_options.GetBoolean(
                'apply_all_parents_to_all_services'):

            service_key = CC.COMBINED_TAG_SERVICE_KEY

        results = []

        with self._lock:

            for predicate in predicates:

                results.append(predicate)

                if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG:

                    tag = predicate.GetValue()

                    parents = self._service_keys_to_children_to_parents[
                        service_key][tag]

                    for parent in parents:

                        parent_predicate = ClientSearch.Predicate(
                            ClientSearch.PREDICATE_TYPE_PARENT, parent)

                        results.append(parent_predicate)

            return results
コード例 #5
0
def FilterAndConvertLabelPredicates(
    predicates: typing.Collection[ClientSearch.Predicate]
) -> typing.List[ClientSearch.Predicate]:

    good_predicates = []

    for predicate in predicates:

        predicate = predicate.GetCountlessCopy()

        predicate_type = predicate.GetType()

        if predicate_type in (ClientSearch.PREDICATE_TYPE_LABEL,
                              ClientSearch.PREDICATE_TYPE_PARENT):

            continue

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_UNTAGGED:

            predicate = ClientSearch.Predicate(
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, (None, '=', 0))

        good_predicates.append(predicate)

    return good_predicates
コード例 #6
0
    def GetSearchPredicates(self) -> typing.List[ClientSearch.Predicate]:

        # with counts? or just merge this into texttag???

        return [
            ClientSearch.Predicate(ClientSearch.PREDICATE_TYPE_TAG, self._tag)
        ]
コード例 #7
0
    def ExpandPredicates(self, service_key, predicates, service_strict=False):

        results = []

        with self._lock:

            for predicate in predicates:

                results.append(predicate)

                if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG:

                    tag = predicate.GetValue()

                    parents = self._service_keys_to_children_to_parents[
                        service_key][tag]

                    for parent in parents:

                        parent_predicate = ClientSearch.Predicate(
                            ClientSearch.PREDICATE_TYPE_PARENT, parent)

                        results.append(parent_predicate)

            return results
コード例 #8
0
 def GetPredicates( self ):
     
     rating = None
     
     if self._rated_checkbox.isChecked():
         
         operator = '='
         rating = 'rated'
         
     elif self._not_rated_checkbox.isChecked():
         
         operator = '='
         rating = 'not rated'
         
     elif self._rating_control.GetRatingState() != ClientRatings.NULL:
         
         operator = self._operator.GetStringSelection()
         
         rating = self._rating_control.GetRating()
         
     
     if rating is None:
         
         return []
         
     else:
         
         predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( operator, rating, self._service_key ) )
         
         return [ predicate ]
コード例 #9
0
def file_service_pred_generator(o, v, u):

    o_dict = {
        'is not currently in': (False, HC.CONTENT_STATUS_CURRENT),
        'is currently in': (True, HC.CONTENT_STATUS_CURRENT),
        'is not pending to': (False, HC.CONTENT_STATUS_PENDING),
        'is pending to': (True, HC.CONTENT_STATUS_PENDING)
    }

    (is_in, status) = o_dict[o]

    try:

        service_name = v

        service_key = HG.client_controller.services_manager.GetServiceKeyFromName(
            HC.FILE_SERVICES, service_name)

    except:

        raise HydrusExceptions.BadRequestException(
            'Could not find the service "{}"!'.format(service_name))

    return ClientSearch.Predicate(
        ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE,
        (is_in, status, service_key))
コード例 #10
0
 def GetPredicates( self ):
     
     rating = None
     
     if self._rated_checkbox.isChecked():
         
         rating = 'rated'
         
     elif self._not_rated_checkbox.isChecked():
         
         rating = 'not rated'
         
     else:
         
         rating_state = self._rating_control.GetRatingState()
         
         if rating_state == ClientRatings.LIKE:
             
             rating = 1
             
         elif rating_state == ClientRatings.DISLIKE:
             
             rating = 0
             
         
     
     if rating is None:
         
         return []
         
     else:
         
         predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', rating, self._service_key ) )
         
         return [ predicate ]
コード例 #11
0
 def CollapsePredicates( self, service_key, predicates, service_strict = False ):
     
     if not service_strict and self._controller.new_options.GetBoolean( 'apply_all_siblings_to_all_services' ):
         
         service_key = CC.COMBINED_TAG_SERVICE_KEY
         
     
     with self._lock:
         
         siblings = self._service_keys_to_siblings[ service_key ]
         
         results = [ predicate for predicate in predicates if predicate.GetType() != ClientSearch.PREDICATE_TYPE_TAG ]
         
         tag_predicates = [ predicate for predicate in predicates if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG ]
         
         tags_to_predicates = {predicate.GetValue() : predicate for predicate in predicates if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG}
         
         tags = list( tags_to_predicates.keys() )
         
         tags_to_include_in_results = set()
         
         for tag in tags:
             
             if tag in siblings:
                 
                 old_tag = tag
                 old_predicate = tags_to_predicates[ old_tag ]
                 
                 new_tag = siblings[ old_tag ]
                 
                 if new_tag not in tags_to_predicates:
                     
                     ( old_pred_type, old_value, old_inclusive ) = old_predicate.GetInfo()
                     
                     new_predicate = ClientSearch.Predicate( old_pred_type, new_tag, old_inclusive )
                     
                     tags_to_predicates[ new_tag ] = new_predicate
                     
                     tags_to_include_in_results.add( new_tag )
                     
                 
                 new_predicate = tags_to_predicates[ new_tag ]
                 
                 new_predicate.AddCounts( old_predicate )
                 
             else:
                 
                 tags_to_include_in_results.add( tag )
                 
             
         
         results.extend( [ tags_to_predicates[ tag ] for tag in tags_to_include_in_results ] )
         
         return results
コード例 #12
0
def num_file_relationships_pred_generator( o, v, u ):
    
    u_dict = {
        'not related/false positive' : HC.DUPLICATE_FALSE_POSITIVE,
        'duplicates' : HC.DUPLICATE_MEMBER,
        'alternates' : HC.DUPLICATE_ALTERNATE,
        'potential duplicates' : HC.DUPLICATE_POTENTIAL
    }
    
    dupe_type = u_dict[ u ]
    
    return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( o, v, dupe_type ) )
コード例 #13
0
def date_pred_generator(pred_type, o, v):

    #Either a tuple of 4 non-negative integers: (years, months, days, hours) where the latter is < 24 OR
    #a datetime.date object. For the latter, only the YYYY-MM-DD format is accepted.

    date_type = 'delta'

    if isinstance(v, datetime.date):

        date_type = 'date'
        v = (v.year, v.month, v.day)

    return ClientSearch.Predicate(pred_type, (o, date_type, tuple(v)))
コード例 #14
0
 def ExpandPredicate( self, service_key: bytes, predicate: ClientSearch.Predicate ):
     
     ideal_sibling_predicate = predicate
     other_sibling_predicates = []
     
     if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG:
         
         tag = predicate.GetValue()
         
         ideal_sibling = self.GetSibling( service_key, tag )
         
         ideal_sibling_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, ideal_sibling, predicate.IsInclusive() )
         
         other_siblings = set( self.GetAllSiblings( service_key, tag ) )
         
         other_siblings.discard( tag )
         other_siblings.discard( ideal_sibling )
         
         other_sibling_predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, sibling, predicate.IsInclusive() ) for sibling in other_siblings ]
         
     
     return ( ideal_sibling_predicate, other_sibling_predicates )
コード例 #15
0
def url_class_pred_generator( include, url_class_name ):
    
    description = ( 'has {} url' if include else 'does not have {} url' ).format( url_class_name )
    
    try:
        
        url_class = HG.client_controller.network_engine.domain_manager.GetURLClassFromName( url_class_name )
        
    except HydrusExceptions.DataMissing as e:
        
        raise ValueError( str( e ) )
        
    
    return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( include, 'url_class', url_class, description ) )
コード例 #16
0
    def GetPredicates(self):

        or_sub_predicates = self._search_control.GetPredicates()

        if len(or_sub_predicates) == 0:

            return []

        elif len(or_sub_predicates) == 1:

            return or_sub_predicates

        or_predicate = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_OR_CONTAINER, or_sub_predicates)

        return [or_predicate]
コード例 #17
0
def file_service_pred_generator( o, v, u ):
    
    if o.startswith( 'is not' ):
        
        is_in = False
        
    else:
        
        is_in = True
        
    
    o_dict = {
        'currently in' : HC.CONTENT_STATUS_CURRENT,
        'deleted from' : HC.CONTENT_STATUS_DELETED,
        'pending to' : HC.CONTENT_STATUS_PENDING,
        'petitioned from' : HC.CONTENT_STATUS_PETITIONED
    }
    
    status = None
    
    for ( phrase, possible_status ) in o_dict.items():
        
        if phrase in o:
            
            status = possible_status
            
            break
            
        
    
    if status is None:
        
        raise HydrusExceptions.BadRequestException( 'Did not understand the file service status!' )
        
    
    try:
        
        service_name = v
        
        service_key = HG.client_controller.services_manager.GetServiceKeyFromName( HC.FILE_SERVICES, service_name )
        
    except:
        
        raise HydrusExceptions.BadRequestException( 'Could not find the service "{}"!'.format( service_name ) )
        
    
    return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( is_in, status, service_key ) )
コード例 #18
0
        bytes_hashlist = tuple((bytes.fromhex(hex_hash)
                                for hex_hash in hex_hashlist_and_other[0]))

    except HydrusExceptions.DataMissing as e:

        raise ValueError(str(e))

    return (bytes_hashlist, hex_hashlist_and_other[1])


SystemPredicateParser.InitialiseFiletypes(HC.mime_enum_lookup)

pred_generators = {
    SystemPredicateParser.Predicate.EVERYTHING:
    lambda o, v, u: ClientSearch.Predicate(ClientSearch.
                                           PREDICATE_TYPE_SYSTEM_EVERYTHING),
    SystemPredicateParser.Predicate.INBOX:
    lambda o, v, u: ClientSearch.SYSTEM_PREDICATE_INBOX.Duplicate(),
    SystemPredicateParser.Predicate.ARCHIVE:
    lambda o, v, u: ClientSearch.SYSTEM_PREDICATE_ARCHIVE.Duplicate(),
    SystemPredicateParser.Predicate.BEST_QUALITY_OF_GROUP:
    lambda o, v, u: ClientSearch.Predicate(
        ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True),
    SystemPredicateParser.Predicate.NOT_BEST_QUALITY_OF_GROUP:
    lambda o, v, u: ClientSearch.Predicate(
        ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False),
    SystemPredicateParser.Predicate.HAS_AUDIO:
    lambda o, v, u: ClientSearch.Predicate(
        ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True),
    SystemPredicateParser.Predicate.NO_AUDIO:
    lambda o, v, u: ClientSearch.Predicate(
コード例 #19
0
    def test_duplicates(self):

        self._dupe_hashes = [HydrusData.GenerateKey() for i in range(16)]
        self._second_group_dupe_hashes = [
            HydrusData.GenerateKey() for i in range(4)
        ]
        self._similar_looking_alternate_hashes = [
            HydrusData.GenerateKey() for i in range(5)
        ]
        self._similar_looking_false_positive_hashes = [
            HydrusData.GenerateKey() for i in range(5)
        ]

        self._all_hashes = set()

        self._all_hashes.update(self._dupe_hashes)
        self._all_hashes.update(self._second_group_dupe_hashes)
        self._all_hashes.update(self._similar_looking_alternate_hashes)
        self._all_hashes.update(self._similar_looking_false_positive_hashes)

        self._king_hash = self._dupe_hashes[0]
        self._second_group_king_hash = self._second_group_dupe_hashes[0]
        self._false_positive_king_hash = self._similar_looking_false_positive_hashes[
            0]
        self._alternate_king_hash = self._similar_looking_alternate_hashes[0]

        self._our_main_dupe_group_hashes = set([self._king_hash])
        self._our_second_dupe_group_hashes = set(
            [self._second_group_king_hash])
        self._our_alt_dupe_group_hashes = set([self._alternate_king_hash])
        self._our_fp_dupe_group_hashes = set([self._false_positive_king_hash])

        n = len(self._all_hashes)

        self._num_free_agents = n

        # initial number pair combinations is (n(n-1))/2
        self._expected_num_potentials = int(n * (n - 1) / 2)

        size_pred = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE,
            ('=', 65535, HydrusData.ConvertUnitToInt('B')))

        location_search_context = ClientSearch.LocationSearchContext(
            current_service_keys=[CC.LOCAL_FILE_SERVICE_KEY])

        self._file_search_context = ClientSearch.FileSearchContext(
            location_search_context=location_search_context,
            predicates=[size_pred])

        self._import_and_find_dupes()

        self._test_initial_state()

        self._test_initial_better_worse()
        self._test_initial_king_usurp()
        self._test_initial_same_quality()

        self._test_explicit_set_new_king()

        self._test_establish_second_group()
        self._test_poach_better()
        self._test_poach_same()
        self._test_group_merge()

        self._test_establish_false_positive_group()
        self._test_false_positive()

        self._test_establish_alt_group()
        self._test_alt()

        self._test_expand_false_positive()
        self._test_expand_alt()

        self._test_dissolve()
コード例 #20
0
    def GetSearchPredicates(self) -> typing.List[ClientSearch.Predicate]:

        return [
            ClientSearch.Predicate(ClientSearch.PREDICATE_TYPE_TAG, self._tag)
        ]
コード例 #21
0
    def __init__(self, parent, predicate: ClientSearch.Predicate):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        predicate_type = predicate.GetType()

        self._predicates = []

        label = None
        editable_pred_panels = []
        static_pred_buttons = []

        recent_predicate_types = [predicate_type]

        if predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 0, 1, 0))), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 0, 7, 0))), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
                        ('<', 'delta', (0, 1, 0, 0))), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemAgeDelta,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemModifiedDelta, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemModifiedDate,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH,
                ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 16, 9)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 9, 16)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 4, 3)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO,
                        ('=', 1, 1)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1920)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 1080))),
                    forced_label='1080p'))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 1280)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 720))),
                    forced_label='720p'))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self,
                    self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ('=', 3840)),
                           ClientSearch.Predicate(
                               ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT,
                               ('=', 2160))),
                    forced_label='4k'))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemHeight,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemWidth,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemRatio,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumPixels,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                        ('>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
                        ('=', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                        ('=', 30)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE,
                        ('=', 60)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemDuration,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemFramerate,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumFrames,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemFileService,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsExactURL, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsDomain, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsRegex, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemKnownURLsURLClass, predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO:

            recent_predicate_types = []

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
                        True), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
                        False), )))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemHash,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT:

            label = 'system:limit clips a large search result down to the given number of files. It is very useful for processing in smaller batches.'
            label += os.linesep * 2
            label += 'For all the simpler sorts (filesize, duration, etc...), it will select the n largest/smallest in the result set appropriate for that sort. For complicated sorts like tags, it will sample randomly.'

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 64), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 256), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 1024), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemLimit,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemMime,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
                        (None, '>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
                        (None, '=', 0)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumTags,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES:

            recent_predicate_types = [
                ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME
            ]

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                        ('>', 0)), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
                        ('=', 0)), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumNotes,
                    predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemHasNoteName,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumWords,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING:

            services_manager = HG.client_controller.services_manager

            ratings_services = services_manager.GetServices(
                (HC.LOCAL_RATING_LIKE, HC.LOCAL_RATING_NUMERICAL))

            if len(ratings_services) > 0:

                editable_pred_panels.append(
                    self._PredOKPanel(
                        self,
                        ClientGUIPredicatesMultiple.PanelPredicateSystemRating,
                        (predicate, )))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemSimilarTo,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.PanelPredicateSystemSize,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self,
                    ClientGUIPredicatesSingle.PanelPredicateSystemTagAsNumber,
                    predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS:

            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.
                        PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING,
                        False), )))
            static_pred_buttons.append(
                ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                    self, self, (ClientSearch.Predicate(
                        ClientSearch.
                        PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING,
                        True), )))

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemDuplicateRelationships, predicate))

        elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:

            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemFileViewingStatsViews, predicate))
            editable_pred_panels.append(
                self._PredOKPanel(
                    self, ClientGUIPredicatesSingle.
                    PanelPredicateSystemFileViewingStatsViewtime, predicate))

        vbox = QP.VBoxLayout()

        if label is not None:

            st = ClientGUICommon.BetterStaticText(self, label=label)

            st.setWordWrap(True)

            QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)

        recent_predicates = []

        if len(recent_predicate_types) > 0:

            recent_predicates = HG.client_controller.new_options.GetRecentPredicates(
                recent_predicate_types)

            if len(recent_predicates) > 0:

                recent_predicates_box = ClientGUICommon.StaticBox(
                    self, 'recent')

                for recent_predicate in recent_predicates:

                    button = ClientGUIPredicatesSingle.StaticSystemPredicateButton(
                        recent_predicates_box, self, (recent_predicate, ))

                    recent_predicates_box.Add(button,
                                              CC.FLAGS_EXPAND_PERPENDICULAR)

                QP.AddToLayout(vbox, recent_predicates_box,
                               CC.FLAGS_EXPAND_PERPENDICULAR)

        for button in static_pred_buttons:

            QP.AddToLayout(vbox, button, CC.FLAGS_EXPAND_PERPENDICULAR)

        for panel in editable_pred_panels:

            QP.AddToLayout(vbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR)

        if len(static_pred_buttons) > 0 and len(editable_pred_panels) == 0:

            HG.client_controller.CallAfterQtSafe(
                static_pred_buttons[0], static_pred_buttons[0].setFocus,
                QC.Qt.OtherFocusReason)

        self.widget().setLayout(vbox)
コード例 #22
0
    def __init__(self, parent,
                 predicates: typing.Collection[ClientSearch.Predicate]):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        predicates = list(predicates)

        predicates.sort(key=lambda p: p.ToString(with_count=False))

        self._uneditable_predicates = []

        self._invertible_pred_buttons = []
        self._editable_pred_panels = []

        rating_preds = []

        # I hate this pred comparison stuff, but let's hang in there until we split this stuff up by type mate
        # then we can just have a dict type->panel_class lookup or whatever
        # also it would be nice to have proper rating editing here, think about it

        AGE_DELTA_PRED = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
            ('>', 'delta', (2000, 1, 1, 1)))
        MODIFIED_DELTA_PRED = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME,
            ('>', 'delta', (2000, 1, 1, 1)))
        KNOWN_URL_EXACT = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS,
            (True, 'exact_match', '', ''))
        KNOWN_URL_DOMAIN = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS,
            (True, 'domain', '', ''))
        KNOWN_URL_REGEX = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS,
            (True, 'regex', '', ''))
        FILE_VIEWS_PRED = ClientSearch.Predicate(
            ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS,
            ('views', ('media', ), '>', 0))

        for predicate in predicates:

            predicate_type = predicate.GetType()

            if predicate_type == ClientSearch.PREDICATE_TYPE_OR_CONTAINER:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesOR.ORPredicateControl(self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE:

                if predicate.IsUIEditable(AGE_DELTA_PRED):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.PanelPredicateSystemAgeDelta(
                            self, predicate))

                else:

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate(
                            self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:

                if predicate.IsUIEditable(MODIFIED_DELTA_PRED):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemModifiedDelta(self, predicate))

                else:

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemModifiedDate(self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemHeight(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemWidth(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemRatio(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumPixels(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemDuration(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemFramerate(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumFrames(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemFileService(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:

                if predicate.IsUIEditable(KNOWN_URL_EXACT):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemKnownURLsExactURL(self, predicate))

                elif predicate.IsUIEditable(KNOWN_URL_DOMAIN):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemKnownURLsDomain(self, predicate))

                elif predicate.IsUIEditable(KNOWN_URL_REGEX):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemKnownURLsRegex(self, predicate))

                else:

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemKnownURLsURLClass(self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemHash(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemLimit(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemMime(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumTags(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumNotes(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemHasNoteName(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemNumWords(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemSimilarTo(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemSize(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.PanelPredicateSystemTagAsNumber(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT:

                self._editable_pred_panels.append(
                    ClientGUIPredicatesSingle.
                    PanelPredicateSystemDuplicateRelationships(
                        self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:

                if predicate.IsUIEditable(FILE_VIEWS_PRED):

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemFileViewingStatsViews(
                            self, predicate))

                else:

                    self._editable_pred_panels.append(
                        ClientGUIPredicatesSingle.
                        PanelPredicateSystemFileViewingStatsViewtime(
                            self, predicate))

            elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING:

                rating_preds.append(predicate)

            elif predicate.IsInvertible():

                self._invertible_pred_buttons.append(
                    ClientGUIPredicatesSingle.InvertiblePredicateButton(
                        self, predicate))

            else:

                self._uneditable_predicates.append(predicate)

        if len(rating_preds) > 0:

            self._editable_pred_panels.append(
                ClientGUIPredicatesMultiple.PanelPredicateSystemRating(
                    self, rating_preds))

        vbox = QP.VBoxLayout()

        for button in self._invertible_pred_buttons:

            QP.AddToLayout(vbox, button, CC.FLAGS_EXPAND_PERPENDICULAR)

        for panel in self._editable_pred_panels:

            if isinstance(panel, ClientGUIPredicatesOR.ORPredicateControl):

                flags = CC.FLAGS_EXPAND_BOTH_WAYS

            else:

                flags = CC.FLAGS_EXPAND_PERPENDICULAR

            QP.AddToLayout(vbox, panel, flags)

        self.widget().setLayout(vbox)
コード例 #23
0
    
    try:
        
        bytes_hashlist = tuple( ( bytes.fromhex( hex_hash ) for hex_hash in hex_hashlist_and_other[0] ) )
        
    except HydrusExceptions.DataMissing as e:
        
        raise ValueError( str( e ) )
        
    
    return ( bytes_hashlist, hex_hashlist_and_other[1] )
    
SystemPredicateParser.InitialiseFiletypes( HC.mime_enum_lookup )

pred_generators = {
    SystemPredicateParser.Predicate.EVERYTHING : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ),
    SystemPredicateParser.Predicate.INBOX : lambda o, v, u: ClientSearch.SYSTEM_PREDICATE_INBOX.Duplicate(),
    SystemPredicateParser.Predicate.ARCHIVE : lambda o, v, u: ClientSearch.SYSTEM_PREDICATE_ARCHIVE.Duplicate(),
    SystemPredicateParser.Predicate.BEST_QUALITY_OF_GROUP : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True ),
    SystemPredicateParser.Predicate.NOT_BEST_QUALITY_OF_GROUP : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False ),
    SystemPredicateParser.Predicate.HAS_AUDIO : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True ),
    SystemPredicateParser.Predicate.NO_AUDIO : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False ),
    SystemPredicateParser.Predicate.HAS_ICC_PROFILE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ),
    SystemPredicateParser.Predicate.NO_ICC_PROFILE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ),
    SystemPredicateParser.Predicate.LIMIT : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, v ),
    SystemPredicateParser.Predicate.FILETYPE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, tuple( v ) ),
    SystemPredicateParser.Predicate.HAS_DURATION : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ( '>', 0 ) ),
    SystemPredicateParser.Predicate.NO_DURATION : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ( '=', 0 ) ),
    SystemPredicateParser.Predicate.HAS_TAGS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 0 ) ),
    SystemPredicateParser.Predicate.UNTAGGED : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 0 ) ),
    SystemPredicateParser.Predicate.NUM_OF_TAGS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, o, v ) ),