diff --git a/docs/changelog.md b/docs/changelog.md
index 08acf14dc..358fdc082 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -7,6 +7,40 @@ title: Changelog
!!! note
This is the new changelog, only the most recent builds. For all versions, see the [old changelog](old_changelog.html).
+## [Version 590](https://github.com/hydrusnetwork/hydrus/releases/tag/v590)
+
+### misc
+
+* the 'check now' button in manage subscriptions is generally more intelligent and now offers questions around paused status: if _all_ the selected queries are DEAD, it now asks you if you want to resurrect them with a yes/no variant of the DEAD/ALIVE question (previously it just did it); if you are in _edit subscriptions_ and any of the selected subs are paused, it now asks you if you want to include them (and unpause) in the check now, and if not it reduces the queries examined for the DEAD/ALIVE question appropriately (previously it just did their queries, and did not unpause); in either _edit subscriptions_ or _edit subscription_, if any queries in the selection after any 'paused subs' or 'DEAD/ALIVE' filtering are paused, it asks you if you want to include (and unpause) them in the check now (previously it just did and unpaused them all)
+* if you shrink the search page's preview window down to 0 size (which it will suddenly snap to, and which is a silghtly different hide state to the one caused by double-left-clicking the splitter sash), the preview canvas will now recognise it is hidden and no longer load media as you click on thumbs. previously this thing was loading noisy videos in the background etc..
+* the `StringMatch` 'character set' match type now has 'hexadecimal characters' (`^[\da-fA-F]+$`) and 'base-64 characters' (`^[a-zA-Z\d+/]+={0,2}$`) in its dropdown choice
+* the 'gui pages' options panel now has 'when closing tabs, move focus (left/right)', so if you'd rather move left when middle-clicking tabs etc.., you can now set it, and if your style's default behaviour is whack and never moved to the right before despite you wanting it, now you can force it; it is now explicit either way. let me know if any crazy edge-case focus logic happens in this mode with nested page of pages or whatever
+* when you right-click a file, in the _share->copy hash_ menu, the md5, sha1, and sha512 hashes are now loaded from the database, usually in the milliseconds after the menu is opened, and shown in the menu labels for quick human reference. if your client does not have these hashes for the file, it says so
+* the 'share' thumbnail menu is now visible on non-local files. it is severely truncated, basically just shows copy hash/file_id stuff
+* wrote a 'Current Deleted Pending Petitioned' section for the Developer API to discuss how the states in the content storage system overlap and change in relation to various commands in the content update pipeline https://hydrusnetwork.github.io/hydrus/developer_api.html#CDPP It may be of interest to non-API-devs who are generally interested in what exactly the 'pending' state etc.. is
+* if the file import options in a hard drive import page currently imports to an empty location context (e.g. you deleted the local file service it wanted to import to), the import page now pauses and presents an appropriate error text. the URL importers already did this, so this is the hdd import joining them
+* this 'check we are good to do file work' test in the importer pages now in all cases pursues a 'default' file import options to the actual real one that will be used, so if your importer file import options are borked, this is now detected too and the importer will pause rather than fail everything in its file log
+* thanks to a user, fixed a typo bug in the new multi-column list work that was causing problems when looking at gallery logs that included mis-linked log entries. in general, the main 'turn this integer into something human' function will now handle errors better
+
+### default downloaders
+
+* _advanced/technical, tl;dr: x.com URLs save better now._ since a better fix will take more work, the 'x post' URL class is for now set to associate URLs. this fixes the association of x.com URLs when those are explicitly referred to as source URLs in a booru post. previously, some hydrus network engine magic related to how x URLs are converted to twitter URLs (and then fx/vxtwitter URLs) to get parsed by the twitter parser was causing some problems. a full 'render this URL as this URL' system will roll out in future to better handle this situation where two non-API URLs can mean the same thing. this will result in some twitter/x post URL duplication--we'll figure out a nice merge later!
+
+### duplicate auto-resolution tech
+
+* I have written the first skeleton of the `MetadataConditional` object. it has a rule based on a system predicate (like 'width > 400px') and returns True/False when you give it a media object. this lego-brick will plug into a variety of different systems in future, including the duplicate auto-resolution system, with a unified UI
+* system predicates cannot yet do this arbitrarily, so it will be future work to fill out this code. to start with, I've just got system:filetype working to ultimately effect the first duplicate auto-resolution job of 'if pixel duplicates and one is jpeg, one png, then keep the jpeg'
+* add some unit tests to test this capability
+
+### boring search object code decoupling
+
+* refactored the main `Predicate` object and friends to the new `ClientSearchPredicate`
+* refactored the main `NumberTest` object and friends to the new `ClientNumberTest`
+* refactored the main `TagContext` object and friends to the new `ClientTagContext`
+* refactored the main `FileSearchContext` object and friends to the new `ClientSearchFileSearchContext`
+* moved some other `ClientSearch` stuff to other places and renamed the original file to `ClientSearchFavourites`; it now just contains the favourite searches manager
+* some misc cleanup around here. some enums had bad names, that sort of thing
+
## [Version 589](https://github.com/hydrusnetwork/hydrus/releases/tag/v589)
### misc
@@ -352,30 +386,3 @@ title: Changelog
* decoupled how some service admin stuff works behind the scenes to make it easier to launch this stuff from different UI widgets
* refactored `ToHumanInt` and the `ToPrettyOrdinalString` guys to a new `HydrusNumbers.py` file
* fixed some bad Client API documentation for the params in `/get_files/search_files`
-
-## [Version 580](https://github.com/hydrusnetwork/hydrus/releases/tag/v580)
-
-### misc
-
-* I _may_, and a very hesitant _may_, have fixed the program hanging after minimising to system tray from the close button. thanks to the user who pinned down that it was the close button doing this rather than the other ways to minimise to system tray. if you have had trouble with minimising to the system tray, please try again when it is convenient and let me know how you get on. please also note which exact command, whether it was the file menu, system tray icon menu, minimise button, or close button, that you hit to trigger the minimise event that ultimately would not restore correctly
-* the taglist right-click menu now has a _maintenance->regenerate tag display_ command, which is basically the 'regenerate mappings storage cache' command in the database menu, but limited just to your selection. this _should_, with luck, fix incorrect autocomplete counts or sibling/parent presentation for any tags you see that are weird. I've wanted this for years, since the whole-cache regen is so large that it is essentially impossible to run on the PTR, but now we can debug individual tag presentation problems a lot easier!
-* fixed an issue where read-only import files would not delete from the temp dir after import, despite, if desired, successfully deleting from their original locations. it turns out the read-only property was being copied to the temp path for import, and the 'I'm done with the temp file, delete it' routine, unlike the normal file delete, wasn't checking for and undoing read-only status. note this was also screwing with the 'delete the hydrus temp dir on shutdown' routine, so if you do a lot of unusual/misc hard drive imports, feel free to shut your client down, check your temp folder (hit _help->about_ to find it), and delete anything called hydrusXXXXXXXX
-* the new 'eye' icon in the media viewer now has 'apply image ICC Profile colour adjustments', which will flip on/off the fairly newish checkbox added to _options->media playback_. it updates the image live!
-* added a shortcut for the 'flip apply image ICC Profile colour adjustments' to the 'media viewer' set! if you are big into this stuff and also do duplicate filtering, set it up and let me know how it goes
-* important but subtle file import options fix: when you set a file to import to a specific destination in file import options, or you say to archive all imports, this is supposed to work even when the file is 'already in db'. this was not working when 'already in db' was caused by a 'url/hash recognised' result in the downloader system. I have fixed this; it now works for 'already in db' for url/hash/file recognised states. thank you to the user who noticed this and did the debug legwork to figure out what was going on
-* import _file logs_ now have a menu item 'search for URLs', which does the same as the recent 'urls' media right-click menu command, opening a search page for any files that share these URLs
-* added a shortcut command 'reload the current qss stylesheet' to the 'main gui' shortcut set. moreover, the 'reload current ui session' entry in the debug menu, which was just above this before, is renamed to 'close and reload current ui session' because of common misclicks
-* the options panel uses less CPU on ok/cancel to set/reset style as needed. same deal with the old hack that makes the colour-picker work--it'll now be more efficient about setting/resetting style
-* fixed a stupid list/tuple type error when trying to edit the 'frame locations' in options->gui. this was from an accident during the selection/scroll rewrites last week
-* generally improved the reliability of the multi-column list against the above bug in its various forms
-* added a simple click-through login script to fix recent changes to the 8chan.moe TOS filter, which broke the respective watcher. all users get this and it should just work out of the box
-* thanks to a user, the default danbooru parsers are fixed to fetch md5 hash correctly
-* some misc tooltip and description fixes
-* improved some media result testing stuff
-
-### client api
-
-* the `/add_tags/add_tags` command has two new parameters, `override_previously_deleted_mappings`, and `create_new_deleted_mappings`, both True by default (which was also previous behaviour). turning either off allows you to, respectively, not force-add a tag mapping when it has been previously deleted (like how the gallery downloader works) and not force-delete (and thus make a 'delete' record) when deleting a tag mapping unless it already exists
-* updated the Client API help to talk about these
-* added some unit tests to test these
-* the client api is now version 65
diff --git a/docs/developer_api.md b/docs/developer_api.md
index c7611ce87..cd1a80dad 100644
--- a/docs/developer_api.md
+++ b/docs/developer_api.md
@@ -305,6 +305,53 @@ If you want to know the services in a client, hit up [/get\_services](#get_servi
Note: If you need to do some quick testing, you should be able to copy the `service_key` of any service by hitting the 'copy service key' button in _review services_.
+## Current Deleted Pending Petitioned { id="CDPP" }
+
+The content storage and update pipeline systems in hydrus consider content (e.g. 'on file service x, file y exists', 'on tag service x, file y has tag z', or 'on rating service x, file y has rating z') as existing within a blend of four states:
+
+* **Current** - The content exists on the service.
+* **Deleted** - The content has been removed from on the service.
+* **Pending** - The content is queued to be added to the service.
+* **Petitioned** - The content is queued to be removed from the service.
+
+Where content that has never touched the service has a default 'null status' of no state at all.
+
+Content may be in two categories at once--for instance, any Petitioned data is always also Current--but some states are mutually exclusive: Current data cannot also be Deleted.
+
+Let's examine this more carefully specifically. Current, Deleted, and Pending may exist on their own, and Deleted and Pending may exist simultaneously. Read this horizontally to vertically, such that 'Content that is Current may also be Petitioned' while 'Content that is Petitioned must also be Current':
+
+| | Current | Deleted | Pending | Petitioned |
+|----------------|---------|---------|---------|------------|
+| **Current** | - | Never | Never | May |
+| **Deleted** | Never | - | May | Never |
+| **Pending** | Never | May | - | Never |
+| **Petitioned** | Must | Never | Never | - |
+
+Local services have no concept of pending or petitioned, so they generally just have 'add x'/'delete x' verbs to convert content between current and deleted. Remote services like the PTR have a queue of pending changes waiting to be committed by the user to the server, so in these cases I will expose to you the full suite of 'pend x'/'petition x'/'rescind pend x'/'rescind petition x'. Although you might somewhere be able to 'pend'/'petition' content to a local service, these 'pending' changes will be committed instantly so they are synonymous with add/delete.
+
+* When an 'add' is committed, the data is removed from the deleted record and added to the current record.
+* When a 'delete' is committed, the data is removed from the current record and added to the deleted record.
+* When a 'pend' is committed, the data is removed from the deleted record and added to the current record. (It is also deleted from the pending record!)
+* When a 'petition' is committed, the data is removed from the current record and added to the deleted record. (It is also deleted from the petitioned record!)
+* When a 'rescind pend' is committed, the data is removed from the pending record.
+* When a 'rescind petition' is committed, the data is removed from the petitioned record.
+
+Let's look at where the verbs make sense. Again, horizontal, so 'Content that is Current can receive a Petition command':
+
+| | Add/Pend | Delete/Petition | Rescind Pend | Rescind Petition |
+|----------------|----------------------------------|----------------------------------|--------------|------------------|
+| **No state** | May | May | - | - |
+| **Current** | - | May | - | - |
+| **Deleted** | _May_ | - | - | - |
+| **Pending** | May overwrite an existing reason | - | May | - |
+| **Petitioned** | - | May overwrite an existing reason | - | May |
+
+In hydrus, anything in the content update pipeline that _doesn't_ make sense, here a '-', tends to result in an errorless no-op, so you might not care to do too much filtering on your end of things if you don't need to--don't worry about deleting something twice.
+
+Note that content that does not yet exist _can_ be pre-emptively petitioned/deleted. A couple of advanced cases enjoy this capability, for instance when you are syncing delete records from one client to another.
+
+Also, it is often the case that content that is recorded as deleted is more difficult to re-add/re-pend. You might need to be a janitor to re-pend something, or, for this API, set some `override_previously_deleted_mappings` parameter. This is by design and helps you to stop automatically re-adding something that the user spent slow human time deciding to delete.
+
## Access Management
### **GET `/api_version`** { id="api_version" }
@@ -1178,7 +1225,9 @@ Arguments (in JSON):
* 3 - Rescind a pend from a tag repository.
* 4 - Petition from a tag repository. (This is special)
* 5 - Rescind a petition from a tag repository.
-
+
+ Read about [Current Deleted Pending Petitioned](#CDPP) for more info on these states.
+
When you petition a tag from a repository, a 'reason' for the petition is typically needed. If you send a normal list of tags here, a default reason of "Petitioned from API" will be given. If you want to set your own reason, you can instead give a list of \[ tag, reason \] pairs.
Some example requests:
@@ -1971,6 +2020,8 @@ The `tags` structure is similar to the [/add\_tags/add\_tags](#add_tags_add_tags
!!! note
Since JSON Object keys must be strings, these status numbers are strings, not ints.
+Read about [Current Deleted Pending Petitioned](#CDPP) for more info on these states.
+
While the 'storage_tags' represent the actual tags stored on the database for a file, 'display_tags' reflect how tags appear in the UI, after siblings are collapsed and parents are added. If you want to edit a file's tags, refer to the storage tags. If you want to render to the user, use the display tags. The display tag calculation logic is very complicated; if the storage tags change, do not try to guess the new display tags yourself--just ask the API again.
#### ratings
diff --git a/docs/getting_started_installing.md b/docs/getting_started_installing.md
index 1ecb3324b..c15bd8264 100644
--- a/docs/getting_started_installing.md
+++ b/docs/getting_started_installing.md
@@ -182,7 +182,7 @@ After that, you'll have a 'clean' version of hydrus that only has the latest ver
## Big updates { id="big_updates" }
-If you have not updated in some time--say twenty versions or more--doing it all in one jump, like v290->v330, may not work. I am doing a lot of unusual stuff with hydrus, change my code at a fast pace, and do not have a ton of testing in place. Hydrus update code often falls to [bitrot](https://en.wikipedia.org/wiki/Software_rot), and so some underlying truth I assumed for the v299->v300 code may not still apply six months later. If you try to update more than 50 versions at once (i.e. trying to perform more than a year of updates in one go), the client will give you a polite error rather than even try.
+If you have not updated in some time--say twenty versions or more--doing it all in one jump, like v290->v330, may not work. I am doing a lot of unusual stuff with hydrus, change my code at a fast pace, and do not have a ton of testing in place. Hydrus update code often falls to [bit rot](https://en.wikipedia.org/wiki/Software_rot), and so some underlying truth I assumed for the v299->v300 code may not still apply six months later. If you try to update more than 50 versions at once (i.e. trying to perform more than a year of updates in one go), the client will give you a polite error rather than even try.
As a result, if you get a failure on trying to do a big update, try cutting the distance in half--try v290->v310 first, and boot it. If the database updates correctly and the program boots, then shut down and move on to v310->v330. If the update does not work, cut down the gap and try v290->v300, and so on. **Again, it is very important you make a backup before starting a process like this so you can roll back and try a different version if things go wrong.**
diff --git a/docs/old_changelog.html b/docs/old_changelog.html
index ddef5c73a..b371d3c64 100644
--- a/docs/old_changelog.html
+++ b/docs/old_changelog.html
@@ -34,6 +34,35 @@
+ -
+
+
+ misc
+ - the 'check now' button in manage subscriptions is generally more intelligent and now offers questions around paused status: if _all_ the selected queries are DEAD, it now asks you if you want to resurrect them with a yes/no variant of the DEAD/ALIVE question (previously it just did it); if you are in _edit subscriptions_ and any of the selected subs are paused, it now asks you if you want to include them (and unpause) in the check now, and if not it reduces the queries examined for the DEAD/ALIVE question appropriately (previously it just did their queries, and did not unpause); in either _edit subscriptions_ or _edit subscription_, if any queries in the selection after any 'paused subs' or 'DEAD/ALIVE' filtering are paused, it asks you if you want to include (and unpause) them in the check now (previously it just did and unpaused them all)
+ - if you shrink the search page's preview window down to 0 size (which it will suddenly snap to, and which is a silghtly different hide state to the one caused by double-left-clicking the splitter sash), the preview canvas will now recognise it is hidden and no longer load media as you click on thumbs. previously this thing was loading noisy videos in the background etc..
+ - the `StringMatch` 'character set' match type now has 'hexadecimal characters' (`^[\da-fA-F]+$`) and 'base-64 characters' (`^[a-zA-Z\d+/]+={0,2}$`) in its dropdown choice
+ - the 'gui pages' options panel now has 'when closing tabs, move focus (left/right)', so if you'd rather move left when middle-clicking tabs etc.., you can now set it, and if your style's default behaviour is whack and never moved to the right before despite you wanting it, now you can force it; it is now explicit either way. let me know if any crazy edge-case focus logic happens in this mode with nested page of pages or whatever
+ - when you right-click a file, in the _share->copy hash_ menu, the md5, sha1, and sha512 hashes are now loaded from the database, usually in the milliseconds after the menu is opened, and shown in the menu labels for quick human reference. if your client does not have these hashes for the file, it says so
+ - the 'share' thumbnail menu is now visible on non-local files. it is severely truncated, basically just shows copy hash/file_id stuff
+ - wrote a 'Current Deleted Pending Petitioned' section for the Developer API to discuss how the states in the content storage system overlap and change in relation to various commands in the content update pipeline https://hydrusnetwork.github.io/hydrus/developer_api.html#CDPP It may be of interest to non-API-devs who are generally interested in what exactly the 'pending' state etc.. is
+ - if the file import options in a hard drive import page currently imports to an empty location context (e.g. you deleted the local file service it wanted to import to), the import page now pauses and presents an appropriate error text. the URL importers already did this, so this is the hdd import joining them
+ - this 'check we are good to do file work' test in the importer pages now in all cases pursues a 'default' file import options to the actual real one that will be used, so if your importer file import options are borked, this is now detected too and the importer will pause rather than fail everything in its file log
+ - thanks to a user, fixed a typo bug in the new multi-column list work that was causing problems when looking at gallery logs that included mis-linked log entries. in general, the main 'turn this integer into something human' function will now handle errors better
+ default downloaders
+ - _advanced/technical, tl;dr: x.com URLs save better now._ since a better fix will take more work, the 'x post' URL class is for now set to associate URLs. this fixes the association of x.com URLs when those are explicitly referred to as source URLs in a booru post. previously, some hydrus network engine magic related to how x URLs are converted to twitter URLs (and then fx/vxtwitter URLs) to get parsed by the twitter parser was causing some problems. a full 'render this URL as this URL' system will roll out in future to better handle this situation where two non-API URLs can mean the same thing. this will result in some twitter/x post URL duplication--we'll figure out a nice merge later!
+ duplicate auto-resolution tech
+ - I have written the first skeleton of the `MetadataConditional` object. it has a rule based on a system predicate (like 'width > 400px') and returns True/False when you give it a media object. this lego-brick will plug into a variety of different systems in future, including the duplicate auto-resolution system, with a unified UI
+ - system predicates cannot yet do this arbitrarily, so it will be future work to fill out this code. to start with, I've just got system:filetype working to ultimately effect the first duplicate auto-resolution job of 'if pixel duplicates and one is jpeg, one png, then keep the jpeg'
+ - add some unit tests to test this capability
+ boring search object code decoupling
+ - refactored the main `Predicate` object and friends to the new `ClientSearchPredicate`
+ - refactored the main `NumberTest` object and friends to the new `ClientNumberTest`
+ - refactored the main `TagContext` object and friends to the new `ClientTagContext`
+ - refactored the main `FileSearchContext` object and friends to the new `ClientSearchFileSearchContext`
+ - moved some other `ClientSearch` stuff to other places and renamed the original file to `ClientSearchFavourites`; it now just contains the favourite searches manager
+ - some misc cleanup around here. some enums had bad names, that sort of thing
+
+
-
diff --git a/hydrus/client/ClientAPI.py b/hydrus/client/ClientAPI.py
index f95ad2549..ff7ba11fd 100644
--- a/hydrus/client/ClientAPI.py
+++ b/hydrus/client/ClientAPI.py
@@ -9,7 +9,7 @@
from hydrus.core import HydrusTime
from hydrus.client import ClientGlobals as CG
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
CLIENT_API_PERMISSION_ADD_URLS = 0
CLIENT_API_PERMISSION_ADD_FILES = 1
@@ -228,6 +228,7 @@ def SetPermissions( self, api_permissions_objects ):
+
HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_CLIENT_API_MANAGER ] = APIManager
class APIPermissions( HydrusSerialisable.SerialisableBaseNamed ):
@@ -372,7 +373,7 @@ def CheckPermissionToSeeFiles( self, hash_ids: typing.Collection[ int ] ):
- def FilterTagPredicateResponse( self, predicates: typing.List[ ClientSearch.Predicate ] ):
+ def FilterTagPredicateResponse( self, predicates: typing.List[ ClientSearchPredicate.Predicate ] ):
with self._lock:
diff --git a/hydrus/client/ClientConstants.py b/hydrus/client/ClientConstants.py
index fef0d48c5..1893af406 100644
--- a/hydrus/client/ClientConstants.py
+++ b/hydrus/client/ClientConstants.py
@@ -267,6 +267,14 @@
NEW_PAGE_GOES_FAR_RIGHT : 'the far right'
}
+CLOSED_PAGE_FOCUS_GOES_LEFT = 0
+CLOSED_PAGE_FOCUS_GOES_RIGHT = 1
+
+closed_page_focus_string_lookup = {
+ CLOSED_PAGE_FOCUS_GOES_LEFT : 'left of the closed page tab',
+ CLOSED_PAGE_FOCUS_GOES_RIGHT : 'right of the closed page tab'
+}
+
NETWORK_CONTEXT_GLOBAL = 0
NETWORK_CONTEXT_HYDRUS = 1
NETWORK_CONTEXT_DOMAIN = 2
diff --git a/hydrus/client/ClientController.py b/hydrus/client/ClientController.py
index 2ef3c0d5c..e8ab166b2 100644
--- a/hydrus/client/ClientController.py
+++ b/hydrus/client/ClientController.py
@@ -1233,13 +1233,13 @@ def InitModel( self ):
self.frame_splash_status.SetSubtext( 'favourite searches' )
- from hydrus.client.search import ClientSearch
+ from hydrus.client.search import ClientSearchFavouriteSearches
favourite_search_manager = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_FAVOURITE_SEARCH_MANAGER )
if favourite_search_manager is None:
- favourite_search_manager = ClientSearch.FavouriteSearchManager()
+ favourite_search_manager = ClientSearchFavouriteSearches.FavouriteSearchManager()
ClientDefaults.SetDefaultFavouriteSearchManagerData( favourite_search_manager )
diff --git a/hydrus/client/ClientDefaults.py b/hydrus/client/ClientDefaults.py
index 34181a736..4c9b788c4 100644
--- a/hydrus/client/ClientDefaults.py
+++ b/hydrus/client/ClientDefaults.py
@@ -915,7 +915,9 @@ def SetDefaultDomainManagerData( domain_manager ):
def SetDefaultFavouriteSearchManagerData( favourite_search_manager ):
from hydrus.client.media import ClientMedia
- from hydrus.client.search import ClientSearch
+ from hydrus.client.search import ClientSearchFileSearchContext
+ from hydrus.client.search import ClientSearchPredicate
+ from hydrus.client.search import ClientSearchTagContext
rows = []
@@ -926,21 +928,21 @@ def SetDefaultFavouriteSearchManagerData( favourite_search_manager ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- tag_context = ClientSearch.TagContext()
+ tag_context = ClientSearchTagContext.TagContext()
predicates = []
- predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX ) )
- predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, value = 256 ) )
+ predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX ) )
+ predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, value = 256 ) )
filetypes = []
filetypes.extend( HC.general_mimetypes_to_mime_groups[ HC.GENERAL_IMAGE ] )
filetypes.extend( HC.general_mimetypes_to_mime_groups[ HC.GENERAL_ANIMATION ] )
filetypes.extend( HC.general_mimetypes_to_mime_groups[ HC.GENERAL_VIDEO ] )
- predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = filetypes ) )
+ predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = filetypes ) )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
synchronised = True
media_sort = ClientMedia.MediaSort( sort_type = ( 'system', CC.SORT_FILES_BY_FILESIZE ), sort_order = CC.SORT_DESC )
@@ -955,11 +957,11 @@ def SetDefaultFavouriteSearchManagerData( favourite_search_manager ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- tag_context = ClientSearch.TagContext()
+ tag_context = ClientSearchTagContext.TagContext()
predicates = []
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
synchronised = True
media_sort = None
diff --git a/hydrus/client/ClientOptions.py b/hydrus/client/ClientOptions.py
index c4888b384..98b687d4b 100644
--- a/hydrus/client/ClientOptions.py
+++ b/hydrus/client/ClientOptions.py
@@ -370,6 +370,7 @@ def _InitialiseDefaults( self ):
'suggested_tags_width' : 300,
'similar_files_duplicate_pairs_search_distance' : 0,
'default_new_page_goes' : CC.NEW_PAGE_GOES_FAR_RIGHT,
+ 'close_page_focus_goes' : CC.CLOSED_PAGE_FOCUS_GOES_RIGHT,
'num_recent_petition_reasons' : 5,
'max_page_name_chars' : 20,
'page_file_count_display' : CC.PAGE_FILE_COUNT_DISPLAY_ALL,
diff --git a/hydrus/client/ClientStrings.py b/hydrus/client/ClientStrings.py
index d5818a73d..2fdd05686 100644
--- a/hydrus/client/ClientStrings.py
+++ b/hydrus/client/ClientStrings.py
@@ -615,9 +615,11 @@ def ToString( self, simple = False, with_type = False ) -> str:
STRING_MATCH_REGEX = 2
STRING_MATCH_ANY = 3
-ALPHA = 0
-ALPHANUMERIC = 1
-NUMERIC = 2
+FLEXIBLE_MATCH_ALPHA = 0
+FLEXIBLE_MATCH_ALPHANUMERIC = 1
+FLEXIBLE_MATCH_NUMERIC = 2
+FLEXIBLE_MATCH_HEX = 3
+FLEXIBLE_MATCH_BASE64 = 4
class StringMatch( StringProcessingStep ):
@@ -724,21 +726,36 @@ def Test( self, text ):
if self._match_type == STRING_MATCH_FLEXIBLE:
- if self._match_value == ALPHA:
+ if self._match_value == FLEXIBLE_MATCH_ALPHA:
r = '^[a-zA-Z]+$'
fail_reason = ' had non-alpha characters'
- elif self._match_value == ALPHANUMERIC:
+ elif self._match_value == FLEXIBLE_MATCH_ALPHANUMERIC:
r = '^[a-zA-Z\\d]+$'
fail_reason = ' had non-alphanumeric characters'
- elif self._match_value == NUMERIC:
+ elif self._match_value == FLEXIBLE_MATCH_NUMERIC:
r = '^\\d+$'
fail_reason = ' had non-numeric characters'
+ elif self._match_value == FLEXIBLE_MATCH_HEX:
+
+ r = '^[\\da-fA-F]+$'
+ fail_reason = ' had non-hex characters'
+
+ elif self._match_value == FLEXIBLE_MATCH_BASE64:
+
+ r = '^[a-zA-Z\\d+/]+={0,2}$'
+ fail_reason = ' had non-base64 characters'
+
+ else:
+
+ r = ''
+ fail_reason = ' (unknown error, this object is probably from a newer client)'
+
elif self._match_type == STRING_MATCH_REGEX:
@@ -822,18 +839,30 @@ def ToString( self, simple = False, with_type = False ) -> str:
elif self._match_type == STRING_MATCH_FLEXIBLE:
- if self._match_value == ALPHA:
+ if self._match_value == FLEXIBLE_MATCH_ALPHA:
result += 'alphabetical characters'
- elif self._match_value == ALPHANUMERIC:
+ elif self._match_value == FLEXIBLE_MATCH_ALPHANUMERIC:
result += 'alphanumeric characters'
- elif self._match_value == NUMERIC:
+ elif self._match_value == FLEXIBLE_MATCH_NUMERIC:
result += 'numeric characters'
+ elif self._match_value == FLEXIBLE_MATCH_HEX:
+
+ result += 'hex characters'
+
+ elif self._match_value == FLEXIBLE_MATCH_BASE64:
+
+ result += 'base-64 characters'
+
+ else:
+
+ result += 'unknown characters, this object is probably from a newer client'
+
elif self._match_type == STRING_MATCH_REGEX:
diff --git a/hydrus/client/db/ClientDB.py b/hydrus/client/db/ClientDB.py
index 5f5141bec..c3964d800 100644
--- a/hydrus/client/db/ClientDB.py
+++ b/hydrus/client/db/ClientDB.py
@@ -84,7 +84,9 @@
from hydrus.client.networking import ClientNetworkingDomain
from hydrus.client.networking import ClientNetworkingLogin
from hydrus.client.networking import ClientNetworkingSessions
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFavouriteSearches
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
from hydrus.client.importing import ClientImportSubscriptionLegacy
from hydrus.client.networking import ClientNetworkingSessionsLegacy
@@ -1400,7 +1402,7 @@ def _CreateDB( self ):
self.modules_serialisable.SetJSONDump( login_manager )
- favourite_search_manager = ClientSearch.FavouriteSearchManager()
+ favourite_search_manager = ClientSearchFavouriteSearches.FavouriteSearchManager()
ClientDefaults.SetDefaultFavouriteSearchManagerData( favourite_search_manager )
@@ -1815,8 +1817,8 @@ def _DoAfterJobWork( self ):
def _DuplicatesGetRandomPotentialDuplicateHashes(
self,
- file_search_context_1: ClientSearch.FileSearchContext,
- file_search_context_2: ClientSearch.FileSearchContext,
+ file_search_context_1: ClientSearchFileSearchContext.FileSearchContext,
+ file_search_context_2: ClientSearchFileSearchContext.FileSearchContext,
dupe_search_type: int,
pixel_dupes_preference,
max_hamming_distance
@@ -1950,7 +1952,7 @@ def _DuplicatesGetRandomPotentialDuplicateHashes(
- def _DuplicatesGetPotentialDuplicatePairsForFiltering( self, file_search_context_1: ClientSearch.FileSearchContext, file_search_context_2: ClientSearch.FileSearchContext, dupe_search_type: int, pixel_dupes_preference, max_hamming_distance, max_num_pairs: typing.Optional[ int ] = None ):
+ def _DuplicatesGetPotentialDuplicatePairsForFiltering( self, file_search_context_1: ClientSearchFileSearchContext.FileSearchContext, file_search_context_2: ClientSearchFileSearchContext.FileSearchContext, dupe_search_type: int, pixel_dupes_preference, max_hamming_distance, max_num_pairs: typing.Optional[ int ] = None ):
if max_num_pairs is None:
@@ -2515,7 +2517,7 @@ def _GenerateFileInfoManagers( self, hash_ids: typing.Collection[ int ], hash_id
return file_info_managers
- def _GetBonedStats( self, file_search_context: ClientSearch.FileSearchContext = None, job_status = None ):
+ def _GetBonedStats( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext = None, job_status = None ):
if job_status is None:
@@ -2524,7 +2526,7 @@ def _GetBonedStats( self, file_search_context: ClientSearch.FileSearchContext =
if file_search_context is None:
- file_search_context = ClientSearch.FileSearchContext(
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext(
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
)
@@ -2811,7 +2813,7 @@ def _GetBonedStatsFromTable(
return boned_stats
- def _GetFileHistory( self, num_steps: int, file_search_context: ClientSearch.FileSearchContext = None, job_status = None ):
+ def _GetFileHistory( self, num_steps: int, file_search_context: ClientSearchFileSearchContext.FileSearchContext = None, job_status = None ):
# TODO: clean this up. it is a mess cribbed from the boned work, and I'm piping similar nonsense down to the db tables
# don't supply deleted timestamps for 'all files deleted' and all that gubbins, it is a mess
@@ -2823,7 +2825,7 @@ def _GetFileHistory( self, num_steps: int, file_search_context: ClientSearch.Fil
if file_search_context is None:
- file_search_context = ClientSearch.FileSearchContext(
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext(
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
)
@@ -3260,7 +3262,7 @@ def _GetFileInfoManagersFromHashes( self, hashes: typing.Collection[ bytes ], so
return file_info_managers
- def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearchContext, force_system_everything = False ):
+ def _GetFileSystemPredicates( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, force_system_everything = False ):
location_context = file_search_context.GetLocationContext()
@@ -3269,21 +3271,21 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
predicates = []
- system_everythings = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
+ system_everythings = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
blank_pred_types = {
- ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HASH,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
}
if len( self.modules_services.GetServiceIds( HC.RATINGS_SERVICES ) ) > 0:
- blank_pred_types.add( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING )
+ blank_pred_types.add( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING )
if location_context.IsAllKnownFiles():
@@ -3296,7 +3298,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
if force_system_everything or self._controller.new_options.GetBoolean( 'always_show_system_everything' ):
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) )
else:
@@ -3313,7 +3315,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
num_everything = service_info[ info_type ]
- system_everythings.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
+ system_everythings.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
@@ -3348,7 +3350,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
num_everything = service_info[ HC.SERVICE_INFO_NUM_VIEWABLE_FILES ]
- system_everythings.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
+ system_everythings.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
if location_context.IncludesDeleted():
@@ -3374,13 +3376,13 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
num_not_local = 0
- file_repo_preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_local ) ) )
- file_repo_preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_not_local ) ) )
+ file_repo_preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_local ) ) )
+ file_repo_preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_not_local ) ) )
num_archive = num_local - num_inbox
- inbox_archive_preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_inbox ) ) )
- inbox_archive_preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_archive ) ) )
+ inbox_archive_preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_inbox ) ) )
+ inbox_archive_preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_archive ) ) )
elif status == HC.CONTENT_STATUS_DELETED:
@@ -3388,7 +3390,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
num_everything = service_info[ HC.SERVICE_INFO_NUM_DELETED_FILES ]
- system_everythings.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
+ system_everythings.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( num_everything ) ) )
@@ -3399,7 +3401,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
if len( inbox_archive_preds ) > 0:
- inbox_archive_preds = ClientSearch.MergePredicates( inbox_archive_preds )
+ inbox_archive_preds = ClientSearchPredicate.MergePredicates( inbox_archive_preds )
zero_counts = [ pred.GetCount().HasZeroCount() for pred in inbox_archive_preds ]
@@ -3410,7 +3412,7 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
# something is in here, but we are hiding, so let's inform system everything
useful_pred = list( ( pred for pred in inbox_archive_preds if pred.GetCount().HasNonZeroCount() ) )[0]
- if useful_pred.GetType() == ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX:
+ if useful_pred.GetType() == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX:
system_everything_suffix = 'all in inbox'
@@ -3427,22 +3429,22 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
blank_pred_types.update( [
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_TIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES,
- ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES,
- ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_URLS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_MIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DIMENSIONS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOTES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_URLS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO
] )
if len( system_everythings ) > 0:
- system_everythings = ClientSearch.MergePredicates( system_everythings )
+ system_everythings = ClientSearchPredicate.MergePredicates( system_everythings )
system_everything = list( system_everythings )[0]
@@ -3456,31 +3458,31 @@ def _GetFileSystemPredicates( self, file_search_context: ClientSearch.FileSearch
- predicates.extend( [ ClientSearch.Predicate( predicate_type ) for predicate_type in blank_pred_types ] )
+ predicates.extend( [ ClientSearchPredicate.Predicate( predicate_type ) for predicate_type in blank_pred_types ] )
- predicates = ClientSearch.MergePredicates( predicates )
+ predicates = ClientSearchPredicate.MergePredicates( predicates )
def sys_preds_key( s ):
t = s.GetType()
- if t == ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING:
+ if t == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING:
return ( 0, 0 )
- elif t == ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX:
+ elif t == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX:
return ( 1, 0 )
- elif t == ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE:
+ elif t == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE:
return ( 2, 0 )
- elif t == ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL:
+ elif t == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL:
return ( 3, 0 )
- elif t == ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL:
+ elif t == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL:
return ( 4, 0 )
@@ -4293,7 +4295,7 @@ def get_weight_from_dict( tag, d ):
if len( search_tags ) == 0:
- return ( num_tags_searched, num_tags_to_search, num_skipped, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = 'no search tags to work with!' ) ] )
+ return ( num_tags_searched, num_tags_to_search, num_skipped, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'no search tags to work with!' ) ] )
tag_display_type = ClientTags.TAG_DISPLAY_DISPLAY_ACTUAL
@@ -4350,7 +4352,7 @@ def get_weight_from_dict( tag, d ):
# all have count 0 or were filtered out by 0.0 weight
- return ( num_tags_searched, num_tags_to_search, num_skipped, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = 'no related tags found!' ) ] )
+ return ( num_tags_searched, num_tags_to_search, num_skipped, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'no related tags found!' ) ] )
#
@@ -4560,7 +4562,7 @@ def get_weight_from_dict( tag, d ):
existing_count = predicate.GetCount()
- new_count = ClientSearch.PredicateCount( int( existing_count.min_current_count * weight ), 0, None, None )
+ new_count = ClientSearchPredicate.PredicateCount( int( existing_count.min_current_count * weight ), 0, None, None )
predicate.SetCount( new_count )
@@ -10769,6 +10771,38 @@ def ask_what_to_do_zip_docx_scan():
+ if version == 589:
+
+ try:
+
+ domain_manager = self.modules_serialisable.GetJSONDump( HydrusSerialisable.SERIALISABLE_TYPE_NETWORK_DOMAIN_MANAGER )
+
+ domain_manager.Initialise()
+
+ #
+
+ domain_manager.OverwriteDefaultURLClasses( [
+ 'x post'
+ ] )
+
+ #
+
+ domain_manager.TryToLinkURLClassesAndParsers()
+
+ #
+
+ self.modules_serialisable.SetJSONDump( domain_manager )
+
+ except Exception as e:
+
+ HydrusData.PrintException( e )
+
+ message = 'Trying to update some downloader objects failed! Please let hydrus dev know!'
+
+ self.pub_initial_message( message )
+
+
+
self._controller.frame_splash_status.SetTitleText( 'updated db to v{}'.format( HydrusNumbers.ToHumanInt( version + 1 ) ) )
self._Execute( 'UPDATE version SET version = ?;', ( version + 1, ) )
diff --git a/hydrus/client/db/ClientDBFilesSearch.py b/hydrus/client/db/ClientDBFilesSearch.py
index 162def9fd..83c74b1f1 100644
--- a/hydrus/client/db/ClientDBFilesSearch.py
+++ b/hydrus/client/db/ClientDBFilesSearch.py
@@ -30,7 +30,10 @@
from hydrus.client.db import ClientDBURLMap
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
def intersection_update_qhi( query_hash_ids: typing.Optional[ typing.Set[ int ] ], some_hash_ids: typing.Collection[ int ], force_create_new_set = False ) -> typing.Set[ int ]:
@@ -51,7 +54,7 @@ def intersection_update_qhi( query_hash_ids: typing.Optional[ typing.Set[ int ]
-def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates ):
+def GetFilesInfoPredicates( system_predicates: ClientSearchFileSearchContext.FileSystemPredicates ):
simple_preds = system_predicates.GetSimpleInfo()
@@ -114,9 +117,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
files_info_predicates.append( 'has_audio = {}'.format( int( has_audio ) ) )
- if ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH ]
for number_test in number_tests:
@@ -124,9 +127,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
- if ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT ]
for number_test in number_tests:
@@ -176,9 +179,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
files_info_predicates.append( '( width * 1.0 ) / height < ' + str( float( ratio_width ) ) + ' / ' + str( ratio_height ) )
- if ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS ]
for number_test in number_tests:
@@ -186,9 +189,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
- if ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION ]
for number_test in number_tests:
@@ -196,9 +199,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
- if ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE ]
for number_test in number_tests:
@@ -206,9 +209,9 @@ def GetFilesInfoPredicates( system_predicates: ClientSearch.FileSystemPredicates
- if ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES in simple_preds:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES in simple_preds:
- number_tests: typing.List[ ClientSearch.NumberTest ] = simple_preds[ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES ]
+ number_tests: typing.List[ ClientNumberTest.NumberTest ] = simple_preds[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES ]
for number_test in number_tests:
@@ -240,7 +243,7 @@ def __init__(
super().__init__( 'client file search using tags', cursor )
- def GetHashIdsAndNonZeroTagCounts( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearch.TagContext, hash_ids, namespace_wildcard = '*', job_status = None ):
+ def GetHashIdsAndNonZeroTagCounts( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearchTagContext.TagContext, hash_ids, namespace_wildcard = '*', job_status = None ):
if namespace_wildcard == '*':
@@ -315,7 +318,7 @@ def GetHashIdsAndNonZeroTagCounts( self, tag_display_type: int, location_context
- def GetHashIdsFromNamespaceIdsSubtagIds( self, tag_display_type: int, file_service_key, tag_context: ClientSearch.TagContext, namespace_ids, subtag_ids, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromNamespaceIdsSubtagIds( self, tag_display_type: int, file_service_key, tag_context: ClientSearchTagContext.TagContext, namespace_ids, subtag_ids, hash_ids = None, hash_ids_table_name = None, job_status = None ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_id = self.modules_services.GetServiceId( tag_context.service_key )
@@ -325,7 +328,7 @@ def GetHashIdsFromNamespaceIdsSubtagIds( self, tag_display_type: int, file_servi
return self.GetHashIdsFromTagIds( tag_display_type, file_service_key, tag_context, tag_ids, hash_ids = hash_ids, hash_ids_table_name = hash_ids_table_name, job_status = job_status )
- def GetHashIdsFromNamespaceIdsSubtagIdsTables( self, tag_display_type: int, file_service_key, tag_context: ClientSearch.TagContext, namespace_ids_table_name, subtag_ids_table_name, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromNamespaceIdsSubtagIdsTables( self, tag_display_type: int, file_service_key, tag_context: ClientSearchTagContext.TagContext, namespace_ids_table_name, subtag_ids_table_name, hash_ids = None, hash_ids_table_name = None, job_status = None ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_id = self.modules_services.GetServiceId( tag_context.service_key )
@@ -335,7 +338,7 @@ def GetHashIdsFromNamespaceIdsSubtagIdsTables( self, tag_display_type: int, file
return self.GetHashIdsFromTagIds( tag_display_type, file_service_key, tag_context, tag_ids, hash_ids = hash_ids, hash_ids_table_name = hash_ids_table_name, job_status = job_status )
- def GetHashIdsFromSubtagIds( self, tag_display_type: int, file_service_key, tag_context: ClientSearch.TagContext, subtag_ids, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromSubtagIds( self, tag_display_type: int, file_service_key, tag_context: ClientSearchTagContext.TagContext, subtag_ids, hash_ids = None, hash_ids_table_name = None, job_status = None ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_id = self.modules_services.GetServiceId( tag_context.service_key )
@@ -345,7 +348,7 @@ def GetHashIdsFromSubtagIds( self, tag_display_type: int, file_service_key, tag_
return self.GetHashIdsFromTagIds( tag_display_type, file_service_key, tag_context, tag_ids, hash_ids = hash_ids, hash_ids_table_name = hash_ids_table_name, job_status = job_status )
- def GetHashIdsFromSubtagIdsTable( self, tag_display_type: int, file_service_key, tag_context: ClientSearch.TagContext, subtag_ids_table_name, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromSubtagIdsTable( self, tag_display_type: int, file_service_key, tag_context: ClientSearchTagContext.TagContext, subtag_ids_table_name, hash_ids = None, hash_ids_table_name = None, job_status = None ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_id = self.modules_services.GetServiceId( tag_context.service_key )
@@ -355,7 +358,7 @@ def GetHashIdsFromSubtagIdsTable( self, tag_display_type: int, file_service_key,
return self.GetHashIdsFromTagIds( tag_display_type, file_service_key, tag_context, tag_ids, hash_ids = hash_ids, hash_ids_table_name = hash_ids_table_name, job_status = job_status )
- def GetHashIdsFromTag( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearch.TagContext, tag, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromTag( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearchTagContext.TagContext, tag, hash_ids = None, hash_ids_table_name = None, job_status = None ):
( file_service_keys, file_location_is_cross_referenced ) = location_context.GetCoveringCurrentFileServiceKeys()
@@ -390,7 +393,7 @@ def GetHashIdsFromTag( self, tag_display_type: int, location_context: ClientLoca
search_tag_service_key = service_ids_to_service_keys[ search_tag_service_id ]
- search_tag_context = ClientSearch.TagContext( service_key = search_tag_service_key, include_current_tags = tag_context.include_current_tags, include_pending_tags = tag_context.include_pending_tags, display_service_key = search_tag_service_key )
+ search_tag_context = ClientSearchTagContext.TagContext( service_key = search_tag_service_key, include_current_tags = tag_context.include_current_tags, include_pending_tags = tag_context.include_pending_tags, display_service_key = search_tag_service_key )
ideal_tag_id = self.modules_tag_search.modules_tag_siblings.GetIdealTagId( tag_display_type, search_tag_service_id, tag_id )
@@ -421,7 +424,7 @@ def GetHashIdsFromTag( self, tag_display_type: int, location_context: ClientLoca
return results
- def GetHashIdsFromTagIds( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearch.TagContext, tag_ids: typing.Collection[ int ], hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromTagIds( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext, tag_ids: typing.Collection[ int ], hash_ids = None, hash_ids_table_name = None, job_status = None ):
do_hash_table_join = False
@@ -496,7 +499,7 @@ def GetHashIdsFromTagIds( self, tag_display_type: int, file_service_key: bytes,
return result_hash_ids
- def GetHashIdsFromTagIdsTables( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearch.TagContext, tag_ids: typing.Collection[ int ], hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromTagIdsTables( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext, tag_ids: typing.Collection[ int ], hash_ids = None, hash_ids_table_name = None, job_status = None ):
do_hash_table_join = False
@@ -571,7 +574,7 @@ def GetHashIdsFromTagIdsTables( self, tag_display_type: int, file_service_key: b
return result_hash_ids
- def GetHashIdsFromWildcardComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearch.TagContext, wildcard, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromWildcardComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearchTagContext.TagContext, wildcard, hash_ids = None, hash_ids_table_name = None, job_status = None ):
( namespace_wildcard, subtag_wildcard ) = HydrusTags.SplitTag( wildcard )
@@ -637,7 +640,7 @@ def GetHashIdsFromWildcardComplexLocation( self, tag_display_type: int, location
return results
- def GetHashIdsFromWildcardSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearch.TagContext, subtag_wildcard, namespace_ids_table_name = None, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsFromWildcardSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext, subtag_wildcard, namespace_ids_table_name = None, hash_ids = None, hash_ids_table_name = None, job_status = None ):
with self._MakeTemporaryIntegerTable( [], 'subtag_id' ) as temp_subtag_ids_table_name:
@@ -657,7 +660,7 @@ def GetHashIdsFromWildcardSimpleLocation( self, tag_display_type: int, file_serv
- def GetHashIdsThatHaveTagAsNumComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearch.TagContext, namespace_wildcard, num, operator, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsThatHaveTagAsNumComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearchTagContext.TagContext, namespace_wildcard, num, operator, hash_ids = None, hash_ids_table_name = None, job_status = None ):
if location_context.IsEmpty():
@@ -695,7 +698,7 @@ def GetHashIdsThatHaveTagAsNumComplexLocation( self, tag_display_type: int, loca
return results
- def GetHashIdsThatHaveTagAsNumSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearch.TagContext, namespace_wildcard, num, operator, hash_ids = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsThatHaveTagAsNumSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext, namespace_wildcard, num, operator, hash_ids = None, hash_ids_table_name = None, job_status = None ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_id = self.modules_services.GetServiceId( tag_context.service_key )
@@ -730,7 +733,7 @@ def GetHashIdsThatHaveTagAsNumSimpleLocation( self, tag_display_type: int, file_
- def GetHashIdsThatHaveTagsComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearch.TagContext, namespace_wildcard = '*', hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsThatHaveTagsComplexLocation( self, tag_display_type: int, location_context: ClientLocation.LocationContext, tag_context: ClientSearchTagContext.TagContext, namespace_wildcard = '*', hash_ids_table_name = None, job_status = None ):
if location_context.IsEmpty():
@@ -794,7 +797,7 @@ def GetHashIdsThatHaveTagsComplexLocation( self, tag_display_type: int, location
return results
- def GetHashIdsThatHaveTagsSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearch.TagContext, namespace_ids_table_name = None, hash_ids_table_name = None, job_status = None ):
+ def GetHashIdsThatHaveTagsSimpleLocation( self, tag_display_type: int, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext, namespace_ids_table_name = None, hash_ids_table_name = None, job_status = None ):
mapping_and_tag_table_names = self.modules_tag_search.GetMappingAndTagTables( tag_display_type, file_service_key, tag_context )
@@ -902,11 +905,11 @@ def __init__(
super().__init__( 'client file query', cursor )
- def _DoNotePreds( self, system_predicates: ClientSearch.FileSystemPredicates, query_hash_ids: typing.Optional[ typing.Set[ int ] ], job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Optional[ typing.Set[ int ] ]:
+ def _DoNotePreds( self, system_predicates: ClientSearchFileSearchContext.FileSystemPredicates, query_hash_ids: typing.Optional[ typing.Set[ int ] ], job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Optional[ typing.Set[ int ] ]:
simple_preds = system_predicates.GetSimpleInfo()
- number_tests = simple_preds.get( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, [] )
+ number_tests = simple_preds.get( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, [] )
if len( number_tests ) > 0:
@@ -959,9 +962,9 @@ def _DoNotePreds( self, system_predicates: ClientSearch.FileSystemPredicates, qu
def _DoOrPreds(
self,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
job_status: typing.Optional[ ClientThreading.JobStatus ],
- or_predicates: typing.Collection[ ClientSearch.Predicate ],
+ or_predicates: typing.Collection[ ClientSearchPredicate.Predicate ],
query_hash_ids: typing.Optional[ typing.Set[ int ] ]
) -> typing.Optional[ typing.Set[ int ] ]:
@@ -1007,7 +1010,7 @@ def or_sort_key( p ):
- def _DoSimpleRatingPreds( self, file_search_context: ClientSearch.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Optional[ typing.Set[ int ] ]:
+ def _DoSimpleRatingPreds( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Optional[ typing.Set[ int ] ]:
cancelled_hook = None
@@ -1119,7 +1122,7 @@ def _DoSimpleRatingPreds( self, file_search_context: ClientSearch.FileSearchCont
return query_hash_ids
- def _DoSpecificKnownURLPreds( self, file_search_context: ClientSearch.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], allowed_rule_types: typing.Collection[ str ] ) -> typing.Optional[ typing.Set[ int ] ]:
+ def _DoSpecificKnownURLPreds( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], allowed_rule_types: typing.Collection[ str ] ) -> typing.Optional[ typing.Set[ int ] ]:
system_predicates = file_search_context.GetSystemPredicates()
@@ -1190,7 +1193,7 @@ def url_rules_key( row ):
return query_hash_ids
- def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], have_cross_referenced_file_locations: bool, job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Tuple[ typing.Optional[ typing.Set[ int ] ], bool ]:
+ def _DoTimestampPreds( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, query_hash_ids: typing.Optional[ typing.Set[ int ] ], have_cross_referenced_file_locations: bool, job_status: typing.Optional[ ClientThreading.JobStatus ] = None ) -> typing.Tuple[ typing.Optional[ typing.Set[ int ] ], bool ]:
system_predicates = file_search_context.GetSystemPredicates()
@@ -1212,11 +1215,11 @@ def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext
# for now we'll check current domain
# if domain is deleted, we search deletion time
- if ClientSearch.PREDICATE_TYPE_SYSTEM_AGE in system_pred_type_to_timestamp_ranges_ms:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE in system_pred_type_to_timestamp_ranges_ms:
import_timestamp_predicates = []
- timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearch.PREDICATE_TYPE_SYSTEM_AGE ]
+ timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE ]
if '>' in timestamp_ranges_ms:
@@ -1251,9 +1254,9 @@ def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext
- if ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME in system_pred_type_to_timestamp_ranges_ms:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME in system_pred_type_to_timestamp_ranges_ms:
- timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME ]
+ timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME ]
if len( timestamp_ranges_ms ) > 0:
@@ -1263,9 +1266,9 @@ def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext
- if ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME in system_pred_type_to_timestamp_ranges_ms:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME in system_pred_type_to_timestamp_ranges_ms:
- timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ]
+ timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ]
if len( timestamp_ranges_ms ) > 0:
@@ -1275,9 +1278,9 @@ def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext
- if ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME in system_pred_type_to_timestamp_ranges_ms:
+ if ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME in system_pred_type_to_timestamp_ranges_ms:
- timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME ]
+ timestamp_ranges_ms = system_pred_type_to_timestamp_ranges_ms[ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME ]
min_last_viewed_timestamp_ms = timestamp_ranges_ms.get( '>', None )
max_last_viewed_timestamp_ms = timestamp_ranges_ms.get( '<', None )
@@ -1292,7 +1295,7 @@ def _DoTimestampPreds( self, file_search_context: ClientSearch.FileSearchContext
def GetHashIdsFromQuery(
self,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
job_status: typing.Optional[ ClientThreading.JobStatus ] = None,
query_hash_ids: typing.Optional[ set ] = None,
apply_implicit_limit: bool = True,
@@ -2208,7 +2211,7 @@ def sort_longest_tag_first_key( s ):
#
- num_urls_tests = simple_preds.get( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, [] )
+ num_urls_tests = simple_preds.get( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, [] )
if len( num_urls_tests ) > 0:
@@ -2244,7 +2247,7 @@ def sort_longest_tag_first_key( s ):
specific_number_tests = [ number_test for number_test in number_tests if not ( number_test.IsZero() or number_test.IsAnythingButZero() ) ]
- megalambda = ClientSearch.NumberTest.STATICCreateMegaLambda( specific_number_tests )
+ megalambda = ClientNumberTest.NumberTest.STATICCreateMegaLambda( specific_number_tests )
is_zero = True in ( number_test.IsZero() for number_test in number_tests )
is_anything_but_zero = True in ( number_test.IsAnythingButZero() for number_test in number_tests )
@@ -2384,7 +2387,7 @@ def GetTablesAndColumnsThatUseDefinitions( self, content_type: int ) -> typing.L
return tables_and_columns
- def PopulateSearchIntoTempTable( self, file_search_context: ClientSearch.FileSearchContext, temp_table_name: str ) -> typing.List[ int ]:
+ def PopulateSearchIntoTempTable( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, temp_table_name: str ) -> typing.List[ int ]:
query_hash_ids = self.GetHashIdsFromQuery( file_search_context, apply_implicit_limit = False )
diff --git a/hydrus/client/db/ClientDBNotesMap.py b/hydrus/client/db/ClientDBNotesMap.py
index fec06d044..fe782d56c 100644
--- a/hydrus/client/db/ClientDBNotesMap.py
+++ b/hydrus/client/db/ClientDBNotesMap.py
@@ -8,7 +8,7 @@
from hydrus.client import ClientThreading
from hydrus.client.db import ClientDBMaster
from hydrus.client.db import ClientDBModule
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
class ClientDBNotesMap( ClientDBModule.ClientDBModule ):
@@ -60,13 +60,13 @@ def GetHashIdsFromNoteName( self, name: str, hash_ids_table_name: str, job_statu
return self._STS( self._ExecuteCancellable( 'SELECT hash_id FROM file_notes CROSS JOIN {} USING ( hash_id ) WHERE name_id = ?;'.format( hash_ids_table_name ), ( label_id, ), cancelled_hook ) )
- def GetHashIdsFromNumNotes( self, number_tests: typing.List[ ClientSearch.NumberTest ], hash_ids: typing.Collection[ int ], hash_ids_table_name: str, job_status: typing.Optional[ ClientThreading.JobStatus ] = None ):
+ def GetHashIdsFromNumNotes( self, number_tests: typing.List[ ClientNumberTest.NumberTest ], hash_ids: typing.Collection[ int ], hash_ids_table_name: str, job_status: typing.Optional[ ClientThreading.JobStatus ] = None ):
result_hash_ids = set( hash_ids )
specific_number_tests = [ number_test for number_test in number_tests if not ( number_test.IsZero() or number_test.IsAnythingButZero() ) ]
- megalambda = ClientSearch.NumberTest.STATICCreateMegaLambda( specific_number_tests )
+ megalambda = ClientNumberTest.NumberTest.STATICCreateMegaLambda( specific_number_tests )
is_zero = True in ( number_test.IsZero() for number_test in number_tests )
is_anything_but_zero = True in ( number_test.IsAnythingButZero() for number_test in number_tests )
diff --git a/hydrus/client/db/ClientDBServices.py b/hydrus/client/db/ClientDBServices.py
index 3d3fc6c69..9b8444bdb 100644
--- a/hydrus/client/db/ClientDBServices.py
+++ b/hydrus/client/db/ClientDBServices.py
@@ -12,7 +12,7 @@
from hydrus.client import ClientLocation
from hydrus.client import ClientServices
from hydrus.client.db import ClientDBModule
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
class FileSearchContextLeaf( object ):
@@ -29,7 +29,7 @@ def __init__( self, file_service_id: int, tag_service_id: int ):
class FileSearchContextBranch( object ):
- def __init__( self, file_search_context: ClientSearch.FileSearchContext, file_service_ids: typing.Collection[ int ], tag_service_ids: typing.Collection[ int ], file_location_is_cross_referenced: bool ):
+ def __init__( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext, file_service_ids: typing.Collection[ int ], tag_service_ids: typing.Collection[ int ], file_location_is_cross_referenced: bool ):
self.file_search_context = file_search_context
@@ -43,7 +43,7 @@ def FileLocationIsCrossReferenced( self ) -> bool:
return self.file_location_is_cross_referenced
- def GetFileSearchContext( self ) -> ClientSearch.FileSearchContext:
+ def GetFileSearchContext( self ) -> ClientSearchFileSearchContext.FileSearchContext:
return self.file_search_context
@@ -205,7 +205,7 @@ def FileServiceIsCoveredByAllLocalFiles( self, service_id ) -> bool:
return service_type in HC.FILE_SERVICES_COVERED_BY_COMBINED_LOCAL_FILE
- def GetFileSearchContextBranch( self, file_search_context: ClientSearch.FileSearchContext ) -> FileSearchContextBranch:
+ def GetFileSearchContextBranch( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ) -> FileSearchContextBranch:
location_context = file_search_context.GetLocationContext()
tag_context = file_search_context.GetTagContext()
diff --git a/hydrus/client/db/ClientDBTagDisplay.py b/hydrus/client/db/ClientDBTagDisplay.py
index 7d728ad05..c4bdc6207 100644
--- a/hydrus/client/db/ClientDBTagDisplay.py
+++ b/hydrus/client/db/ClientDBTagDisplay.py
@@ -19,7 +19,8 @@
from hydrus.client.db import ClientDBTagParents
from hydrus.client.db import ClientDBTagSiblings
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
class ClientDBTagDisplay( ClientDBModule.ClientDBModule ):
@@ -122,7 +123,7 @@ def GeneratePredicatesFromTagIdsAndCounts( self, tag_display_type: int, display_
tag = tag_ids_to_tags[ tag_id ]
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = tag, inclusive = inclusive, count = ClientSearch.PredicateCount( min_current_count, min_pending_count, max_current_count, max_pending_count ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = tag, inclusive = inclusive, count = ClientSearchPredicate.PredicateCount( min_current_count, min_pending_count, max_current_count, max_pending_count ) )
if tag_id in tag_ids_to_ideal_tag_ids_for_siblings:
@@ -198,7 +199,7 @@ def GeneratePredicatesFromTagIdsAndCounts( self, tag_display_type: int, display_
tag = tag_ids_to_tags[ tag_id ]
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = tag, inclusive = inclusive, count = ClientSearch.PredicateCount( min_current_count, min_pending_count, max_current_count, max_pending_count ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = tag, inclusive = inclusive, count = ClientSearchPredicate.PredicateCount( min_current_count, min_pending_count, max_current_count, max_pending_count ) )
if tag_id in tag_ids_to_known_chain_tag_ids:
@@ -368,7 +369,7 @@ def GetInterestedServiceIds( self, tag_service_id ) -> typing.Set[ int ]:
return set( self.modules_tag_siblings.GetInterestedServiceIds( tag_service_id ) ).union( self.modules_tag_parents.GetInterestedServiceIds( tag_service_id ) )
- def GetMediaPredicates( self, tag_context: ClientSearch.TagContext, tags_to_counts, inclusive, job_status = None ):
+ def GetMediaPredicates( self, tag_context: ClientSearchTagContext.TagContext, tags_to_counts, inclusive, job_status = None ):
if HG.autocomplete_delay_mode:
diff --git a/hydrus/client/db/ClientDBTagSearch.py b/hydrus/client/db/ClientDBTagSearch.py
index 647b0561f..5244bce16 100644
--- a/hydrus/client/db/ClientDBTagSearch.py
+++ b/hydrus/client/db/ClientDBTagSearch.py
@@ -24,7 +24,10 @@
from hydrus.client.db import ClientDBTagDisplay
from hydrus.client.db import ClientDBTagSiblings
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchAutocomplete
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
# Sqlite can handle -( 2 ** 63 ) -> ( 2 ** 63 ) - 1
MIN_CACHED_INTEGER = - ( 2 ** 63 )
@@ -322,7 +325,7 @@ def AddTags( self, file_service_id, tag_service_id, tag_ids ):
for ( subtag_id, subtag ) in subtag_ids_and_subtags:
- searchable_subtag = ClientSearch.ConvertSubtagToSearchable( subtag )
+ searchable_subtag = ClientSearchTagContext.ConvertSubtagToSearchable( subtag )
if searchable_subtag != subtag:
@@ -485,7 +488,7 @@ def GetAllTagIds( self, leaf: ClientDBServices.FileSearchContextLeaf, job_status
def GetAutocompletePredicates(
self,
tag_display_type: int,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
search_text: str = '',
exact_match = False,
inclusive = True,
@@ -578,7 +581,7 @@ def GetAutocompletePredicates(
- predicates = ClientSearch.MergePredicates( all_predicates )
+ predicates = ClientSearchPredicate.MergePredicates( all_predicates )
return predicates
@@ -713,7 +716,7 @@ def GetIntegerSubtagsTableName( self, file_service_id, tag_service_id ):
return integer_subtags_table_name
- def GetMappingTables( self, tag_display_type, file_service_key: bytes, tag_context: ClientSearch.TagContext ):
+ def GetMappingTables( self, tag_display_type, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext ):
mapping_and_tag_table_names = self.GetMappingAndTagTables( tag_display_type, file_service_key, tag_context )
@@ -722,7 +725,7 @@ def GetMappingTables( self, tag_display_type, file_service_key: bytes, tag_conte
return mapping_table_names
- def GetMappingAndTagTables( self, tag_display_type, file_service_key: bytes, tag_context: ClientSearch.TagContext ):
+ def GetMappingAndTagTables( self, tag_display_type, file_service_key: bytes, tag_context: ClientSearchTagContext.TagContext ):
file_service_id = self.modules_services.GetServiceId( file_service_key )
tag_service_key = tag_context.service_key
@@ -859,7 +862,7 @@ def GetSubtagIdsFromWildcard( self, file_service_id: int, tag_service_id: int, s
query = 'SELECT docid FROM {};'.format( subtags_fts4_table_name )
query_args = ()
- elif ClientSearch.IsComplexWildcard( subtag_wildcard ) or not wildcard_has_fts4_searchable_characters:
+ elif ClientSearchAutocomplete.IsComplexWildcard( subtag_wildcard ) or not wildcard_has_fts4_searchable_characters:
# FTS4 does not support complex wildcards, so instead we'll search our raw subtags
# however, since we want to search 'searchable' text, we use the 'searchable subtags map' to cross between real and searchable
@@ -974,7 +977,7 @@ def GetSubtagIdsFromWildcardIntoTable( self, file_service_id: int, tag_service_i
query = self._Execute( 'SELECT docid FROM {};'.format( subtags_fts4_table_name ) )
query_args = ()
- elif ClientSearch.IsComplexWildcard( subtag_wildcard ) or not wildcard_has_fts4_searchable_characters:
+ elif ClientSearchAutocomplete.IsComplexWildcard( subtag_wildcard ) or not wildcard_has_fts4_searchable_characters:
# FTS4 does not support complex wildcards, so instead we'll search our raw subtags
# however, since we want to search 'searchable' text, we use the 'searchable subtags map' to cross between real and searchable
@@ -1305,7 +1308,7 @@ def GetTagIdsFromSubtagIdsTable( self, file_service_id: int, tag_service_id: int
def GetTagIdPredicates(
self,
tag_display_type: int,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
tag_ids: typing.Collection[ int ],
inclusive = True,
zero_count_ok = False,
@@ -1354,7 +1357,7 @@ def GetTagIdPredicates(
- predicates = ClientSearch.MergePredicates( all_predicates )
+ predicates = ClientSearchPredicate.MergePredicates( all_predicates )
return predicates
@@ -1362,7 +1365,7 @@ def GetTagIdPredicates(
def GetTagPredicates(
self,
tag_display_type: int,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
tags: typing.Collection[ str ],
inclusive = True,
zero_count_ok = False,
@@ -1532,7 +1535,7 @@ def RegenerateSearchableSubtagMap( self, file_service_id, tag_service_id, status
( subtag, ) = result
- searchable_subtag = ClientSearch.ConvertSubtagToSearchable( subtag )
+ searchable_subtag = ClientSearchTagContext.ConvertSubtagToSearchable( subtag )
if searchable_subtag != subtag:
@@ -1573,7 +1576,7 @@ def RepopulateMissingSubtags( self, file_service_id, tag_service_id ):
( subtag, ) = result
- searchable_subtag = ClientSearch.ConvertSubtagToSearchable( subtag )
+ searchable_subtag = ClientSearchTagContext.ConvertSubtagToSearchable( subtag )
if searchable_subtag != subtag:
diff --git a/hydrus/client/db/ClientDBURLMap.py b/hydrus/client/db/ClientDBURLMap.py
index 1ba536a7e..cb180c4a3 100644
--- a/hydrus/client/db/ClientDBURLMap.py
+++ b/hydrus/client/db/ClientDBURLMap.py
@@ -7,7 +7,7 @@
from hydrus.client.db import ClientDBMaster
from hydrus.client.db import ClientDBModule
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
class ClientDBURLMap( ClientDBModule.ClientDBModule ):
@@ -57,7 +57,7 @@ def GetHashIds( self, search_url: str ):
return hash_ids
- def GetHashIdsFromCountTests( self, number_tests: typing.List[ ClientSearch.NumberTest ], hash_ids: typing.Collection[ int ], hash_ids_table_name: str ):
+ def GetHashIdsFromCountTests( self, number_tests: typing.List[ ClientNumberTest.NumberTest ], hash_ids: typing.Collection[ int ], hash_ids_table_name: str ):
# we'll have to natural join 'urls' or 'urls-class-map-cache' or whatever when we add a proper filter to this guy
@@ -74,7 +74,7 @@ def GetHashIdsFromCountTests( self, number_tests: typing.List[ ClientSearch.Numb
specific_number_tests = [ number_test for number_test in number_tests if not ( number_test.IsZero() or number_test.IsAnythingButZero() ) ]
- megalambda = ClientSearch.NumberTest.STATICCreateMegaLambda( specific_number_tests )
+ megalambda = ClientNumberTest.NumberTest.STATICCreateMegaLambda( specific_number_tests )
is_zero = True in ( number_test.IsZero() for number_test in number_tests )
is_anything_but_zero = True in ( number_test.IsAnythingButZero() for number_test in number_tests )
diff --git a/hydrus/client/duplicates/ClientAutoDuplicates.py b/hydrus/client/duplicates/ClientAutoDuplicates.py
index afc05dc79..3ade103c1 100644
--- a/hydrus/client/duplicates/ClientAutoDuplicates.py
+++ b/hydrus/client/duplicates/ClientAutoDuplicates.py
@@ -5,13 +5,16 @@
from hydrus.client import ClientConstants as CC
from hydrus.client.duplicates import ClientDuplicates
+from hydrus.client.metadata import ClientMetadataConditional
+# in the database I guess we'll assign these in a new table to all outstanding pairs that match a search
DUPLICATE_STATUS_DOES_NOT_MATCH_SEARCH = 0
DUPLICATE_STATUS_MATCHES_SEARCH_BUT_NOT_TESTED = 1
DUPLICATE_STATUS_MATCHES_SEARCH_FAILED_TEST = 2
DUPLICATE_STATUS_MATCHES_SEARCH_PASSED_TEST = 3 # presumably this will not be needed much since we'll delete the duplicate pair soon after, but we may as well be careful
+DUPLICATE_STATUS_NOT_SEARCHED = 4 # assign this to new pairs that are added, by default??? then re-do the search with system:hash tacked on maybe, regularly
-class PairComparatorRule( HydrusSerialisable.SerialisableBase ):
+class PairComparator( HydrusSerialisable.SerialisableBase ):
def Test( self, media_result_better, media_result_worse ):
@@ -22,25 +25,29 @@ def Test( self, media_result_better, media_result_worse ):
LOOKING_AT_BETTER_CANDIDATE = 0
LOOKING_AT_WORSE_CANDIDATE = 1
-class PairComparatorRuleOneFile( PairComparatorRule ):
+class PairComparatorOneFile( PairComparator ):
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_ONE_FILE
- SERIALISABLE_NAME = 'Auto-Duplicates Pair Comparator Rule - One File'
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_ONE_FILE
+ SERIALISABLE_NAME = 'Auto-Duplicates Pair Comparator - One File'
SERIALISABLE_VERSION = 1
def __init__( self ):
+ """
+ This guy holds one test and is told to test either the better or worse candidate. Multiple of these stacked up make for 'the better file is a jpeg over one megabyte, the worse file is a jpeg under 100KB'.
+ """
- PairComparatorRule.__init__( self )
+ PairComparator.__init__( self )
+
+ # this guy tests the better or the worse for a single property
+ # user could set up multiple on either side of the equation
+ # what are we testing?
+ # better file mime is jpeg (& worse file is png)
+ # better file has icc profile
+ # worse file filesize < 200KB
self._looking_at = LOOKING_AT_BETTER_CANDIDATE
- # ok bro time to get metadata conditional working. first draft will be filetype test for jpeg/png. no need for UI yet
- self._metadata_conditional = None
- # what are we testing?
- # this would be a great place to insert MetadataConditional
- # mime is jpeg
- # has icc profile
- # maybe stuff like filesize > 200KB
+ self._metadata_conditional = ClientMetadataConditional.MetadataConditional()
# serialisable gubbins
@@ -59,17 +66,22 @@ def Test( self, media_result_better, media_result_worse ):
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_ONE_FILE ] = PairComparatorRuleOneFile
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_ONE_FILE ] = PairComparatorOneFile
-class PairComparatorRuleTwoFiles( PairComparatorRule ):
+class PairComparatorRelative( PairComparator ):
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_TWO_FILES
- SERIALISABLE_NAME = 'Auto-Duplicates Pair Comparator Rule - Two Files'
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_TWO_FILES_RELATIVE
+ SERIALISABLE_NAME = 'Auto-Duplicates Pair Comparator - Relative'
SERIALISABLE_VERSION = 1
def __init__( self ):
+ """
+ This guy compares the pair directly. It can say 'yes the better candidate is 4x bigger than the worse'.
+ """
- PairComparatorRule.__init__( self )
+ PairComparator.__init__( self )
+
+ # this work does not need to be done yet!
# if I am feeling big brain, isn't this just a dynamic one-file metadata conditional?
# if we want 4x size, then we just pull the size of A and ask if B is <0.25x that or whatever. we don't need a clever two-file MetadataConditional test
@@ -94,19 +106,24 @@ def Test( self, media_result_better, media_result_worse ):
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_TWO_FILES ] = PairComparatorRuleTwoFiles
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_TWO_FILES_RELATIVE ] = PairComparatorRelative
class PairSelectorAndComparator( HydrusSerialisable.SerialisableBase ):
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR
SERIALISABLE_NAME = 'Auto-Duplicates Pair Selector and Comparator'
SERIALISABLE_VERSION = 1
def __init__( self ):
+ """
+ This guy holds a bunch of rules. It is given a pair of media and it tests all the rules both ways around. If the files pass all the rules, we have a match and thus a confirmed better file.
+
+ A potential future expansion here is to attach scores to the rules and have a score threshold, but let's not get ahead of ourselves.
+ """
super().__init__()
- self._rules = HydrusSerialisable.SerialisableList()
+ self._comparators = HydrusSerialisable.SerialisableList()
# serialisable gubbins
@@ -121,11 +138,11 @@ def GetMatchingMedia( self, media_result_1, media_result_2 ):
( media_result_1, media_result_2 ) = pair
- if False not in ( rule.Test( media_result_1, media_result_2 ) for rule in self._rules ):
+ if False not in ( comparator.Test( media_result_1, media_result_2 ) for comparator in self._comparators ):
return media_result_1
- elif False not in ( rule.Test( media_result_2, media_result_1 ) for rule in self._rules ):
+ elif False not in ( comparator.Test( media_result_2, media_result_1 ) for comparator in self._comparators ):
return media_result_2
@@ -136,18 +153,22 @@ def GetMatchingMedia( self, media_result_1, media_result_2 ):
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR ] = PairSelectorAndComparator
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR ] = PairSelectorAndComparator
class DuplicatesAutoResolutionRule( HydrusSerialisable.SerialisableBaseNamed ):
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_RULE
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_RULE
SERIALISABLE_NAME = 'Auto-Duplicates Rule'
SERIALISABLE_VERSION = 1
def __init__( self, name ):
+ """
+ This guy holds everything to make a single auto-resolution job work. It knows the search it wants to do, and, when given pairs from that search, will confirm whether one file passes its auto-resolution threshold and should be auto-considered better.
+ """
HydrusSerialisable.SerialisableBaseNamed.__init__( self, name )
+ # the id here will be for the database to match up rules to cached pair statuses. slightly wewmode, but we'll see
self._id = -1
# maybe make this search part into its own object? in ClientDuplicates
@@ -171,13 +192,18 @@ def __init__( self, name ):
# 'here's a pair of media results, pass/fail?'
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_AUTO_DUPLICATES_RULE ] = DuplicatesAutoResolutionRule
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_AUTO_DUPLICATES_RULE ] = DuplicatesAutoResolutionRule
class DuplicatesAutoResolutionManager( object ):
my_instance = None
def __init__( self ):
+ """
+ This guy is going to be the mainloop daemon that runs all this gubbins.
+
+ Needs some careful locking for when the edit dialog is open, like import folders manager etc..
+ """
DuplicatesAutoResolutionManager.my_instance = self
diff --git a/hydrus/client/exporting/ClientExportingFiles.py b/hydrus/client/exporting/ClientExportingFiles.py
index 7cd96a036..0674a33ca 100644
--- a/hydrus/client/exporting/ClientExportingFiles.py
+++ b/hydrus/client/exporting/ClientExportingFiles.py
@@ -22,7 +22,7 @@
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientMetadataMigration
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
def GenerateExportFilename( destination_directory, media, terms, file_index, do_not_use_filenames = None ):
@@ -323,7 +323,7 @@ def __init__(
default_location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context )
if metadata_routers is None:
diff --git a/hydrus/client/gui/ClientGUIOptionsPanels.py b/hydrus/client/gui/ClientGUIOptionsPanels.py
index ca9ff2b00..8242a3f06 100644
--- a/hydrus/client/gui/ClientGUIOptionsPanels.py
+++ b/hydrus/client/gui/ClientGUIOptionsPanels.py
@@ -4,13 +4,10 @@
from qtpy import QtWidgets as QW
from hydrus.core import HydrusConstants as HC
-from hydrus.core import HydrusData
from hydrus.client import ClientConstants as CC
-from hydrus.client.gui import ClientGUIFunctions
from hydrus.client.gui import QtPorting as QP
-from hydrus.client.gui.widgets import ClientGUICommon
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
class OptionsPanel( QW.QWidget ):
@@ -107,7 +104,7 @@ def GetValue( self ) -> typing.Tuple[ int ]:
def SetValue( self, checked_mimes: typing.Collection[ int ] ):
- checked_mimes = ClientSearch.ConvertSummaryFiletypesToSpecific( checked_mimes, only_searchable = False )
+ checked_mimes = ClientSearchPredicate.ConvertSummaryFiletypesToSpecific( checked_mimes, only_searchable = False )
for ( mime, item ) in self._mimes_to_items.items():
diff --git a/hydrus/client/gui/ClientGUIStringPanels.py b/hydrus/client/gui/ClientGUIStringPanels.py
index 6b6335dd8..584d11d88 100644
--- a/hydrus/client/gui/ClientGUIStringPanels.py
+++ b/hydrus/client/gui/ClientGUIStringPanels.py
@@ -1330,9 +1330,11 @@ def __init__( self, parent: QW.QWidget, string_match: ClientStrings.StringMatch,
self._match_value_flexible_input = ClientGUICommon.BetterChoice( self )
- self._match_value_flexible_input.addItem( 'alphabetic characters (a-zA-Z)', ClientStrings.ALPHA )
- self._match_value_flexible_input.addItem( 'alphanumeric characters (a-zA-Z0-9)', ClientStrings.ALPHANUMERIC )
- self._match_value_flexible_input.addItem( 'numeric characters (0-9)', ClientStrings.NUMERIC )
+ self._match_value_flexible_input.addItem( 'alphabetic characters (a-zA-Z)', ClientStrings.FLEXIBLE_MATCH_ALPHA )
+ self._match_value_flexible_input.addItem( 'alphanumeric characters (a-zA-Z0-9)', ClientStrings.FLEXIBLE_MATCH_ALPHANUMERIC )
+ self._match_value_flexible_input.addItem( 'numeric characters (0-9)', ClientStrings.FLEXIBLE_MATCH_NUMERIC )
+ self._match_value_flexible_input.addItem( 'hexadecimal characters (0-9a-fA-F)', ClientStrings.FLEXIBLE_MATCH_HEX )
+ self._match_value_flexible_input.addItem( 'base-64 characters (a-zA-z0-9+/, = padding)', ClientStrings.FLEXIBLE_MATCH_BASE64 )
self._min_chars = ClientGUICommon.NoneableSpinCtrl( self, 16, min = 1, max = 65535, unit = 'characters', none_phrase = 'no limit' )
self._max_chars = ClientGUICommon.NoneableSpinCtrl( self, 64, min = 1, max = 65535, unit = 'characters', none_phrase = 'no limit' )
@@ -1534,7 +1536,7 @@ def SetValue( self, string_match: ClientStrings.StringMatch ):
self._match_type.SetValue( match_type )
- self._match_value_flexible_input.SetValue( ClientStrings.ALPHA )
+ self._match_value_flexible_input.SetValue( ClientStrings.FLEXIBLE_MATCH_ALPHA )
if match_type == ClientStrings.STRING_MATCH_FIXED:
diff --git a/hydrus/client/gui/ClientGUISubscriptions.py b/hydrus/client/gui/ClientGUISubscriptions.py
index 2c5cdb0b3..0cd74e1f3 100644
--- a/hydrus/client/gui/ClientGUISubscriptions.py
+++ b/hydrus/client/gui/ClientGUISubscriptions.py
@@ -39,22 +39,79 @@
from hydrus.client.importing import ClientImportSubscriptionQuery
from hydrus.client.importing import ClientImportSubscriptionLegacy # keep this here so the serialisable stuff is registered, it has to be imported somewhere
-def DoAliveOrDeadCheck( win: QW.QWidget, query_headers: typing.Collection[ ClientImportSubscriptionQuery.SubscriptionQueryHeader ] ):
+def DoAliveOrDeadCheck( win: QW.QWidget, subscriptions: typing.Collection[ ClientImportSubscriptions.Subscription ], query_headers: typing.Collection[ ClientImportSubscriptionQuery.SubscriptionQueryHeader ] ):
+
+ do_paused_subs = True
+
+ num_paused_subs = sum( ( 1 for subscription in subscriptions if subscription.IsPaused() ) )
+
+ if 0 < num_paused_subs:
+
+ message = f'Of the {HydrusNumbers.ToHumanInt(len(subscriptions))} selected subscriptions, {HydrusNumbers.ToHumanInt(num_paused_subs)} are paused. Do you want to unpause these paused subs and check their queries?'
+
+ if num_paused_subs == len( subscriptions ):
+
+ choice_tuples = [
+ ( f'yes, unpause them and check their queries', True, 'Unpause and check what is paused.' ),
+ ( f'no, leave them alone', False, 'Exit out of this.' )
+ ]
+
+ else:
+
+ choice_tuples = [
+ ( f'yes, check queries within paused subs', True, 'Unpause and check what is paused.' ),
+ ( f'no, just check within unpaused subs', False, 'Only check what is currently active.' )
+ ]
+
+
+ try:
+
+ do_paused_subs = ClientGUIDialogsQuick.SelectFromListButtons( win, 'Check which?', choice_tuples, message = message )
+
+ except HydrusExceptions.CancelledException:
+
+ raise
+
+
+
+ if len( subscriptions ) > 0 and len( query_headers ) == 0:
+
+ if do_paused_subs:
+
+ subs_to_pull_from = subscriptions
+
+ else:
+
+ subs_to_pull_from = [ subscription for subscription in subscriptions if not subscription.IsPaused() ]
+
+
+ query_headers = HydrusLists.MassExtend( ( subscription.GetQueryHeaders() for subscription in subs_to_pull_from ) )
+
do_alive = True
do_dead = True
num_dead = sum( ( 1 for query_header in query_headers if query_header.IsDead() ) )
- if 0 < num_dead < len( query_headers ):
+ if 0 < num_dead:
- message = f'Of the {HydrusNumbers.ToHumanInt(len(query_headers))} selected queries, {HydrusNumbers.ToHumanInt(num_dead)} are DEAD. Which queries do you want to check?'
+ message = f'Of the {HydrusNumbers.ToHumanInt(len(query_headers))} selected queries, {HydrusNumbers.ToHumanInt(num_dead)} are DEAD. Do you want to check these?'
- choice_tuples = [
- ( f'all of them', ( True, True ), 'Resuscitate the DEAD queries and check everything.' ),
- ( f'the {HydrusNumbers.ToHumanInt(len(query_headers)-num_dead)} ALIVE', ( True, False ), 'Check the ALIVE queries.' ),
- ( f'the {HydrusNumbers.ToHumanInt(num_dead)} DEAD', ( False, True ), 'Resuscitate the DEAD queries and check them.' )
- ]
+ if num_dead == len( query_headers ):
+
+ choice_tuples = [
+ ( f'yes, resurrect the DEAD queries', ( False, True ), 'Resuscitate the DEAD queries and check everything.' ),
+ ( f'no, leave them DEAD', ( False, False ), 'Exit out of this.' )
+ ]
+
+ else:
+
+ choice_tuples = [
+ ( f'yes, check all of them', ( True, True ), 'Resuscitate the DEAD queries and check everything.' ),
+ ( f'check the {HydrusNumbers.ToHumanInt(len(query_headers)-num_dead)} ALIVE', ( True, False ), 'Check the ALIVE queries.' ),
+ ( f'resurrect and check the {HydrusNumbers.ToHumanInt(num_dead)} DEAD', ( False, True ), 'Resuscitate the DEAD queries and check them.' )
+ ]
+
try:
@@ -66,7 +123,50 @@ def DoAliveOrDeadCheck( win: QW.QWidget, query_headers: typing.Collection[ Clien
- return ( do_alive, do_dead )
+ if not do_alive:
+
+ query_headers = [ query_header for query_header in query_headers if query_header.IsDead() ]
+
+
+ if not do_dead:
+
+ query_headers = [ query_header for query_header in query_headers if not query_header.IsDead() ]
+
+
+ do_paused_queries = True
+
+ num_paused_queries = sum( ( 1 for query_header in query_headers if query_header.IsPaused() ) )
+
+ if 0 < num_paused_queries:
+
+ message = f'Of the {HydrusNumbers.ToHumanInt(len(query_headers))} selected queries, {HydrusNumbers.ToHumanInt(num_paused_queries)} are paused. Do you want to unpause and check them?'
+
+ if num_paused_queries == len( query_headers ):
+
+ choice_tuples = [
+ ( f'yes, check them', True, 'Unpause and check what is paused.' ),
+ ( f'no, leave them alone', False, 'Exit out of this.' )
+ ]
+
+ else:
+
+ choice_tuples = [
+ ( f'yes check paused queries', True, 'Unpause and check what is paused.' ),
+ ( f'no just what is currently unpaused', False, 'Only check what is currently active.' )
+ ]
+
+
+ try:
+
+ do_paused_queries = ClientGUIDialogsQuick.SelectFromListButtons( win, 'Check which?', choice_tuples, message = message )
+
+ except HydrusExceptions.CancelledException:
+
+ raise
+
+
+
+ return ( do_alive, do_dead, do_paused_subs, do_paused_queries )
def GetQueryHeadersQualityInfo( query_headers: typing.Iterable[ ClientImportSubscriptionQuery.SubscriptionQueryHeader ] ):
@@ -439,7 +539,7 @@ def _CheckNow( self ):
try:
- ( do_alive, do_dead ) = DoAliveOrDeadCheck( self, selected_query_headers )
+ ( do_alive, do_dead, do_paused_subs, do_paused_queries ) = DoAliveOrDeadCheck( self, [], selected_query_headers )
except HydrusExceptions.CancelledException:
@@ -463,6 +563,11 @@ def _CheckNow( self ):
+ if not do_paused_queries and query_header.IsPaused():
+
+ continue
+
+
query_header.CheckNow()
@@ -2146,11 +2251,9 @@ def CheckNow( self ):
subscriptions = self._subscriptions.GetData( only_selected = True )
- query_headers = HydrusLists.MassExtend( ( subscription.GetQueryHeaders() for subscription in subscriptions ) )
-
try:
- ( do_alive, do_dead ) = DoAliveOrDeadCheck( self, query_headers )
+ ( do_alive, do_dead, do_paused_subs, do_paused_queries ) = DoAliveOrDeadCheck( self, subscriptions, [] )
except HydrusExceptions.CancelledException:
@@ -2159,6 +2262,11 @@ def CheckNow( self ):
for subscription in subscriptions:
+ if not do_paused_subs and subscription.IsPaused():
+
+ continue
+
+
we_did_some = False
query_headers = subscription.GetQueryHeaders()
@@ -2180,6 +2288,11 @@ def CheckNow( self ):
+ if not do_paused_queries and query_header.IsPaused():
+
+ continue
+
+
query_header.CheckNow()
we_did_some = True
@@ -2187,6 +2300,8 @@ def CheckNow( self ):
if we_did_some:
+ subscription.SetPaused( False )
+
subscription.ScrubDelay()
diff --git a/hydrus/client/gui/ClientGUITagSuggestions.py b/hydrus/client/gui/ClientGUITagSuggestions.py
index 831229c6e..f12c71039 100644
--- a/hydrus/client/gui/ClientGUITagSuggestions.py
+++ b/hydrus/client/gui/ClientGUITagSuggestions.py
@@ -26,9 +26,9 @@
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientTags
from hydrus.client.metadata import ClientTagSorting
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
-def FilterSuggestedPredicatesForMedia( predicates: typing.Sequence[ ClientSearch.Predicate ], medias: typing.Collection[ ClientMedia.Media ], service_key: bytes ) -> typing.List[ ClientSearch.Predicate ]:
+def FilterSuggestedPredicatesForMedia( predicates: typing.Sequence[ ClientSearchPredicate.Predicate ], medias: typing.Collection[ ClientMedia.Media ], service_key: bytes ) -> typing.List[ ClientSearchPredicate.Predicate ]:
tags = [ predicate.GetValue() for predicate in predicates ]
@@ -150,7 +150,7 @@ def _Activate( self, ctrl_down, shift_down ) -> bool:
return False
- def _GenerateTermFromPredicate( self, predicate: ClientSearch.Predicate ) -> ClientGUIListBoxesData.ListBoxItemPredicate:
+ def _GenerateTermFromPredicate( self, predicate: ClientSearchPredicate.Predicate ) -> ClientGUIListBoxesData.ListBoxItemPredicate:
predicate = predicate.GetCountlessCopy()
@@ -478,7 +478,7 @@ def qt_code( predicates, num_done, num_to_do, num_skipped, total_time_took ):
total_time_took = HydrusTime.GetNowPrecise() - start_time
- predicates = ClientSearch.SortPredicates( predicates )
+ predicates = ClientSearchPredicate.SortPredicates( predicates )
QP.CallAfter( qt_code, predicates, num_done, num_to_do, num_skipped, total_time_took )
diff --git a/hydrus/client/gui/canvas/ClientGUICanvas.py b/hydrus/client/gui/canvas/ClientGUICanvas.py
index a293caf61..741d654c3 100644
--- a/hydrus/client/gui/canvas/ClientGUICanvas.py
+++ b/hydrus/client/gui/canvas/ClientGUICanvas.py
@@ -45,7 +45,7 @@
from hydrus.client.metadata import ClientRatings
from hydrus.client.metadata import ClientTags
from hydrus.client.metadata import ClientTagSorting
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
def AddAudioVolumeMenu( menu, canvas_type ):
@@ -1406,6 +1406,8 @@ def __init__( self, parent, page_key, location_context: ClientLocation.LocationC
self._hidden_page_current_media = None
self._hidden_page_paused_status = False
+ self._is_splitter_hidden = False
+
self._media_container.launchMediaViewer.connect( self.LaunchMediaViewer )
CG.client_controller.sub( self, 'ProcessContentUpdatePackage', 'content_updates_gui' )
@@ -1428,6 +1430,7 @@ def mouseReleaseEvent( self, event ):
def ClearMedia( self ):
self._hidden_page_current_media = None
+ self._hidden_splitter_current_media = None
Canvas.ClearMedia( self )
@@ -1615,7 +1618,7 @@ def ProcessContentUpdatePackage( self, content_update_package: ClientContentUpda
def SetMedia( self, media ):
- if HC.options[ 'hide_preview' ]:
+ if HC.options[ 'hide_preview' ] or self._hidden_page_paused_status or self._is_splitter_hidden:
return
@@ -1623,6 +1626,25 @@ def SetMedia( self, media ):
Canvas.SetMedia( self, media )
+ def SetSplitterHiddenStatus( self, is_hidden ):
+
+ if is_hidden and not self._is_splitter_hidden:
+
+ # we are hiding
+
+ self.ClearMedia()
+
+ elif self._is_splitter_hidden and not is_hidden:
+
+ # we are showing again. I could do a restore status thing like I have for pagehidden/shown in future, but for now this is a nice simple thing
+
+ pass
+
+
+ self._is_splitter_hidden = is_hidden
+
+
+
class CanvasWithDetails( Canvas ):
def __init__( self, parent, location_context ):
@@ -2388,7 +2410,7 @@ class CanvasFilterDuplicates( CanvasWithHovers ):
showPairInPage = QC.Signal( list )
- def __init__( self, parent, file_search_context_1: ClientSearch.FileSearchContext, file_search_context_2: ClientSearch.FileSearchContext, dupe_search_type, pixel_dupes_preference, max_hamming_distance ):
+ def __init__( self, parent, file_search_context_1: ClientSearchFileSearchContext.FileSearchContext, file_search_context_2: ClientSearchFileSearchContext.FileSearchContext, dupe_search_type, pixel_dupes_preference, max_hamming_distance ):
location_context = file_search_context_1.GetLocationContext()
diff --git a/hydrus/client/gui/exporting/ClientGUIExport.py b/hydrus/client/gui/exporting/ClientGUIExport.py
index 1a7824268..62c80036d 100644
--- a/hydrus/client/gui/exporting/ClientGUIExport.py
+++ b/hydrus/client/gui/exporting/ClientGUIExport.py
@@ -41,7 +41,7 @@
from hydrus.client.metadata import ClientMetadataMigrationExporters
from hydrus.client.metadata import ClientMetadataMigrationImporters
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
class EditExportFoldersPanel( ClientGUIScrolledPanels.EditPanel ):
@@ -90,7 +90,7 @@ def _AddFolder( self ):
default_location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context )
metadata_routers = new_options.GetDefaultExportFilesMetadataRouters()
diff --git a/hydrus/client/gui/importing/ClientGUIFileSeedCache.py b/hydrus/client/gui/importing/ClientGUIFileSeedCache.py
index 7c885366e..e70d7d8fc 100644
--- a/hydrus/client/gui/importing/ClientGUIFileSeedCache.py
+++ b/hydrus/client/gui/importing/ClientGUIFileSeedCache.py
@@ -31,7 +31,7 @@
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTagSorting
from hydrus.client.networking import ClientNetworkingFunctions
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
def ClearFileSeeds( win: QW.QWidget, file_seed_cache: ClientImportFileSeeds.FileSeedCache, statuses_to_remove ):
@@ -683,9 +683,9 @@ def _GetListCtrlMenu( self ):
file_seed_datas = [ file_seed.file_seed_data for file_seed in selected_file_seeds ]
urls = [ file_seed_data for file_seed_data in file_seed_datas if isinstance( file_seed_data, str ) and file_seed_data.startswith( 'http' ) ]
- url_preds = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', url, f'has url {url}' ) ) for url in urls ]
+ url_preds = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', url, f'has url {url}' ) ) for url in urls ]
- predicates = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = url_preds ) ]
+ predicates = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = url_preds ) ]
page_name = 'url search'
activate_window = False
diff --git a/hydrus/client/gui/importing/ClientGUIGallerySeedLog.py b/hydrus/client/gui/importing/ClientGUIGallerySeedLog.py
index d8607393f..a0c7cf9b1 100644
--- a/hydrus/client/gui/importing/ClientGUIGallerySeedLog.py
+++ b/hydrus/client/gui/importing/ClientGUIGallerySeedLog.py
@@ -291,9 +291,11 @@ def _ConvertGallerySeedToDisplayTuple( self, gallery_seed ):
gallery_seed_index = self._gallery_seed_log.GetGallerySeedIndex( gallery_seed )
+ pretty_gallery_seed_index = HydrusNumbers.ToHumanInt( gallery_seed_index )
+
except:
- gallery_seed_index = '--'
+ pretty_gallery_seed_index = '--'
url = gallery_seed.url
@@ -302,7 +304,6 @@ def _ConvertGallerySeedToDisplayTuple( self, gallery_seed ):
modified = gallery_seed.modified
note = gallery_seed.note
- pretty_gallery_seed_index = HydrusNumbers.ToHumanInt( gallery_seed_index )
pretty_url = ClientNetworkingFunctions.ConvertURLToHumanString( url )
pretty_status = CC.status_string_lookup[ status ] if status != CC.STATUS_UNKNOWN else ''
pretty_added = ClientTime.TimestampToPrettyTimeDelta( added )
@@ -321,7 +322,7 @@ def _ConvertGallerySeedToSortTuple( self, gallery_seed ):
except:
- gallery_seed_index = '--'
+ gallery_seed_index = -1
url = gallery_seed.url
diff --git a/hydrus/client/gui/lists/ClientGUIListBoxes.py b/hydrus/client/gui/lists/ClientGUIListBoxes.py
index e6e75e9db..7063d8b83 100644
--- a/hydrus/client/gui/lists/ClientGUIListBoxes.py
+++ b/hydrus/client/gui/lists/ClientGUIListBoxes.py
@@ -40,7 +40,7 @@
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientTags
from hydrus.client.metadata import ClientTagSorting
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
class BetterQListWidget( QW.QListWidget ):
@@ -1410,9 +1410,9 @@ def _GetSelectedPredicatesAndInverseCopies( self ):
predicates = self._GetPredicatesFromTerms( self._selected_terms )
inverse_predicates = [ predicate.GetInverseCopy() for predicate in predicates if predicate.IsInvertible() ]
- if len( predicates ) > 1 and ClientSearch.PREDICATE_TYPE_OR_CONTAINER not in ( p.GetType() for p in predicates ):
+ if len( predicates ) > 1 and ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER not in ( p.GetType() for p in predicates ):
- or_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = list( predicates ) )
+ or_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = list( predicates ) )
else:
@@ -1422,7 +1422,7 @@ def _GetSelectedPredicatesAndInverseCopies( self ):
namespace_predicate = None
inverse_namespace_predicate = None
- if False not in [ predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG for predicate in predicates ]:
+ if False not in [ predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG for predicate in predicates ]:
namespaces = { HydrusTags.SplitTag( predicate.GetValue() )[0] for predicate in predicates }
@@ -1430,7 +1430,7 @@ def _GetSelectedPredicatesAndInverseCopies( self ):
( namespace, ) = namespaces
- namespace_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, value = namespace )
+ namespace_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, value = namespace )
inverse_namespace_predicate = namespace_predicate.GetInverseCopy()
@@ -2575,7 +2575,7 @@ def _GetCurrentLocationContext( self ):
return ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
- def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearch.Predicate ]:
+ def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearchPredicate.Predicate ]:
return set()
@@ -3677,7 +3677,7 @@ def __init__( self, *args, tag_display_type = ClientTags.TAG_DISPLAY_DISPLAY_ACT
ListBoxTags.__init__( self, *args, tag_display_type = tag_display_type, **kwargs )
- def _GenerateTermFromPredicate( self, predicate: ClientSearch.Predicate ) -> ClientGUIListBoxesData.ListBoxItemPredicate:
+ def _GenerateTermFromPredicate( self, predicate: ClientSearchPredicate.Predicate ) -> ClientGUIListBoxesData.ListBoxItemPredicate:
return ClientGUIListBoxesData.ListBoxItemPredicate( predicate )
@@ -3696,7 +3696,7 @@ def _HasCounts( self ):
return True
- def GetPredicates( self ) -> typing.Set[ ClientSearch.Predicate ]:
+ def GetPredicates( self ) -> typing.Set[ ClientSearchPredicate.Predicate ]:
return set( self._GetPredicatesFromTerms( self._ordered_terms ) )
diff --git a/hydrus/client/gui/lists/ClientGUIListBoxesData.py b/hydrus/client/gui/lists/ClientGUIListBoxesData.py
index 4687eab0d..bb0624e3c 100644
--- a/hydrus/client/gui/lists/ClientGUIListBoxesData.py
+++ b/hydrus/client/gui/lists/ClientGUIListBoxesData.py
@@ -6,7 +6,7 @@
from hydrus.core import HydrusTags
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
class ListBoxItem( object ):
@@ -45,7 +45,7 @@ def GetCopyableText( self, with_counts: bool = False ) -> str:
raise NotImplementedError()
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
raise NotImplementedError()
@@ -89,7 +89,7 @@ def GetCopyableText( self, with_counts: bool = False ) -> str:
return self._tag_slice
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
return []
@@ -162,7 +162,7 @@ def GetNamespaceAndColour( self ):
return ( self._namespace, self._colour )
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
return []
@@ -254,9 +254,9 @@ def GetCopyableText( self, with_counts: bool = False ) -> str:
return self._tag
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
- return [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = self._tag ) ]
+ return [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = self._tag ) ]
def GetRowCount( self, show_parent_rows: bool ):
@@ -373,11 +373,11 @@ def GetCopyableText( self, with_counts: bool = False ) -> str:
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
# with counts? or just merge this into texttag???
- return [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = self._tag ) ]
+ return [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = self._tag ) ]
def GetRowsOfPresentationTextsWithNamespaces( self, render_for_user: bool, sibling_decoration_allowed: bool, sibling_connector_string: str, sibling_connector_namespace: typing.Optional[ str ], parent_decoration_allowed: bool, show_parent_rows: bool ) -> typing.List[ typing.List[ typing.Tuple[ str, str, str ] ] ]:
@@ -463,7 +463,7 @@ def UpdateFromOtherTerm( self, term: "ListBoxItemTextTagWithCounts" ):
class ListBoxItemPredicate( ListBoxItem ):
- def __init__( self, predicate: ClientSearch.Predicate ):
+ def __init__( self, predicate: ClientSearchPredicate.Predicate ):
super().__init__()
@@ -493,18 +493,18 @@ def CanFadeColours( self ):
def GetCopyableText( self, with_counts: bool = False ) -> str:
- if self._predicate.GetType() == ClientSearch.PREDICATE_TYPE_NAMESPACE:
+ if self._predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE:
namespace = self._predicate.GetValue()
# this is useful for workflow
text = '{}:*'.format( namespace )
- elif self._predicate.GetType() == ClientSearch.PREDICATE_TYPE_PARENT:
+ elif self._predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_PARENT:
text = HydrusTags.CleanTag( self._predicate.GetValue() )
- elif self._predicate.GetType() == ClientSearch.PREDICATE_TYPE_WILDCARD:
+ elif self._predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_WILDCARD:
wildcard = self._predicate.GetValue()
@@ -518,7 +518,7 @@ def GetCopyableText( self, with_counts: bool = False ) -> str:
return text
- def GetPredicate( self ) -> ClientSearch.Predicate:
+ def GetPredicate( self ) -> ClientSearchPredicate.Predicate:
return self._predicate
@@ -580,9 +580,9 @@ def GetRowsOfPresentationTextsWithNamespaces( self, render_for_user: bool, sibli
return rows_of_texts_and_namespaces
- def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetSearchPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
- if self._predicate.GetType() in ( ClientSearch.PREDICATE_TYPE_LABEL, ClientSearch.PREDICATE_TYPE_PARENT ):
+ if self._predicate.GetType() in ( ClientSearchPredicate.PREDICATE_TYPE_LABEL, ClientSearchPredicate.PREDICATE_TYPE_PARENT ):
return []
@@ -594,7 +594,7 @@ def GetSearchPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
def GetTags( self ) -> typing.Set[ str ]:
- if self._predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG:
+ if self._predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG:
tag = self._predicate.GetValue()
diff --git a/hydrus/client/gui/media/ClientGUIMediaMenus.py b/hydrus/client/gui/media/ClientGUIMediaMenus.py
index 5c5bbe04e..6a865088a 100644
--- a/hydrus/client/gui/media/ClientGUIMediaMenus.py
+++ b/hydrus/client/gui/media/ClientGUIMediaMenus.py
@@ -10,6 +10,7 @@
from hydrus.core import HydrusData
from hydrus.core import HydrusNumbers
from hydrus.core import HydrusSerialisable
+from hydrus.core import HydrusText
from hydrus.core.files.images import HydrusImageHandling
from hydrus.client import ClientApplicationCommand as CAC
@@ -17,13 +18,14 @@
from hydrus.client import ClientGlobals as CG
from hydrus.client import ClientLocation
from hydrus.client import ClientPaths
+from hydrus.client.gui import ClientGUIAsync
from hydrus.client.gui import ClientGUIMenus
from hydrus.client.gui.media import ClientGUIMediaModalActions
from hydrus.client.gui.media import ClientGUIMediaSimpleActions
from hydrus.client.media import ClientMedia
from hydrus.client.media import ClientMediaManagers
from hydrus.client.networking import ClientNetworkingFunctions
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
def AddDuplicatesMenu( win: QW.QWidget, menu: QW.QMenu, location_context: ClientLocation.LocationContext, focus_singleton: ClientMedia.Media, num_selected: int, collections_selected: bool ):
@@ -493,7 +495,7 @@ def AddKnownURLsViewCopyMenu( win, menu, focus_media, num_files_selected: int, s
def call_generator( u ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
- predicates = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', u, f'has url {u}' ) ) ]
+ predicates = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', u, f'has url {u}' ) ) ]
page_name = 'url search'
activate_window = False
@@ -511,9 +513,9 @@ def call_generator( u ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
- url_preds = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', url, f'has url {url}' ) ) for ( label, url ) in focus_labels_and_urls ]
+ url_preds = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, value = ( True, 'exact_match', url, f'has url {url}' ) ) for ( label, url ) in focus_labels_and_urls ]
- predicates = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = url_preds ) ]
+ predicates = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = url_preds ) ]
page_name = 'url search'
activate_window = False
@@ -853,6 +855,62 @@ def AddServiceKeysToMenu( menu, service_keys, submenu_name, description, bare_ca
ClientGUIMenus.AppendMenuOrItem( menu, submenu_name, menu_tuples )
+def StartOtherHashesMenuFetch( win: QW.QWidget, media: ClientMedia.MediaSingleton, md5_menu_item: QW.QAction, sha1_menu_item: QW.QAction, sha512_menu_item: QW.QAction ):
+
+ def work_callable():
+
+ hash = media.GetHash()
+
+ hashes_to_other_hashes = CG.client_controller.Read( 'file_hashes', ( hash, ), 'sha256', 'md5' )
+
+ if hash in hashes_to_other_hashes:
+
+ md5_hash = hashes_to_other_hashes[ hash ]
+
+ md5_menu_item.setText( f'md5 ({md5_hash.hex()})' )
+
+ else:
+
+ md5_menu_item.setText( 'md5 (unknown)' )
+
+
+ hashes_to_other_hashes = CG.client_controller.Read( 'file_hashes', ( hash, ), 'sha256', 'sha1' )
+
+ if hash in hashes_to_other_hashes:
+
+ sha1_hash = hashes_to_other_hashes[ hash ]
+
+ sha1_menu_item.setText( f'sha1 ({sha1_hash.hex()})' )
+
+ else:
+
+ sha1_menu_item.setText( 'sha1 (unknown)' )
+
+
+ hashes_to_other_hashes = CG.client_controller.Read( 'file_hashes', ( hash, ), 'sha256', 'sha512' )
+
+ if hash in hashes_to_other_hashes:
+
+ sha512_hash = hashes_to_other_hashes[ hash ]
+
+ sha512_menu_item.setText( f'sha512 ({HydrusText.ElideText( sha512_hash.hex(), 64, elide_center = True )})' )
+
+ else:
+
+ sha512_menu_item.setText( 'md5 (unknown)' )
+
+
+
+ def publish_callable( result ):
+
+ pass
+
+
+ job = ClientGUIAsync.AsyncQtJob( win, work_callable, publish_callable )
+
+ job.start()
+
+
def AddShareMenu( win: QW.QWidget, menu: QW.QMenu, focused_media: typing.Optional[ ClientMedia.Media ], selected_media: typing.Collection[ ClientMedia.Media ] ):
if focused_media is not None:
@@ -872,26 +930,23 @@ def AddShareMenu( win: QW.QWidget, menu: QW.QMenu, focused_media: typing.Optiona
local_selection_is_useful = len( local_selection ) > 0 and not ( len( local_selection ) == 1 and focused_media in local_selection )
- if not focused_is_local and len( local_selection ) == 0:
-
- # nothing to share!
- return
-
-
share_menu = ClientGUIMenus.GenerateMenu( menu )
- ClientGUIMenus.AppendMenuItem( share_menu, 'export files', 'Export the selected files to an external folder.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_EXPORT_FILES ) )
-
- ClientGUIMenus.AppendSeparator( share_menu )
-
if local_selection_is_useful:
- ClientGUIMenus.AppendMenuItem( share_menu, 'copy files', 'Copy these files to your clipboard.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILES, simple_data = CAC.FILE_COMMAND_TARGET_SELECTED_FILES ) )
+ ClientGUIMenus.AppendMenuItem( share_menu, 'export files', 'Export the selected files to an external folder.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_EXPORT_FILES ) )
-
- if local_selection_is_useful:
+ ClientGUIMenus.AppendSeparator( share_menu )
- ClientGUIMenus.AppendMenuItem( share_menu, 'copy paths', 'Copy these files\' paths to your clipboard, just as raw text.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_PATHS, simple_data = CAC.FILE_COMMAND_TARGET_SELECTED_FILES ) )
+ if local_selection_is_useful:
+
+ ClientGUIMenus.AppendMenuItem( share_menu, 'copy files', 'Copy these files to your clipboard.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILES, simple_data = CAC.FILE_COMMAND_TARGET_SELECTED_FILES ) )
+
+
+ if local_selection_is_useful:
+
+ ClientGUIMenus.AppendMenuItem( share_menu, 'copy paths', 'Copy these files\' paths to your clipboard, just as raw text.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_PATHS, simple_data = CAC.FILE_COMMAND_TARGET_SELECTED_FILES ) )
+
if selection_is_useful:
@@ -992,9 +1047,11 @@ def AddShareMenu( win: QW.QWidget, menu: QW.QMenu, focused_media: typing.Optiona
copy_hash_menu = ClientGUIMenus.GenerateMenu( share_menu )
ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'sha256 ({})'.format( focused_media.GetHash().hex() ), 'Copy this file\'s SHA256 hash to your clipboard.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'sha256' ) ) )
- ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'md5', 'Copy this file\'s MD5 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'md5' ) ) )
- ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'sha1', 'Copy this file\'s SHA1 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'sha1' ) ) )
- ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'sha512', 'Copy this file\'s SHA512 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'sha512' ) ) )
+ md5_menu_item = ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'md5', 'Copy this file\'s MD5 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'md5' ) ) )
+ sha1_menu_item = ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'sha1', 'Copy this file\'s SHA1 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'sha1' ) ) )
+ sha512_menu_item = ClientGUIMenus.AppendMenuItem( copy_hash_menu, 'sha512', 'Copy this file\'s SHA512 hash to your clipboard. Your client may not know this.', win.ProcessApplicationCommand, CAC.ApplicationCommand.STATICCreateSimpleCommand( CAC.SIMPLE_COPY_FILE_HASHES, simple_data = ( CAC.FILE_COMMAND_TARGET_FOCUSED_FILE, 'sha512' ) ) )
+
+ StartOtherHashesMenuFetch( share_menu, focused_media, md5_menu_item, sha1_menu_item, sha512_menu_item )
file_info_manager = focused_media.GetMediaResult().GetFileInfoManager()
diff --git a/hydrus/client/gui/media/ClientGUIMediaSimpleActions.py b/hydrus/client/gui/media/ClientGUIMediaSimpleActions.py
index 2155495ff..bf5096f09 100644
--- a/hydrus/client/gui/media/ClientGUIMediaSimpleActions.py
+++ b/hydrus/client/gui/media/ClientGUIMediaSimpleActions.py
@@ -14,7 +14,7 @@
from hydrus.client import ClientPaths
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientContentUpdates
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
def GetLocalMediaPaths( medias: typing.Collection[ ClientMedia.Media ] ):
@@ -389,7 +389,7 @@ def ShowFilesInNewDuplicatesFilterPage( hashes: typing.Collection[ bytes ], loca
activate_window = CG.client_controller.new_options.GetBoolean( 'activate_window_on_tag_search_page_activation' )
- predicates = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, value = ( tuple( hashes ), 'sha256' ) ) ]
+ predicates = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, value = ( tuple( hashes ), 'sha256' ) ) ]
page_name = 'duplicates'
@@ -415,7 +415,7 @@ def ShowSimilarFilesInNewPage( media: typing.Collection[ ClientMedia.MediaSingle
if len( hashes ) > 0:
- initial_predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( tuple( hashes ), max_hamming ) ) ]
+ initial_predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( tuple( hashes ), max_hamming ) ) ]
CG.client_controller.pub( 'new_page_query', location_context, initial_predicates = initial_predicates )
diff --git a/hydrus/client/gui/pages/ClientGUIManagementController.py b/hydrus/client/gui/pages/ClientGUIManagementController.py
index 951c2239e..c86de6264 100644
--- a/hydrus/client/gui/pages/ClientGUIManagementController.py
+++ b/hydrus/client/gui/pages/ClientGUIManagementController.py
@@ -17,7 +17,8 @@
from hydrus.client.importing.options import FileImportOptions
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientMetadataMigration
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
MANAGEMENT_TYPE_DUMPER = 0
MANAGEMENT_TYPE_IMPORT_MULTIPLE_GALLERY = 1
@@ -57,7 +58,7 @@ def CreateManagementControllerDuplicateFilter(
if initial_predicates is None:
- initial_predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
+ initial_predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
if page_name is None:
@@ -67,7 +68,7 @@ def CreateManagementControllerDuplicateFilter(
management_controller = CreateManagementController( page_name, MANAGEMENT_TYPE_DUPLICATE_FILTER )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = initial_predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = initial_predicates )
synchronised = CG.client_controller.new_options.GetBoolean( 'default_search_synchronised' )
@@ -176,7 +177,7 @@ def CreateManagementControllerPetitions( petition_service_key ):
return management_controller
-def CreateManagementControllerQuery( page_name, file_search_context: ClientSearch.FileSearchContext, search_enabled ):
+def CreateManagementControllerQuery( page_name, file_search_context: ClientSearchFileSearchContext.FileSearchContext, search_enabled ):
location_context = file_search_context.GetLocationContext()
@@ -410,7 +411,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ] )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ] )
serialisable_serialisables[ 'file_search_context' ] = file_search_context.GetSerialisableTuple()
@@ -523,7 +524,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
default_location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context, predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ] )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context, predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ] )
variables[ 'file_search_context_1' ] = file_search_context
variables[ 'file_search_context_2' ] = file_search_context.Duplicate()
diff --git a/hydrus/client/gui/pages/ClientGUIManagementPanels.py b/hydrus/client/gui/pages/ClientGUIManagementPanels.py
index 1f96457e5..d9abf9185 100644
--- a/hydrus/client/gui/pages/ClientGUIManagementPanels.py
+++ b/hydrus/client/gui/pages/ClientGUIManagementPanels.py
@@ -66,7 +66,8 @@
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
from hydrus.client.networking import ClientNetworkingFunctions
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
management_panel_types_to_classes = {}
@@ -151,7 +152,7 @@ def _Activate( self, ctrl_down, shift_down ) -> bool:
if shift_down and len( predicates ) > 1:
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = predicates ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = predicates ), )
CG.client_controller.pub( 'enter_predicates', self._page_key, predicates )
@@ -172,7 +173,7 @@ def _GetCurrentLocationContext( self ):
return self._management_controller.GetLocationContext()
- def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearch.Predicate ]:
+ def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearchPredicate.Predicate ]:
if self._tag_autocomplete is None:
@@ -751,7 +752,7 @@ def _FilterSearchDomainUpdated( self ):
- def _GetDuplicateFileSearchData( self, optimise_for_search = True ) -> typing.Tuple[ ClientSearch.FileSearchContext, ClientSearch.FileSearchContext, int, int, int ]:
+ def _GetDuplicateFileSearchData( self, optimise_for_search = True ) -> typing.Tuple[ ClientSearchFileSearchContext.FileSearchContext, ClientSearchFileSearchContext.FileSearchContext, int, int, int ]:
file_search_context_1 = self._tag_autocomplete_1.GetFileSearchContext()
file_search_context_2 = self._tag_autocomplete_2.GetFileSearchContext()
@@ -1108,7 +1109,7 @@ def REPEATINGPageUpdate( self ):
self._tag_autocomplete_2.REPEATINGPageUpdate()
- def Search1Changed( self, file_search_context: ClientSearch.FileSearchContext ):
+ def Search1Changed( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
self._tag_autocomplete_2.blockSignals( True )
@@ -1120,7 +1121,7 @@ def Search1Changed( self, file_search_context: ClientSearch.FileSearchContext ):
self._FilterSearchDomainUpdated()
- def Search2Changed( self, file_search_context: ClientSearch.FileSearchContext ):
+ def Search2Changed( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
self._tag_autocomplete_1.blockSignals( True )
@@ -5979,7 +5980,7 @@ def RefreshQuery( self ):
self._RefreshQuery()
- def SearchChanged( self, file_search_context: ClientSearch.FileSearchContext ):
+ def SearchChanged( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
if self._search_enabled:
@@ -6055,7 +6056,7 @@ def Start( self ):
- def THREADDoQuery( self, controller, page_key, query_job_status, file_search_context: ClientSearch.FileSearchContext, sort_by ):
+ def THREADDoQuery( self, controller, page_key, query_job_status, file_search_context: ClientSearchFileSearchContext.FileSearchContext, sort_by ):
def qt_code():
diff --git a/hydrus/client/gui/pages/ClientGUINewPageChooser.py b/hydrus/client/gui/pages/ClientGUINewPageChooser.py
index a38d69bd7..d8b580095 100644
--- a/hydrus/client/gui/pages/ClientGUINewPageChooser.py
+++ b/hydrus/client/gui/pages/ClientGUINewPageChooser.py
@@ -11,7 +11,8 @@
from hydrus.client.gui import ClientGUIShortcuts
from hydrus.client.gui import QtPorting as QP
from hydrus.client.gui.pages import ClientGUIManagementController
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchTagContext
class DialogPageChooser( ClientGUIDialogs.Dialog ):
@@ -185,9 +186,9 @@ def _HitButton( self, button_id ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( file_service_key )
- tag_context = ClientSearch.TagContext( service_key = tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context )
self._result = ( 'page', ClientGUIManagementController.CreateManagementControllerQuery( page_name, file_search_context, search_enabled ) )
diff --git a/hydrus/client/gui/pages/ClientGUIPages.py b/hydrus/client/gui/pages/ClientGUIPages.py
index b18c97b37..3ea60c040 100644
--- a/hydrus/client/gui/pages/ClientGUIPages.py
+++ b/hydrus/client/gui/pages/ClientGUIPages.py
@@ -36,7 +36,9 @@
from hydrus.client.gui.pages import ClientGUIResults
from hydrus.client.gui.pages import ClientGUISession
from hydrus.client.gui.pages import ClientGUISessionLegacy # to get serialisable data types loaded
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
def ConvertNumHashesToWeight( num_hashes: int ) -> int:
@@ -146,6 +148,8 @@ def __init__( self, parent, controller, management_controller: ClientGUIManageme
self.SetSplitterPositions()
+ self._search_preview_split.splitterMoved.connect( self._PreviewSplitterMoved )
+
def _ConnectMediaPanelSignals( self ):
@@ -167,6 +171,19 @@ def _GetCurrentSessionPageHashesHash( self ):
return hash( hashlist_hashable )
+ def _PreviewSplitterMoved( self ):
+
+ sizes = self._search_preview_split.sizes()
+
+ if len( sizes ) > 0:
+
+ # can't test the preview itself, it has funky minimum size gubbins. we are explicitly testing the splitter viewport or whatever
+ preview_split_size = sizes[-1]
+
+ self._preview_canvas.SetSplitterHiddenStatus( preview_split_size == 0 )
+
+
+
def _SetCurrentPageContainer( self, page_container: ClientGUISession.GUISessionContainerPageSingle ):
self._current_session_page_container = page_container
@@ -1015,7 +1032,7 @@ def _ClosePage( self, index, polite = True, delete_page = False ):
self._controller.ResetIdleTimer()
self._controller.ResetPageChangeTimer()
- if index == -1 or index > self.count() - 1:
+ if index < 0 or index > self.count() - 1:
return False
@@ -1042,8 +1059,6 @@ def _ClosePage( self, index, polite = True, delete_page = False ):
self.removeTab( index )
- self._UpdatePreviousPageIndex()
-
self._controller.pub( 'refresh_page_name', self._page_key )
if delete_page:
@@ -1055,6 +1070,26 @@ def _ClosePage( self, index, polite = True, delete_page = False ):
self._controller.pub( 'notify_closed_page', page )
+ focus_goes_to = self._controller.new_options.GetInteger( 'close_page_focus_goes' )
+
+ new_page_focus = None
+
+ if focus_goes_to == CC.CLOSED_PAGE_FOCUS_GOES_LEFT:
+
+ new_page_focus = index - 1
+
+ elif focus_goes_to == CC.CLOSED_PAGE_FOCUS_GOES_RIGHT:
+
+ new_page_focus = index
+
+
+ if new_page_focus is not None and index >= 0 or index <= self.count() - 1 and new_page_focus != self.currentIndex():
+
+ self.setCurrentIndex( new_page_focus )
+
+
+ self._UpdatePreviousPageIndex()
+
return True
@@ -1139,6 +1174,10 @@ def _GetDefaultPageInsertionIndex( self ):
insertion_index = self.count()
+ else:
+
+ insertion_index = 0
+
return insertion_index
@@ -2981,7 +3020,7 @@ def NewPageQuery(
if len( initial_hashes ) > 0:
- initial_predicates = [ ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, value = ( tuple( initial_hashes ), 'sha256' ) ) ]
+ initial_predicates = [ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, value = ( tuple( initial_hashes ), 'sha256' ) ) ]
else:
@@ -3011,9 +3050,9 @@ def NewPageQuery(
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_FILE_SERVICE_KEY )
- tag_context = ClientSearch.TagContext( service_key = tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = initial_predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = initial_predicates )
if len( initial_hashes ) > 0:
diff --git a/hydrus/client/gui/pages/ClientGUIResultsSortCollect.py b/hydrus/client/gui/pages/ClientGUIResultsSortCollect.py
index 04861650e..4354f32ed 100644
--- a/hydrus/client/gui/pages/ClientGUIResultsSortCollect.py
+++ b/hydrus/client/gui/pages/ClientGUIResultsSortCollect.py
@@ -21,7 +21,7 @@
from hydrus.client.gui.widgets import ClientGUIMenuButton
from hydrus.client.media import ClientMedia
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchTagContext
# wew lad
# https://stackoverflow.com/questions/46456238/checkbox-not-visible-inside-combobox
@@ -488,7 +488,7 @@ def __init__( self, parent, media_sort = None ):
self._sort_tag_display_type_button = ClientGUIMenuButton.MenuChoiceButton( self, [] )
self._sort_order_choice = ClientGUIMenuButton.MenuChoiceButton( self, [] )
- tag_context = ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
self._tag_context_button = ClientGUISearch.TagContextButton( self, tag_context, use_short_label = True )
@@ -834,7 +834,7 @@ def EventSortAscChoice( self ):
self._BroadcastSort()
- def EventTagContextChanged( self, tag_context: ClientSearch.TagContext ):
+ def EventTagContextChanged( self, tag_context: ClientSearchTagContext.TagContext ):
self._UserChoseASort()
diff --git a/hydrus/client/gui/panels/ClientGUIManageOptionsPanel.py b/hydrus/client/gui/panels/ClientGUIManageOptionsPanel.py
index 19c500cb9..a53767d35 100644
--- a/hydrus/client/gui/panels/ClientGUIManageOptionsPanel.py
+++ b/hydrus/client/gui/panels/ClientGUIManageOptionsPanel.py
@@ -1708,7 +1708,14 @@ def __init__( self, parent, new_options ):
for value in [ CC.NEW_PAGE_GOES_FAR_LEFT, CC.NEW_PAGE_GOES_LEFT_OF_CURRENT, CC.NEW_PAGE_GOES_RIGHT_OF_CURRENT, CC.NEW_PAGE_GOES_FAR_RIGHT ]:
- self._default_new_page_goes.addItem( CC.new_page_goes_string_lookup[ value], value )
+ self._default_new_page_goes.addItem( CC.new_page_goes_string_lookup[ value ], value )
+
+
+ self._close_page_focus_goes = ClientGUICommon.BetterChoice( self._pages_panel )
+
+ for value in [ CC.CLOSED_PAGE_FOCUS_GOES_LEFT, CC.CLOSED_PAGE_FOCUS_GOES_RIGHT ]:
+
+ self._close_page_focus_goes.addItem( CC.closed_page_focus_string_lookup[ value ], value )
self._notebook_tab_alignment = ClientGUICommon.BetterChoice( self._pages_panel )
@@ -1793,6 +1800,7 @@ def __init__( self, parent, new_options ):
self._show_local_files_on_page_chooser.setChecked( self._new_options.GetBoolean( 'show_local_files_on_page_chooser' ) )
self._default_new_page_goes.SetValue( self._new_options.GetInteger( 'default_new_page_goes' ) )
+ self._close_page_focus_goes.SetValue( self._new_options.GetInteger( 'close_page_focus_goes' ) )
self._notebook_tab_alignment.SetValue( self._new_options.GetInteger( 'notebook_tab_alignment' ) )
@@ -1837,7 +1845,8 @@ def __init__( self, parent, new_options ):
rows.append( ( 'In new page chooser, show "all my files" if appropriate: ', self._show_all_my_files_on_page_chooser ) )
rows.append( ( 'In new page chooser, show "local files": ', self._show_local_files_on_page_chooser ) )
- rows.append( ( 'By default, put new page tabs on: ', self._default_new_page_goes ) )
+ rows.append( ( 'Put new page tabs on: ', self._default_new_page_goes ) )
+ rows.append( ( 'When closing tabs, move focus: ', self._close_page_focus_goes ) )
rows.append( ( 'Notebook tab alignment: ', self._notebook_tab_alignment ) )
rows.append( ( 'Selection chases dropped page after drag and drop: ', self._page_drop_chase_normally ) )
rows.append( ( ' With shift held down?: ', self._page_drop_chase_with_shift ) )
@@ -1915,6 +1924,7 @@ def UpdateOptions( self ):
self._new_options.SetBoolean( 'show_local_files_on_page_chooser', self._show_local_files_on_page_chooser.isChecked() )
self._new_options.SetInteger( 'default_new_page_goes', self._default_new_page_goes.GetValue() )
+ self._new_options.SetInteger( 'close_page_focus_goes', self._close_page_focus_goes.GetValue() )
self._new_options.SetInteger( 'max_page_name_chars', self._max_page_name_chars.value() )
diff --git a/hydrus/client/gui/panels/ClientGUIScrolledPanelsReview.py b/hydrus/client/gui/panels/ClientGUIScrolledPanelsReview.py
index e5958cd9b..cd0fd7100 100644
--- a/hydrus/client/gui/panels/ClientGUIScrolledPanelsReview.py
+++ b/hydrus/client/gui/panels/ClientGUIScrolledPanelsReview.py
@@ -61,7 +61,7 @@
from hydrus.client.networking import ClientNetworkingGUG
from hydrus.client.networking import ClientNetworkingLogin
from hydrus.client.networking import ClientNetworkingURLClass
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
class AboutPanel( ClientGUIScrolledPanels.ReviewPanel ):
@@ -1658,7 +1658,7 @@ def __init__( self, parent ):
panel_vbox = QP.VBoxLayout()
- file_search_context = ClientSearch.FileSearchContext(
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext(
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
)
@@ -1878,7 +1878,7 @@ def __init__( self, parent, stats ):
default_location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context )
self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead( self._search_panel, page_key, file_search_context, allow_all_known_files = False, force_system_everything = True )
@@ -2167,7 +2167,7 @@ def _SelectAllMediaFiles( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context )
def work_callable():
@@ -2194,7 +2194,7 @@ def _SelectRepoUpdateFiles( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_UPDATE_SERVICE_KEY )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context )
def work_callable():
@@ -2338,7 +2338,7 @@ def __init__( self, parent ):
panel_vbox = QP.VBoxLayout()
- file_search_context = ClientSearch.FileSearchContext(
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext(
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
)
diff --git a/hydrus/client/gui/search/ClientGUIACDropdown.py b/hydrus/client/gui/search/ClientGUIACDropdown.py
index d5e4663df..c2045bf49 100644
--- a/hydrus/client/gui/search/ClientGUIACDropdown.py
+++ b/hydrus/client/gui/search/ClientGUIACDropdown.py
@@ -39,19 +39,20 @@
from hydrus.client.gui.search import ClientGUISearch
from hydrus.client.gui.widgets import ClientGUICommon
from hydrus.client.metadata import ClientTags
-from hydrus.client.metadata import ClientTagSorting
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
from hydrus.client.search import ClientSearchAutocomplete
from hydrus.client.search import ClientSearchParseSystemPredicates
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
from hydrus.external import LogicExpressionQueryParser
def AppendLoadingPredicate( predicates, label ):
- predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_LABEL, value = label + HC.UNICODE_ELLIPSIS ) )
+ predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_LABEL, value = label + HC.UNICODE_ELLIPSIS ) )
-def InsertOtherPredicatesForRead( predicates: list, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText, include_unusual_predicate_types: bool, under_construction_or_predicate: typing.Optional[ ClientSearch.Predicate ] ):
+def InsertOtherPredicatesForRead( predicates: list, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText, include_unusual_predicate_types: bool, under_construction_or_predicate: typing.Optional[ ClientSearchPredicate.Predicate ] ):
if include_unusual_predicate_types:
@@ -72,7 +73,7 @@ def InsertOtherPredicatesForRead( predicates: list, parsed_autocomplete_text: Cl
PutAtTopOfMatches( predicates, under_construction_or_predicate )
-def InsertTagPredicates( predicates: typing.List[ ClientSearch.Predicate ], tag_service_key: bytes, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText, allow_auto_wildcard_conversion: bool, insert_if_does_not_exist: bool = True ):
+def InsertTagPredicates( predicates: typing.List[ ClientSearchPredicate.Predicate ], tag_service_key: bytes, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText, allow_auto_wildcard_conversion: bool, insert_if_does_not_exist: bool = True ):
if parsed_autocomplete_text.IsTagSearch( allow_auto_wildcard_conversion ):
@@ -114,7 +115,7 @@ def InsertTagPredicates( predicates: typing.List[ ClientSearch.Predicate ], tag_
- ClientSearch.SortPredicates( other_matching_predicates )
+ ClientSearchPredicate.SortPredicates( other_matching_predicates )
other_matching_predicates.reverse()
@@ -140,7 +141,7 @@ def ReadFetch(
results_callable,
parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText,
qt_media_callable,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
synchronised,
include_unusual_predicate_types,
results_cache: ClientSearchAutocomplete.PredicateResultsCache,
@@ -255,9 +256,9 @@ def ReadFetch(
else:
- exact_match_matches = ClientSearch.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, exact_match_predicates )
+ exact_match_matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, exact_match_predicates )
- exact_match_matches = ClientSearch.SortPredicates( exact_match_matches )
+ exact_match_matches = ClientSearchPredicate.SortPredicates( exact_match_matches )
allow_auto_wildcard_conversion = True
@@ -282,7 +283,7 @@ def ReadFetch(
if is_explicit_wildcard:
- matches = ClientSearch.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, predicates )
+ matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, predicates )
else:
@@ -367,11 +368,11 @@ def ReadFetch(
# we have data sans siblings and parents. send it as prefetch results, user will have _something_
- prefetch_predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = tag, inclusive = parsed_autocomplete_text.inclusive, count = ClientSearch.PredicateCount( current_count, pending_count, None, None ) ) for ( tag, ( current_count, pending_count ) ) in tags_to_count.items() ]
+ prefetch_predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = tag, inclusive = parsed_autocomplete_text.inclusive, count = ClientSearchPredicate.PredicateCount( current_count, pending_count, None, None ) ) for ( tag, ( current_count, pending_count ) ) in tags_to_count.items() ]
- prefetch_matches = ClientSearch.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, prefetch_predicates )
+ prefetch_matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( tag_service_key, autocomplete_search_text, prefetch_predicates )
- prefetch_matches = ClientSearch.SortPredicates( prefetch_matches )
+ prefetch_matches = ClientSearchPredicate.SortPredicates( prefetch_matches )
allow_auto_wildcard_conversion = True
@@ -404,12 +405,12 @@ def ReadFetch(
return
- predicates = ClientSearch.MergePredicates( predicates )
+ predicates = ClientSearchPredicate.MergePredicates( predicates )
matches = predicates
- matches = ClientSearch.SortPredicates( matches )
+ matches = ClientSearchPredicate.SortPredicates( matches )
if not parsed_autocomplete_text.inclusive:
@@ -433,7 +434,7 @@ def ReadFetch(
CG.client_controller.CallAfterQtSafe( win, 'read a/c full results', results_callable, job_status, parsed_autocomplete_text, results_cache, matches )
-def PutAtTopOfMatches( matches: list, predicate: ClientSearch.Predicate, insert_if_does_not_exist: bool = True ):
+def PutAtTopOfMatches( matches: list, predicate: ClientSearchPredicate.Predicate, insert_if_does_not_exist: bool = True ):
# we have to be careful here to preserve autocomplete counts!
# if it already exists, we move it up, do not replace with the test pred param
@@ -497,7 +498,7 @@ def WriteFetch(
prefetch_callable,
results_callable,
parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText,
- file_search_context: ClientSearch.FileSearchContext,
+ file_search_context: ClientSearchFileSearchContext.FileSearchContext,
results_cache: ClientSearchAutocomplete.PredicateResultsCache
):
@@ -548,9 +549,9 @@ def WriteFetch(
else:
- exact_match_matches = ClientSearch.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, exact_match_predicates )
+ exact_match_matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, exact_match_predicates )
- exact_match_matches = ClientSearch.SortPredicates( exact_match_matches )
+ exact_match_matches = ClientSearchPredicate.SortPredicates( exact_match_matches )
allow_auto_wildcard_conversion = False
@@ -573,7 +574,7 @@ def WriteFetch(
if is_explicit_wildcard:
- matches = ClientSearch.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, predicates )
+ matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, predicates )
else:
@@ -590,7 +591,7 @@ def WriteFetch(
- matches = ClientSearch.SortPredicates( matches )
+ matches = ClientSearchPredicate.SortPredicates( matches )
allow_auto_wildcard_conversion = False
@@ -637,11 +638,11 @@ def _Activate( self, ctrl_down, shift_down ) -> bool:
return False
- def _GenerateTermFromPredicate( self, predicate: ClientSearch.Predicate ):
+ def _GenerateTermFromPredicate( self, predicate: ClientSearchPredicate.Predicate ):
term = ClientGUIListBoxes.ListBoxTagsPredicates._GenerateTermFromPredicate( self, predicate )
- if predicate.GetType() == ClientSearch.PREDICATE_TYPE_OR_CONTAINER:
+ if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER:
term.SetORUnderConstruction( True )
@@ -728,12 +729,12 @@ def SetPredicates( self, predicates, preserve_single_selection = False ):
# now only apply this to simple tags, not wildcards and system tags
- if skip_ors and predicate.GetType() == ClientSearch.PREDICATE_TYPE_OR_CONTAINER:
+ if skip_ors and predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER:
continue
- if skip_countless and predicate.GetType() in ( ClientSearch.PREDICATE_TYPE_PARENT, ClientSearch.PREDICATE_TYPE_TAG ) and predicate.GetCount().HasZeroCount():
+ if skip_countless and predicate.GetType() in ( ClientSearchPredicate.PREDICATE_TYPE_PARENT, ClientSearchPredicate.PREDICATE_TYPE_TAG ) and predicate.GetCount().HasZeroCount():
continue
@@ -1625,9 +1626,9 @@ def UpdateChildrenIfNeeded( self, context_tags: typing.Collection[ str ] ):
search_location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_TAG_SERVICE_KEY )
- tag_context = ClientSearch.TagContext( service_key = tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key )
- file_search_context = ClientSearch.FileSearchContext(
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext(
location_context = search_location_context,
tag_context = tag_context
)
@@ -1675,7 +1676,7 @@ def work_callable():
child_predicates = [ predicate for predicate in child_predicates if predicate.GetValue() not in context_tags ]
- ClientSearch.SortPredicates( child_predicates )
+ ClientSearchPredicate.SortPredicates( child_predicates )
child_predicates = [ predicate.GetCountlessCopy() for predicate in child_predicates ]
@@ -1748,7 +1749,7 @@ def __init__( self, parent, location_context: ClientLocation.LocationContext, ta
self._location_context_button = ClientGUILocation.LocationSearchContextButton( self._dropdown_window, location_context, is_paired_with_tag_domain = True )
self._location_context_button.setMinimumWidth( 20 )
- tag_context = ClientSearch.TagContext( service_key = self._tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = self._tag_service_key )
self._tag_context_button = ClientGUISearch.TagContextButton( self._dropdown_window, tag_context )
self._tag_context_button.setMinimumWidth( 20 )
@@ -1779,7 +1780,7 @@ def _BroadcastChoices( self, predicates, shift_down ):
raise NotImplementedError()
- def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearch.Predicate ]:
+ def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearchPredicate.Predicate ]:
raise NotImplementedError()
@@ -1905,7 +1906,7 @@ def _StartSearchResultsFetchJob( self, job_status ):
raise NotImplementedError()
- def _TagContextJustChanged( self, tag_context: ClientSearch.TagContext ):
+ def _TagContextJustChanged( self, tag_context: ClientSearchTagContext.TagContext ):
self._RestoreTextCtrlFocus()
@@ -1966,7 +1967,7 @@ def RefreshFavouriteTags( self ):
favourite_tags = sorted( CG.client_controller.new_options.GetStringList( 'favourite_tags' ) )
- predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = tag ) for tag in favourite_tags ]
+ predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = tag ) for tag in favourite_tags ]
self._favourites_list.SetPredicates( predicates )
@@ -2003,7 +2004,7 @@ def SetLocationContext( self, location_context: ClientLocation.LocationContext )
self._SetLocationContext( location_context )
- def SetPrefetchResults( self, job_status: ClientThreading.JobStatus, predicates: typing.List[ ClientSearch.Predicate ], parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText ):
+ def SetPrefetchResults( self, job_status: ClientThreading.JobStatus, predicates: typing.List[ ClientSearchPredicate.Predicate ], parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText ):
if self._current_fetch_job_status is not None and self._current_fetch_job_status.GetKey() == job_status.GetKey():
@@ -2030,10 +2031,10 @@ def SetTagServiceKey( self, tag_service_key ):
class AutoCompleteDropdownTagsRead( AutoCompleteDropdownTags ):
- searchChanged = QC.Signal( ClientSearch.FileSearchContext )
+ searchChanged = QC.Signal( ClientSearchFileSearchContext.FileSearchContext )
searchCancelled = QC.Signal()
- def __init__( self, parent: QW.QWidget, page_key, file_search_context: ClientSearch.FileSearchContext, media_sort_widget: typing.Optional[ ClientGUIResultsSortCollect.MediaSortControl ] = None, media_collect_widget: typing.Optional[ ClientGUIResultsSortCollect.MediaCollectControl ] = None, media_callable = None, synchronised = True, include_unusual_predicate_types = True, allow_all_known_files = True, only_allow_local_file_domains = False, force_system_everything = False, hide_favourites_edit_actions = False, fixed_results_list_height = None ):
+ def __init__( self, parent: QW.QWidget, page_key, file_search_context: ClientSearchFileSearchContext.FileSearchContext, media_sort_widget: typing.Optional[ ClientGUIResultsSortCollect.MediaSortControl ] = None, media_collect_widget: typing.Optional[ ClientGUIResultsSortCollect.MediaCollectControl ] = None, media_callable = None, synchronised = True, include_unusual_predicate_types = True, allow_all_known_files = True, only_allow_local_file_domains = False, force_system_everything = False, hide_favourites_edit_actions = False, fixed_results_list_height = None ):
self._page_key = page_key
@@ -2150,7 +2151,7 @@ def __init__( self, parent: QW.QWidget, page_key, file_search_context: ClientSea
predicates = self._file_search_context.GetPredicates()
- tags = [ predicate.GetValue() for predicate in predicates if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG ]
+ tags = [ predicate.GetValue() for predicate in predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG ]
self.SetContextTags( tags )
@@ -2188,7 +2189,7 @@ def _BroadcastChoices( self, predicates, shift_down ):
if self._under_construction_or_predicate is None:
- self._under_construction_or_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = predicates )
+ self._under_construction_or_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = predicates )
else:
@@ -2201,7 +2202,7 @@ def _BroadcastChoices( self, predicates, shift_down ):
or_preds.extend( [ predicate for predicate in predicates if predicate not in or_preds ] )
- self._under_construction_or_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = or_preds )
+ self._under_construction_or_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = or_preds )
else:
@@ -2223,7 +2224,7 @@ def _BroadcastChoices( self, predicates, shift_down ):
or_preds.extend( [ predicate for predicate in predicates if predicate not in or_preds ] )
- predicates = { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = or_preds ) }
+ predicates = { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = or_preds ) }
self._under_construction_or_predicate = None
@@ -2257,7 +2258,7 @@ def _CancelORConstruction( self ):
def _CreateNewOR( self ):
- predicates = { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = [ ] ) }
+ predicates = { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = [ ] ) }
try:
@@ -2340,7 +2341,7 @@ def _FavouriteSearchesMenu( self ):
CGC.core().PopupMenu( self, menu )
- def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearch.Predicate ]:
+ def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearchPredicate.Predicate ]:
parsed_autocomplete_text = self._GetParsedAutocompleteText()
@@ -2561,7 +2562,7 @@ def _RewindORConstruction( self ):
or_preds = or_preds[:-1]
- self._under_construction_or_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = or_preds )
+ self._under_construction_or_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = or_preds )
self._UpdateORButtons()
@@ -2612,7 +2613,7 @@ def _NotifyPredicatesBoxChanged( self ):
self._file_search_context.SetPredicates( predicates )
- tags = [ predicate.GetValue() for predicate in predicates if predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG ]
+ tags = [ predicate.GetValue() for predicate in predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG ]
self.SetContextTags( tags )
@@ -2674,7 +2675,7 @@ def _SynchronisedChanged( self, value ):
- def _TagContextJustChanged( self, tag_context: ClientSearch.TagContext ):
+ def _TagContextJustChanged( self, tag_context: ClientSearchTagContext.TagContext ):
it_changed = AutoCompleteDropdownTags._TagContextJustChanged( self, tag_context )
@@ -2725,12 +2726,12 @@ def _UpdateORButtons( self ):
- def GetFileSearchContext( self ) -> ClientSearch.FileSearchContext:
+ def GetFileSearchContext( self ) -> ClientSearchFileSearchContext.FileSearchContext:
return self._file_search_context.Duplicate()
- def GetPredicates( self ) -> typing.Set[ ClientSearch.Predicate ]:
+ def GetPredicates( self ) -> typing.Set[ ClientSearchPredicate.Predicate ]:
return self._file_search_context.GetPredicates()
@@ -2778,7 +2779,7 @@ def SetFetchedResults( self, job_status: ClientThreading.JobStatus, parsed_autoc
- def SetFileSearchContext( self, file_search_context: ClientSearch.FileSearchContext ):
+ def SetFileSearchContext( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
self._ClearInput()
@@ -2829,7 +2830,7 @@ def ShowCancelSearchButton( self, show ):
class ListBoxTagsActiveSearchPredicates( ClientGUIListBoxes.ListBoxTagsPredicates ):
- def __init__( self, parent: AutoCompleteDropdownTagsRead, page_key, file_search_context: ClientSearch.FileSearchContext ):
+ def __init__( self, parent: AutoCompleteDropdownTagsRead, page_key, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
ClientGUIListBoxes.ListBoxTagsPredicates.__init__( self, parent, height_num_chars = 6 )
@@ -3031,7 +3032,7 @@ def _GetCurrentLocationContext( self ):
return self._my_ac_parent.GetFileSearchContext().GetLocationContext()
- def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearch.Predicate ]:
+ def _GetCurrentPagePredicates( self ) -> typing.Set[ ClientSearchPredicate.Predicate ]:
return self.GetPredicates()
@@ -3082,7 +3083,7 @@ def EnterPredicates( self, page_key, predicates, permit_add = True, permit_remov
- def SetFileSearchContext( self, file_search_context: ClientSearch.FileSearchContext ):
+ def SetFileSearchContext( self, file_search_context: ClientSearchFileSearchContext.FileSearchContext ):
self._Clear()
@@ -3173,7 +3174,7 @@ def _BroadcastCurrentInputFromEnterKey( self, shift_down ):
- def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearch.Predicate ]:
+ def _GetCurrentBroadcastTextPredicate( self ) -> typing.Optional[ ClientSearchPredicate.Predicate ]:
parsed_autocomplete_text = self._GetParsedAutocompleteText()
@@ -3281,9 +3282,9 @@ def _StartSearchResultsFetchJob( self, job_status ):
parsed_autocomplete_text = self._GetParsedAutocompleteText()
- tag_context = ClientSearch.TagContext( service_key = self._tag_service_key, display_service_key = self._display_tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = self._tag_service_key, display_service_key = self._display_tag_service_key )
- file_search_context = ClientSearch.FileSearchContext( location_context = self._location_context_button.GetValue(), tag_context = tag_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = self._location_context_button.GetValue(), tag_context = tag_context )
CG.client_controller.CallToThread( WriteFetch, self, job_status, self.SetPrefetchResults, self.SetFetchedResults, parsed_autocomplete_text, file_search_context, self._results_cache )
@@ -3426,16 +3427,16 @@ def _UpdateText( self ):
if len( namespace ) > 0 and subtag == '*':
- row_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, value = namespace, inclusive = inclusive )
+ row_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, value = namespace, inclusive = inclusive )
else:
- row_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, value = tag_string, inclusive = inclusive )
+ row_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, value = tag_string, inclusive = inclusive )
else:
- row_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, value = tag_string, inclusive = inclusive )
+ row_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, value = tag_string, inclusive = inclusive )
tag_preds.append( row_pred )
@@ -3466,7 +3467,7 @@ def _UpdateText( self ):
else:
- self._current_predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, value = row_preds ) )
+ self._current_predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, value = row_preds ) )
diff --git a/hydrus/client/gui/search/ClientGUIPredicatesMultiple.py b/hydrus/client/gui/search/ClientGUIPredicatesMultiple.py
index dd1fe16e6..3576aa8d9 100644
--- a/hydrus/client/gui/search/ClientGUIPredicatesMultiple.py
+++ b/hydrus/client/gui/search/ClientGUIPredicatesMultiple.py
@@ -14,11 +14,11 @@
from hydrus.client.gui.search import ClientGUIPredicatesSingle
from hydrus.client.gui.widgets import ClientGUICommon
from hydrus.client.metadata import ClientRatings
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
class PredicateSystemRatingIncDecControl( QW.QWidget ):
- def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ):
+ def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearchPredicate.Predicate ] ):
super().__init__( parent )
@@ -99,14 +99,14 @@ def GetPredicates( self ):
rating = self._rating_value.value()
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( operator, rating, self._service_key ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( operator, rating, self._service_key ) )
return [ predicate ]
class PredicateSystemRatingLikeControl( QW.QWidget ):
- def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ):
+ def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearchPredicate.Predicate ] ):
super().__init__( parent )
@@ -235,14 +235,14 @@ def GetPredicates( self ):
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', rating, self._service_key ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', rating, self._service_key ) )
return [ predicate ]
class PredicateSystemRatingNumericalControl( QW.QWidget ):
- def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ):
+ def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearchPredicate.Predicate ] ):
super().__init__( parent )
@@ -374,19 +374,19 @@ def GetPredicates( self ):
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( operator, rating, self._service_key ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( operator, rating, self._service_key ) )
return [ predicate ]
class PanelPredicateSystemMultiple( ClientGUIPredicatesSingle.PanelPredicateSystem ):
- def _FilterWhatICanEdit( self, predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.Collection[ ClientSearch.Predicate ]:
+ def _FilterWhatICanEdit( self, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.Collection[ ClientSearchPredicate.Predicate ]:
raise NotImplementedError()
- def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.Collection[ ClientSearch.Predicate ]:
+ def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.Collection[ ClientSearchPredicate.Predicate ]:
raise NotImplementedError()
@@ -396,7 +396,7 @@ def ClearCustomDefault( self ):
raise NotImplementedError()
- def GetDefaultPredicates( self ) -> typing.Collection[ ClientSearch.Predicate ]:
+ def GetDefaultPredicates( self ) -> typing.Collection[ ClientSearchPredicate.Predicate ]:
raise NotImplementedError()
@@ -510,7 +510,7 @@ def __init__( self, parent, predicates ):
self.setLayout( vbox )
- def _FilterWhatICanEdit( self, predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.Collection[ ClientSearch.Predicate ]:
+ def _FilterWhatICanEdit( self, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.Collection[ ClientSearchPredicate.Predicate ]:
local_rating_service_keys = CG.client_controller.services_manager.GetServiceKeys( HC.RATINGS_SERVICES )
@@ -534,7 +534,7 @@ def _FilterWhatICanEdit( self, predicates: typing.Collection[ ClientSearch.Predi
return good_predicates
- def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.Collection[ ClientSearch.Predicate ]:
+ def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.Collection[ ClientSearchPredicate.Predicate ]:
predicates = self._FilterWhatICanEdit( predicates )
@@ -543,7 +543,7 @@ def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ Cl
return predicates
- custom_default_predicates = CG.client_controller.new_options.GetCustomDefaultSystemPredicates( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_RATING )
+ custom_default_predicates = CG.client_controller.new_options.GetCustomDefaultSystemPredicates( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING )
custom_default_predicates = self._FilterWhatICanEdit( custom_default_predicates )
@@ -559,7 +559,7 @@ def _GetPredicatesToInitialisePanelWith( self, predicates: typing.Collection[ Cl
def ClearCustomDefault( self ):
- CG.client_controller.new_options.ClearCustomDefaultSystemPredicates( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_RATING )
+ CG.client_controller.new_options.ClearCustomDefaultSystemPredicates( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING )
def GetDefaultPredicates( self ):
@@ -583,12 +583,12 @@ def SaveCustomDefault( self ):
predicates = self.GetPredicates()
- CG.client_controller.new_options.SetCustomDefaultSystemPredicates( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, predicates = predicates )
+ CG.client_controller.new_options.SetCustomDefaultSystemPredicates( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, predicates = predicates )
def UsesCustomDefault( self ) -> bool:
- custom_default_predicates = CG.client_controller.new_options.GetCustomDefaultSystemPredicates( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_RATING )
+ custom_default_predicates = CG.client_controller.new_options.GetCustomDefaultSystemPredicates( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING )
custom_default_predicates = self._FilterWhatICanEdit( custom_default_predicates )
diff --git a/hydrus/client/gui/search/ClientGUIPredicatesOR.py b/hydrus/client/gui/search/ClientGUIPredicatesOR.py
index ade0d428c..a9b9b0f55 100644
--- a/hydrus/client/gui/search/ClientGUIPredicatesOR.py
+++ b/hydrus/client/gui/search/ClientGUIPredicatesOR.py
@@ -11,7 +11,8 @@
from hydrus.client import ClientGlobals as CG
from hydrus.client.gui import ClientGUIFunctions
from hydrus.client.gui import QtPorting as QP
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
# ultimately, rewrite acread to be two classes, acread and acreadthatsupportsor
# and then this guy only imports the base class, and only the supportsor will know about this
@@ -20,13 +21,13 @@
class ORPredicateControl( QW.QWidget ):
- def __init__( self, parent: QW.QWidget, predicate: ClientSearch.Predicate, empty_file_search_context: typing.Optional[ ClientSearch.FileSearchContext ] = None ):
+ def __init__( self, parent: QW.QWidget, predicate: ClientSearchPredicate.Predicate, empty_file_search_context: typing.Optional[ ClientSearchFileSearchContext.FileSearchContext ] = None ):
super().__init__( parent )
from hydrus.client.gui.search import ClientGUIACDropdown
- if predicate.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER:
+ if predicate.GetType() != ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER:
raise Exception( 'Launched an ORPredicateControl without an OR Pred!' )
@@ -39,7 +40,7 @@ def __init__( self, parent: QW.QWidget, predicate: ClientSearch.Predicate, empty
location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
else:
@@ -88,7 +89,7 @@ def GetPredicates( self ):
return or_sub_predicates
- or_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, or_sub_predicates )
+ or_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, or_sub_predicates )
return [ or_predicate ]
diff --git a/hydrus/client/gui/search/ClientGUIPredicatesSingle.py b/hydrus/client/gui/search/ClientGUIPredicatesSingle.py
index 28f8d6de9..62be4ea71 100644
--- a/hydrus/client/gui/search/ClientGUIPredicatesSingle.py
+++ b/hydrus/client/gui/search/ClientGUIPredicatesSingle.py
@@ -24,7 +24,8 @@
from hydrus.client.gui.widgets import ClientGUICommon
from hydrus.client.gui.widgets import ClientGUINumberTest
from hydrus.client.gui.widgets import ClientGUIRegex
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchPredicate
class StaticSystemPredicateButton( QW.QWidget ):
@@ -81,7 +82,7 @@ def _DoPredicatesRemove( self ):
self.predicatesRemoved.emit( self )
- def GetPredicates( self ) -> typing.List[ ClientSearch.Predicate ]:
+ def GetPredicates( self ) -> typing.List[ ClientSearchPredicate.Predicate ]:
return self._predicates
@@ -118,7 +119,7 @@ def __init__( self, parent ):
class InvertiblePredicateButton( ClientGUICommon.BetterButton ):
- def __init__( self, parent: QW.QWidget, predicate: ClientSearch.Predicate ):
+ def __init__( self, parent: QW.QWidget, predicate: ClientSearchPredicate.Predicate ):
self._predicate = predicate
@@ -183,29 +184,29 @@ def GetPredicateFromSimpleTagText( simple_tag_text: str ):
raise Exception( 'Please enter some namespace text!' )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, namespace, inclusive = inclusive )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, namespace, inclusive = inclusive )
elif '*' in simple_tag_text:
wildcard = simple_tag_text
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, wildcard, inclusive = inclusive )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, wildcard, inclusive = inclusive )
else:
tag = simple_tag_text
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag, inclusive = inclusive )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag, inclusive = inclusive )
class PanelPredicateSimpleTagTypes( QW.QWidget ):
- def __init__( self, parent: QW.QWidget, predicate: ClientSearch.Predicate ):
+ def __init__( self, parent: QW.QWidget, predicate: ClientSearchPredicate.Predicate ):
super().__init__( parent )
- if predicate.GetType() not in ( ClientSearch.PREDICATE_TYPE_TAG, ClientSearch.PREDICATE_TYPE_NAMESPACE, ClientSearch.PREDICATE_TYPE_WILDCARD ):
+ if predicate.GetType() not in ( ClientSearchPredicate.PREDICATE_TYPE_TAG, ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, ClientSearchPredicate.PREDICATE_TYPE_WILDCARD ):
raise Exception( 'Launched a SimpleTextPredicateControl without a Tag, Namespace, or Wildcard Pred!' )
@@ -214,7 +215,7 @@ def __init__( self, parent: QW.QWidget, predicate: ClientSearch.Predicate ):
inclusive = predicate.IsInclusive()
- if predicate.GetType() == ClientSearch.PREDICATE_TYPE_NAMESPACE:
+ if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE:
namespace = predicate.GetValue()
@@ -302,7 +303,7 @@ def UsesCustomDefault( self ) -> bool:
class PanelPredicateSystemSingle( PanelPredicateSystem ):
- def _GetPredicateToInitialisePanelWith( self, predicate: ClientSearch.Predicate ) -> ClientSearch.Predicate:
+ def _GetPredicateToInitialisePanelWith( self, predicate: ClientSearchPredicate.Predicate ) -> ClientSearchPredicate.Predicate:
default_predicate = self.GetDefaultPredicate()
@@ -328,7 +329,7 @@ def ClearCustomDefault( self ):
CG.client_controller.new_options.ClearCustomDefaultSystemPredicates( comparable_predicate = default_predicate )
- def GetDefaultPredicate( self ) -> ClientSearch.Predicate:
+ def GetDefaultPredicate( self ) -> ClientSearchPredicate.Predicate:
raise NotImplementedError()
@@ -410,7 +411,7 @@ def _GetPredicateType( self ) -> int:
raise NotImplementedError()
- def GetDefaultPredicate( self ) -> ClientSearch.Predicate:
+ def GetDefaultPredicate( self ) -> ClientSearchPredicate.Predicate:
qt_dt = QC.QDate.currentDate()
@@ -425,7 +426,7 @@ def GetDefaultPredicate( self ) -> ClientSearch.Predicate:
predicate_type = self._GetPredicateType()
- return ClientSearch.Predicate( predicate_type, ( '>', 'date', ( year, month, day, hour, minute ) ) )
+ return ClientSearchPredicate.Predicate( predicate_type, ( '>', 'date', ( year, month, day, hour, minute ) ) )
def GetPredicates( self ):
@@ -443,7 +444,7 @@ def GetPredicates( self ):
predicate_type = self._GetPredicateType()
- predicates = ( ClientSearch.Predicate( predicate_type, ( self._sign.GetValue(), 'date', ( year, month, day, hour, minute ) ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( predicate_type, ( self._sign.GetValue(), 'date', ( year, month, day, hour, minute ) ) ), )
return predicates
@@ -458,10 +459,10 @@ def _GetSystemPredicateLabel( self ) -> str:
def _GetPredicateType( self ) -> int:
- return ClientSearch.PREDICATE_TYPE_SYSTEM_AGE
+ return ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE
- def GetDefaultPredicate( self ) -> ClientSearch.Predicate:
+ def GetDefaultPredicate( self ) -> ClientSearchPredicate.Predicate:
qt_dt = QC.QDate.currentDate()
@@ -476,7 +477,7 @@ def GetDefaultPredicate( self ) -> ClientSearch.Predicate:
predicate_type = self._GetPredicateType()
- return ClientSearch.Predicate( predicate_type, ( '<', 'date', ( year, month, day, hour, minute ) ) )
+ return ClientSearchPredicate.Predicate( predicate_type, ( '<', 'date', ( year, month, day, hour, minute ) ) )
@@ -489,7 +490,7 @@ def _GetSystemPredicateLabel( self ) -> str:
def _GetPredicateType( self ) -> int:
- return ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME
+ return ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME
@@ -502,7 +503,7 @@ def _GetSystemPredicateLabel( self ) -> str:
def _GetPredicateType( self ) -> int:
- return ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME
+ return ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME
@@ -515,7 +516,7 @@ def _GetSystemPredicateLabel( self ) -> str:
def _GetPredicateType( self ) -> int:
- return ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME
+ return ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME
@@ -569,12 +570,12 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( self._sign.GetValue(), 'delta', (self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( self._sign.GetValue(), 'delta', (self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
return predicates
@@ -629,12 +630,12 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
return predicates
@@ -688,12 +689,12 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
return predicates
@@ -747,12 +748,12 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ( '<', 'delta', ( 0, 0, 7, 0 ) ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ( self._sign.GetValue(), 'delta', ( self._years.value(), self._months.value(), self._days.value(), self._hours.value() ) ) ), )
return predicates
@@ -805,12 +806,12 @@ def GetDefaultPredicate( self ):
num = 0
dupe_type = HC.DUPLICATE_MEMBER
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( sign, num, dupe_type ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( sign, num, dupe_type ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( self._sign.GetValue(), self._num.value(), self._dupe_type.GetValue() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( self._sign.GetValue(), self._num.value(), self._dupe_type.GetValue() ) ), )
return predicates
@@ -822,10 +823,10 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUITime.NumberTestWidgetDuration( self, allowed_operators = allowed_operators, appropriate_absolute_plus_or_minus_default = 30000, appropriate_percentage_plus_or_minus_default = 5 )
@@ -854,16 +855,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 0 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 0 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, number_test ), )
return predicates
@@ -924,12 +925,12 @@ def GetDefaultPredicate( self ):
status = HC.CONTENT_STATUS_CURRENT
file_service_key = bytes()
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( sign, status, file_service_key ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( sign, status, file_service_key ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( self._sign.GetValue(), self._status.GetValue(), self._file_service_key.GetValue() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( self._sign.GetValue(), self._status.GetValue(), self._file_service_key.GetValue() ) ), )
return predicates
@@ -989,7 +990,7 @@ def GetDefaultPredicate( self ):
sign = '>'
num = 10
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', tuple( viewing_locations ), sign, num ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', tuple( viewing_locations ), sign, num ) )
def GetPredicates( self ):
@@ -1005,7 +1006,7 @@ def GetPredicates( self ):
num = self._num.value()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', tuple( viewing_locations ), sign, num ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', tuple( viewing_locations ), sign, num ) ), )
return predicates
@@ -1065,7 +1066,7 @@ def GetDefaultPredicate( self ):
sign = '>'
time_delta = 600
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', tuple( viewing_locations ), sign, time_delta ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', tuple( viewing_locations ), sign, time_delta ) )
def GetPredicates( self ):
@@ -1081,7 +1082,7 @@ def GetPredicates( self ):
time_delta = self._time_delta.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', tuple( viewing_locations ), sign, time_delta ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', tuple( viewing_locations ), sign, time_delta ) ), )
return predicates
@@ -1093,10 +1094,10 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators, max = 1000000, unit_string = 'fps', appropriate_absolute_plus_or_minus_default = 1, appropriate_percentage_plus_or_minus_default = 5 )
@@ -1125,16 +1126,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT, value = 60, extra_value = 0.05 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT, value = 60, extra_value = 0.05 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, number_test ), )
return predicates
@@ -1194,7 +1195,7 @@ def GetDefaultPredicate( self ):
hashes = tuple()
hash_type = 'sha256'
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ( hashes, hash_type ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ( hashes, hash_type ) )
def GetPredicates( self ):
@@ -1207,7 +1208,7 @@ def GetPredicates( self ):
hashes = ClientParsing.ParseHashesFromRawHexText( hash_type, hex_hashes_raw )
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ( hashes, hash_type ), inclusive = inclusive ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ( hashes, hash_type ), inclusive = inclusive ), )
return predicates
@@ -1254,7 +1255,7 @@ def GetDefaultPredicate( self ):
operator = True
name = ''
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( operator, name ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( operator, name ) )
def GetPredicates( self ):
@@ -1266,7 +1267,7 @@ def GetPredicates( self ):
name = 'notes'
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( self._operator.GetValue(), name ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( self._operator.GetValue(), name ) ), )
return predicates
@@ -1278,12 +1279,12 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators, unit_string = 'px', appropriate_absolute_plus_or_minus_default = 200 )
@@ -1312,16 +1313,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_EQUAL, value = 1080 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL, value = 1080 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, number_test ), )
return predicates
@@ -1369,7 +1370,7 @@ def GetDefaultPredicate( self ):
rule = ''
description = ''
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
def GetPredicates( self ):
@@ -1393,7 +1394,7 @@ def GetPredicates( self ):
description = operator_description + exact_url
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
return predicates
@@ -1443,7 +1444,7 @@ def GetDefaultPredicate( self ):
rule = ''
description = ''
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
def GetPredicates( self ):
@@ -1467,7 +1468,7 @@ def GetPredicates( self ):
description = operator_description + domain
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
return predicates
@@ -1515,7 +1516,7 @@ def GetDefaultPredicate( self ):
rule = ''
description = ''
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
def CheckValid( self ):
@@ -1553,7 +1554,7 @@ def GetPredicates( self ):
description = operator_description + regex
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
return predicates
@@ -1613,7 +1614,7 @@ def GetDefaultPredicate( self ):
)
description = ''
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) )
def GetPredicates( self ):
@@ -1630,7 +1631,7 @@ def GetPredicates( self ):
description = f'has url with class {url_class_name}' if operator else f'does not have url with class {url_class_name}'
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( operator, rule_type, rule, description ) ), )
return predicates
@@ -1669,12 +1670,12 @@ def GetDefaultPredicate( self ):
limit = 256
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, limit )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, limit )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, self._limit.value() ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, self._limit.value() ), )
return predicates
@@ -1698,7 +1699,7 @@ def __init__( self, parent, predicate ):
summary_mimes = ( summary_mimes, )
- specific_mimes = ClientSearch.ConvertSummaryFiletypesToSpecific( summary_mimes )
+ specific_mimes = ClientSearchPredicate.ConvertSummaryFiletypesToSpecific( summary_mimes )
self._mimes.SetValue( specific_mimes )
@@ -1718,14 +1719,14 @@ def GetDefaultPredicate( self ):
specific_mimes = tuple()
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, specific_mimes )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, specific_mimes )
def GetPredicates( self ):
specific_mimes = self._mimes.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, specific_mimes ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, specific_mimes ), )
return predicates
@@ -1780,12 +1781,12 @@ def GetDefaultPredicate( self ):
num_pixels = 2
unit = 1000000
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( sign, num_pixels, unit ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( sign, num_pixels, unit ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( self._sign.GetValue(), self._num_pixels.value(), self._unit.GetValue() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( self._sign.GetValue(), self._num_pixels.value(), self._unit.GetValue() ) ), )
return predicates
@@ -1797,12 +1798,12 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators, max = 1000000, appropriate_absolute_plus_or_minus_default = 300 )
@@ -1831,16 +1832,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 600 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 600 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, number_test ), )
return predicates
@@ -1900,7 +1901,7 @@ def GetDefaultPredicate( self ):
sign = '>'
num_tags = 4
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( namespace, sign, num_tags ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( namespace, sign, num_tags ) )
def GetPredicates( self ):
@@ -1912,21 +1913,21 @@ def GetPredicates( self ):
# swap num character tags > 0 with character:*anything*
if namespace != '*':
- number_test = ClientSearch.NumberTest.STATICCreateFromCharacters( operator, value )
+ number_test = ClientNumberTest.NumberTest.STATICCreateFromCharacters( operator, value )
if number_test.IsZero():
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, namespace, inclusive = False )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, namespace, inclusive = False )
elif number_test.IsAnythingButZero():
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, namespace )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, namespace )
if predicate is None:
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( namespace, operator, value ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( namespace, operator, value ) )
predicates = ( predicate, )
@@ -1941,10 +1942,10 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators )
@@ -1973,16 +1974,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_EQUAL, value = 2 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL, value = 2 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, number_test ), )
return predicates
@@ -1995,10 +1996,10 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators )
@@ -2027,16 +2028,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 0 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN, value = 0 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, number_test ), )
return predicates
@@ -2049,12 +2050,12 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators, max = 100000000, appropriate_absolute_plus_or_minus_default = 5000 )
@@ -2083,16 +2084,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN, value = 30000 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN, value = 30000 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, number_test ), )
return predicates
@@ -2147,12 +2148,12 @@ def GetDefaultPredicate( self ):
width = 16
height = 9
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( sign, width, height ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( sign, width, height ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( self._sign.GetValue(), self._width.value(), self._height.value() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( self._sign.GetValue(), self._width.value(), self._height.value() ) ), )
return predicates
@@ -2345,7 +2346,7 @@ def GetDefaultPredicate( self ):
perceptual_hashes = tuple()
max_hamming = 8
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( pixel_hashes, perceptual_hashes, max_hamming ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( pixel_hashes, perceptual_hashes, max_hamming ) )
def GetPredicates( self ):
@@ -2358,7 +2359,7 @@ def GetPredicates( self ):
perceptual_hashes = ClientParsing.ParseHashesFromRawHexText( 'perceptual', hex_perceptual_hashes_raw )
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( pixel_hashes, perceptual_hashes, self._max_hamming.value() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( pixel_hashes, perceptual_hashes, self._max_hamming.value() ) ), )
return predicates
@@ -2426,7 +2427,7 @@ def GetDefaultPredicate( self ):
hashes = tuple()
max_hamming = 4
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( hashes, max_hamming ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( hashes, max_hamming ) )
def GetPredicates( self ):
@@ -2435,7 +2436,7 @@ def GetPredicates( self ):
hashes = ClientParsing.ParseHashesFromRawHexText( 'sha256', hex_hashes_raw )
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( hashes, self._max_hamming.value() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( hashes, self._max_hamming.value() ) ), )
return predicates
@@ -2484,14 +2485,14 @@ def GetDefaultPredicate( self ):
size = 200
unit = 1024
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( sign, size, unit ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( sign, size, unit ) )
def GetPredicates( self ):
( size, unit ) = self._bytes.GetSeparatedValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( self._sign.GetValue(), size, unit ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( self._sign.GetValue(), size, unit ) ), )
return predicates
@@ -2543,12 +2544,12 @@ def GetDefaultPredicate( self ):
sign = '>'
num = 0
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( namespace, sign, num ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( namespace, sign, num ) )
def GetPredicates( self ):
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( self._namespace.text(), self._sign.GetValue(), self._num.value() ) ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( self._namespace.text(), self._sign.GetValue(), self._num.value() ) ), )
return predicates
@@ -2560,12 +2561,12 @@ def __init__( self, parent, predicate ):
PanelPredicateSystemSingle.__init__( self, parent )
allowed_operators = [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]
self._number_test = ClientGUINumberTest.NumberTestWidget( self, allowed_operators = allowed_operators, unit_string = 'px', appropriate_absolute_plus_or_minus_default = 200 )
@@ -2594,16 +2595,16 @@ def __init__( self, parent, predicate ):
def GetDefaultPredicate( self ):
- number_test = ClientSearch.NumberTest( operator = ClientSearch.NUMBER_TEST_OPERATOR_EQUAL, value = 1920 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL, value = 1920 )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, number_test )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, number_test )
def GetPredicates( self ):
number_test = self._number_test.GetValue()
- predicates = ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, number_test ), )
+ predicates = ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, number_test ), )
return predicates
diff --git a/hydrus/client/gui/search/ClientGUISearch.py b/hydrus/client/gui/search/ClientGUISearch.py
index a1d5720f6..a6d1690af 100644
--- a/hydrus/client/gui/search/ClientGUISearch.py
+++ b/hydrus/client/gui/search/ClientGUISearch.py
@@ -20,43 +20,46 @@
from hydrus.client.gui.search import ClientGUIPredicatesSingle
from hydrus.client.gui.search import ClientGUIPredicatesOR
from hydrus.client.gui.widgets import ClientGUICommon
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
FLESH_OUT_SYSTEM_PRED_TYPES = {
- ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT,
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES,
- ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_AGE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HASH,
- ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_MIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_RATING,
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO,
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA,
- ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE,
- ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER,
- ClientSearch.PREDICATE_TYPE_SYSTEM_URLS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS,
- ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES,
- ClientSearch.PREDICATE_TYPE_SYSTEM_TIME,
- ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DIMENSIONS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_URLS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOTES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TIME,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
}
-def EditPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSearch.Predicate ], empty_file_search_context: typing.Optional[ ClientSearch.FileSearchContext ] = None ) -> typing.List[ ClientSearch.Predicate ]:
+def EditPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSearchPredicate.Predicate ], empty_file_search_context: typing.Optional[ ClientSearchFileSearchContext.FileSearchContext ] = None ) -> typing.List[ ClientSearchPredicate.Predicate ]:
( editable_predicates, only_invertible_predicates, non_editable_predicates ) = GetEditablePredicates( predicates )
@@ -77,7 +80,7 @@ def EditPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSea
if len( editable_predicates ) == 1:
- if list( editable_predicates )[0].GetType() == ClientSearch.PREDICATE_TYPE_OR_CONTAINER:
+ if list( editable_predicates )[0].GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER:
title = 'edit OR predicate'
@@ -105,7 +108,7 @@ def EditPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSea
raise HydrusExceptions.CancelledException()
-def FilterAndConvertLabelPredicates( predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.List[ ClientSearch.Predicate ]:
+def FilterAndConvertLabelPredicates( predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.List[ ClientSearchPredicate.Predicate ]:
good_predicates = []
@@ -115,13 +118,13 @@ def FilterAndConvertLabelPredicates( predicates: typing.Collection[ ClientSearch
predicate_type = predicate.GetType()
- if predicate_type in ( ClientSearch.PREDICATE_TYPE_LABEL, ClientSearch.PREDICATE_TYPE_PARENT ):
+ if predicate_type in ( ClientSearchPredicate.PREDICATE_TYPE_LABEL, ClientSearchPredicate.PREDICATE_TYPE_PARENT ):
continue
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_UNTAGGED:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_UNTAGGED:
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) )
good_predicates.append( predicate )
@@ -129,7 +132,7 @@ def FilterAndConvertLabelPredicates( predicates: typing.Collection[ ClientSearch
return good_predicates
-def FleshOutPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSearch.Predicate ] ) -> typing.List[ ClientSearch.Predicate ]:
+def FleshOutPredicates( widget: QW.QWidget, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ) -> typing.List[ ClientSearchPredicate.Predicate ]:
window = None
@@ -178,7 +181,7 @@ def FleshOutPredicates( widget: QW.QWidget, predicates: typing.Collection[ Clien
return good_predicates
-def GetEditablePredicates( predicates: typing.Collection[ ClientSearch.Predicate ] ):
+def GetEditablePredicates( predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ):
editable_predicates = [ predicate for predicate in predicates if predicate.IsEditable() ]
only_invertible_predicates = [ predicate for predicate in predicates if predicate.IsInvertible() and not predicate.IsEditable() ]
@@ -189,7 +192,7 @@ def GetEditablePredicates( predicates: typing.Collection[ ClientSearch.Predicate
class EditPredicatesPanel( ClientGUIScrolledPanels.EditPanel ):
- def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicate ], empty_file_search_context: typing.Optional[ ClientSearch.FileSearchContext ] = None ):
+ def __init__( self, parent, predicates: typing.Collection[ ClientSearchPredicate.Predicate ], empty_file_search_context: typing.Optional[ ClientSearchFileSearchContext.FileSearchContext ] = None ):
ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
@@ -208,28 +211,28 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
# 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 ) ) )
- LAST_VIEWED_DELTA_PRED = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( '>', 'delta', ( 2000, 1, 1, 1 ) ) )
- ARCHIVED_DELTA_PRED = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( '>', '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 ) )
+ AGE_DELTA_PRED = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 2000, 1, 1, 1 ) ) )
+ LAST_VIEWED_DELTA_PRED = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ( '>', 'delta', ( 2000, 1, 1, 1 ) ) )
+ ARCHIVED_DELTA_PRED = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, ( '>', 'delta', ( 2000, 1, 1, 1 ) ) )
+ MODIFIED_DELTA_PRED = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ( '>', 'delta', ( 2000, 1, 1, 1 ) ) )
+ KNOWN_URL_EXACT = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'exact_match', '', '' ) )
+ KNOWN_URL_DOMAIN = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'domain', '', '' ) )
+ KNOWN_URL_REGEX = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'regex', '', '' ) )
+ FILE_VIEWS_PRED = ClientSearchPredicate.Predicate( ClientSearchPredicate.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:
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER:
self._editable_pred_panels.append( ClientGUIPredicatesOR.ORPredicateControl( self, predicate, empty_file_search_context = empty_file_search_context ) )
- elif predicate_type in ( ClientSearch.PREDICATE_TYPE_TAG, ClientSearch.PREDICATE_TYPE_NAMESPACE, ClientSearch.PREDICATE_TYPE_WILDCARD ):
+ elif predicate_type in ( ClientSearchPredicate.PREDICATE_TYPE_TAG, ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, ClientSearchPredicate.PREDICATE_TYPE_WILDCARD ):
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSimpleTagTypes( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE:
if predicate.IsUIEditable( AGE_DELTA_PRED ):
@@ -240,7 +243,7 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME:
if predicate.IsUIEditable( LAST_VIEWED_DELTA_PRED ):
@@ -251,7 +254,7 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemLastViewedDate( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME:
if predicate.IsUIEditable( ARCHIVED_DELTA_PRED ):
@@ -262,7 +265,7 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemArchivedDate( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:
if predicate.IsUIEditable( MODIFIED_DELTA_PRED ):
@@ -273,39 +276,39 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemModifiedDate( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemHeight( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemWidth( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemRatio( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumPixels( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemDuration( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemFramerate( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumFrames( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemFileService( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:
if predicate.IsUIEditable( KNOWN_URL_EXACT ):
@@ -324,59 +327,59 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemKnownURLsURLClass( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumURLs( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemHash( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemLimit( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemMime( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumTags( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumNotes( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemHasNoteName( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemNumWords( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemSimilarToData( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemSimilarToFiles( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE:
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemSize( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:
+ elif predicate_type == ClientSearchPredicate.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:
+ elif predicate_type == ClientSearchPredicate.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:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:
if predicate.IsUIEditable( FILE_VIEWS_PRED ):
@@ -387,7 +390,7 @@ def __init__( self, parent, predicates: typing.Collection[ ClientSearch.Predicat
self._editable_pred_panels.append( ClientGUIPredicatesSingle.PanelPredicateSystemFileViewingStatsViewtime( self, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING:
rating_preds.append( predicate )
@@ -466,7 +469,7 @@ def GetValue( self ):
class FleshOutPredicatePanel( ClientGUIScrolledPanels.EditPanel ):
- def __init__( self, parent, predicate: ClientSearch.Predicate ):
+ def __init__( self, parent, predicate: ClientSearchPredicate.Predicate ):
ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
@@ -483,39 +486,39 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
static_pred_buttons = []
editable_pred_panels = []
- if predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_AGE:
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE:
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 1, 0 ) ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 1, 0, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 1, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 1, 0, 0 ) ) ), ), show_remove_button = False ) )
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_ARCHIVED_TIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemArchivedDelta, predicate ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemArchivedDate, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME:
+ elif predicate_type == ClientSearchPredicate.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_TIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TIME:
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_AGE ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE ]
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 1, 0 ) ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 1, 0, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 1, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 7, 0 ) ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 1, 0, 0 ) ) ), ), show_remove_button = False ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemAgeDelta, predicate ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemAgeDate, predicate ) )
pages.append( ( 'import', recent_predicate_types, static_pred_buttons, editable_pred_panels ) )
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME ]
static_pred_buttons = []
editable_pred_panels = []
@@ -524,7 +527,7 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
pages.append( ( 'modified', recent_predicate_types, static_pred_buttons, editable_pred_panels ) )
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME ]
static_pred_buttons = []
editable_pred_panels = []
@@ -535,65 +538,65 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
page_name = 'archived'
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ]
static_pred_buttons = []
editable_pred_panels = []
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemArchivedDelta, predicate ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemArchivedDate, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS:
+ elif predicate_type == ClientSearchPredicate.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 ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS ]
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 16, 9 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 9, 16 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 4, 3 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 1, 1 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( 'taller than', 1, 1 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( 'wider than', 1, 1 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1920 ) ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1080 ) ) ), forced_label = '1080p', show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1280 ) ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 720 ) ) ), forced_label = '720p', show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 3840 ) ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 2160 ) ) ), forced_label = '4k', show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 16, 9 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 9, 16 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 4, 3 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 1, 1 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( 'taller than', 1, 1 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( 'wider than', 1, 1 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1920 ) ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1080 ) ) ), forced_label = '1080p', show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1280 ) ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 720 ) ) ), forced_label = '720p', show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 3840 ) ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 2160 ) ) ), forced_label = '4k', show_remove_button = False ) )
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:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION:
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES ]
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 30 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 60 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 30 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 60 ) ), ), show_remove_button = False ) )
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:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemFileService, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:
+ elif predicate_type == ClientSearchPredicate.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_NUM_URLS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumURLs, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_URLS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_URLS:
label = 'Note that "number of urls" counts all URLs, regardless of how important.'
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS ]
+ recent_predicate_types = [ ClientSearchPredicate.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 ) )
@@ -604,109 +607,109 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
page_name = 'number of urls'
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS ]
static_pred_buttons = []
editable_pred_panels = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumURLs, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False ), ), show_remove_button = False ) )
-
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY:
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False ), ), show_remove_button = False ) )
+
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ), ), show_remove_button = False ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ), ), show_remove_button = False ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False ), ), show_remove_button = False ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ), ), show_remove_button = False ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE:
recent_predicate_types = []
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False ), ), show_remove_button = False ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_HASH:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemHash, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT:
+ elif predicate_type == ClientSearchPredicate.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 += '\n' * 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, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 64 ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 256 ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 1024 ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 64 ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 256 ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 1024 ), ), show_remove_button = False ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemLimit, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_MIME:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemMime, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS:
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '>', 0 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '>', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) ), ), show_remove_button = False ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumTags, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOTES:
- recent_predicate_types = [ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME ]
+ recent_predicate_types = [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME ]
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) ), ), show_remove_button = False ) )
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:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemNumWords, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_RATING:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING:
services_manager = CG.client_controller.services_manager
@@ -717,7 +720,7 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesMultiple.PanelPredicateSystemRating, ( predicate, ) ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO:
recent_predicate_types = []
@@ -733,22 +736,22 @@ def __init__( self, parent, predicate: ClientSearch.Predicate ):
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemSimilarToFiles, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE:
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemSize, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:
+ elif predicate_type == ClientSearchPredicate.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:
+ elif predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS:
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False ), ), show_remove_button = False ) )
- static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False ), ), show_remove_button = False ) )
+ static_pred_buttons.append( ClientGUIPredicatesSingle.StaticSystemPredicateButton( self, ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True ), ), show_remove_button = False ) )
editable_pred_panels.append( self._PredOKPanel( self, ClientGUIPredicatesSingle.PanelPredicateSystemDuplicateRelationships, predicate ) )
- elif predicate_type == ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:
+ elif predicate_type == ClientSearchPredicate.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 ) )
@@ -1001,11 +1004,11 @@ def keyPressEvent( self, event ):
class TagContextButton( ClientGUICommon.BetterButton ):
- valueChanged = QC.Signal( ClientSearch.TagContext )
+ valueChanged = QC.Signal( ClientSearchTagContext.TagContext )
- def __init__( self, parent: QW.QWidget, tag_context: ClientSearch.TagContext, use_short_label = False ):
+ def __init__( self, parent: QW.QWidget, tag_context: ClientSearchTagContext.TagContext, use_short_label = False ):
- self._tag_context = ClientSearch.TagContext()
+ self._tag_context = ClientSearchTagContext.TagContext()
self._use_short_label = use_short_label
@@ -1033,7 +1036,7 @@ def _Edit( self ):
ClientGUIMenus.AppendSeparator( menu )
- tag_context = ClientSearch.TagContext( service_key = service.GetServiceKey() )
+ tag_context = ClientSearchTagContext.TagContext( service_key = service.GetServiceKey() )
ClientGUIMenus.AppendMenuCheckItem( menu, service.GetName(), 'Change the current tag domain to {}.'.format( service.GetName() ), tag_context == self._tag_context, self.SetValue, tag_context )
@@ -1043,12 +1046,12 @@ def _Edit( self ):
CGC.core().PopupMenu( self, menu )
- def GetValue( self ) -> ClientSearch.TagContext:
+ def GetValue( self ) -> ClientSearchTagContext.TagContext:
return self._tag_context
- def SetValue( self, tag_context: ClientSearch.TagContext ):
+ def SetValue( self, tag_context: ClientSearchTagContext.TagContext ):
original_tag_context = self._tag_context
diff --git a/hydrus/client/gui/search/ClientGUISearchPanels.py b/hydrus/client/gui/search/ClientGUISearchPanels.py
index 1fac59aa7..4bf02c851 100644
--- a/hydrus/client/gui/search/ClientGUISearchPanels.py
+++ b/hydrus/client/gui/search/ClientGUISearchPanels.py
@@ -19,7 +19,7 @@
from hydrus.client.gui.pages import ClientGUIResultsSortCollect
from hydrus.client.gui.panels import ClientGUIScrolledPanels
from hydrus.client.gui.widgets import ClientGUICommon
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
class EditFavouriteSearchPanel( ClientGUIScrolledPanels.EditPanel ):
@@ -220,7 +220,7 @@ def _AddNewFavouriteSearch( self, search_row = None ):
default_location_context = CG.client_controller.new_options.GetDefaultLocalLocationContext()
- file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context )
synchronised = True
media_sort = None
diff --git a/hydrus/client/gui/widgets/ClientGUINumberTest.py b/hydrus/client/gui/widgets/ClientGUINumberTest.py
index 7450acc31..c01507609 100644
--- a/hydrus/client/gui/widgets/ClientGUINumberTest.py
+++ b/hydrus/client/gui/widgets/ClientGUINumberTest.py
@@ -7,7 +7,7 @@
from hydrus.client import ClientConstants as CC
from hydrus.client.gui import QtPorting as QP
from hydrus.client.gui.widgets import ClientGUICommon
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
class NumberTestWidget( QW.QWidget ):
@@ -18,19 +18,19 @@ def __init__( self, parent, allowed_operators = None, max = 200000, unit_string
choice_tuples = []
for possible_operator in [
- ClientSearch.NUMBER_TEST_OPERATOR_LESS_THAN,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
- ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
- ClientSearch.NUMBER_TEST_OPERATOR_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_NOT_EQUAL,
- ClientSearch.NUMBER_TEST_OPERATOR_GREATER_THAN
+ ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_NOT_EQUAL,
+ ClientNumberTest.NUMBER_TEST_OPERATOR_GREATER_THAN
]:
if possible_operator in allowed_operators:
- text = ClientSearch.number_test_operator_to_str_lookup[ possible_operator ]
+ text = ClientNumberTest.number_test_operator_to_str_lookup[ possible_operator ]
- if possible_operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+ if possible_operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
text += '%'
@@ -139,20 +139,20 @@ def _UpdateVisibility( self ):
operator = self._operator.GetValue()
- self._absolute_plus_or_minus_panel.setVisible( operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE )
- self._percent_plus_or_minus_panel.setVisible( operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT )
+ self._absolute_plus_or_minus_panel.setVisible( operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE )
+ self._percent_plus_or_minus_panel.setVisible( operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT )
- def GetValue( self ) -> ClientSearch.NumberTest:
+ def GetValue( self ) -> ClientNumberTest.NumberTest:
operator = self._operator.GetValue()
value = self._GetSubValue()
- if operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+ if operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
extra_value = self._GetAbsoluteValue()
- elif operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+ elif operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
extra_value = self._percent_plus_or_minus.value() / 100
@@ -161,19 +161,19 @@ def GetValue( self ) -> ClientSearch.NumberTest:
extra_value = None
- return ClientSearch.NumberTest( operator = operator, value = value, extra_value = extra_value )
+ return ClientNumberTest.NumberTest( operator = operator, value = value, extra_value = extra_value )
- def SetValue( self, number_test: ClientSearch.NumberTest ):
+ def SetValue( self, number_test: ClientNumberTest.NumberTest ):
self._operator.SetValue( number_test.operator )
self._SetSubValue( number_test.value )
- if number_test.operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+ if number_test.operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
self._SetAbsoluteValue( number_test.extra_value )
- elif number_test.operator == ClientSearch.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+ elif number_test.operator == ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
self._percent_plus_or_minus.setValue( int( number_test.extra_value * 100 ) )
diff --git a/hydrus/client/importing/ClientImportGallery.py b/hydrus/client/importing/ClientImportGallery.py
index da34d8217..67dfe5dd4 100644
--- a/hydrus/client/importing/ClientImportGallery.py
+++ b/hydrus/client/importing/ClientImportGallery.py
@@ -919,7 +919,9 @@ def CheckCanDoFileWork( self ):
try:
- ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( self._file_import_options )
+ real_file_import_options = FileImportOptions.GetRealFileImportOptions( self._file_import_options, FileImportOptions.IMPORT_TYPE_LOUD )
+
+ ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( real_file_import_options )
except HydrusExceptions.VetoException:
diff --git a/hydrus/client/importing/ClientImportLocal.py b/hydrus/client/importing/ClientImportLocal.py
index ed2b7be02..5868bd1ea 100644
--- a/hydrus/client/importing/ClientImportLocal.py
+++ b/hydrus/client/importing/ClientImportLocal.py
@@ -409,6 +409,19 @@ def CheckCanDoFileWork( self ):
ClientImportControl.CheckImporterCanDoFileWorkBecausePaused( self._paused, self._file_seed_cache, self._page_key )
+ try:
+
+ real_file_import_options = FileImportOptions.GetRealFileImportOptions( self._file_import_options, FileImportOptions.IMPORT_TYPE_LOUD )
+
+ ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( real_file_import_options )
+
+ except HydrusExceptions.VetoException:
+
+ self._paused = True
+
+ raise
+
+
return True
diff --git a/hydrus/client/importing/ClientImportSimpleURLs.py b/hydrus/client/importing/ClientImportSimpleURLs.py
index 33e857f1c..456f9a97e 100644
--- a/hydrus/client/importing/ClientImportSimpleURLs.py
+++ b/hydrus/client/importing/ClientImportSimpleURLs.py
@@ -697,7 +697,9 @@ def CheckCanDoFileWork( self ):
try:
- ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( self._file_import_options )
+ real_file_import_options = FileImportOptions.GetRealFileImportOptions( self._file_import_options, FileImportOptions.IMPORT_TYPE_LOUD )
+
+ ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( real_file_import_options )
except HydrusExceptions.VetoException:
@@ -1399,7 +1401,9 @@ def CheckCanDoFileWork( self ):
try:
- ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( self._file_import_options )
+ real_file_import_options = FileImportOptions.GetRealFileImportOptions( self._file_import_options, FileImportOptions.IMPORT_TYPE_LOUD )
+
+ ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( real_file_import_options )
except HydrusExceptions.VetoException:
diff --git a/hydrus/client/importing/ClientImportSubscriptions.py b/hydrus/client/importing/ClientImportSubscriptions.py
index 0c8c1b677..43eb82a4c 100644
--- a/hydrus/client/importing/ClientImportSubscriptions.py
+++ b/hydrus/client/importing/ClientImportSubscriptions.py
@@ -1403,6 +1403,11 @@ def IsExpectingToWorkInFuture( self ):
return result
+ def IsPaused( self ):
+
+ return self._paused
+
+
def LowerCaseQueries( self ):
for query_header in self._query_headers:
@@ -1441,7 +1446,7 @@ def Merge( self, mergees: typing.Iterable[ "Subscription" ] ):
def PauseResume( self ):
- self._paused = not self._paused
+ self.SetPaused( not self._paused )
def RemoveQueryTexts( self, removee_query_texts: typing.Iterable[ str ], enforce_case: bool = True ):
@@ -1553,6 +1558,11 @@ def SetFileImportOptions( self, file_import_options ):
self._file_import_options = file_import_options.Duplicate()
+ def SetPaused( self, value ):
+
+ self._paused = value
+
+
def SetPresentationOptions( self, show_a_popup_while_working, publish_files_to_popup_button, publish_files_to_page, publish_label_override, merge_query_publish_events ):
self._show_a_popup_while_working = show_a_popup_while_working
diff --git a/hydrus/client/importing/ClientImportWatchers.py b/hydrus/client/importing/ClientImportWatchers.py
index 0c9da3f87..5dcbf6cb6 100644
--- a/hydrus/client/importing/ClientImportWatchers.py
+++ b/hydrus/client/importing/ClientImportWatchers.py
@@ -1824,7 +1824,9 @@ def CheckCanDoFileWork( self ):
try:
- ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( self._file_import_options )
+ real_file_import_options = FileImportOptions.GetRealFileImportOptions( self._file_import_options, FileImportOptions.IMPORT_TYPE_LOUD )
+
+ ClientImportControl.CheckImporterCanDoFileWorkBecausePausifyingProblem( real_file_import_options )
except HydrusExceptions.VetoException:
diff --git a/hydrus/client/importing/options/FileImportOptions.py b/hydrus/client/importing/options/FileImportOptions.py
index e42e50995..a882e024f 100644
--- a/hydrus/client/importing/options/FileImportOptions.py
+++ b/hydrus/client/importing/options/FileImportOptions.py
@@ -14,7 +14,7 @@
from hydrus.client.importing.options import PresentationImportOptions
from hydrus.client.media import ClientMediaResult
from hydrus.client.metadata import ClientContentUpdates
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
IMPORT_TYPE_QUIET = 0
IMPORT_TYPE_LOUD = 1
@@ -55,7 +55,7 @@ def __init__( self ):
self._preimport_url_check_type = DO_CHECK
self._preimport_url_check_looks_for_neighbour_spam = True
self._allow_decompression_bombs = True
- self._filetype_filter_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = set( HC.GENERAL_FILETYPES ) )
+ self._filetype_filter_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = set( HC.GENERAL_FILETYPES ) )
self._min_size = None
self._max_size = None
self._max_gif_size = None
@@ -236,7 +236,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
( exclude_deleted, do_not_check_known_urls_before_importing, do_not_check_hashes_before_importing, allow_decompression_bombs, min_size, max_size, max_gif_size, min_resolution, max_resolution, serialisable_import_destination_location_context ) = pre_import_options
- filetype_filter_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = set( HC.GENERAL_FILETYPES ) )
+ filetype_filter_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = set( HC.GENERAL_FILETYPES ) )
serialisable_filetype_filter_predicate = filetype_filter_predicate.GetSerialisableTuple()
@@ -297,7 +297,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
mimes.append( HC.GENERAL_APPLICATION_ARCHIVE )
mimes.append( HC.GENERAL_IMAGE_PROJECT )
- filetype_filter_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = mimes )
+ filetype_filter_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = mimes )
serialisable_filetype_filter_predicate = filetype_filter_predicate.GetSerialisableTuple()
@@ -435,7 +435,7 @@ def ExcludesDeleted( self ):
def GetAllowedSpecificFiletypes( self ) -> typing.Collection[ int ]:
- return ClientSearch.ConvertSummaryFiletypesToSpecific( self._filetype_filter_predicate.GetValue(), only_searchable = False )
+ return ClientSearchPredicate.ConvertSummaryFiletypesToSpecific( self._filetype_filter_predicate.GetValue(), only_searchable = False )
def GetAlreadyInDBPostImportContentUpdatePackage( self, media_result: ClientMediaResult.MediaResult ):
@@ -522,7 +522,7 @@ def GetSummary( self ):
statements = []
- statements.append( 'allowing {}'.format( ClientSearch.ConvertSummaryFiletypesToString( self._filetype_filter_predicate.GetValue() ) ) )
+ statements.append( 'allowing {}'.format( ClientSearchPredicate.ConvertSummaryFiletypesToString( self._filetype_filter_predicate.GetValue() ) ) )
if self._exclude_deleted:
@@ -593,9 +593,9 @@ def PreImportURLCheckLooksForNeighbourSpam( self ) -> bool:
def SetAllowedSpecificFiletypes( self, mimes ) -> None:
- mimes = ClientSearch.ConvertSpecificFiletypesToSummary( mimes, only_searchable = False )
+ mimes = ClientSearchPredicate.ConvertSpecificFiletypesToSummary( mimes, only_searchable = False )
- self._filetype_filter_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = mimes )
+ self._filetype_filter_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = mimes )
def SetDestinationLocationContext( self, location_context: ClientLocation.LocationContext ):
diff --git a/hydrus/client/media/ClientMedia.py b/hydrus/client/media/ClientMedia.py
index d8f324a74..a0c33b24f 100644
--- a/hydrus/client/media/ClientMedia.py
+++ b/hydrus/client/media/ClientMedia.py
@@ -20,7 +20,7 @@
from hydrus.client.media import ClientMediaResult
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchTagContext
def CanDisplayMedia( media: "MediaSingleton" ) -> bool:
@@ -474,7 +474,7 @@ def __init__( self, namespaces = None, rating_service_keys = None, collect_unmat
if tag_context is None:
- tag_context = ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
self.namespaces = namespaces
@@ -507,7 +507,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
( namespaces, serialisable_rating_service_keys, collect_unmatched ) = old_serialisable_info
- tag_context = ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
serialisable_tag_context = tag_context.GetSerialisableTuple()
@@ -2354,7 +2354,7 @@ def __init__( self, sort_type = None, sort_order = None, tag_context = None ):
if tag_context is None:
- tag_context = ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
( sort_metatype, sort_data ) = sort_type
@@ -2457,7 +2457,7 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
( sort_metatype, serialisable_sort_data, sort_order ) = old_serialisable_info
- tag_context = ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY )
serialisable_tag_context = tag_context.GetSerialisableTuple()
diff --git a/hydrus/client/media/ClientMediaManagers.py b/hydrus/client/media/ClientMediaManagers.py
index 5e8e0bcba..4974f8954 100644
--- a/hydrus/client/media/ClientMediaManagers.py
+++ b/hydrus/client/media/ClientMediaManagers.py
@@ -16,7 +16,7 @@
from hydrus.client import ClientTime
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchTagContext
class FileDuplicatesManager( object ):
@@ -1874,7 +1874,7 @@ def GetNamespaceSlice( self, service_key: bytes, namespaces: typing.Collection[
- def GetNumTags( self, tag_context: ClientSearch.TagContext, tag_display_type ):
+ def GetNumTags( self, tag_context: ClientSearchTagContext.TagContext, tag_display_type ):
with self._lock:
diff --git a/hydrus/client/metadata/ClientMetadataConditional.py b/hydrus/client/metadata/ClientMetadataConditional.py
new file mode 100644
index 000000000..2c270c191
--- /dev/null
+++ b/hydrus/client/metadata/ClientMetadataConditional.py
@@ -0,0 +1,47 @@
+from hydrus.core import HydrusSerialisable
+
+from hydrus.client.media import ClientMediaResult
+from hydrus.client.search import ClientSearchPredicate
+
+class MetadataConditional( HydrusSerialisable.SerialisableBase ):
+
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_METADATA_CONDITIONAL
+ SERIALISABLE_NAME = 'Metadata Conditional'
+ SERIALISABLE_VERSION = 1
+
+ def __init__( self ):
+
+ super().__init__()
+
+ # starting this guy out nice and simple, just a wrapper for a system pred
+ # future versions of this object could hold multiple system preds or whatever
+
+ self._predicate = ClientSearchPredicate.SYSTEM_PREDICATE_INBOX
+
+
+ def _GetSerialisableInfo( self ):
+
+ serialisable_predicate = self._predicate.GetSerialisableTuple()
+
+ return serialisable_predicate
+
+
+ def _InitialiseFromSerialisableInfo( self, serialisable_info ):
+
+ serialisable_predicate = serialisable_info
+
+ self._predicate = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_predicate )
+
+
+ def Test( self, media_result: ClientMediaResult.MediaResult ) -> bool:
+
+ if self._predicate.CanTestMediaResult():
+
+ return self._predicate.TestMediaResult( media_result )
+
+
+ raise NotImplementedError( f'The given predicate, "{self._predicate.ToString()}", cannot test a media result! You should not be able to this situation, so please contact hydev with details.' )
+
+
+
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_METADATA_CONDITIONAL ] = MetadataConditional
diff --git a/hydrus/client/networking/ClientLocalServerResources.py b/hydrus/client/networking/ClientLocalServerResources.py
index 71c53d5fe..bcd439274 100644
--- a/hydrus/client/networking/ClientLocalServerResources.py
+++ b/hydrus/client/networking/ClientLocalServerResources.py
@@ -61,9 +61,11 @@
from hydrus.client.networking import ClientNetworkingDomain
from hydrus.client.networking import ClientNetworkingFunctions
from hydrus.client.networking import ClientNetworkingJobs
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
from hydrus.client.search import ClientSearchAutocomplete
from hydrus.client.search import ClientSearchParseSystemPredicates
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
from hydrus.client.gui import ClientGUIPopupMessages
# if a variable name isn't defined here, a GET with it won't work
@@ -569,7 +571,7 @@ def ParseClientAPIPOSTArgs( request ):
return ( parsed_request_args, total_bytes_read )
-def ParseClientAPISearchPredicates( request ) -> typing.List[ ClientSearch.Predicate ]:
+def ParseClientAPISearchPredicates( request ) -> typing.List[ ClientSearchPredicate.Predicate ]:
default_search_values = {}
@@ -592,7 +594,7 @@ def ParseClientAPISearchPredicates( request ) -> typing.List[ ClientSearch.Predi
return predicates
- we_have_at_least_one_inclusive_tag = True in ( predicate.GetType() == ClientSearch.PREDICATE_TYPE_TAG and predicate.IsInclusive() for predicate in predicates )
+ we_have_at_least_one_inclusive_tag = True in ( predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG and predicate.IsInclusive() for predicate in predicates )
if not we_have_at_least_one_inclusive_tag:
@@ -619,15 +621,15 @@ def ParseDuplicateSearch( request: HydrusServerRequest.HydrusRequest ):
CheckTagService( tag_service_key_1 )
CheckTagService( tag_service_key_2 )
- tag_context_1 = ClientSearch.TagContext( service_key = tag_service_key_1 )
- tag_context_2 = ClientSearch.TagContext( service_key = tag_service_key_2 )
+ tag_context_1 = ClientSearchTagContext.TagContext( service_key = tag_service_key_1 )
+ tag_context_2 = ClientSearchTagContext.TagContext( service_key = tag_service_key_2 )
tags_1 = request.parsed_request_args.GetValue( 'tags_1', list, default_value = [] )
tags_2 = request.parsed_request_args.GetValue( 'tags_2', list, default_value = [] )
if len( tags_1 ) == 0:
- predicates_1 = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
+ predicates_1 = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
else:
@@ -636,7 +638,7 @@ def ParseDuplicateSearch( request: HydrusServerRequest.HydrusRequest ):
if len( tags_2 ) == 0:
- predicates_2 = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
+ predicates_2 = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) ]
else:
@@ -644,8 +646,8 @@ def ParseDuplicateSearch( request: HydrusServerRequest.HydrusRequest ):
- file_search_context_1 = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context_1, predicates = predicates_1 )
- file_search_context_2 = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context_2, predicates = predicates_2 )
+ file_search_context_1 = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context_1, predicates = predicates_1 )
+ file_search_context_2 = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context_2, predicates = predicates_2 )
dupe_search_type = request.parsed_request_args.GetValue( 'potentials_search_type', int, default_value = ClientDuplicates.DUPE_SEARCH_ONE_FILE_MATCHES_ONE_SEARCH )
pixel_dupes_preference = request.parsed_request_args.GetValue( 'pixel_duplicates', int, default_value = ClientDuplicates.SIMILAR_FILES_PIXEL_DUPES_ALLOWED )
@@ -871,7 +873,7 @@ def ParseTagServiceKey( request: HydrusServerRequest.HydrusRequest ):
return tag_service_key
-def ConvertTagListToPredicates( request, tag_list, do_permission_check = True, error_on_invalid_tag = True ) -> typing.List[ ClientSearch.Predicate ]:
+def ConvertTagListToPredicates( request, tag_list, do_permission_check = True, error_on_invalid_tag = True ) -> typing.List[ ClientSearchPredicate.Predicate ]:
or_tag_lists = [ tag for tag in tag_list if isinstance( tag, list ) ]
tag_strings = [ tag for tag in tag_list if isinstance( tag, str ) ]
@@ -973,7 +975,7 @@ def ConvertTagListToPredicates( request, tag_list, do_permission_check = True, e
or_preds = ConvertTagListToPredicates( request, or_tag_list, do_permission_check = False )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, or_preds ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, or_preds ) )
predicates.extend( ClientSearchParseSystemPredicates.ParseSystemPredicateStringsToPredicates( system_predicate_strings ) )
@@ -990,19 +992,19 @@ def ConvertTagListToPredicates( request, tag_list, do_permission_check = True, e
if subtag == '*':
tag = namespace
- predicate_type = ClientSearch.PREDICATE_TYPE_NAMESPACE
+ predicate_type = ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE
else:
- predicate_type = ClientSearch.PREDICATE_TYPE_WILDCARD
+ predicate_type = ClientSearchPredicate.PREDICATE_TYPE_WILDCARD
else:
- predicate_type = ClientSearch.PREDICATE_TYPE_TAG
+ predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG
- predicates.append( ClientSearch.Predicate( predicate_type = predicate_type, value = tag, inclusive = inclusive ) )
+ predicates.append( ClientSearchPredicate.Predicate( predicate_type = predicate_type, value = tag, inclusive = inclusive ) )
return predicates
@@ -2134,19 +2136,19 @@ def _GetParsedAutocompleteText( self, search, tag_service_key ) -> ClientSearchA
return parsed_autocomplete_text
- def _GetTagMatches( self, request: HydrusServerRequest.HydrusRequest, tag_display_type: int, tag_service_key: bytes, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText ) -> typing.List[ ClientSearch.Predicate ]:
+ def _GetTagMatches( self, request: HydrusServerRequest.HydrusRequest, tag_display_type: int, tag_service_key: bytes, parsed_autocomplete_text: ClientSearchAutocomplete.ParsedAutocompleteText ) -> typing.List[ ClientSearchPredicate.Predicate ]:
matches = []
if parsed_autocomplete_text.IsAcceptableForTagSearches():
- tag_context = ClientSearch.TagContext( service_key = tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key )
autocomplete_search_text = parsed_autocomplete_text.GetSearchText( True )
location_context = ParseLocationContext( request, ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY ) )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context )
job_status = ClientThreading.JobStatus( cancellable = True )
@@ -2158,9 +2160,9 @@ def _GetTagMatches( self, request: HydrusServerRequest.HydrusRequest, tag_displa
display_tag_service_key = tag_context.display_service_key
- matches = ClientSearch.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, predicates )
+ matches = ClientSearchAutocomplete.FilterPredicatesBySearchText( display_tag_service_key, autocomplete_search_text, predicates )
- matches = ClientSearch.SortPredicates( matches )
+ matches = ClientSearchPredicate.SortPredicates( matches )
return matches
@@ -2837,7 +2839,7 @@ def _threadDoGETJob( self, request: HydrusServerRequest.HydrusRequest ):
include_current_tags = request.parsed_request_args.GetValue( 'include_current_tags', bool, default_value = True )
include_pending_tags = request.parsed_request_args.GetValue( 'include_pending_tags', bool, default_value = True )
- tag_context = ClientSearch.TagContext( service_key = tag_service_key, include_current_tags = include_current_tags, include_pending_tags = include_pending_tags )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key, include_current_tags = include_current_tags, include_pending_tags = include_pending_tags )
predicates = ParseClientAPISearchPredicates( request )
return_hashes = False
@@ -2849,7 +2851,7 @@ def _threadDoGETJob( self, request: HydrusServerRequest.HydrusRequest ):
else:
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
file_sort_type = CC.SORT_FILES_BY_IMPORT_TIME
@@ -4046,10 +4048,10 @@ def _threadDoGETJob( self, request: HydrusServerRequest.HydrusRequest ):
raise HydrusExceptions.BadRequestException( 'Sorry, search for all known tags over all known files is not supported!' )
- tag_context = ClientSearch.TagContext( service_key = tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key )
predicates = ParseClientAPISearchPredicates( request )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = predicates )
job_status = ClientThreading.JobStatus( cancellable = True )
diff --git a/hydrus/client/networking/ClientNetworkingURLClass.py b/hydrus/client/networking/ClientNetworkingURLClass.py
index c0cd0db59..151ca240b 100644
--- a/hydrus/client/networking/ClientNetworkingURLClass.py
+++ b/hydrus/client/networking/ClientNetworkingURLClass.py
@@ -290,7 +290,7 @@ def __init__(
p = URLClassParameterFixedName(
name = 'id',
- value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' )
+ value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' )
)
parameters.append( p )
diff --git a/hydrus/client/search/ClientNumberTest.py b/hydrus/client/search/ClientNumberTest.py
new file mode 100644
index 000000000..630ccb0d5
--- /dev/null
+++ b/hydrus/client/search/ClientNumberTest.py
@@ -0,0 +1,320 @@
+import typing
+
+from hydrus.core import HydrusConstants as HC
+from hydrus.core import HydrusNumbers
+from hydrus.core import HydrusSerialisable
+
+NUMBER_TEST_OPERATOR_LESS_THAN = 0
+NUMBER_TEST_OPERATOR_GREATER_THAN = 1
+NUMBER_TEST_OPERATOR_EQUAL = 2
+NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT = 3
+NUMBER_TEST_OPERATOR_NOT_EQUAL = 4
+NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE = 5
+
+number_test_operator_to_str_lookup = {
+ NUMBER_TEST_OPERATOR_LESS_THAN : '<',
+ NUMBER_TEST_OPERATOR_GREATER_THAN : '>',
+ NUMBER_TEST_OPERATOR_EQUAL : '=',
+ NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT : HC.UNICODE_APPROX_EQUAL,
+ NUMBER_TEST_OPERATOR_NOT_EQUAL : HC.UNICODE_NOT_EQUAL,
+ NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE : HC.UNICODE_APPROX_EQUAL
+}
+
+number_test_str_to_operator_lookup = { value : key for ( key, value ) in number_test_operator_to_str_lookup.items() if key != NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE }
+
+class NumberTest( HydrusSerialisable.SerialisableBase ):
+
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_NUMBER_TEST
+ SERIALISABLE_NAME = 'Number Test'
+ SERIALISABLE_VERSION = 2
+
+ def __init__( self, operator = NUMBER_TEST_OPERATOR_EQUAL, value = 1, extra_value = None ):
+
+ super().__init__()
+
+ if operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT and value == 0:
+
+ operator = NUMBER_TEST_OPERATOR_EQUAL
+ extra_value = None
+
+
+ self.operator = operator
+ self.value = value
+
+ if extra_value is None:
+
+ if self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+
+ extra_value = 0.15
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+
+ extra_value = 1
+
+
+
+ self.extra_value = extra_value
+
+
+ def __eq__( self, other ):
+
+ if isinstance( other, NumberTest ):
+
+ return self.__hash__() == other.__hash__()
+
+
+ return NotImplemented
+
+
+ def __hash__( self ):
+
+ return ( self.operator, self.value, self.extra_value ).__hash__()
+
+
+ def __repr__( self ):
+
+ return self.ToString()
+
+
+ def _GetSerialisableInfo( self ):
+
+ return ( self.operator, self.value, self.extra_value )
+
+
+ def _InitialiseFromSerialisableInfo( self, serialisable_info ):
+
+ ( self.operator, self.value, self.extra_value ) = serialisable_info
+
+
+ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
+
+ if version == 1:
+
+ ( operator, value ) = old_serialisable_info
+
+ if operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+
+ extra_value = 0.15
+
+ else:
+
+ extra_value = None
+
+
+ new_serialisable_info = ( operator, value, extra_value )
+
+ return ( 2, new_serialisable_info )
+
+
+
+ def GetLambda( self ):
+
+ if self.operator == NUMBER_TEST_OPERATOR_LESS_THAN:
+
+ if self.value > 0:
+
+ return lambda x: x is None or x < self.value
+
+ else:
+
+ return lambda x: x is not None and x < self.value
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_GREATER_THAN:
+
+ if self.value < 0:
+
+ return lambda x: x is None or x > self.value
+
+ else:
+
+ return lambda x: x is not None and x > self.value
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_EQUAL:
+
+ if self.value == 0:
+
+ return lambda x: x is None or x == self.value
+
+ else:
+
+ return lambda x: x == self.value
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+
+ lower = self.value * ( 1 - self.extra_value )
+ upper = self.value * ( 1 + self.extra_value )
+
+ if lower <= 0:
+
+ return lambda x: x is None or x < upper
+
+ else:
+
+ return lambda x: x is not None and lower < x < upper
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+
+ lower = self.value - self.extra_value
+ upper = self.value + self.extra_value
+
+ if lower <= 0:
+
+ return lambda x: x is None or x < upper
+
+ else:
+
+ return lambda x: x is not None and lower < x < upper
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_NOT_EQUAL:
+
+ if self.value == 0:
+
+ return lambda x: x is not None and x != self.value
+
+ else:
+
+ return lambda x: x is None or x != self.value
+
+
+
+
+ def GetSQLitePredicates( self, variable_name ):
+
+ if self.operator == NUMBER_TEST_OPERATOR_LESS_THAN:
+
+ if self.value > 0:
+
+ return [ f'( {variable_name} IS NULL OR {variable_name} < {self.value} )' ]
+
+ else:
+
+ return [ f'{variable_name} < {self.value}' ]
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_GREATER_THAN:
+
+ if self.value < 0:
+
+ return [ f'( {variable_name} IS NULL OR {variable_name} > {self.value} )' ]
+
+ else:
+
+ return [ f'{variable_name} > {self.value}' ]
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_EQUAL:
+
+ if self.value == 0:
+
+ return [ f'( {variable_name} IS NULL OR {variable_name} = {self.value} )' ]
+
+ else:
+
+ return [ f'{variable_name} = {self.value}' ]
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+
+ lower = self.value * ( 1 - self.extra_value )
+ upper = self.value * ( 1 + self.extra_value )
+
+ if lower <= 0:
+
+ return [ f'( {variable_name} is NULL OR {variable_name} < {upper} )' ]
+
+ else:
+
+ return [ f'{variable_name} > {lower}', f'{variable_name} < {upper}' ]
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+
+ lower = self.value - self.extra_value
+ upper = self.value + self.extra_value
+
+ if lower <= 0:
+
+ return [ f'( {variable_name} IS NULL OR {variable_name} < {upper} )' ]
+
+ else:
+
+ return [ f'{variable_name} > {lower}', f'{variable_name} < {upper}' ]
+
+
+ elif self.operator == NUMBER_TEST_OPERATOR_NOT_EQUAL:
+
+ if self.value == 0:
+
+ return [ f'{variable_name} IS NOT NULL AND {variable_name} != {self.value}' ]
+
+ else:
+
+ return [ f'( {variable_name} IS NULL OR {variable_name} != {self.value} )' ]
+
+
+
+ return []
+
+
+ def IsAnythingButZero( self ):
+
+ return self.operator in ( NUMBER_TEST_OPERATOR_NOT_EQUAL, NUMBER_TEST_OPERATOR_GREATER_THAN ) and self.value == 0
+
+
+ def IsZero( self ):
+
+ actually_zero = self.operator == NUMBER_TEST_OPERATOR_EQUAL and self.value == 0
+ less_than_one = self.operator == NUMBER_TEST_OPERATOR_LESS_THAN and self.value == 1
+
+ return actually_zero or less_than_one
+
+
+ def ToString( self, absolute_number_renderer: typing.Optional[ typing.Callable ] = None ) -> str:
+
+ if absolute_number_renderer is None:
+
+ absolute_number_renderer = HydrusNumbers.ToHumanInt
+
+
+ result = f'{number_test_operator_to_str_lookup[ self.operator ]} {absolute_number_renderer( self.value )}'
+
+ if self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
+
+ result += f' {HC.UNICODE_PLUS_OR_MINUS}{HydrusNumbers.FloatToPercentage(self.extra_value)}'
+
+ elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
+
+ result += f' {HC.UNICODE_PLUS_OR_MINUS}{absolute_number_renderer(self.extra_value)}'
+
+
+ return result
+
+
+ def WantsZero( self ):
+
+ return self.GetLambda()( 0 )
+
+
+ @staticmethod
+ def STATICCreateFromCharacters( operator_str: str, value: int ) -> "NumberTest":
+
+ operator = number_test_str_to_operator_lookup[ operator_str ]
+
+ return NumberTest( operator, value )
+
+
+ @staticmethod
+ def STATICCreateMegaLambda( number_tests: typing.Collection[ "NumberTest" ] ):
+
+ lambdas = [ number_test.GetLambda() for number_test in number_tests ]
+
+ return lambda x: False not in ( lamb( x ) for lamb in lambdas )
+
+
+
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_NUMBER_TEST ] = NumberTest
diff --git a/hydrus/client/search/ClientSearchAutocomplete.py b/hydrus/client/search/ClientSearchAutocomplete.py
index a24570e47..901a01a6b 100644
--- a/hydrus/client/search/ClientSearchAutocomplete.py
+++ b/hydrus/client/search/ClientSearchAutocomplete.py
@@ -1,11 +1,117 @@
+import re
import typing
from hydrus.core import HydrusData
from hydrus.core import HydrusTags
from hydrus.client.metadata import ClientTagsHandling
-from hydrus.client.search import ClientSearch
from hydrus.client.search import ClientSearchParseSystemPredicates
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
+
+def FilterPredicatesBySearchText( service_key, search_text, predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ):
+
+ def compile_re( s ):
+
+ regular_parts_of_s = s.split( '*' )
+
+ escaped_parts_of_s = [ re.escape( rpos ) for rpos in regular_parts_of_s ]
+
+ s = '.*'.join( escaped_parts_of_s )
+
+ # \A is start of string
+ # \Z is end of string
+ # \s is whitespace
+
+ # ':' is no longer escaped to '\:' in py 3.7 lmaooooo, so some quick hackery
+ if re.escape( ':' ) == r'\:':
+
+ s = s.replace( r'\:', ':' )
+
+
+ if ':' in s:
+
+ ( namespace, subtag ) = s.split( ':', 1 )
+
+ if namespace == '.*':
+
+ beginning = r'(\A|:|\s)'
+ s = subtag
+
+ else:
+
+ beginning = r'\A'
+ s = r'{}:(.*\s)?{}'.format( namespace, subtag )
+
+
+ elif s.startswith( '.*' ):
+
+ beginning = r'(\A|:)'
+
+ else:
+
+ beginning = r'(\A|:|\s)'
+
+
+ if s.endswith( '.*' ):
+
+ end = r'\Z' # end of string
+
+ else:
+
+ end = r'(\s|\Z)' # whitespace or end of string
+
+
+ return re.compile( beginning + s + end )
+
+
+ re_predicate = compile_re( search_text )
+
+ matches = []
+
+ for predicate in predicates:
+
+ ( predicate_type, value, inclusive ) = predicate.GetInfo()
+
+ if predicate_type != ClientSearchPredicate.PREDICATE_TYPE_TAG:
+
+ continue
+
+
+ possible_tags = predicate.GetMatchableSearchTexts()
+
+ searchable_tags = { ClientSearchTagContext.ConvertTagToSearchable( possible_tag ) for possible_tag in possible_tags }
+
+ for searchable_tag in searchable_tags:
+
+ if re_predicate.search( searchable_tag ) is not None:
+
+ matches.append( predicate )
+
+ break
+
+
+
+
+ return matches
+
+
+def IsComplexWildcard( search_text ):
+
+ num_stars = search_text.count( '*' )
+
+ if num_stars > 1:
+
+ return True
+
+
+ if num_stars == 1 and not search_text.endswith( '*' ):
+
+ return True
+
+
+ return False
+
def SearchTextIsFetchAll( search_text: str ):
@@ -43,6 +149,13 @@ def SearchTextIsNamespaceFetchAll( search_text: str ):
return False
+def SubtagIsEmpty( search_text: str ):
+
+ ( namespace, subtag ) = HydrusTags.SplitTag( search_text )
+
+ return subtag == ''
+
+
class ParsedAutocompleteText( object ):
def __init__( self, raw_input: str, tag_autocomplete_options: ClientTagsHandling.TagAutocompleteOptions, collapse_search_characters: bool ):
@@ -78,7 +191,7 @@ def __repr__( self ):
def _GetSearchText( self, always_autocompleting: bool, force_do_not_collapse: bool = False, allow_auto_wildcard_conversion: bool = False ) -> str:
- text = ClientSearch.CollapseWildcardCharacters( self.raw_content )
+ text = ClientSearchTagContext.CollapseWildcardCharacters( self.raw_content )
if len( text ) == 0:
@@ -87,7 +200,7 @@ def _GetSearchText( self, always_autocompleting: bool, force_do_not_collapse: bo
if self._collapse_search_characters and not force_do_not_collapse:
- text = ClientSearch.ConvertTagToSearchable( text )
+ text = ClientSearchTagContext.ConvertTagToSearchable( text )
if allow_auto_wildcard_conversion and self._tag_autocomplete_options.UnnamespacedSearchGivesAnyNamespaceWildcards():
@@ -125,7 +238,7 @@ def _GetSearchText( self, always_autocompleting: bool, force_do_not_collapse: bo
def GetAddTagPredicate( self ):
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, self.raw_content, self.inclusive )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, self.raw_content, self.inclusive )
def GetImmediateFileSearchPredicate( self, allow_auto_wildcard_conversion ):
@@ -142,7 +255,7 @@ def GetImmediateFileSearchPredicate( self, allow_auto_wildcard_conversion ):
return non_tag_predicates[0]
- tag_search_predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, self.raw_content, self.inclusive )
+ tag_search_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, self.raw_content, self.inclusive )
return tag_search_predicate
@@ -159,7 +272,7 @@ def GetNonTagFileSearchPredicates( self, allow_auto_wildcard_conversion ):
( namespace, subtag ) = HydrusTags.SplitTag( search_text )
- predicate = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, namespace, self.inclusive )
+ predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, namespace, self.inclusive )
predicates.append( predicate )
@@ -184,7 +297,7 @@ def GetNonTagFileSearchPredicates( self, allow_auto_wildcard_conversion ):
search_texts = HydrusData.DedupeList( search_texts )
- predicates.extend( ( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, search_text, self.inclusive ) for search_text in search_texts ) )
+ predicates.extend( ( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, search_text, self.inclusive ) for search_text in search_texts ) )
@@ -290,7 +403,7 @@ def IsTagSearch( self, allow_auto_wildcard_conversion ):
search_text = self._GetSearchText( False )
- if ClientSearch.SubtagIsEmpty( search_text ):
+ if SubtagIsEmpty( search_text ):
return False
@@ -346,7 +459,7 @@ def SetInclusive( self, inclusive: bool ):
class PredicateResultsCache( object ):
- def __init__( self, predicates: typing.Iterable[ ClientSearch.Predicate ] ):
+ def __init__( self, predicates: typing.Iterable[ ClientSearchPredicate.Predicate ] ):
self._predicates = list( predicates )
@@ -358,7 +471,7 @@ def CanServeTagResults( self, parsed_autocomplete_text: ParsedAutocompleteText,
def FilterPredicates( self, service_key: bytes, search_text: str ):
- return ClientSearch.FilterPredicatesBySearchText( service_key, search_text, self._predicates )
+ return FilterPredicatesBySearchText( service_key, search_text, self._predicates )
def GetPredicates( self ):
@@ -384,7 +497,7 @@ class PredicateResultsCacheMedia( PredicateResultsCache ):
class PredicateResultsCacheTag( PredicateResultsCache ):
- def __init__( self, predicates: typing.Iterable[ ClientSearch.Predicate ], strict_search_text: str, exact_match: bool ):
+ def __init__( self, predicates: typing.Iterable[ ClientSearchPredicate.Predicate ], strict_search_text: str, exact_match: bool ):
PredicateResultsCache.__init__( self, predicates )
diff --git a/hydrus/client/search/ClientSearchFavouriteSearches.py b/hydrus/client/search/ClientSearchFavouriteSearches.py
new file mode 100644
index 000000000..f7dc242f7
--- /dev/null
+++ b/hydrus/client/search/ClientSearchFavouriteSearches.py
@@ -0,0 +1,164 @@
+import collections
+import threading
+
+from hydrus.core import HydrusExceptions
+from hydrus.core import HydrusSerialisable
+
+class FavouriteSearchManager( HydrusSerialisable.SerialisableBase ):
+
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_FAVOURITE_SEARCH_MANAGER
+ SERIALISABLE_NAME = 'Favourite Search Manager'
+ SERIALISABLE_VERSION = 1
+
+ def __init__( self ):
+
+ super().__init__()
+
+ self._favourite_search_rows = []
+
+ self._lock = threading.Lock()
+ self._dirty = False
+
+
+ def _GetSerialisableInfo( self ):
+
+ serialisable_favourite_search_info = []
+
+ for row in self._favourite_search_rows:
+
+ ( folder, name, file_search_context, synchronised, media_sort, media_collect ) = row
+
+ serialisable_file_search_context = file_search_context.GetSerialisableTuple()
+
+ if media_sort is None:
+
+ serialisable_media_sort = None
+
+ else:
+
+ serialisable_media_sort = media_sort.GetSerialisableTuple()
+
+
+ if media_collect is None:
+
+ serialisable_media_collect = None
+
+ else:
+
+ serialisable_media_collect = media_collect.GetSerialisableTuple()
+
+
+ serialisable_row = ( folder, name, serialisable_file_search_context, synchronised, serialisable_media_sort, serialisable_media_collect )
+
+ serialisable_favourite_search_info.append( serialisable_row )
+
+
+ return serialisable_favourite_search_info
+
+
+ def _InitialiseFromSerialisableInfo( self, serialisable_info ):
+
+ self._favourite_search_rows = []
+
+ for serialisable_row in serialisable_info:
+
+ ( folder, name, serialisable_file_search_context, synchronised, serialisable_media_sort, serialisable_media_collect ) = serialisable_row
+
+ file_search_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_file_search_context )
+
+ if serialisable_media_sort is None:
+
+ media_sort = None
+
+ else:
+
+ media_sort = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_media_sort )
+
+
+ if serialisable_media_collect is None:
+
+ media_collect = None
+
+ else:
+
+ media_collect = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_media_collect )
+
+
+ row = ( folder, name, file_search_context, synchronised, media_sort, media_collect )
+
+ self._favourite_search_rows.append( row )
+
+
+
+ def GetFavouriteSearch( self, desired_folder_name, desired_name ):
+
+ with self._lock:
+
+ for ( folder, name, file_search_context, synchronised, media_sort, media_collect ) in self._favourite_search_rows:
+
+ if folder == desired_folder_name and name == desired_name:
+
+ return ( file_search_context, synchronised, media_sort, media_collect )
+
+
+
+
+ raise HydrusExceptions.DataMissing( 'Could not find a favourite search named "{}"!'.format( desired_name ) )
+
+
+ def GetFavouriteSearchRows( self ):
+
+ return list( self._favourite_search_rows )
+
+
+ def GetFoldersToNames( self ):
+
+ with self._lock:
+
+ folders_to_names = collections.defaultdict( list )
+
+ for ( folder, name, file_search_context, synchronised, media_sort, media_collect ) in self._favourite_search_rows:
+
+ folders_to_names[ folder ].append( name )
+
+
+ return folders_to_names
+
+
+
+ def IsDirty( self ):
+
+ with self._lock:
+
+ return self._dirty
+
+
+
+ def SetClean( self ):
+
+ with self._lock:
+
+ self._dirty = False
+
+
+
+ def SetDirty( self ):
+
+ with self._lock:
+
+ self._dirty = True
+
+
+
+ def SetFavouriteSearchRows( self, favourite_search_rows ):
+
+ with self._lock:
+
+ self._favourite_search_rows = list( favourite_search_rows )
+
+ self._dirty = True
+
+
+
+
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_FAVOURITE_SEARCH_MANAGER ] = FavouriteSearchManager
diff --git a/hydrus/client/search/ClientSearchFileSearchContext.py b/hydrus/client/search/ClientSearchFileSearchContext.py
new file mode 100644
index 000000000..55abc0ed2
--- /dev/null
+++ b/hydrus/client/search/ClientSearchFileSearchContext.py
@@ -0,0 +1,755 @@
+import collections
+import typing
+
+from hydrus.core import HydrusConstants as HC
+from hydrus.core import HydrusSerialisable
+from hydrus.core import HydrusTime
+
+from hydrus.client import ClientConstants as CC
+from hydrus.client import ClientGlobals as CG
+from hydrus.client import ClientLocation
+from hydrus.client import ClientTime
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
+
+SEARCH_TYPE_AND = 0
+SEARCH_TYPE_OR = 1
+
+class FileSystemPredicates( object ):
+
+ def __init__( self, system_predicates: typing.Collection[ ClientSearchPredicate.Predicate ] ):
+
+ self._has_system_everything = False
+
+ self._inbox = False
+ self._archive = False
+ self._local = False
+ self._not_local = False
+
+ self._common_info = {}
+ self._system_pred_types_to_timestamp_ranges_ms = collections.defaultdict( dict )
+
+ self._limit = None
+ self._similar_to_files = None
+ self._similar_to_data = None
+
+ self._required_file_service_statuses = collections.defaultdict( set )
+ self._excluded_file_service_statuses = collections.defaultdict( set )
+
+ self._ratings_predicates = []
+
+ self._num_tags_predicates = []
+ self._num_urls_predicates = []
+
+ self._duplicate_count_predicates = []
+
+ self._king_filter = None
+
+ self._file_viewing_stats_predicates = []
+
+ new_options = CG.client_controller.new_options
+
+ for predicate in system_predicates:
+
+ predicate_type = predicate.GetType()
+ value = predicate.GetValue()
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING: self._has_system_everything = True
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX: self._inbox = True
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE: self._archive = True
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL: self._local = True
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL: self._not_local = True
+
+ for number_test_predicate_type in [
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION,
+ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE
+ ]:
+
+ if predicate_type == number_test_predicate_type:
+
+ if number_test_predicate_type not in self._common_info:
+
+ self._common_info[ number_test_predicate_type ] = []
+
+
+ number_test = value
+
+ self._common_info[ number_test_predicate_type ].append( number_test )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS:
+
+ ( operator, rule_type, rule, description ) = value
+
+ if 'known_url_rules' not in self._common_info:
+
+ self._common_info[ 'known_url_rules' ] = []
+
+
+ self._common_info[ 'known_url_rules' ].append( ( operator, rule_type, rule ) )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO:
+
+ has_audio = value
+
+ self._common_info[ 'has_audio' ] = has_audio
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY:
+
+ has_transparency = value
+
+ self._common_info[ 'has_transparency' ] = has_transparency
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF:
+
+ has_exif = value
+
+ self._common_info[ 'has_exif' ] = has_exif
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA:
+
+ has_human_readable_embedded_metadata = value
+
+ self._common_info[ 'has_human_readable_embedded_metadata' ] = has_human_readable_embedded_metadata
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE:
+
+ has_icc_profile = value
+
+ self._common_info[ 'has_icc_profile' ] = has_icc_profile
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE:
+
+ has_forced_filetype = value
+
+ self._common_info[ 'has_forced_filetype' ] = has_forced_filetype
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH:
+
+ ( hashes, hash_type ) = value
+
+ self._common_info[ 'hash' ] = ( hashes, hash_type, predicate.IsInclusive() )
+
+
+ if predicate_type in ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ):
+
+ ( operator, age_type, age_value ) = value
+
+ if age_type == 'delta':
+
+ ( years, months, days, hours ) = age_value
+
+ dt = HydrusTime.CalendarDeltaToDateTime( years, months, days, hours )
+
+ time_pivot_ms = HydrusTime.DateTimeToTimestampMS( dt )
+
+ # this is backwards (less than means min timestamp) because we are talking about age, not timestamp
+
+ # the before/since semantic logic is:
+ # '<' 7 days age means 'since that date'
+ # '>' 7 days ago means 'before that date'
+
+ if operator == '<':
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = time_pivot_ms
+
+ elif operator == '>':
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = time_pivot_ms
+
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ rough_timedelta_gap = HydrusTime.CalendarDeltaToRoughDateTimeTimeDelta( years, months, days, hours ) * 0.15
+
+ earliest_dt = dt - rough_timedelta_gap
+ latest_dt = dt + rough_timedelta_gap
+
+ earliest_time_pivot_ms = HydrusTime.DateTimeToTimestampMS( earliest_dt )
+ latest_time_pivot_ms = HydrusTime.DateTimeToTimestampMS( latest_dt )
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = earliest_time_pivot_ms
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = latest_time_pivot_ms
+
+
+ elif age_type == 'date':
+
+ ( year, month, day, hour, minute ) = age_value
+
+ dt = HydrusTime.GetDateTime( year, month, day, hour, minute )
+
+ time_pivot_ms = HydrusTime.DateTimeToTimestampMS( dt )
+
+ dt_day_of_start = HydrusTime.GetDateTime( year, month, day, 0, 0 )
+
+ day_of_start_timestamp_ms = HydrusTime.DateTimeToTimestampMS( dt_day_of_start )
+ day_of_end_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt_day_of_start, day_delta = 1 ) )
+
+ # the before/since semantic logic is:
+ # '<' 2022-05-05 means 'before that date'
+ # '>' 2022-05-05 means 'since that date'
+
+ if operator == '<':
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = time_pivot_ms
+
+ elif operator == '>':
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = time_pivot_ms
+
+ elif operator == '=':
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = day_of_start_timestamp_ms
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = day_of_end_timestamp_ms
+
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ previous_month_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt, month_delta = -1 ) )
+ next_month_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt, month_delta = 1 ) )
+
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = previous_month_timestamp_ms
+ self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = next_month_timestamp_ms
+
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME:
+
+ summary_mimes = value
+
+ if isinstance( summary_mimes, int ):
+
+ summary_mimes = ( summary_mimes, )
+
+
+ self._common_info[ 'mimes' ] = ClientSearchPredicate.ConvertSummaryFiletypesToSpecific( summary_mimes )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS:
+
+ self._num_tags_predicates.append( predicate )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING:
+
+ ( operator, value, service_key ) = value
+
+ self._ratings_predicates.append( ( operator, value, service_key ) )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO:
+
+ ( operator, ratio_width, ratio_height ) = value
+
+ if operator == '=': self._common_info[ 'ratio' ] = ( ratio_width, ratio_height )
+ elif operator == 'wider than':
+
+ self._common_info[ 'min_ratio' ] = ( ratio_width, ratio_height )
+
+ elif operator == 'taller than':
+
+ self._common_info[ 'max_ratio' ] = ( ratio_width, ratio_height )
+
+ elif operator == HC.UNICODE_NOT_EQUAL:
+
+ self._common_info[ 'not_ratio' ] = ( ratio_width, ratio_height )
+
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ self._common_info[ 'min_ratio' ] = ( ratio_width * 0.85, ratio_height )
+ self._common_info[ 'max_ratio' ] = ( ratio_width * 1.15, ratio_height )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE:
+
+ ( operator, size, unit ) = value
+
+ size = size * unit
+
+ if operator == '<': self._common_info[ 'max_size' ] = size
+ elif operator == '>': self._common_info[ 'min_size' ] = size
+ elif operator == '=': self._common_info[ 'size' ] = size
+ elif operator == HC.UNICODE_NOT_EQUAL: self._common_info[ 'not_size' ] = size
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ self._common_info[ 'min_size' ] = int( size * 0.85 )
+ self._common_info[ 'max_size' ] = int( size * 1.15 )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:
+
+ ( namespace, operator, num ) = value
+
+ if operator == '<': self._common_info[ 'max_tag_as_number' ] = ( namespace, num )
+ elif operator == '>': self._common_info[ 'min_tag_as_number' ] = ( namespace, num )
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ self._common_info[ 'min_tag_as_number' ] = ( namespace, int( num * 0.85 ) )
+ self._common_info[ 'max_tag_as_number' ] = ( namespace, int( num * 1.15 ) )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS:
+
+ ( operator, num_pixels, unit ) = value
+
+ num_pixels = num_pixels * unit
+
+ if operator == '<': self._common_info[ 'max_num_pixels' ] = num_pixels
+ elif operator == '>': self._common_info[ 'min_num_pixels' ] = num_pixels
+ elif operator == '=': self._common_info[ 'num_pixels' ] = num_pixels
+ elif operator == HC.UNICODE_NOT_EQUAL: self._common_info[ 'not_num_pixels' ] = num_pixels
+ elif operator == HC.UNICODE_APPROX_EQUAL:
+
+ self._common_info[ 'min_num_pixels' ] = int( num_pixels * 0.85 )
+ self._common_info[ 'max_num_pixels' ] = int( num_pixels * 1.15 )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME:
+
+ ( operator, name ) = value
+
+ if operator:
+
+ label = 'has_note_names'
+
+ else:
+
+ label = 'not_has_note_names'
+
+
+ if label not in self._common_info:
+
+ self._common_info[ label ] = set()
+
+
+ self._common_info[ label ].add( name )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT:
+
+ limit = value
+
+ if self._limit is None:
+
+ self._limit = limit
+
+ else:
+
+ self._limit = min( limit, self._limit )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE:
+
+ ( operator, status, service_key ) = value
+
+ if operator:
+
+ self._required_file_service_statuses[ service_key ].add( status )
+
+ else:
+
+ self._excluded_file_service_statuses[ service_key ].add( status )
+
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES:
+
+ ( hashes, max_hamming ) = value
+
+ self._similar_to_files = ( hashes, max_hamming )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA:
+
+ ( pixel_hashes, perceptual_hashes, max_hamming ) = value
+
+ self._similar_to_data = ( pixel_hashes, perceptual_hashes, max_hamming )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT:
+
+ ( operator, num_relationships, dupe_type ) = value
+
+ self._duplicate_count_predicates.append( ( operator, num_relationships, dupe_type ) )
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING:
+
+ king = value
+
+ self._king_filter = king
+
+
+ if predicate_type == ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:
+
+ ( view_type, viewing_locations, operator, viewing_value ) = value
+
+ self._file_viewing_stats_predicates.append( ( view_type, viewing_locations, operator, viewing_value ) )
+
+
+
+
+ def GetDuplicateRelationshipCountPredicates( self ):
+
+ return self._duplicate_count_predicates
+
+
+ def GetFileServiceStatuses( self ):
+
+ return ( self._required_file_service_statuses, self._excluded_file_service_statuses )
+
+
+ def GetFileViewingStatsPredicates( self ):
+
+ return self._file_viewing_stats_predicates
+
+
+ def GetKingFilter( self ):
+
+ return self._king_filter
+
+
+ def GetLimit( self, apply_implicit_limit = True ):
+
+ if self._limit is None and apply_implicit_limit:
+
+ forced_search_limit = CG.client_controller.new_options.GetNoneableInteger( 'forced_search_limit' )
+
+ return forced_search_limit
+
+
+ return self._limit
+
+
+ def GetNumTagsNumberTests( self ) -> typing.Dict[ str, typing.List[ ClientNumberTest.NumberTest ] ]:
+
+ namespaces_to_tests = collections.defaultdict( list )
+
+ for predicate in self._num_tags_predicates:
+
+ ( namespace, operator, value ) = predicate.GetValue()
+
+ test = ClientNumberTest.NumberTest.STATICCreateFromCharacters( operator, value )
+
+ namespaces_to_tests[ namespace ].append( test )
+
+
+ return namespaces_to_tests
+
+
+ def GetRatingsPredicates( self ):
+
+ return self._ratings_predicates
+
+
+ def GetSimilarToData( self ):
+
+ return self._similar_to_data
+
+
+ def GetSimilarToFiles( self ):
+
+ return self._similar_to_files
+
+
+ def GetSimpleInfo( self ):
+
+ return self._common_info
+
+
+ def GetTimestampRangesMS( self ):
+
+ return self._system_pred_types_to_timestamp_ranges_ms
+
+
+ def HasSimilarToData( self ):
+
+ return self._similar_to_data is not None
+
+
+ def HasSimilarToFiles( self ):
+
+ return self._similar_to_files is not None
+
+
+ def HasSystemEverything( self ):
+
+ return self._has_system_everything
+
+
+ def HasSystemLimit( self ):
+
+ return self._limit is not None
+
+
+ def MustBeArchive( self ): return self._archive
+
+ def MustBeInbox( self ): return self._inbox
+
+ def MustBeLocal( self ): return self._local
+
+ def MustNotBeLocal( self ): return self._not_local
+
+
+class FileSearchContext( HydrusSerialisable.SerialisableBase ):
+
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_FILE_SEARCH_CONTEXT
+ SERIALISABLE_NAME = 'File Search Context'
+ SERIALISABLE_VERSION = 5
+
+ def __init__( self, location_context = None, tag_context = None, search_type = SEARCH_TYPE_AND, predicates = None ):
+
+ if location_context is None:
+
+ location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
+
+
+ if tag_context is None:
+
+ tag_context = ClientSearchTagContext.TagContext()
+
+
+ if predicates is None:
+
+ predicates = []
+
+
+ self._location_context = location_context
+ self._tag_context = tag_context
+
+ self._search_type = search_type
+
+ self._predicates = predicates
+
+ self._search_complete = False
+
+ self._InitialiseTemporaryVariables()
+
+
+ def _GetSerialisableInfo( self ):
+
+ serialisable_predicates = [ predicate.GetSerialisableTuple() for predicate in self._predicates ]
+ serialisable_location_context = self._location_context.GetSerialisableTuple()
+
+ return ( serialisable_location_context, self._tag_context.GetSerialisableTuple(), self._search_type, serialisable_predicates, self._search_complete )
+
+
+ def _InitialiseFromSerialisableInfo( self, serialisable_info ):
+
+ ( serialisable_location_context, serialisable_tag_context, self._search_type, serialisable_predicates, self._search_complete ) = serialisable_info
+
+ self._location_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_location_context )
+ self._tag_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_tag_context )
+
+ self._predicates = [ HydrusSerialisable.CreateFromSerialisableTuple( pred_tuple ) for pred_tuple in serialisable_predicates ]
+
+ self._InitialiseTemporaryVariables()
+
+
+ def _InitialiseTemporaryVariables( self ):
+
+ system_predicates = [ predicate for predicate in self._predicates if predicate.GetType() in ClientSearchPredicate.SYSTEM_PREDICATE_TYPES ]
+
+ self._system_predicates = FileSystemPredicates( system_predicates )
+
+ tag_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_TAG ]
+
+ self._tags_to_include = []
+ self._tags_to_exclude = []
+
+ for predicate in tag_predicates:
+
+ tag = predicate.GetValue()
+
+ if predicate.GetInclusive(): self._tags_to_include.append( tag )
+ else: self._tags_to_exclude.append( tag )
+
+
+ namespace_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE ]
+
+ self._namespaces_to_include = []
+ self._namespaces_to_exclude = []
+
+ for predicate in namespace_predicates:
+
+ namespace = predicate.GetValue()
+
+ if predicate.GetInclusive(): self._namespaces_to_include.append( namespace )
+ else: self._namespaces_to_exclude.append( namespace )
+
+
+ wildcard_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_WILDCARD ]
+
+ self._wildcards_to_include = []
+ self._wildcards_to_exclude = []
+
+ for predicate in wildcard_predicates:
+
+ # this is an important convert. preds store nice looking text, but convert for the actual search
+ wildcard = ClientSearchTagContext.ConvertTagToSearchable( predicate.GetValue() )
+
+ if predicate.GetInclusive(): self._wildcards_to_include.append( wildcard )
+ else: self._wildcards_to_exclude.append( wildcard )
+
+
+ self._or_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER ]
+
+
+ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
+
+ if version == 1:
+
+ ( file_service_key_hex, tag_service_key_hex, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
+
+ search_type = SEARCH_TYPE_AND
+
+ new_serialisable_info = ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete )
+
+ return ( 2, new_serialisable_info )
+
+
+ if version == 2:
+
+ ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
+
+ # screwed up the serialisation code for the previous update, so these were getting swapped
+
+ search_type = SEARCH_TYPE_AND
+ include_current_tags = True
+
+ new_serialisable_info = ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete )
+
+ return ( 3, new_serialisable_info )
+
+
+ if version == 3:
+
+ ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
+
+ tag_service_key = bytes.fromhex( tag_service_key_hex )
+
+ tag_context = ClientSearchTagContext.TagContext( service_key = tag_service_key, include_current_tags = include_current_tags, include_pending_tags = include_pending_tags )
+
+ serialisable_tag_context = tag_context.GetSerialisableTuple()
+
+ new_serialisable_info = ( file_service_key_hex, serialisable_tag_context, search_type, serialisable_predicates, search_complete )
+
+ return ( 4, new_serialisable_info )
+
+
+ if version == 4:
+
+ ( file_service_key_hex, serialisable_tag_context, search_type, serialisable_predicates, search_complete ) = old_serialisable_info
+
+ file_service_key = bytes.fromhex( file_service_key_hex )
+
+ location_context = ClientLocation.LocationContext.STATICCreateSimple( file_service_key )
+
+ serialisable_location_context = location_context.GetSerialisableTuple()
+
+ new_serialisable_info = ( serialisable_location_context, serialisable_tag_context, search_type, serialisable_predicates, search_complete )
+
+ return ( 5, new_serialisable_info )
+
+
+
+ def FixMissingServices( self, filter_method ):
+
+ self._location_context.FixMissingServices( filter_method )
+ self._tag_context.FixMissingServices( filter_method )
+
+
+ def GetLocationContext( self ) -> ClientLocation.LocationContext:
+
+ return self._location_context
+
+
+ def GetNamespacesToExclude( self ): return self._namespaces_to_exclude
+ def GetNamespacesToInclude( self ): return self._namespaces_to_include
+ def GetORPredicates( self ): return self._or_predicates
+ def GetPredicates( self ): return self._predicates
+
+ def GetSystemPredicates( self ) -> FileSystemPredicates:
+
+ return self._system_predicates
+
+
+ def GetTagContext( self ) -> ClientSearchTagContext.TagContext:
+
+ return self._tag_context
+
+
+ def GetTagsToExclude( self ): return self._tags_to_exclude
+ def GetTagsToInclude( self ): return self._tags_to_include
+ def GetWildcardsToExclude( self ): return self._wildcards_to_exclude
+ def GetWildcardsToInclude( self ): return self._wildcards_to_include
+
+ def HasNoPredicates( self ):
+
+ return len( self._predicates ) == 0
+
+
+ def IsComplete( self ):
+
+ return self._search_complete
+
+
+ def IsJustSystemEverything( self ):
+
+ return len( self._predicates ) == 1 and self._system_predicates.HasSystemEverything()
+
+
+ def SetComplete( self ):
+
+ self._search_complete = True
+
+
+ def SetLocationContext( self, location_context: ClientLocation.LocationContext ):
+
+ self._location_context = location_context
+
+
+ def SetIncludeCurrentTags( self, value ):
+
+ self._tag_context.include_current_tags = value
+
+
+ def SetIncludePendingTags( self, value ):
+
+ self._tag_context.include_pending_tags = value
+
+
+ def SetPredicates( self, predicates ):
+
+ self._predicates = predicates
+
+ self._InitialiseTemporaryVariables()
+
+
+ def SetTagServiceKey( self, tag_service_key ):
+
+ self._tag_context.service_key = tag_service_key
+ self._tag_context.display_service_key = tag_service_key
+
+
+
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_FILE_SEARCH_CONTEXT ] = FileSearchContext
diff --git a/hydrus/client/search/ClientSearchParseSystemPredicates.py b/hydrus/client/search/ClientSearchParseSystemPredicates.py
index 95798046c..f538f0216 100644
--- a/hydrus/client/search/ClientSearchParseSystemPredicates.py
+++ b/hydrus/client/search/ClientSearchParseSystemPredicates.py
@@ -9,7 +9,8 @@
from hydrus.client import ClientConstants as CC
from hydrus.client import ClientGlobals as CG
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchPredicate
from hydrus.external import SystemPredicateParser
@@ -69,7 +70,7 @@ def date_pred_generator( pred_type, o, v ):
- return ClientSearch.Predicate( pred_type, ( o, date_type, tuple( v ) ) )
+ return ClientSearchPredicate.Predicate( pred_type, ( o, date_type, tuple( v ) ) )
def file_service_pred_generator( o, v, u ):
@@ -118,7 +119,7 @@ def file_service_pred_generator( o, v, u ):
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 ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( is_in, status, service_key ) )
def filetype_pred_generator( v ):
@@ -127,7 +128,7 @@ def filetype_pred_generator( v ):
mimes = ( 1, )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, mimes )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, mimes )
def num_file_relationships_pred_generator( o, v, u ):
@@ -141,7 +142,7 @@ def num_file_relationships_pred_generator( o, v, u ):
dupe_type = u_dict[ u ]
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( o, v, dupe_type ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT, ( o, v, dupe_type ) )
def rating_service_pred_generator( operator, value_and_service_name ):
@@ -166,7 +167,7 @@ def rating_service_pred_generator( operator, value_and_service_name ):
predicate_value = ( operator, value, service_key )
- return ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, value = predicate_value )
+ return ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, value = predicate_value )
def strip_quotes( s: str ) -> str:
@@ -198,7 +199,7 @@ def url_class_pred_generator( include, url_class_name ):
raise ValueError( str( e ) )
- return ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( include, 'url_class', url_class, description ) )
+ return ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( include, 'url_class', url_class, description ) )
SystemPredicateParser.InitialiseFiletypes( HC.mime_enum_lookup )
@@ -206,71 +207,71 @@ def url_class_pred_generator( include, url_class_name ):
SystemPredicateParser.InitialiseFiletypes( { 'gif' : [ HC.IMAGE_GIF, HC.ANIMATION_GIF ] } )
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_TRANSPARENCY : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ),
- SystemPredicateParser.Predicate.NO_TRANSPARENCY : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ),
- SystemPredicateParser.Predicate.HAS_EXIF : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ),
- SystemPredicateParser.Predicate.NO_EXIF : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ),
- SystemPredicateParser.Predicate.HAS_HUMAN_READABLE_EMBEDDED_METADATA : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ),
- SystemPredicateParser.Predicate.NO_HUMAN_READABLE_EMBEDDED_METADATA : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, 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.HAS_FORCED_FILETYPE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ),
- SystemPredicateParser.Predicate.NO_FORCED_FILETYPE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, 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, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ) ),
- SystemPredicateParser.Predicate.NO_DURATION : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ) ),
- SystemPredicateParser.Predicate.HAS_TAGS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '>', 0 ) ),
- SystemPredicateParser.Predicate.UNTAGGED : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) ),
- SystemPredicateParser.Predicate.NUM_OF_TAGS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', o, v ) ),
- SystemPredicateParser.Predicate.NUM_OF_TAGS_WITH_NAMESPACE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, v ),
- SystemPredicateParser.Predicate.NUM_OF_URLS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.NUM_OF_WORDS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.HEIGHT : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.WIDTH : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.FILESIZE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( o, v, HydrusNumbers.UnitToInt( u ) ) ),
- SystemPredicateParser.Predicate.SIMILAR_TO_FILES : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, convert_hex_hashlist_and_other_to_bytes_and_other( v ) ),
- SystemPredicateParser.Predicate.SIMILAR_TO_DATA : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, convert_double_hex_hashlist_and_other_to_double_bytes_and_other( v ) ),
- SystemPredicateParser.Predicate.HASH : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, convert_hex_hashlist_and_other_to_bytes_and_other( v ), inclusive = o == '=' ),
- SystemPredicateParser.Predicate.DURATION : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v[0] * 1000 + v[1] ) ),
- SystemPredicateParser.Predicate.FRAMERATE : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.NUM_OF_FRAMES : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.NUM_PIXELS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( o, v, HydrusNumbers.PixelsToInt( u ) ) ),
- SystemPredicateParser.Predicate.RATIO : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( o, v[0], v[1] ) ),
- SystemPredicateParser.Predicate.RATIO_SPECIAL : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( o, v[0], v[1] ) ),
- SystemPredicateParser.Predicate.TAG_AS_NUMBER : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( o[0], o[1], v ) ),
- SystemPredicateParser.Predicate.MEDIA_VIEWS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'media', ), o, v ) ),
- SystemPredicateParser.Predicate.PREVIEW_VIEWS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'preview', ), o, v ) ),
- SystemPredicateParser.Predicate.ALL_VIEWS : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'media', 'preview' ), o, v ) ),
- SystemPredicateParser.Predicate.MEDIA_VIEWTIME : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'media', ), o, convert_timetuple_to_seconds( v ) ) ),
- SystemPredicateParser.Predicate.PREVIEW_VIEWTIME : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'preview', ), o, convert_timetuple_to_seconds( v ) ) ),
- SystemPredicateParser.Predicate.ALL_VIEWTIME : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'media', 'preview' ), o, convert_timetuple_to_seconds( v ) ) ),
- SystemPredicateParser.Predicate.URL_REGEX : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'regex', v, 'has url matching regex {}'.format( v ) ) ),
- SystemPredicateParser.Predicate.NO_URL_REGEX : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'regex', v, 'does not have url matching regex {}'.format( v ) ) ),
- SystemPredicateParser.Predicate.URL : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'exact_match', v, 'has url {}'.format( v ) ) ),
- SystemPredicateParser.Predicate.NO_URL : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'exact_match', v, 'does not have url {}'.format( v ) ) ),
- SystemPredicateParser.Predicate.DOMAIN : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'domain', v, 'has url with domain {}'.format( v ) ) ),
- SystemPredicateParser.Predicate.NO_DOMAIN : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'domain', v, 'does not have url with domain {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.EVERYTHING : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ),
+ SystemPredicateParser.Predicate.INBOX : lambda o, v, u: ClientSearchPredicate.SYSTEM_PREDICATE_INBOX.Duplicate(),
+ SystemPredicateParser.Predicate.ARCHIVE : lambda o, v, u: ClientSearchPredicate.SYSTEM_PREDICATE_ARCHIVE.Duplicate(),
+ SystemPredicateParser.Predicate.BEST_QUALITY_OF_GROUP : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, True ),
+ SystemPredicateParser.Predicate.NOT_BEST_QUALITY_OF_GROUP : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING, False ),
+ SystemPredicateParser.Predicate.HAS_AUDIO : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True ),
+ SystemPredicateParser.Predicate.NO_AUDIO : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False ),
+ SystemPredicateParser.Predicate.HAS_TRANSPARENCY : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True ),
+ SystemPredicateParser.Predicate.NO_TRANSPARENCY : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False ),
+ SystemPredicateParser.Predicate.HAS_EXIF : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True ),
+ SystemPredicateParser.Predicate.NO_EXIF : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False ),
+ SystemPredicateParser.Predicate.HAS_HUMAN_READABLE_EMBEDDED_METADATA : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True ),
+ SystemPredicateParser.Predicate.NO_HUMAN_READABLE_EMBEDDED_METADATA : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False ),
+ SystemPredicateParser.Predicate.HAS_ICC_PROFILE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True ),
+ SystemPredicateParser.Predicate.NO_ICC_PROFILE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False ),
+ SystemPredicateParser.Predicate.HAS_FORCED_FILETYPE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True ),
+ SystemPredicateParser.Predicate.NO_FORCED_FILETYPE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False ),
+ SystemPredicateParser.Predicate.LIMIT : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, v ),
+ SystemPredicateParser.Predicate.FILETYPE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, tuple( v ) ),
+ SystemPredicateParser.Predicate.HAS_DURATION : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) ),
+ SystemPredicateParser.Predicate.NO_DURATION : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) ),
+ SystemPredicateParser.Predicate.HAS_TAGS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '>', 0 ) ),
+ SystemPredicateParser.Predicate.UNTAGGED : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '=', 0 ) ),
+ SystemPredicateParser.Predicate.NUM_OF_TAGS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', o, v ) ),
+ SystemPredicateParser.Predicate.NUM_OF_TAGS_WITH_NAMESPACE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, v ),
+ SystemPredicateParser.Predicate.NUM_OF_URLS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.NUM_OF_WORDS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.HEIGHT : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.WIDTH : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.FILESIZE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( o, v, HydrusNumbers.UnitToInt( u ) ) ),
+ SystemPredicateParser.Predicate.SIMILAR_TO_FILES : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, convert_hex_hashlist_and_other_to_bytes_and_other( v ) ),
+ SystemPredicateParser.Predicate.SIMILAR_TO_DATA : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, convert_double_hex_hashlist_and_other_to_double_bytes_and_other( v ) ),
+ SystemPredicateParser.Predicate.HASH : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, convert_hex_hashlist_and_other_to_bytes_and_other( v ), inclusive = o == '=' ),
+ SystemPredicateParser.Predicate.DURATION : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v[0] * 1000 + v[1] ) ),
+ SystemPredicateParser.Predicate.FRAMERATE : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FRAMERATE, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.NUM_OF_FRAMES : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_FRAMES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.NUM_PIXELS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_PIXELS, ( o, v, HydrusNumbers.PixelsToInt( u ) ) ),
+ SystemPredicateParser.Predicate.RATIO : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( o, v[0], v[1] ) ),
+ SystemPredicateParser.Predicate.RATIO_SPECIAL : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( o, v[0], v[1] ) ),
+ SystemPredicateParser.Predicate.TAG_AS_NUMBER : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ( o[0], o[1], v ) ),
+ SystemPredicateParser.Predicate.MEDIA_VIEWS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'media', ), o, v ) ),
+ SystemPredicateParser.Predicate.PREVIEW_VIEWS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'preview', ), o, v ) ),
+ SystemPredicateParser.Predicate.ALL_VIEWS : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'views', ( 'media', 'preview' ), o, v ) ),
+ SystemPredicateParser.Predicate.MEDIA_VIEWTIME : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'media', ), o, convert_timetuple_to_seconds( v ) ) ),
+ SystemPredicateParser.Predicate.PREVIEW_VIEWTIME : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'preview', ), o, convert_timetuple_to_seconds( v ) ) ),
+ SystemPredicateParser.Predicate.ALL_VIEWTIME : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS, ( 'viewtime', ( 'media', 'preview' ), o, convert_timetuple_to_seconds( v ) ) ),
+ SystemPredicateParser.Predicate.URL_REGEX : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'regex', v, 'has url matching regex {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.NO_URL_REGEX : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'regex', v, 'does not have url matching regex {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.URL : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'exact_match', v, 'has url {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.NO_URL : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'exact_match', v, 'does not have url {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.DOMAIN : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( True, 'domain', v, 'has url with domain {}'.format( v ) ) ),
+ SystemPredicateParser.Predicate.NO_DOMAIN : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_KNOWN_URLS, ( False, 'domain', v, 'does not have url with domain {}'.format( v ) ) ),
SystemPredicateParser.Predicate.URL_CLASS : lambda o, v, u: url_class_pred_generator( True, v ),
SystemPredicateParser.Predicate.NO_URL_CLASS : lambda o, v, u: url_class_pred_generator( False, v ),
- SystemPredicateParser.Predicate.MOD_DATE : lambda o, v, u: date_pred_generator( ClientSearch.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, o, v ),
- SystemPredicateParser.Predicate.ARCHIVED_DATE : lambda o, v, u: date_pred_generator( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, o, v ),
- SystemPredicateParser.Predicate.LAST_VIEWED_TIME : lambda o, v, u: date_pred_generator( ClientSearch.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, o, v ),
- SystemPredicateParser.Predicate.TIME_IMPORTED : lambda o, v, u: date_pred_generator( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, o, v ),
+ SystemPredicateParser.Predicate.MOD_DATE : lambda o, v, u: date_pred_generator( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, o, v ),
+ SystemPredicateParser.Predicate.ARCHIVED_DATE : lambda o, v, u: date_pred_generator( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME, o, v ),
+ SystemPredicateParser.Predicate.LAST_VIEWED_TIME : lambda o, v, u: date_pred_generator( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, o, v ),
+ SystemPredicateParser.Predicate.TIME_IMPORTED : lambda o, v, u: date_pred_generator( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, o, v ),
SystemPredicateParser.Predicate.FILE_SERVICE : file_service_pred_generator,
SystemPredicateParser.Predicate.NUM_FILE_RELS : num_file_relationships_pred_generator,
- SystemPredicateParser.Predicate.HAS_NOTES : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ) ),
- SystemPredicateParser.Predicate.NO_NOTES : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ) ),
- SystemPredicateParser.Predicate.NUM_NOTES : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientSearch.NumberTest.STATICCreateFromCharacters( o, v ) ),
- SystemPredicateParser.Predicate.HAS_NOTE_NAME : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( True, strip_quotes( v ) ) ),
- SystemPredicateParser.Predicate.NO_NOTE_NAME : lambda o, v, u: ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( False, strip_quotes( v ) ) ),
+ SystemPredicateParser.Predicate.HAS_NOTES : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) ),
+ SystemPredicateParser.Predicate.NO_NOTES : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) ),
+ SystemPredicateParser.Predicate.NUM_NOTES : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_NOTES, ClientNumberTest.NumberTest.STATICCreateFromCharacters( o, v ) ),
+ SystemPredicateParser.Predicate.HAS_NOTE_NAME : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( True, strip_quotes( v ) ) ),
+ SystemPredicateParser.Predicate.NO_NOTE_NAME : lambda o, v, u: ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME, ( False, strip_quotes( v ) ) ),
SystemPredicateParser.Predicate.HAS_RATING : lambda o, v, u: rating_service_pred_generator( '=', ( 'rated', v ) ),
SystemPredicateParser.Predicate.NO_RATING : lambda o, v, u: rating_service_pred_generator( '=', ( 'not rated', v ) ),
SystemPredicateParser.Predicate.RATING_SPECIFIC_NUMERICAL : lambda o, v, u: rating_service_pred_generator( o, v ),
@@ -278,7 +279,7 @@ def url_class_pred_generator( include, url_class_name ):
SystemPredicateParser.Predicate.RATING_SPECIFIC_INCDEC : lambda o, v, u: rating_service_pred_generator( o, v )
}
-def ParseSystemPredicateStringsToPredicates( system_predicate_strings: typing.Collection[ str ], discard_failures = False ) -> typing.List[ ClientSearch.Predicate ]:
+def ParseSystemPredicateStringsToPredicates( system_predicate_strings: typing.Collection[ str ], discard_failures = False ) -> typing.List[ ClientSearchPredicate.Predicate ]:
system_predicates = []
diff --git a/hydrus/client/search/ClientSearch.py b/hydrus/client/search/ClientSearchPredicate.py
similarity index 57%
rename from hydrus/client/search/ClientSearch.py
rename to hydrus/client/search/ClientSearchPredicate.py
index 2bd2fa1f5..16a674e24 100644
--- a/hydrus/client/search/ClientSearch.py
+++ b/hydrus/client/search/ClientSearchPredicate.py
@@ -1,7 +1,4 @@
-import collections
import datetime
-import re
-import threading
import typing
from hydrus.core import HydrusConstants as HC
@@ -10,15 +7,13 @@
from hydrus.core import HydrusNumbers
from hydrus.core import HydrusSerialisable
from hydrus.core import HydrusTags
-from hydrus.core import HydrusText
from hydrus.core import HydrusTime
-from hydrus.client import ClientConstants as CC
from hydrus.client import ClientData
from hydrus.client import ClientGlobals as CG
-from hydrus.client import ClientLocation
-from hydrus.client import ClientTime
+from hydrus.client.media import ClientMediaResult
from hydrus.client.metadata import ClientTags
+from hydrus.client.search import ClientNumberTest
PREDICATE_TYPE_TAG = 0
PREDICATE_TYPE_NAMESPACE = 1
@@ -126,1474 +121,71 @@
PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE
}
-IGNORED_TAG_SEARCH_CHARACTERS = '[](){}/\\"\'-_'
-IGNORED_TAG_SEARCH_CHARACTERS_UNICODE_TRANSLATE = { ord( char ) : ' ' for char in IGNORED_TAG_SEARCH_CHARACTERS }
-
-def CollapseWildcardCharacters( text ):
-
- while '**' in text:
-
- text = text.replace( '**', '*' )
-
-
- return text
-
-
-def ConvertSpecificFiletypesToSummary( specific_mimes: typing.Collection[ int ], only_searchable = True ) -> typing.Collection[ int ]:
-
- specific_mimes_to_process = set( specific_mimes )
-
- summary_mimes = set()
-
- for ( general_mime, mime_group ) in HC.general_mimetypes_to_mime_groups.items():
-
- if only_searchable:
-
- mime_group = set( mime_group )
- mime_group.intersection_update( HC.SEARCHABLE_MIMES )
-
-
- if specific_mimes_to_process.issuperset( mime_group ):
-
- summary_mimes.add( general_mime )
- specific_mimes_to_process.difference_update( mime_group )
-
-
-
- summary_mimes.update( specific_mimes_to_process )
-
- return summary_mimes
-
-
-def ConvertSubtagToSearchable( subtag ):
-
- if subtag == '':
-
- return ''
-
-
- subtag = CollapseWildcardCharacters( subtag )
-
- subtag = subtag.translate( IGNORED_TAG_SEARCH_CHARACTERS_UNICODE_TRANSLATE )
-
- subtag = HydrusText.re_one_or_more_whitespace.sub( ' ', subtag )
-
- subtag = subtag.strip()
-
- return subtag
-
-
-def ConvertSummaryFiletypesToSpecific( summary_mimes: typing.Collection[ int ], only_searchable = True ) -> typing.Collection[ int ]:
-
- specific_mimes = set()
-
- for mime in summary_mimes:
-
- if mime in HC.GENERAL_FILETYPES:
-
- specific_mimes.update( HC.general_mimetypes_to_mime_groups[ mime ] )
-
- else:
-
- specific_mimes.add( mime )
-
-
-
- if only_searchable:
-
- specific_mimes.intersection_update( HC.SEARCHABLE_MIMES )
-
-
- return specific_mimes
-
-
-def ConvertSummaryFiletypesToString( summary_mimes: typing.Collection[ int ] ) -> str:
-
- if set( summary_mimes ) == HC.GENERAL_FILETYPES:
-
- mime_text = 'anything'
-
- else:
-
- summary_mimes = sorted( summary_mimes, key = lambda m: HC.mime_mimetype_string_lookup[ m ] )
-
- mime_text = ', '.join( [ HC.mime_string_lookup[ mime ] for mime in summary_mimes ] )
-
-
- return mime_text
-
-
-def ConvertTagToSearchable( tag ):
-
- ( namespace, subtag ) = HydrusTags.SplitTag( tag )
-
- searchable_subtag = ConvertSubtagToSearchable( subtag )
-
- return HydrusTags.CombineTag( namespace, searchable_subtag )
-
-
-def MergePredicates( predicates ):
-
- master_predicate_dict = {}
-
- for predicate in predicates:
-
- # this works because predicate.__hash__ exists
-
- if predicate in master_predicate_dict:
-
- master_predicate_dict[ predicate ].GetCount().AddCounts( predicate.GetCount() )
-
- else:
-
- master_predicate_dict[ predicate ] = predicate
-
-
-
- return list( master_predicate_dict.values() )
-
-
-def IsComplexWildcard( search_text ):
-
- num_stars = search_text.count( '*' )
-
- if num_stars > 1:
-
- return True
-
-
- if num_stars == 1 and not search_text.endswith( '*' ):
-
- return True
-
-
- return False
-
-
-def SortPredicates( predicates ):
-
- key = lambda p: ( - p.GetCount().GetMinCount(), p.ToString() )
-
- predicates.sort( key = key )
-
- return predicates
-
-
-def SubtagIsEmpty( search_text: str ):
-
- ( namespace, subtag ) = HydrusTags.SplitTag( search_text )
-
- return subtag == ''
-
-
-NUMBER_TEST_OPERATOR_LESS_THAN = 0
-NUMBER_TEST_OPERATOR_GREATER_THAN = 1
-NUMBER_TEST_OPERATOR_EQUAL = 2
-NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT = 3
-NUMBER_TEST_OPERATOR_NOT_EQUAL = 4
-NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE = 5
-
-number_test_operator_to_str_lookup = {
- NUMBER_TEST_OPERATOR_LESS_THAN : '<',
- NUMBER_TEST_OPERATOR_GREATER_THAN : '>',
- NUMBER_TEST_OPERATOR_EQUAL : '=',
- NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT : HC.UNICODE_APPROX_EQUAL,
- NUMBER_TEST_OPERATOR_NOT_EQUAL : HC.UNICODE_NOT_EQUAL,
- NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE : HC.UNICODE_APPROX_EQUAL
-}
-
-number_test_str_to_operator_lookup = { value : key for ( key, value ) in number_test_operator_to_str_lookup.items() if key != NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE }
-
-class NumberTest( HydrusSerialisable.SerialisableBase ):
-
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_NUMBER_TEST
- SERIALISABLE_NAME = 'Number Test'
- SERIALISABLE_VERSION = 2
-
- def __init__( self, operator = NUMBER_TEST_OPERATOR_EQUAL, value = 1, extra_value = None ):
-
- super().__init__()
-
- if operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT and value == 0:
-
- operator = NUMBER_TEST_OPERATOR_EQUAL
- extra_value = None
-
-
- self.operator = operator
- self.value = value
-
- if extra_value is None:
-
- if self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
-
- extra_value = 0.15
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
-
- extra_value = 1
-
-
-
- self.extra_value = extra_value
-
-
- def __eq__( self, other ):
-
- if isinstance( other, NumberTest ):
-
- return self.__hash__() == other.__hash__()
-
-
- return NotImplemented
-
-
- def __hash__( self ):
-
- return ( self.operator, self.value, self.extra_value ).__hash__()
-
-
- def __repr__( self ):
-
- return self.ToString()
-
-
- def _GetSerialisableInfo( self ):
-
- return ( self.operator, self.value, self.extra_value )
-
-
- def _InitialiseFromSerialisableInfo( self, serialisable_info ):
-
- ( self.operator, self.value, self.extra_value ) = serialisable_info
-
-
- def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
-
- if version == 1:
-
- ( operator, value ) = old_serialisable_info
-
- if operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
-
- extra_value = 0.15
-
- else:
-
- extra_value = None
-
-
- new_serialisable_info = ( operator, value, extra_value )
-
- return ( 2, new_serialisable_info )
-
-
-
- def GetLambda( self ):
-
- if self.operator == NUMBER_TEST_OPERATOR_LESS_THAN:
-
- if self.value > 0:
-
- return lambda x: x is None or x < self.value
-
- else:
-
- return lambda x: x is not None and x < self.value
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_GREATER_THAN:
-
- if self.value < 0:
-
- return lambda x: x is None or x > self.value
-
- else:
-
- return lambda x: x is not None and x > self.value
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_EQUAL:
-
- if self.value == 0:
-
- return lambda x: x is None or x == self.value
-
- else:
-
- return lambda x: x == self.value
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
-
- lower = self.value * ( 1 - self.extra_value )
- upper = self.value * ( 1 + self.extra_value )
-
- if lower <= 0:
-
- return lambda x: x is None or x < upper
-
- else:
-
- return lambda x: x is not None and lower < x < upper
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
-
- lower = self.value - self.extra_value
- upper = self.value + self.extra_value
-
- if lower <= 0:
-
- return lambda x: x is None or x < upper
-
- else:
-
- return lambda x: x is not None and lower < x < upper
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_NOT_EQUAL:
-
- if self.value == 0:
-
- return lambda x: x is not None and x != self.value
-
- else:
-
- return lambda x: x is None or x != self.value
-
-
-
-
- def GetSQLitePredicates( self, variable_name ):
-
- if self.operator == NUMBER_TEST_OPERATOR_LESS_THAN:
-
- if self.value > 0:
-
- return [ f'( {variable_name} IS NULL OR {variable_name} < {self.value} )' ]
-
- else:
-
- return [ f'{variable_name} < {self.value}' ]
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_GREATER_THAN:
-
- if self.value < 0:
-
- return [ f'( {variable_name} IS NULL OR {variable_name} > {self.value} )' ]
-
- else:
-
- return [ f'{variable_name} > {self.value}' ]
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_EQUAL:
-
- if self.value == 0:
-
- return [ f'( {variable_name} IS NULL OR {variable_name} = {self.value} )' ]
-
- else:
-
- return [ f'{variable_name} = {self.value}' ]
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
-
- lower = self.value * ( 1 - self.extra_value )
- upper = self.value * ( 1 + self.extra_value )
-
- if lower <= 0:
-
- return [ f'( {variable_name} is NULL OR {variable_name} < {upper} )' ]
-
- else:
-
- return [ f'{variable_name} > {lower}', f'{variable_name} < {upper}' ]
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
-
- lower = self.value - self.extra_value
- upper = self.value + self.extra_value
-
- if lower <= 0:
-
- return [ f'( {variable_name} IS NULL OR {variable_name} < {upper} )' ]
-
- else:
-
- return [ f'{variable_name} > {lower}', f'{variable_name} < {upper}' ]
-
-
- elif self.operator == NUMBER_TEST_OPERATOR_NOT_EQUAL:
-
- if self.value == 0:
-
- return [ f'{variable_name} IS NOT NULL AND {variable_name} != {self.value}' ]
-
- else:
-
- return [ f'( {variable_name} IS NULL OR {variable_name} != {self.value} )' ]
-
-
-
- return []
-
-
- def IsAnythingButZero( self ):
-
- return self.operator in ( NUMBER_TEST_OPERATOR_NOT_EQUAL, NUMBER_TEST_OPERATOR_GREATER_THAN ) and self.value == 0
-
-
- def IsZero( self ):
-
- actually_zero = self.operator == NUMBER_TEST_OPERATOR_EQUAL and self.value == 0
- less_than_one = self.operator == NUMBER_TEST_OPERATOR_LESS_THAN and self.value == 1
-
- return actually_zero or less_than_one
-
-
- def ToString( self, absolute_number_renderer: typing.Optional[ typing.Callable ] = None ) -> str:
-
- if absolute_number_renderer is None:
-
- absolute_number_renderer = HydrusNumbers.ToHumanInt
-
-
- result = f'{number_test_operator_to_str_lookup[ self.operator ]} {absolute_number_renderer( self.value )}'
-
- if self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT:
-
- result += f' {HC.UNICODE_PLUS_OR_MINUS}{HydrusNumbers.FloatToPercentage(self.extra_value)}'
-
- elif self.operator == NUMBER_TEST_OPERATOR_APPROXIMATE_ABSOLUTE:
-
- result += f' {HC.UNICODE_PLUS_OR_MINUS}{absolute_number_renderer(self.extra_value)}'
-
-
- return result
-
-
- def WantsZero( self ):
-
- return self.GetLambda()( 0 )
-
-
- @staticmethod
- def STATICCreateFromCharacters( operator_str: str, value: int ) -> "NumberTest":
-
- operator = number_test_str_to_operator_lookup[ operator_str ]
-
- return NumberTest( operator, value )
-
-
- @staticmethod
- def STATICCreateMegaLambda( number_tests: typing.Collection[ "NumberTest" ] ):
-
- lambdas = [ number_test.GetLambda() for number_test in number_tests ]
-
- return lambda x: False not in ( lamb( x ) for lamb in lambdas )
-
-
-
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_NUMBER_TEST ] = NumberTest
-
-class FileSystemPredicates( object ):
-
- def __init__( self, system_predicates: typing.Collection[ "Predicate" ] ):
-
- self._has_system_everything = False
-
- self._inbox = False
- self._archive = False
- self._local = False
- self._not_local = False
-
- self._common_info = {}
- self._system_pred_types_to_timestamp_ranges_ms = collections.defaultdict( dict )
-
- self._limit = None
- self._similar_to_files = None
- self._similar_to_data = None
-
- self._required_file_service_statuses = collections.defaultdict( set )
- self._excluded_file_service_statuses = collections.defaultdict( set )
-
- self._ratings_predicates = []
-
- self._num_tags_predicates = []
- self._num_urls_predicates = []
-
- self._duplicate_count_predicates = []
-
- self._king_filter = None
-
- self._file_viewing_stats_predicates = []
-
- new_options = CG.client_controller.new_options
-
- for predicate in system_predicates:
-
- predicate_type = predicate.GetType()
- value = predicate.GetValue()
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_EVERYTHING: self._has_system_everything = True
- if predicate_type == PREDICATE_TYPE_SYSTEM_INBOX: self._inbox = True
- if predicate_type == PREDICATE_TYPE_SYSTEM_ARCHIVE: self._archive = True
- if predicate_type == PREDICATE_TYPE_SYSTEM_LOCAL: self._local = True
- if predicate_type == PREDICATE_TYPE_SYSTEM_NOT_LOCAL: self._not_local = True
-
- for number_test_predicate_type in [
- PREDICATE_TYPE_SYSTEM_WIDTH,
- PREDICATE_TYPE_SYSTEM_HEIGHT,
- PREDICATE_TYPE_SYSTEM_NUM_NOTES,
- PREDICATE_TYPE_SYSTEM_NUM_WORDS,
- PREDICATE_TYPE_SYSTEM_NUM_URLS,
- PREDICATE_TYPE_SYSTEM_NUM_FRAMES,
- PREDICATE_TYPE_SYSTEM_DURATION,
- PREDICATE_TYPE_SYSTEM_FRAMERATE
- ]:
-
- if predicate_type == number_test_predicate_type:
-
- if number_test_predicate_type not in self._common_info:
-
- self._common_info[ number_test_predicate_type ] = []
-
-
- number_test = value
-
- self._common_info[ number_test_predicate_type ].append( number_test )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_KNOWN_URLS:
-
- ( operator, rule_type, rule, description ) = value
-
- if 'known_url_rules' not in self._common_info:
-
- self._common_info[ 'known_url_rules' ] = []
-
-
- self._common_info[ 'known_url_rules' ].append( ( operator, rule_type, rule ) )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_AUDIO:
-
- has_audio = value
-
- self._common_info[ 'has_audio' ] = has_audio
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY:
-
- has_transparency = value
-
- self._common_info[ 'has_transparency' ] = has_transparency
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_EXIF:
-
- has_exif = value
-
- self._common_info[ 'has_exif' ] = has_exif
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA:
-
- has_human_readable_embedded_metadata = value
-
- self._common_info[ 'has_human_readable_embedded_metadata' ] = has_human_readable_embedded_metadata
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE:
-
- has_icc_profile = value
-
- self._common_info[ 'has_icc_profile' ] = has_icc_profile
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE:
-
- has_forced_filetype = value
-
- self._common_info[ 'has_forced_filetype' ] = has_forced_filetype
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HASH:
-
- ( hashes, hash_type ) = value
-
- self._common_info[ 'hash' ] = ( hashes, hash_type, predicate.IsInclusive() )
-
-
- if predicate_type in ( PREDICATE_TYPE_SYSTEM_AGE, PREDICATE_TYPE_SYSTEM_LAST_VIEWED_TIME, PREDICATE_TYPE_SYSTEM_MODIFIED_TIME, PREDICATE_TYPE_SYSTEM_ARCHIVED_TIME ):
-
- ( operator, age_type, age_value ) = value
-
- if age_type == 'delta':
-
- ( years, months, days, hours ) = age_value
-
- dt = HydrusTime.CalendarDeltaToDateTime( years, months, days, hours )
-
- time_pivot_ms = HydrusTime.DateTimeToTimestampMS( dt )
-
- # this is backwards (less than means min timestamp) because we are talking about age, not timestamp
-
- # the before/since semantic logic is:
- # '<' 7 days age means 'since that date'
- # '>' 7 days ago means 'before that date'
-
- if operator == '<':
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = time_pivot_ms
-
- elif operator == '>':
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = time_pivot_ms
-
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- rough_timedelta_gap = HydrusTime.CalendarDeltaToRoughDateTimeTimeDelta( years, months, days, hours ) * 0.15
-
- earliest_dt = dt - rough_timedelta_gap
- latest_dt = dt + rough_timedelta_gap
-
- earliest_time_pivot_ms = HydrusTime.DateTimeToTimestampMS( earliest_dt )
- latest_time_pivot_ms = HydrusTime.DateTimeToTimestampMS( latest_dt )
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = earliest_time_pivot_ms
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = latest_time_pivot_ms
-
-
- elif age_type == 'date':
-
- ( year, month, day, hour, minute ) = age_value
-
- dt = HydrusTime.GetDateTime( year, month, day, hour, minute )
-
- time_pivot_ms = HydrusTime.DateTimeToTimestampMS( dt )
-
- dt_day_of_start = HydrusTime.GetDateTime( year, month, day, 0, 0 )
-
- day_of_start_timestamp_ms = HydrusTime.DateTimeToTimestampMS( dt_day_of_start )
- day_of_end_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt_day_of_start, day_delta = 1 ) )
-
- # the before/since semantic logic is:
- # '<' 2022-05-05 means 'before that date'
- # '>' 2022-05-05 means 'since that date'
-
- if operator == '<':
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = time_pivot_ms
-
- elif operator == '>':
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = time_pivot_ms
-
- elif operator == '=':
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = day_of_start_timestamp_ms
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = day_of_end_timestamp_ms
-
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- previous_month_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt, month_delta = -1 ) )
- next_month_timestamp_ms = HydrusTime.DateTimeToTimestampMS( ClientTime.CalendarDelta( dt, month_delta = 1 ) )
-
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '>' ] = previous_month_timestamp_ms
- self._system_pred_types_to_timestamp_ranges_ms[ predicate_type ][ '<' ] = next_month_timestamp_ms
-
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_MIME:
-
- summary_mimes = value
-
- if isinstance( summary_mimes, int ):
-
- summary_mimes = ( summary_mimes, )
-
-
- self._common_info[ 'mimes' ] = ConvertSummaryFiletypesToSpecific( summary_mimes )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_NUM_TAGS:
-
- self._num_tags_predicates.append( predicate )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_RATING:
-
- ( operator, value, service_key ) = value
-
- self._ratings_predicates.append( ( operator, value, service_key ) )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_RATIO:
-
- ( operator, ratio_width, ratio_height ) = value
-
- if operator == '=': self._common_info[ 'ratio' ] = ( ratio_width, ratio_height )
- elif operator == 'wider than':
-
- self._common_info[ 'min_ratio' ] = ( ratio_width, ratio_height )
-
- elif operator == 'taller than':
-
- self._common_info[ 'max_ratio' ] = ( ratio_width, ratio_height )
-
- elif operator == HC.UNICODE_NOT_EQUAL:
-
- self._common_info[ 'not_ratio' ] = ( ratio_width, ratio_height )
-
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- self._common_info[ 'min_ratio' ] = ( ratio_width * 0.85, ratio_height )
- self._common_info[ 'max_ratio' ] = ( ratio_width * 1.15, ratio_height )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_SIZE:
-
- ( operator, size, unit ) = value
-
- size = size * unit
-
- if operator == '<': self._common_info[ 'max_size' ] = size
- elif operator == '>': self._common_info[ 'min_size' ] = size
- elif operator == '=': self._common_info[ 'size' ] = size
- elif operator == HC.UNICODE_NOT_EQUAL: self._common_info[ 'not_size' ] = size
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- self._common_info[ 'min_size' ] = int( size * 0.85 )
- self._common_info[ 'max_size' ] = int( size * 1.15 )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER:
-
- ( namespace, operator, num ) = value
-
- if operator == '<': self._common_info[ 'max_tag_as_number' ] = ( namespace, num )
- elif operator == '>': self._common_info[ 'min_tag_as_number' ] = ( namespace, num )
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- self._common_info[ 'min_tag_as_number' ] = ( namespace, int( num * 0.85 ) )
- self._common_info[ 'max_tag_as_number' ] = ( namespace, int( num * 1.15 ) )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_NUM_PIXELS:
-
- ( operator, num_pixels, unit ) = value
-
- num_pixels = num_pixels * unit
-
- if operator == '<': self._common_info[ 'max_num_pixels' ] = num_pixels
- elif operator == '>': self._common_info[ 'min_num_pixels' ] = num_pixels
- elif operator == '=': self._common_info[ 'num_pixels' ] = num_pixels
- elif operator == HC.UNICODE_NOT_EQUAL: self._common_info[ 'not_num_pixels' ] = num_pixels
- elif operator == HC.UNICODE_APPROX_EQUAL:
-
- self._common_info[ 'min_num_pixels' ] = int( num_pixels * 0.85 )
- self._common_info[ 'max_num_pixels' ] = int( num_pixels * 1.15 )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_HAS_NOTE_NAME:
-
- ( operator, name ) = value
-
- if operator:
-
- label = 'has_note_names'
-
- else:
-
- label = 'not_has_note_names'
-
-
- if label not in self._common_info:
-
- self._common_info[ label ] = set()
-
-
- self._common_info[ label ].add( name )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_LIMIT:
-
- limit = value
-
- if self._limit is None:
-
- self._limit = limit
-
- else:
-
- self._limit = min( limit, self._limit )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_FILE_SERVICE:
-
- ( operator, status, service_key ) = value
-
- if operator:
-
- self._required_file_service_statuses[ service_key ].add( status )
-
- else:
-
- self._excluded_file_service_statuses[ service_key ].add( status )
-
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES:
-
- ( hashes, max_hamming ) = value
-
- self._similar_to_files = ( hashes, max_hamming )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA:
-
- ( pixel_hashes, perceptual_hashes, max_hamming ) = value
-
- self._similar_to_data = ( pixel_hashes, perceptual_hashes, max_hamming )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT:
-
- ( operator, num_relationships, dupe_type ) = value
-
- self._duplicate_count_predicates.append( ( operator, num_relationships, dupe_type ) )
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING:
-
- king = value
-
- self._king_filter = king
-
-
- if predicate_type == PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS:
-
- ( view_type, viewing_locations, operator, viewing_value ) = value
-
- self._file_viewing_stats_predicates.append( ( view_type, viewing_locations, operator, viewing_value ) )
-
-
-
-
- def GetDuplicateRelationshipCountPredicates( self ):
-
- return self._duplicate_count_predicates
-
-
- def GetFileServiceStatuses( self ):
-
- return ( self._required_file_service_statuses, self._excluded_file_service_statuses )
-
-
- def GetFileViewingStatsPredicates( self ):
-
- return self._file_viewing_stats_predicates
-
-
- def GetKingFilter( self ):
-
- return self._king_filter
-
-
- def GetLimit( self, apply_implicit_limit = True ):
-
- if self._limit is None and apply_implicit_limit:
-
- forced_search_limit = CG.client_controller.new_options.GetNoneableInteger( 'forced_search_limit' )
-
- return forced_search_limit
-
-
- return self._limit
-
-
- def GetNumTagsNumberTests( self ) -> typing.Dict[ str, typing.List[ NumberTest ] ]:
-
- namespaces_to_tests = collections.defaultdict( list )
-
- for predicate in self._num_tags_predicates:
-
- ( namespace, operator, value ) = predicate.GetValue()
-
- test = NumberTest.STATICCreateFromCharacters( operator, value )
-
- namespaces_to_tests[ namespace ].append( test )
-
-
- return namespaces_to_tests
-
-
- def GetRatingsPredicates( self ):
-
- return self._ratings_predicates
-
-
- def GetSimilarToData( self ):
-
- return self._similar_to_data
-
-
- def GetSimilarToFiles( self ):
-
- return self._similar_to_files
-
-
- def GetSimpleInfo( self ):
-
- return self._common_info
-
-
- def GetTimestampRangesMS( self ):
-
- return self._system_pred_types_to_timestamp_ranges_ms
-
-
- def HasSimilarToData( self ):
-
- return self._similar_to_data is not None
-
-
- def HasSimilarToFiles( self ):
-
- return self._similar_to_files is not None
-
-
- def HasSystemEverything( self ):
-
- return self._has_system_everything
-
-
- def HasSystemLimit( self ):
-
- return self._limit is not None
-
-
- def MustBeArchive( self ): return self._archive
-
- def MustBeInbox( self ): return self._inbox
-
- def MustBeLocal( self ): return self._local
-
- def MustNotBeLocal( self ): return self._not_local
-
-
-SEARCH_TYPE_AND = 0
-SEARCH_TYPE_OR = 1
-
-class FileSearchContext( HydrusSerialisable.SerialisableBase ):
-
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_FILE_SEARCH_CONTEXT
- SERIALISABLE_NAME = 'File Search Context'
- SERIALISABLE_VERSION = 5
-
- def __init__( self, location_context = None, tag_context = None, search_type = SEARCH_TYPE_AND, predicates = None ):
-
- if location_context is None:
-
- location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
-
-
- if tag_context is None:
-
- tag_context = TagContext()
-
-
- if predicates is None:
-
- predicates = []
-
-
- self._location_context = location_context
- self._tag_context = tag_context
-
- self._search_type = search_type
-
- self._predicates = predicates
-
- self._search_complete = False
-
- self._InitialiseTemporaryVariables()
-
-
- def _GetSerialisableInfo( self ):
-
- serialisable_predicates = [ predicate.GetSerialisableTuple() for predicate in self._predicates ]
- serialisable_location_context = self._location_context.GetSerialisableTuple()
-
- return ( serialisable_location_context, self._tag_context.GetSerialisableTuple(), self._search_type, serialisable_predicates, self._search_complete )
-
-
- def _InitialiseFromSerialisableInfo( self, serialisable_info ):
-
- ( serialisable_location_context, serialisable_tag_context, self._search_type, serialisable_predicates, self._search_complete ) = serialisable_info
-
- self._location_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_location_context )
- self._tag_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_tag_context )
-
- self._predicates = [ HydrusSerialisable.CreateFromSerialisableTuple( pred_tuple ) for pred_tuple in serialisable_predicates ]
-
- self._InitialiseTemporaryVariables()
-
-
- def _InitialiseTemporaryVariables( self ):
-
- system_predicates = [ predicate for predicate in self._predicates if predicate.GetType() in SYSTEM_PREDICATE_TYPES ]
-
- self._system_predicates = FileSystemPredicates( system_predicates )
-
- tag_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == PREDICATE_TYPE_TAG ]
-
- self._tags_to_include = []
- self._tags_to_exclude = []
-
- for predicate in tag_predicates:
-
- tag = predicate.GetValue()
-
- if predicate.GetInclusive(): self._tags_to_include.append( tag )
- else: self._tags_to_exclude.append( tag )
-
-
- namespace_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == PREDICATE_TYPE_NAMESPACE ]
-
- self._namespaces_to_include = []
- self._namespaces_to_exclude = []
-
- for predicate in namespace_predicates:
-
- namespace = predicate.GetValue()
-
- if predicate.GetInclusive(): self._namespaces_to_include.append( namespace )
- else: self._namespaces_to_exclude.append( namespace )
-
-
- wildcard_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == PREDICATE_TYPE_WILDCARD ]
-
- self._wildcards_to_include = []
- self._wildcards_to_exclude = []
-
- for predicate in wildcard_predicates:
-
- # this is an important convert. preds store nice looking text, but convert for the actual search
- wildcard = ConvertTagToSearchable( predicate.GetValue() )
-
- if predicate.GetInclusive(): self._wildcards_to_include.append( wildcard )
- else: self._wildcards_to_exclude.append( wildcard )
-
-
- self._or_predicates = [ predicate for predicate in self._predicates if predicate.GetType() == PREDICATE_TYPE_OR_CONTAINER ]
-
-
- def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
-
- if version == 1:
-
- ( file_service_key_hex, tag_service_key_hex, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
-
- search_type = SEARCH_TYPE_AND
-
- new_serialisable_info = ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete )
-
- return ( 2, new_serialisable_info )
-
-
- if version == 2:
-
- ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
-
- # screwed up the serialisation code for the previous update, so these were getting swapped
-
- search_type = SEARCH_TYPE_AND
- include_current_tags = True
-
- new_serialisable_info = ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete )
-
- return ( 3, new_serialisable_info )
-
-
- if version == 3:
-
- ( file_service_key_hex, tag_service_key_hex, search_type, include_current_tags, include_pending_tags, serialisable_predicates, search_complete ) = old_serialisable_info
-
- tag_service_key = bytes.fromhex( tag_service_key_hex )
-
- tag_context = TagContext( service_key = tag_service_key, include_current_tags = include_current_tags, include_pending_tags = include_pending_tags )
-
- serialisable_tag_context = tag_context.GetSerialisableTuple()
-
- new_serialisable_info = ( file_service_key_hex, serialisable_tag_context, search_type, serialisable_predicates, search_complete )
-
- return ( 4, new_serialisable_info )
-
-
- if version == 4:
-
- ( file_service_key_hex, serialisable_tag_context, search_type, serialisable_predicates, search_complete ) = old_serialisable_info
-
- file_service_key = bytes.fromhex( file_service_key_hex )
-
- location_context = ClientLocation.LocationContext.STATICCreateSimple( file_service_key )
-
- serialisable_location_context = location_context.GetSerialisableTuple()
-
- new_serialisable_info = ( serialisable_location_context, serialisable_tag_context, search_type, serialisable_predicates, search_complete )
-
- return ( 5, new_serialisable_info )
-
-
-
- def FixMissingServices( self, filter_method ):
-
- self._location_context.FixMissingServices( filter_method )
- self._tag_context.FixMissingServices( filter_method )
-
-
- def GetLocationContext( self ) -> ClientLocation.LocationContext:
-
- return self._location_context
-
-
- def GetNamespacesToExclude( self ): return self._namespaces_to_exclude
- def GetNamespacesToInclude( self ): return self._namespaces_to_include
- def GetORPredicates( self ): return self._or_predicates
- def GetPredicates( self ): return self._predicates
-
- def GetSystemPredicates( self ) -> FileSystemPredicates:
-
- return self._system_predicates
-
-
- def GetTagContext( self ) -> "TagContext":
-
- return self._tag_context
-
-
- def GetTagsToExclude( self ): return self._tags_to_exclude
- def GetTagsToInclude( self ): return self._tags_to_include
- def GetWildcardsToExclude( self ): return self._wildcards_to_exclude
- def GetWildcardsToInclude( self ): return self._wildcards_to_include
-
- def HasNoPredicates( self ):
-
- return len( self._predicates ) == 0
-
-
- def IsComplete( self ):
-
- return self._search_complete
-
-
- def IsJustSystemEverything( self ):
-
- return len( self._predicates ) == 1 and self._system_predicates.HasSystemEverything()
-
-
- def SetComplete( self ):
-
- self._search_complete = True
-
-
- def SetLocationContext( self, location_context: ClientLocation.LocationContext ):
-
- self._location_context = location_context
-
-
- def SetIncludeCurrentTags( self, value ):
-
- self._tag_context.include_current_tags = value
-
-
- def SetIncludePendingTags( self, value ):
-
- self._tag_context.include_pending_tags = value
-
-
- def SetPredicates( self, predicates ):
-
- self._predicates = predicates
-
- self._InitialiseTemporaryVariables()
-
-
- def SetTagServiceKey( self, tag_service_key ):
-
- self._tag_context.service_key = tag_service_key
- self._tag_context.display_service_key = tag_service_key
-
-
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_FILE_SEARCH_CONTEXT ] = FileSearchContext
-
-class TagContext( HydrusSerialisable.SerialisableBase ):
-
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_tag_context
- SERIALISABLE_NAME = 'Tag Search Context'
- SERIALISABLE_VERSION = 2
-
- def __init__( self, service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = True, display_service_key = None ):
-
- self.service_key = service_key
-
- self.include_current_tags = include_current_tags
- self.include_pending_tags = include_pending_tags
-
- if display_service_key is None:
-
- self.display_service_key = self.service_key
-
- else:
-
- self.display_service_key = display_service_key
-
-
-
- def __eq__( self, other ):
-
- if isinstance( other, TagContext ):
-
- return self.__hash__() == other.__hash__()
-
-
- return NotImplemented
-
-
- def __hash__( self ):
-
- return ( self.service_key, self.include_current_tags, self.include_pending_tags, self.display_service_key ).__hash__()
-
+def ConvertSpecificFiletypesToSummary( specific_mimes: typing.Collection[ int ], only_searchable = True ) -> typing.Collection[ int ]:
- def _GetSerialisableInfo( self ):
-
- return ( self.service_key.hex(), self.include_current_tags, self.include_pending_tags, self.display_service_key.hex() )
-
+ specific_mimes_to_process = set( specific_mimes )
- def _InitialiseFromSerialisableInfo( self, serialisable_info ):
-
- ( encoded_service_key, self.include_current_tags, self.include_pending_tags, encoded_display_service_key ) = serialisable_info
-
- self.service_key = bytes.fromhex( encoded_service_key )
- self.display_service_key = bytes.fromhex( encoded_display_service_key )
-
+ summary_mimes = set()
- def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
+ for ( general_mime, mime_group ) in HC.general_mimetypes_to_mime_groups.items():
- if version == 1:
-
- ( encoded_service_key, self.include_current_tags, self.include_pending_tags ) = old_serialisable_info
-
- encoded_display_service_key = encoded_service_key
-
- new_serialisable_info = ( encoded_service_key, self.include_current_tags, self.include_pending_tags, encoded_display_service_key )
+ if only_searchable:
- return ( 2, new_serialisable_info )
+ mime_group = set( mime_group )
+ mime_group.intersection_update( HC.SEARCHABLE_MIMES )
-
- def FixMissingServices( self, filter_method ):
-
- if len( filter_method( [ self.service_key ] ) ) == 0:
+ if specific_mimes_to_process.issuperset( mime_group ):
- self.service_key = CC.COMBINED_TAG_SERVICE_KEY
+ summary_mimes.add( general_mime )
+ specific_mimes_to_process.difference_update( mime_group )
- def IsAllKnownTags( self ):
-
- return self.service_key == CC.COMBINED_TAG_SERVICE_KEY
-
-
- def ToString( self, name_method ):
-
- return name_method( self.service_key )
-
+ summary_mimes.update( specific_mimes_to_process )
- def ToDictForAPI( self ):
-
- return {
- 'service_key' : self.service_key.hex(),
- 'include_current_tags' : self.include_current_tags,
- 'include_pending_tags' : self.include_pending_tags,
- 'display_service_key' : self.display_service_key.hex()
- }
-
+ return summary_mimes
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_tag_context ] = TagContext
-
-class FavouriteSearchManager( HydrusSerialisable.SerialisableBase ):
-
- SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_FAVOURITE_SEARCH_MANAGER
- SERIALISABLE_NAME = 'Favourite Search Manager'
- SERIALISABLE_VERSION = 1
-
- def __init__( self ):
-
- super().__init__()
-
- self._favourite_search_rows = []
-
- self._lock = threading.Lock()
- self._dirty = False
-
+def ConvertSummaryFiletypesToSpecific( summary_mimes: typing.Collection[ int ], only_searchable = True ) -> typing.Collection[ int ]:
- def _GetSerialisableInfo( self ):
-
- serialisable_favourite_search_info = []
-
- for row in self._favourite_search_rows:
-
- ( folder, name, file_search_context, synchronised, media_sort, media_collect ) = row
-
- serialisable_file_search_context = file_search_context.GetSerialisableTuple()
-
- if media_sort is None:
-
- serialisable_media_sort = None
-
- else:
-
- serialisable_media_sort = media_sort.GetSerialisableTuple()
-
-
- if media_collect is None:
-
- serialisable_media_collect = None
-
- else:
-
- serialisable_media_collect = media_collect.GetSerialisableTuple()
-
-
- serialisable_row = ( folder, name, serialisable_file_search_context, synchronised, serialisable_media_sort, serialisable_media_collect )
-
- serialisable_favourite_search_info.append( serialisable_row )
-
-
- return serialisable_favourite_search_info
-
+ specific_mimes = set()
- def _InitialiseFromSerialisableInfo( self, serialisable_info ):
-
- self._favourite_search_rows = []
+ for mime in summary_mimes:
- for serialisable_row in serialisable_info:
-
- ( folder, name, serialisable_file_search_context, synchronised, serialisable_media_sort, serialisable_media_collect ) = serialisable_row
-
- file_search_context = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_file_search_context )
-
- if serialisable_media_sort is None:
-
- media_sort = None
-
- else:
-
- media_sort = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_media_sort )
-
+ if mime in HC.GENERAL_FILETYPES:
- if serialisable_media_collect is None:
-
- media_collect = None
-
- else:
-
- media_collect = HydrusSerialisable.CreateFromSerialisableTuple( serialisable_media_collect )
-
+ specific_mimes.update( HC.general_mimetypes_to_mime_groups[ mime ] )
- row = ( folder, name, file_search_context, synchronised, media_sort, media_collect )
+ else:
- self._favourite_search_rows.append( row )
+ specific_mimes.add( mime )
- def GetFavouriteSearch( self, desired_folder_name, desired_name ):
-
- with self._lock:
-
- for ( folder, name, file_search_context, synchronised, media_sort, media_collect ) in self._favourite_search_rows:
-
- if folder == desired_folder_name and name == desired_name:
-
- return ( file_search_context, synchronised, media_sort, media_collect )
-
-
-
+ if only_searchable:
- raise HydrusExceptions.DataMissing( 'Could not find a favourite search named "{}"!'.format( desired_name ) )
+ specific_mimes.intersection_update( HC.SEARCHABLE_MIMES )
- def GetFavouriteSearchRows( self ):
-
- return list( self._favourite_search_rows )
-
+ return specific_mimes
- def GetFoldersToNames( self ):
-
- with self._lock:
-
- folders_to_names = collections.defaultdict( list )
-
- for ( folder, name, file_search_context, synchronised, media_sort, media_collect ) in self._favourite_search_rows:
-
- folders_to_names[ folder ].append( name )
-
-
- return folders_to_names
-
-
+
+def ConvertSummaryFiletypesToString( summary_mimes: typing.Collection[ int ] ) -> str:
- def IsDirty( self ):
-
- with self._lock:
-
- return self._dirty
-
+ if set( summary_mimes ) == HC.GENERAL_FILETYPES:
-
- def SetClean( self ):
+ mime_text = 'anything'
- with self._lock:
-
- self._dirty = False
-
+ else:
-
- def SetDirty( self ):
+ summary_mimes = sorted( summary_mimes, key = lambda m: HC.mime_mimetype_string_lookup[ m ] )
- with self._lock:
-
- self._dirty = True
-
+ mime_text = ', '.join( [ HC.mime_string_lookup[ mime ] for mime in summary_mimes ] )
- def SetFavouriteSearchRows( self, favourite_search_rows ):
-
- with self._lock:
-
- self._favourite_search_rows = list( favourite_search_rows )
-
- self._dirty = True
-
-
+ return mime_text
-HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_FAVOURITE_SEARCH_MANAGER ] = FavouriteSearchManager
class PredicateCount( object ):
@@ -1919,7 +511,7 @@ def _GetSerialisableInfo( self ):
elif self._predicate_type in ( PREDICATE_TYPE_SYSTEM_WIDTH, PREDICATE_TYPE_SYSTEM_HEIGHT, PREDICATE_TYPE_SYSTEM_NUM_NOTES, PREDICATE_TYPE_SYSTEM_NUM_WORDS, PREDICATE_TYPE_SYSTEM_NUM_URLS, PREDICATE_TYPE_SYSTEM_NUM_FRAMES, PREDICATE_TYPE_SYSTEM_DURATION, PREDICATE_TYPE_SYSTEM_FRAMERATE ):
- number_test: NumberTest = self._value
+ number_test: ClientNumberTest.NumberTest = self._value
serialisable_value = number_test.GetSerialisableTuple()
@@ -2169,17 +761,17 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
( operator, value ) = serialisable_value
- number_test = NumberTest.STATICCreateFromCharacters( operator, value )
+ number_test = ClientNumberTest.NumberTest.STATICCreateFromCharacters( operator, value )
if predicate_type in ( PREDICATE_TYPE_SYSTEM_FRAMERATE, PREDICATE_TYPE_SYSTEM_DURATION ):
if operator == '=':
- number_test = NumberTest( operator = NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT, value = value, extra_value = 0.05 )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_APPROXIMATE_PERCENT, value = value, extra_value = 0.05 )
elif operator == HC.UNICODE_NOT_EQUAL:
- number_test = NumberTest( operator = NUMBER_TEST_OPERATOR_LESS_THAN, value = value )
+ number_test = ClientNumberTest.NumberTest( operator = ClientNumberTest.NUMBER_TEST_OPERATOR_LESS_THAN, value = value )
@@ -2192,6 +784,11 @@ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
+ def CanTestMediaResult( self ) -> bool:
+
+ return self._predicate_type in ( PREDICATE_TYPE_SYSTEM_MIME, )
+
+
def GetCopy( self ):
return Predicate( self._predicate_type, self._value, self._inclusive, count = self._count.Duplicate() )
@@ -2312,17 +909,17 @@ def GetInverseCopy( self ):
elif self._predicate_type in ( PREDICATE_TYPE_SYSTEM_NUM_NOTES, PREDICATE_TYPE_SYSTEM_NUM_WORDS, PREDICATE_TYPE_SYSTEM_NUM_URLS, PREDICATE_TYPE_SYSTEM_NUM_FRAMES, PREDICATE_TYPE_SYSTEM_DURATION ):
- number_test: NumberTest = self._value
+ number_test: ClientNumberTest.NumberTest = self._value
if number_test is not None:
if number_test.IsZero():
- return Predicate( self._predicate_type, NumberTest.STATICCreateFromCharacters( '>', 0 ) )
+ return Predicate( self._predicate_type, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ) )
elif number_test.IsAnythingButZero():
- return Predicate( self._predicate_type, NumberTest.STATICCreateFromCharacters( '=', 0 ) )
+ return Predicate( self._predicate_type, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ) )
@@ -2535,6 +1132,18 @@ def SetKnownSiblings( self, siblings: typing.Set[ str ] ):
self._RecalculateMatchableSearchTexts()
+ def TestMediaResult( self, media_result: ClientMediaResult.MediaResult ) -> bool:
+
+ if self._predicate_type == PREDICATE_TYPE_SYSTEM_MIME:
+
+ mimes = ConvertSummaryFiletypesToSpecific( self._value )
+
+ return media_result.GetMime() in mimes
+
+
+ return False
+
+
def ToString( self, with_count: bool = True, render_for_user: bool = False, or_under_construction: bool = False, for_parsable_export: bool = False ) -> str:
base = ''
@@ -2631,7 +1240,7 @@ def ToString( self, with_count: bool = True, render_for_user: bool = False, or_u
if self._value is not None:
- number_test: NumberTest = self._value
+ number_test: ClientNumberTest.NumberTest = self._value
if number_test.IsZero() and not_has_phrase is not None:
@@ -2673,7 +1282,7 @@ def ToString( self, with_count: bool = True, render_for_user: bool = False, or_u
( namespace, operator, value ) = self._value
- number_test = NumberTest.STATICCreateFromCharacters( operator, value )
+ number_test = ClientNumberTest.NumberTest.STATICCreateFromCharacters( operator, value )
any_namespace = namespace is None or namespace == '*'
@@ -3382,91 +1991,34 @@ def ToString( self, with_count: bool = True, render_for_user: bool = False, or_u
-def FilterPredicatesBySearchText( service_key, search_text, predicates: typing.Collection[ Predicate ] ):
+def MergePredicates( predicates: typing.Collection[ Predicate ] ):
- def compile_re( s ):
-
- regular_parts_of_s = s.split( '*' )
-
- escaped_parts_of_s = [ re.escape( rpos ) for rpos in regular_parts_of_s ]
-
- s = '.*'.join( escaped_parts_of_s )
-
- # \A is start of string
- # \Z is end of string
- # \s is whitespace
-
- # ':' is no longer escaped to '\:' in py 3.7 lmaooooo, so some quick hackery
- if re.escape( ':' ) == r'\:':
-
- s = s.replace( r'\:', ':' )
-
+ master_predicate_dict = {}
+
+ for predicate in predicates:
- if ':' in s:
-
- ( namespace, subtag ) = s.split( ':', 1 )
-
- if namespace == '.*':
-
- beginning = r'(\A|:|\s)'
- s = subtag
-
- else:
-
- beginning = r'\A'
- s = r'{}:(.*\s)?{}'.format( namespace, subtag )
-
-
- elif s.startswith( '.*' ):
-
- beginning = r'(\A|:)'
-
- else:
-
- beginning = r'(\A|:|\s)'
-
+ # this works because predicate.__hash__ exists
- if s.endswith( '.*' ):
+ if predicate in master_predicate_dict:
- end = r'\Z' # end of string
+ master_predicate_dict[ predicate ].GetCount().AddCounts( predicate.GetCount() )
else:
- end = r'(\s|\Z)' # whitespace or end of string
+ master_predicate_dict[ predicate ] = predicate
- return re.compile( beginning + s + end )
-
- re_predicate = compile_re( search_text )
+ return list( master_predicate_dict.values() )
- matches = []
+
+def SortPredicates( predicates: typing.Collection[ Predicate ] ):
- for predicate in predicates:
-
- ( predicate_type, value, inclusive ) = predicate.GetInfo()
-
- if predicate_type != PREDICATE_TYPE_TAG:
-
- continue
-
-
- possible_tags = predicate.GetMatchableSearchTexts()
-
- searchable_tags = { ConvertTagToSearchable( possible_tag ) for possible_tag in possible_tags }
-
- for searchable_tag in searchable_tags:
-
- if re_predicate.search( searchable_tag ) is not None:
-
- matches.append( predicate )
-
- break
-
-
-
+ key = lambda p: ( - p.GetCount().GetMinCount(), p.ToString() )
+
+ predicates.sort( key = key )
- return matches
+ return predicates
HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_PREDICATE ] = Predicate
diff --git a/hydrus/client/search/ClientSearchTagContext.py b/hydrus/client/search/ClientSearchTagContext.py
new file mode 100644
index 000000000..e543f933e
--- /dev/null
+++ b/hydrus/client/search/ClientSearchTagContext.py
@@ -0,0 +1,141 @@
+from hydrus.core import HydrusSerialisable
+from hydrus.core import HydrusTags
+from hydrus.core import HydrusText
+
+from hydrus.client import ClientConstants as CC
+
+IGNORED_TAG_SEARCH_CHARACTERS = '[](){}/\\"\'-_'
+IGNORED_TAG_SEARCH_CHARACTERS_UNICODE_TRANSLATE = { ord( char ) : ' ' for char in IGNORED_TAG_SEARCH_CHARACTERS }
+
+def CollapseWildcardCharacters( text ):
+
+ while '**' in text:
+
+ text = text.replace( '**', '*' )
+
+
+ return text
+
+
+def ConvertSubtagToSearchable( subtag ):
+
+ if subtag == '':
+
+ return ''
+
+
+ subtag = CollapseWildcardCharacters( subtag )
+
+ subtag = subtag.translate( IGNORED_TAG_SEARCH_CHARACTERS_UNICODE_TRANSLATE )
+
+ subtag = HydrusText.re_one_or_more_whitespace.sub( ' ', subtag )
+
+ subtag = subtag.strip()
+
+ return subtag
+
+
+def ConvertTagToSearchable( tag ):
+
+ ( namespace, subtag ) = HydrusTags.SplitTag( tag )
+
+ searchable_subtag = ConvertSubtagToSearchable( subtag )
+
+ return HydrusTags.CombineTag( namespace, searchable_subtag )
+
+
+class TagContext( HydrusSerialisable.SerialisableBase ):
+
+ SERIALISABLE_TYPE = HydrusSerialisable.SERIALISABLE_TYPE_tag_context
+ SERIALISABLE_NAME = 'Tag Search Context'
+ SERIALISABLE_VERSION = 2
+
+ def __init__( self, service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = True, display_service_key = None ):
+
+ self.service_key = service_key
+
+ self.include_current_tags = include_current_tags
+ self.include_pending_tags = include_pending_tags
+
+ if display_service_key is None:
+
+ self.display_service_key = self.service_key
+
+ else:
+
+ self.display_service_key = display_service_key
+
+
+
+ def __eq__( self, other ):
+
+ if isinstance( other, TagContext ):
+
+ return self.__hash__() == other.__hash__()
+
+
+ return NotImplemented
+
+
+ def __hash__( self ):
+
+ return ( self.service_key, self.include_current_tags, self.include_pending_tags, self.display_service_key ).__hash__()
+
+
+ def _GetSerialisableInfo( self ):
+
+ return ( self.service_key.hex(), self.include_current_tags, self.include_pending_tags, self.display_service_key.hex() )
+
+
+ def _InitialiseFromSerialisableInfo( self, serialisable_info ):
+
+ ( encoded_service_key, self.include_current_tags, self.include_pending_tags, encoded_display_service_key ) = serialisable_info
+
+ self.service_key = bytes.fromhex( encoded_service_key )
+ self.display_service_key = bytes.fromhex( encoded_display_service_key )
+
+
+ def _UpdateSerialisableInfo( self, version, old_serialisable_info ):
+
+ if version == 1:
+
+ ( encoded_service_key, self.include_current_tags, self.include_pending_tags ) = old_serialisable_info
+
+ encoded_display_service_key = encoded_service_key
+
+ new_serialisable_info = ( encoded_service_key, self.include_current_tags, self.include_pending_tags, encoded_display_service_key )
+
+ return ( 2, new_serialisable_info )
+
+
+
+ def FixMissingServices( self, filter_method ):
+
+ if len( filter_method( [ self.service_key ] ) ) == 0:
+
+ self.service_key = CC.COMBINED_TAG_SERVICE_KEY
+
+
+
+ def IsAllKnownTags( self ):
+
+ return self.service_key == CC.COMBINED_TAG_SERVICE_KEY
+
+
+ def ToString( self, name_method ):
+
+ return name_method( self.service_key )
+
+
+ def ToDictForAPI( self ):
+
+ return {
+ 'service_key' : self.service_key.hex(),
+ 'include_current_tags' : self.include_current_tags,
+ 'include_pending_tags' : self.include_pending_tags,
+ 'display_service_key' : self.display_service_key.hex()
+ }
+
+
+
+HydrusSerialisable.SERIALISABLE_TYPES_TO_OBJECT_TYPES[ HydrusSerialisable.SERIALISABLE_TYPE_tag_context ] = TagContext
diff --git a/hydrus/core/HydrusConstants.py b/hydrus/core/HydrusConstants.py
index f425a8f9e..98329e0e4 100644
--- a/hydrus/core/HydrusConstants.py
+++ b/hydrus/core/HydrusConstants.py
@@ -105,7 +105,7 @@
# Misc
NETWORK_VERSION = 20
-SOFTWARE_VERSION = 589
+SOFTWARE_VERSION = 590
CLIENT_API_VERSION = 70
SERVER_THUMBNAIL_DIMENSIONS = ( 200, 200 )
diff --git a/hydrus/core/HydrusNumbers.py b/hydrus/core/HydrusNumbers.py
index af6e83633..64b1ed4dc 100644
--- a/hydrus/core/HydrusNumbers.py
+++ b/hydrus/core/HydrusNumbers.py
@@ -132,7 +132,14 @@ def ResolutionToPrettyString( resolution ):
def ToHumanInt( num ):
- num = int( num )
+ try:
+
+ num = int( num )
+
+ except:
+
+ return 'unknown'
+
# this got stomped on by mpv, which resets locale
#text = locale.format_string( '%d', num, grouping = True )
diff --git a/hydrus/core/HydrusSerialisable.py b/hydrus/core/HydrusSerialisable.py
index 5cc3a0c0a..c8d1343aa 100644
--- a/hydrus/core/HydrusSerialisable.py
+++ b/hydrus/core/HydrusSerialisable.py
@@ -142,10 +142,11 @@
SERIALISABLE_TYPE_STRING_JOINER = 125
SERIALISABLE_TYPE_FILE_FILTER = 126
SERIALISABLE_TYPE_URL_CLASS_PARAMETER_FIXED_NAME = 127
-SERIALISABLE_AUTO_DUPLICATES_RULE = 128
-SERIALISABLE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR = 129
-SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_ONE_FILE = 130
-SERIALISABLE_AUTO_DUPLICATES_PAIR_COMPARATOR_RULE_TWO_FILES = 131
+SERIALISABLE_TYPE_AUTO_DUPLICATES_RULE = 128
+SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_SELECTOR_AND_COMPARATOR = 129
+SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_ONE_FILE = 130
+SERIALISABLE_TYPE_AUTO_DUPLICATES_PAIR_COMPARATOR_TWO_FILES_RELATIVE = 131
+SERIALISABLE_TYPE_METADATA_CONDITIONAL = 132
SERIALISABLE_TYPES_TO_OBJECT_TYPES = {}
diff --git a/hydrus/test/HelperFunctions.py b/hydrus/test/HelperFunctions.py
index 042ed8c25..9619bc655 100644
--- a/hydrus/test/HelperFunctions.py
+++ b/hydrus/test/HelperFunctions.py
@@ -37,12 +37,17 @@ def compare_content_update_packages( ut: unittest.TestCase, content_update_packa
-def GetFakeMediaResult( hash: bytes ):
+def GetFakeMediaResult( hash: bytes, mime = None ):
hash_id = random.randint( 0, 200 * ( 1024 ** 2 ) )
size = random.randint( 8192, 20 * 1048576 )
- mime = random.choice( [ HC.IMAGE_JPEG, HC.VIDEO_WEBM, HC.APPLICATION_PDF ] )
+
+ if mime is None:
+
+ mime = random.choice( [ HC.IMAGE_JPEG, HC.VIDEO_WEBM, HC.APPLICATION_PDF ] )
+
+
width = random.randint( 200, 4096 )
height = random.randint( 200, 4096 )
duration = random.choice( [ 220, 16.66667, None ] )
diff --git a/hydrus/test/TestClientAPI.py b/hydrus/test/TestClientAPI.py
index 75ae70264..97d432819 100644
--- a/hydrus/test/TestClientAPI.py
+++ b/hydrus/test/TestClientAPI.py
@@ -36,7 +36,9 @@
from hydrus.client.networking import ClientLocalServer
from hydrus.client.networking import ClientLocalServerResources
from hydrus.client.networking import ClientNetworkingContexts
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
from hydrus.test import HelperFunctions as HF
@@ -3001,8 +3003,8 @@ def _test_add_tags_get_tag_siblings_and_parents( self, connection, set_up_permis
def _test_add_tags_search_tags( self, connection, set_up_permissions ):
predicates = [
- ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'green', count = ClientSearch.PredicateCount( 2, 0, None, None ) ),
- ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'green car', count = ClientSearch.PredicateCount( 5, 0, None, None ) )
+ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'green', count = ClientSearchPredicate.PredicateCount( 2, 0, None, None ) ),
+ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'green car', count = ClientSearchPredicate.PredicateCount( 5, 0, None, None ) )
]
HG.test_controller.SetRead( 'autocomplete_predicates', predicates )
@@ -4433,10 +4435,10 @@ def _test_manage_duplicates( self, connection, set_up_permissions ):
# search files failed tag permission
- tag_context = ClientSearch.TagContext( CC.COMBINED_TAG_SERVICE_KEY )
- predicates = { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING ) }
+ tag_context = ClientSearchTagContext.TagContext( CC.COMBINED_TAG_SERVICE_KEY )
+ predicates = { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING ) }
- default_file_search_context = ClientSearch.FileSearchContext( location_context = default_location_context, tag_context = tag_context, predicates = predicates )
+ default_file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context, tag_context = tag_context, predicates = predicates )
default_potentials_search_type = ClientDuplicates.DUPE_SEARCH_ONE_FILE_MATCHES_ONE_SEARCH
default_pixel_duplicates = ClientDuplicates.SIMILAR_FILES_PIXEL_DUPES_ALLOWED
@@ -4445,18 +4447,18 @@ def _test_manage_duplicates( self, connection, set_up_permissions ):
test_tag_service_key_1 = CC.DEFAULT_LOCAL_TAG_SERVICE_KEY
test_tags_1 = [ 'skirt', 'system:width<400' ]
- test_tag_context_1 = ClientSearch.TagContext( test_tag_service_key_1 )
+ test_tag_context_1 = ClientSearchTagContext.TagContext( test_tag_service_key_1 )
test_predicates_1 = ClientLocalServerResources.ConvertTagListToPredicates( None, test_tags_1, do_permission_check = False )
- test_file_search_context_1 = ClientSearch.FileSearchContext( location_context = default_location_context, tag_context = test_tag_context_1, predicates = test_predicates_1 )
+ test_file_search_context_1 = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context, tag_context = test_tag_context_1, predicates = test_predicates_1 )
test_tag_service_key_2 = HG.test_controller.example_tag_repo_service_key
test_tags_2 = [ 'system:untagged' ]
- test_tag_context_2 = ClientSearch.TagContext( test_tag_service_key_2 )
+ test_tag_context_2 = ClientSearchTagContext.TagContext( test_tag_service_key_2 )
test_predicates_2 = ClientLocalServerResources.ConvertTagListToPredicates( None, test_tags_2, do_permission_check = False )
- test_file_search_context_2 = ClientSearch.FileSearchContext( location_context = default_location_context, tag_context = test_tag_context_2, predicates = test_predicates_2 )
+ test_file_search_context_2 = ClientSearchFileSearchContext.FileSearchContext( location_context = default_location_context, tag_context = test_tag_context_2, predicates = test_predicates_2 )
test_potentials_search_type = ClientDuplicates.DUPE_SEARCH_BOTH_FILES_MATCH_DIFFERENT_SEARCHES
test_pixel_duplicates = ClientDuplicates.SIMILAR_FILES_PIXEL_DUPES_EXCLUDED
@@ -5213,7 +5215,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
self.assertEqual( file_search_context.GetTagContext().include_current_tags, True )
self.assertEqual( file_search_context.GetTagContext().include_pending_tags, True )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5332,7 +5334,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5393,7 +5395,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5442,7 +5444,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5483,7 +5485,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5529,7 +5531,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.TRASH_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5576,7 +5578,7 @@ def _test_search_files( self, connection, set_up_permissions ):
self.assertEqual( file_search_context.GetLocationContext().current_service_keys, { CC.TRASH_SERVICE_KEY } )
self.assertEqual( file_search_context.GetTagContext().service_key, CC.COMBINED_TAG_SERVICE_KEY )
- self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
+ self.assertEqual( set( file_search_context.GetPredicates() ), { ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag ) for tag in tags } )
self.assertIn( 'sort_by', kwargs )
@@ -5708,8 +5710,8 @@ class PretendRequest( object ):
expected_predicates = []
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'green' ) )
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'kino', inclusive = False ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'green' ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'kino', inclusive = False ) )
self.assertEqual( set( predicates ), set( expected_predicates ) )
@@ -5724,8 +5726,8 @@ class PretendRequest( object ):
expected_predicates = []
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'green' ) )
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'green' ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE ) )
self.assertEqual( set( predicates ), set( expected_predicates ) )
@@ -5740,22 +5742,22 @@ class PretendRequest( object ):
expected_predicates = []
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'green' ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'green' ) )
expected_predicates.append(
- ClientSearch.Predicate(
- predicate_type = ClientSearch.PREDICATE_TYPE_OR_CONTAINER,
+ ClientSearchPredicate.Predicate(
+ predicate_type = ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER,
value = [
- ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'red' ),
- ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_TAG, value = 'blue' )
+ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'red' ),
+ ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_TAG, value = 'blue' )
]
)
)
- expected_predicates.append( ClientSearch.Predicate( predicate_type = ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE ) )
+ expected_predicates.append( ClientSearchPredicate.Predicate( predicate_type = ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE ) )
- self.assertEqual( { pred for pred in predicates if pred.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER }, { pred for pred in expected_predicates if pred.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER } )
- self.assertEqual( { frozenset( pred.GetValue() ) for pred in predicates if pred.GetType() == ClientSearch.PREDICATE_TYPE_OR_CONTAINER }, { frozenset( pred.GetValue() ) for pred in expected_predicates if pred.GetType() == ClientSearch.PREDICATE_TYPE_OR_CONTAINER } )
+ self.assertEqual( { pred for pred in predicates if pred.GetType() != ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER }, { pred for pred in expected_predicates if pred.GetType() != ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER } )
+ self.assertEqual( { frozenset( pred.GetValue() ) for pred in predicates if pred.GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER }, { frozenset( pred.GetValue() ) for pred in expected_predicates if pred.GetType() == ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER } )
#
diff --git a/hydrus/test/TestClientDB.py b/hydrus/test/TestClientDB.py
index 95b3d37e3..0e8841b25 100644
--- a/hydrus/test/TestClientDB.py
+++ b/hydrus/test/TestClientDB.py
@@ -26,7 +26,10 @@
from hydrus.client.importing.options import FileImportOptions
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
from hydrus.test import TestController
@@ -90,9 +93,9 @@ def test_autocomplete( self ):
file_import_options.SetIsDefault( True )
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_FILE_SERVICE_KEY )
- tag_context = ClientSearch.TagContext( service_key = CC.DEFAULT_LOCAL_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.DEFAULT_LOCAL_TAG_SERVICE_KEY )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context )
TestClientDB._clear_db()
@@ -138,8 +141,8 @@ def test_autocomplete( self ):
preds = set()
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
for p in result: self.assertEqual( p.GetCount().GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
@@ -155,7 +158,7 @@ def test_autocomplete( self ):
result = self._read( 'autocomplete_predicates', ClientTags.TAG_DISPLAY_STORAGE, file_search_context, search_text = 'series:c*' )
- pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) )
+ pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) )
( read_pred, ) = result
@@ -167,7 +170,7 @@ def test_autocomplete( self ):
result = self._read( 'autocomplete_predicates', ClientTags.TAG_DISPLAY_STORAGE, file_search_context, search_text = 'car', exact_match = True )
- pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) )
+ pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) )
( read_pred, ) = result
@@ -187,9 +190,9 @@ def test_autocomplete( self ):
preds = set()
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'maker:ford', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'maker:ford', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
for p in result: self.assertEqual( p.GetCount().GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
@@ -201,7 +204,7 @@ def test_autocomplete( self ):
preds = set()
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
for p in result: self.assertEqual( p.GetCount().GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
@@ -213,8 +216,8 @@ def test_autocomplete( self ):
preds = set()
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
for p in result: self.assertEqual( p.GetCount().GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
@@ -226,7 +229,7 @@ def test_autocomplete( self ):
preds = set()
- preds.add( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ preds.add( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series:cars', count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
for p in result: self.assertEqual( p.GetCount().GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
@@ -235,11 +238,11 @@ def test_autocomplete( self ):
def test_export_folders( self ):
- tag_context = ClientSearch.TagContext( service_key = HydrusData.GenerateKey() )
+ tag_context = ClientSearchTagContext.TagContext( service_key = HydrusData.GenerateKey() )
location_context = ClientLocation.LocationContext.STATICCreateSimple( HydrusData.GenerateKey() )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'test' ) ] )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'test' ) ] )
export_folder = ClientExportingFiles.ExportFolder( 'test path', export_type = HC.EXPORT_FOLDER_TYPE_REGULAR, delete_from_client_after_export = False, file_search_context = file_search_context, period = 3600, phrase = '{hash}' )
@@ -258,11 +261,11 @@ def run_namespace_predicate_tests( tests ):
for ( inclusive, namespace, result ) in tests:
- predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, namespace, inclusive ) ]
+ predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, namespace, inclusive ) ]
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
file_query_ids = self._read( 'file_query_ids', search_context )
@@ -279,11 +282,11 @@ def run_system_predicate_tests( tests ):
for ( predicate_type, info, result ) in tests:
- predicates = [ ClientSearch.Predicate( predicate_type, info ) ]
+ predicates = [ ClientSearchPredicate.Predicate( predicate_type, info ) ]
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
file_query_ids = self._read( 'file_query_ids', search_context )
@@ -300,11 +303,11 @@ def run_tag_predicate_tests( tests ):
for ( inclusive, tag, result ) in tests:
- predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, tag, inclusive ) ]
+ predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, tag, inclusive ) ]
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
file_query_ids = self._read( 'file_query_ids', search_context )
@@ -323,7 +326,7 @@ def run_or_predicate_tests( tests ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
file_query_ids = self._read( 'file_query_ids', search_context )
@@ -338,15 +341,15 @@ def run_or_predicate_tests( tests ):
tests = []
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
run_system_predicate_tests( tests )
@@ -380,162 +383,162 @@ def run_or_predicate_tests( tests ):
tests = []
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 1, 1, 1, 1, ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 0, 0, ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 1, 1, 1, 1, ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 0, 0, 0, 0, ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 1, 1, 1, 1, ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 0, 0, 0, 0, ) ), 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 100, ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 0, ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 100, ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0, ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 100, ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0, ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 100, ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0, ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True, 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True, 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ( ( hash, ), 'sha256' ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ( ( bytes.fromhex( '0123456789abcdef' * 4 ), ), 'sha256' ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 201 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 200 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 200 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 60 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 200 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 200 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 199 ), 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, None, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL, None, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, HC.IMAGES, 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_PNG, ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_JPEG, ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, HC.VIDEO, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 1, 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 4, 3 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 1, 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 200, 201 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 4, 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( hash, ), 5 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( bytes.fromhex( '0123456789abcdef' * 4 ), ), 5 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 1, 1, 1, 1, ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 0, 0, 0, 0, ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 1, 1, 1, 1, ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 0, 0, 0, 0, ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 1, 1, 1, 1, ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 0, 0, 0, 0, ) ), 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 100, ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 0, ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 100, ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0, ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 100, ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0, ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 100, ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0, ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True, 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True, 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ( ( hash, ), 'sha256' ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ( ( bytes.fromhex( '0123456789abcdef' * 4 ), ), 'sha256' ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 201 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 200 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 200 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 60 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 200 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 200 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 199 ), 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, None, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL, None, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, HC.IMAGES, 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_PNG, ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_JPEG, ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, HC.VIDEO, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 1, 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 4, 3 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 1, 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 200, 201 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( HC.UNICODE_APPROX_EQUAL, 4, 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( hash, ), 5 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( bytes.fromhex( '0123456789abcdef' * 4 ), ), 5 ), 0 ) )
pixel_hash = HydrusImageHandling.GetImagePixelHash( path, HC.IMAGE_PNG )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( pixel_hash, ), (), 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( os.urandom( 32 ), ), (), 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( pixel_hash, ), (), 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( os.urandom( 32 ), ), (), 0 ), 0 ) )
perceptual_hashes = ClientImageHandling.GenerateShapePerceptualHashes( path, HC.IMAGE_PNG )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( (), tuple( perceptual_hashes ), 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( (), ( os.urandom( 32 ), ), 0 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 5271, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '=', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '=', 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( HC.UNICODE_APPROX_EQUAL, 5270, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( HC.UNICODE_APPROX_EQUAL, 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5269, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'KB' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'MB' ) ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'GB' ) ), 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 201 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 200 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 200 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 60 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 200 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 200 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '>', 199 ), 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 100, 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 1, 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 0, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( (), tuple( perceptual_hashes ), 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( (), ( os.urandom( 32 ), ), 0 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '<', 5271, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '=', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '=', 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( HC.UNICODE_APPROX_EQUAL, 5270, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( HC.UNICODE_APPROX_EQUAL, 0, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5270, HydrusNumbers.UnitToInt( 'B' ) ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5269, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'B' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'KB' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'MB' ) ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 0, HydrusNumbers.UnitToInt( 'GB' ) ), 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 201 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 200 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 200 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 60 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( HC.UNICODE_APPROX_EQUAL, 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 200 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 200 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '>', 199 ), 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 100, 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 1, 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 0, 0 ) )
run_system_predicate_tests( tests )
@@ -554,33 +557,33 @@ def run_or_predicate_tests( tests ):
tests = []
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 1 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 2 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 2 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 1 ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 2 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 1 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 0 ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 1 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 0 ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 1 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 2 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '=', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( None, '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 2 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '=', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '>', 1 ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 2 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 1 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '<', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 0 ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '=', 1 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 0 ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '', '>', 1 ), 0 ) )
run_system_predicate_tests( tests )
@@ -643,53 +646,53 @@ def run_or_predicate_tests( tests ):
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car' ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'bus' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'bus' ) )
- or_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
tests.append( ( [ or_pred ], 1 ) )
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car' ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 201 ) ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 201 ) ) )
- or_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
tests.append( ( [ or_pred ], 1 ) )
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'truck' ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'bus' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'truck' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'bus' ) )
- or_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
tests.append( ( [ or_pred ], 0 ) )
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'truck', inclusive = False ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'bus' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'truck', inclusive = False ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'bus' ) )
- or_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
tests.append( ( [ or_pred ], 1 ) )
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'car' ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'truck' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'car' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'truck' ) )
- or_pred_1 = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred_1 = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
preds = []
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'maker:toyota' ) )
- preds.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'maker:ford' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'maker:toyota' ) )
+ preds.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'maker:ford' ) )
- or_pred_2 = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, preds )
+ or_pred_2 = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, preds )
tests.append( ( [ or_pred_1, or_pred_2 ], 1 ) )
@@ -739,26 +742,26 @@ def run_or_predicate_tests( tests ):
tests = []
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1.0, TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 0.0, TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'rated', TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'not rated', TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1.0, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.4, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 0.7, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'rated', TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'not rated', TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
-
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 2, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 4, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1.0, TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 0.0, TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'rated', TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'not rated', TestController.LOCAL_RATING_LIKE_SERVICE_KEY ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1.0, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.4, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 0.7, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 0.6, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'rated', TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 'not rated', TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ), 0 ) )
+
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '=', 1, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 2, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '<', 4, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ), 1 ) )
run_system_predicate_tests( tests )
@@ -774,15 +777,15 @@ def run_or_predicate_tests( tests ):
tests = []
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL, None, 0 ) )
- tests.append( ( ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
+ tests.append( ( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, None, 0 ) )
run_system_predicate_tests( tests )
@@ -808,16 +811,16 @@ def test_file_system_predicates( self ):
#
- file_search_context = ClientSearch.FileSearchContext( location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY ), tag_context = ClientSearch.TagContext() )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY ), tag_context = ClientSearchTagContext.TagContext() )
result = self._read( 'file_system_predicates', file_search_context )
predicates = []
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 0 ) ) )
- predicates.extend( [ ClientSearch.Predicate( predicate_type ) for predicate_type in [ ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ClientSearch.PREDICATE_TYPE_SYSTEM_TIME, ClientSearch.PREDICATE_TYPE_SYSTEM_URLS, ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES, ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ClientSearch.PREDICATE_TYPE_SYSTEM_DIMENSIONS, ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.PREDICATE_TYPE_SYSTEM_NOTES, ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO, ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ClientSearch.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS, ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS ] ] )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 0 ) ) )
+ predicates.extend( [ ClientSearchPredicate.Predicate( predicate_type ) for predicate_type in [ ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TIME, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_URLS, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_PROPERTIES, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DIMENSIONS, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOTES, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS, ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS ] ] )
self.assertEqual( set( result ), set( predicates ) )
@@ -1146,7 +1149,7 @@ def test_gui_sessions( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- fsc = ClientSearch.FileSearchContext( location_context = location_context, predicates = [] )
+ fsc = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [] )
management_controller = ClientGUIManagementController.CreateManagementControllerQuery( 'search', fsc, True )
@@ -1164,11 +1167,11 @@ def test_gui_sessions( self ):
#
- tag_context = ClientSearch.TagContext( service_key = CC.DEFAULT_LOCAL_TAG_SERVICE_KEY )
+ tag_context = ClientSearchTagContext.TagContext( service_key = CC.DEFAULT_LOCAL_TAG_SERVICE_KEY )
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- fsc = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = [] )
+ fsc = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context, predicates = [] )
management_controller = ClientGUIManagementController.CreateManagementControllerQuery( 'search', fsc, False )
@@ -1188,7 +1191,7 @@ def test_gui_sessions( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- fsc = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ ClientSearch.SYSTEM_PREDICATE_ARCHIVE ] )
+ fsc = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ ClientSearchPredicate.SYSTEM_PREDICATE_ARCHIVE ] )
management_controller = ClientGUIManagementController.CreateManagementControllerQuery( 'files', fsc, True )
@@ -1208,7 +1211,7 @@ def test_gui_sessions( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- fsc = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'tag', count = ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 3 ) ) ] )
+ fsc = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'tag', count = ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 3 ) ) ] )
management_controller = ClientGUIManagementController.CreateManagementControllerQuery( 'wew lad', fsc, True )
@@ -1228,7 +1231,7 @@ def test_gui_sessions( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- fsc = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.2, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ) ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ) ) ] )
+ fsc = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.2, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ) ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ) ) ] )
management_controller = ClientGUIManagementController.CreateManagementControllerQuery( 'files', fsc, True )
@@ -1672,9 +1675,9 @@ def test_mr_bones( self ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.COMBINED_LOCAL_MEDIA_SERVICE_KEY )
- predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, value = ( HC.APPLICATION_FLASH, ) ) ]
+ predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = ( HC.APPLICATION_FLASH, ) ) ]
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, predicates = predicates )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = predicates )
result = self._read( 'boned_stats', file_search_context = file_search_context )
diff --git a/hydrus/test/TestClientDBDuplicates.py b/hydrus/test/TestClientDBDuplicates.py
index f910d995b..b765ff3ea 100644
--- a/hydrus/test/TestClientDBDuplicates.py
+++ b/hydrus/test/TestClientDBDuplicates.py
@@ -14,7 +14,8 @@
from hydrus.client.importing import ClientImportFiles
from hydrus.client.importing.options import FileImportOptions
from hydrus.client.metadata import ClientContentUpdates
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
from hydrus.test import TestController
@@ -1074,13 +1075,13 @@ def test_duplicates( self ):
# 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, HydrusNumbers.UnitToInt( 'B' ) ) )
- png_pred = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_PNG, ) )
+ size_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '=', 65535, HydrusNumbers.UnitToInt( 'B' ) ) )
+ png_pred = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.IMAGE_PNG, ) )
location_context = ClientLocation.LocationContext.STATICCreateSimple( CC.LOCAL_FILE_SERVICE_KEY )
- self._file_search_context_1 = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ size_pred ] )
- self._file_search_context_2 = ClientSearch.FileSearchContext( location_context = location_context, predicates = [ png_pred ] )
+ self._file_search_context_1 = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ size_pred ] )
+ self._file_search_context_2 = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, predicates = [ png_pred ] )
self._import_and_find_dupes()
diff --git a/hydrus/test/TestClientDBTags.py b/hydrus/test/TestClientDBTags.py
index 3cccc3bf5..a2024c1dd 100644
--- a/hydrus/test/TestClientDBTags.py
+++ b/hydrus/test/TestClientDBTags.py
@@ -17,7 +17,9 @@
from hydrus.client.importing.options import FileImportOptions
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchFileSearchContext
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
from hydrus.test import TestController
@@ -640,9 +642,9 @@ def _sync_display( self ):
def _test_ac( self, search_text, tag_service_key, file_service_key, expected_storage_tags_to_counts, expected_display_tags_to_counts ):
location_context = ClientLocation.LocationContext.STATICCreateSimple( file_service_key )
- tag_context = ClientSearch.TagContext( tag_service_key )
+ tag_context = ClientSearchTagContext.TagContext( tag_service_key )
- file_search_context = ClientSearch.FileSearchContext( location_context = location_context, tag_context = tag_context )
+ file_search_context = ClientSearchFileSearchContext.FileSearchContext( location_context = location_context, tag_context = tag_context )
preds = self._read( 'autocomplete_predicates', ClientTags.TAG_DISPLAY_STORAGE, file_search_context, search_text = search_text )
@@ -1120,8 +1122,8 @@ def test_display_pending_to_current_bug_both_non_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
# now we'll currentify the tags in one action
@@ -1149,8 +1151,8 @@ def test_display_pending_to_current_bug_both_non_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
def test_display_pending_to_current_bug_non_ideal_and_ideal( self ):
@@ -1221,8 +1223,8 @@ def test_display_pending_to_current_bug_non_ideal_and_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
# now we'll currentify the tags in one action
@@ -1250,8 +1252,8 @@ def test_display_pending_to_current_bug_non_ideal_and_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
def test_display_pending_to_current_merge_bug_both_non_ideal( self ):
@@ -1326,8 +1328,8 @@ def test_display_pending_to_current_merge_bug_both_non_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
# now we'll currentify the tags in one action
@@ -1355,8 +1357,8 @@ def test_display_pending_to_current_merge_bug_both_non_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
def test_display_pending_to_current_merge_bug_non_ideal_and_ideal( self ):
@@ -1430,8 +1432,8 @@ def test_display_pending_to_current_merge_bug_non_ideal_and_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
# now we'll currentify the tags in one action
@@ -1459,8 +1461,8 @@ def test_display_pending_to_current_merge_bug_non_ideal_and_ideal( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
def test_display_pending_regen( self ):
@@ -1534,11 +1536,11 @@ def test_display_pending_regen( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'lara*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'lara*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'lara*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'lara*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
# now we'll currentify the tags in one action
@@ -1558,11 +1560,11 @@ def test_display_pending_regen( self ):
# and a/c results, both specific and combined
- self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'samu*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { bad_samus_tag_1 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ), bad_samus_tag_2 : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { good_samus_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'lara*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'lara*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'lara*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'lara*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { lara_tag : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
def test_parents_pairs_lookup( self ):
@@ -2525,28 +2527,28 @@ def test_no_sibs( force_no_local_files = False ):
self.assertEqual( hash_ids_to_tags_managers[ self._samus_good_hash_id ].GetCurrentAndPending( CC.COMBINED_TAG_SERVICE_KEY, ClientTags.TAG_DISPLAY_DISPLAY_ACTUAL ), { 'mc good', 'process these', 'pc good', 'pp good', 'character:samus aran' } )
- self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
if on_local_files and not force_no_local_files:
- self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
- self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
- self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
- self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
+ self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) } )
+ self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) } )
+ self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) } )
else:
@@ -2758,32 +2760,32 @@ def test_no_sibs( force_no_local_files = False ):
self.assertEqual( hash_ids_to_tags_managers[ self._samus_good_hash_id ].GetCurrentAndPending( CC.COMBINED_TAG_SERVICE_KEY, ClientTags.TAG_DISPLAY_DISPLAY_ACTUAL ), { 'mc good', 'process these', 'pc good', 'pp good', 'character:samus aran' } )
# now we get more write a/c suggestions, and accurated merged read a/c values
- self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
if on_local_files:
# same deal, just smaller file domain
- self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
# the storage/write a/c used to get funky here because it was tricky to do siblings over all known tags. it merged all sibling lookups for all fetched tags
# but now it is fixed I am pretty sure! each set of positive count tag results is siblinged in a service leaf silo
# I basically just fixed these tests to the new results. it seems good in UI. this is more reason that these unit tests are way too complicated and need to be redone
- self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ), 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ), 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
else:
@@ -2874,32 +2876,32 @@ def test_no_sibs( force_no_local_files = False ):
self.assertEqual( hash_ids_to_tags_managers[ self._samus_good_hash_id ].GetCurrentAndPending( CC.COMBINED_TAG_SERVICE_KEY, ClientTags.TAG_DISPLAY_DISPLAY_ACTUAL ), { 'mc good', 'process these', 'pc good', 'pp good', 'character:samus aran' } )
# now we get more write a/c suggestions, and accurated merged read a/c values
- self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.COMBINED_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
if on_local_files:
# same deal, just smaller file domain
- self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
- self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
- self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'mc bad*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'sameus aran*', self._my_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ) } )
+ self._test_ac( 'samus metroid*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
+ self._test_ac( 'samus aran*', self._public_service_key, CC.LOCAL_FILE_SERVICE_KEY, { 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 1 ) } )
- self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
- self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
+ self._test_ac( 'mc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'mc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'mc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pc bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pc bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ), 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 2, 0 ) }, { 'pc good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 3, 0 ) } )
+ self._test_ac( 'pp bad*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'pp bad' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ), 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 2 ) }, { 'pp good' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 3 ) } )
# the storage/write a/c used to get funky here because it was tricky to do siblings over all known tags. it merged all sibling lookups for all fetched tags
# but now it is fixed I am pretty sure! each set of positive count tag results is siblinged in a service leaf silo
# I basically just fixed these tests to the new results. it seems good in UI. this is more reason that these unit tests are way too complicated and need to be redone
- self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount( 1, 1, 2, 1 ) } )
- self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount( 1, 1, 2, 1 ) } )
- self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearch.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearch.PredicateCount( 1, 1, 2, 1 ) } )
+ self._test_ac( 'sameus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount( 1, 1, 2, 1 ) } )
+ self._test_ac( 'samus metroid*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount( 1, 1, 2, 1 ) } )
+ self._test_ac( 'samus aran*', CC.COMBINED_TAG_SERVICE_KEY, CC.LOCAL_FILE_SERVICE_KEY, { 'sameus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'samus metroid' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 0 ), 'character:samus aran' : ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 0, 1 ) }, { 'character:samus aran' : ClientSearchPredicate.PredicateCount( 1, 1, 2, 1 ) } )
else:
@@ -3063,45 +3065,45 @@ def test_expand_predicates( self ):
predicates = []
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'grandmother', ClientSearch.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'grandfather', ClientSearch.PredicateCount.STATICCreateCurrentCount( 15 ) ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'not_exist', ClientSearch.PredicateCount.STATICCreateCurrentCount( 20 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'grandmother', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'grandfather', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 15 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'not_exist', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 20 ) ) )
self.assertEqual( self._tag_parents_manager.ExpandPredicates( CC.COMBINED_TAG_SERVICE_KEY, predicates ), predicates )
predicates = []
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'child', ClientSearch.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'child', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
results = []
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'child', ClientSearch.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'mother' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'father' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandmother' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandfather' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'child', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'mother' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'father' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandmother' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandfather' ) )
self.assertEqual( set( self._tag_parents_manager.ExpandPredicates( CC.COMBINED_TAG_SERVICE_KEY, predicates ) ), set( results ) )
predicates = []
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'series' ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'child', ClientSearch.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
- predicates.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'cousin', ClientSearch.PredicateCount.STATICCreateCurrentCount( 5 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'series' ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'child', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
+ predicates.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'cousin', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 5 ) ) )
results = []
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'series' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'child', ClientSearch.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'mother' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'father' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandmother' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandfather' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'cousin', ClientSearch.PredicateCount.STATICCreateCurrentCount( 5 ) ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'aunt' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'uncle' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandmother' ) )
- results.append( ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'grandfather' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'series' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'child', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 10 ) ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'mother' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'father' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandmother' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandfather' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'cousin', ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 5 ) ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'aunt' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'uncle' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandmother' ) )
+ results.append( ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'grandfather' ) )
self.assertEqual( set( self._tag_parents_manager.ExpandPredicates( CC.COMBINED_TAG_SERVICE_KEY, predicates ) ), set( results ) )
diff --git a/hydrus/test/TestClientNetworking.py b/hydrus/test/TestClientNetworking.py
index b7c1cc0a1..64a8d3589 100644
--- a/hydrus/test/TestClientNetworking.py
+++ b/hydrus/test/TestClientNetworking.py
@@ -303,7 +303,7 @@ def test_url_class_basics( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
send_referral_url = ClientNetworkingURLClass.SEND_REFERRAL_URL_ONLY_IF_PROVIDED
referral_url_converter = None
@@ -394,7 +394,7 @@ def test_defaults( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
send_referral_url = ClientNetworkingURLClass.SEND_REFERRAL_URL_ONLY_IF_PROVIDED
referral_url_converter = None
@@ -412,9 +412,9 @@ def test_defaults( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
- p = ClientNetworkingURLClass.URLClassParameterFixedName( name = 'pid', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '0' ) )
+ p = ClientNetworkingURLClass.URLClassParameterFixedName( name = 'pid', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '0' ) )
p.SetDefaultValue( '0' )
@@ -470,7 +470,7 @@ def test_is_ephemeral( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
p = ClientNetworkingURLClass.URLClassParameterFixedName( name = 'token', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_ANY, example_string = 'abcd' ) )
@@ -533,7 +533,7 @@ def test_defaults_with_string_processor( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
p = ClientNetworkingURLClass.URLClassParameterFixedName( name = 'cache_reset', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_ANY, example_string = 'abcd' ) )
@@ -599,7 +599,7 @@ def test_alphabetise_params( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
send_referral_url = ClientNetworkingURLClass.SEND_REFERRAL_URL_ONLY_IF_PROVIDED
referral_url_converter = None
@@ -655,7 +655,7 @@ def test_referral( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
referral_url_converter = None
gallery_index_type = None
@@ -780,7 +780,7 @@ def test_extra_params( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
send_referral_url = ClientNetworkingURLClass.SEND_REFERRAL_URL_ONLY_IF_PROVIDED
referral_url_converter = None
@@ -846,7 +846,7 @@ def test_single_value_params( self ):
parameters = []
parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 's', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = 'view', example_string = 'view' ) ) )
- parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC, example_string = '123456' ) ) )
+ parameters.append( ClientNetworkingURLClass.URLClassParameterFixedName( name = 'id', value_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC, example_string = '123456' ) ) )
has_single_value_parameters = True
single_value_parameters_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_REGEX, match_value = '^token.*', example_string = 'token1' )
diff --git a/hydrus/test/TestClientParsing.py b/hydrus/test/TestClientParsing.py
index ff40729d0..5cfd8bffb 100644
--- a/hydrus/test/TestClientParsing.py
+++ b/hydrus/test/TestClientParsing.py
@@ -397,7 +397,7 @@ def test_basics( self ):
#
- alpha_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.ALPHA )
+ alpha_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_ALPHA )
self.assertFalse( alpha_string_match.Matches( '123' ) )
self.assertTrue( alpha_string_match.Matches( 'abc' ) )
@@ -405,15 +405,16 @@ def test_basics( self ):
#
- alphanum_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.ALPHANUMERIC )
+ alphanum_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_ALPHANUMERIC )
self.assertTrue( alphanum_string_match.Matches( '123' ) )
self.assertTrue( alphanum_string_match.Matches( 'abc' ) )
self.assertTrue( alphanum_string_match.Matches( 'abc123' ) )
+ self.assertFalse( alphanum_string_match.Matches( 'abc123@' ) )
#
- num_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC )
+ num_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC )
self.assertTrue( num_string_match.Matches( '123' ) )
self.assertFalse( num_string_match.Matches( 'abc' ) )
@@ -421,6 +422,25 @@ def test_basics( self ):
#
+ hex_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_HEX )
+
+ self.assertTrue( hex_string_match.Matches( '123' ) )
+ self.assertTrue( hex_string_match.Matches( 'abc' ) )
+ self.assertTrue( hex_string_match.Matches( 'abc123' ) )
+ self.assertFalse( hex_string_match.Matches( 'abc123z' ) )
+
+ #
+
+ base64_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_BASE64 )
+
+ self.assertTrue( base64_string_match.Matches( '123' ) )
+ self.assertTrue( base64_string_match.Matches( 'abc' ) )
+ self.assertTrue( base64_string_match.Matches( 'abc123+' ) )
+ self.assertTrue( base64_string_match.Matches( 'abc123+=' ) )
+ self.assertFalse( base64_string_match.Matches( 'abc123+]' ) )
+
+ #
+
fixed_string_match = ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FIXED, match_value = '123' )
self.assertTrue( fixed_string_match.Matches( '123' ) )
@@ -678,7 +698,7 @@ def test_basics( self ):
processing_steps.append( ClientStrings.StringSplitter( separator = ',', max_splits = 2 ) )
- processing_steps.append( ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.NUMERIC ) )
+ processing_steps.append( ClientStrings.StringMatch( match_type = ClientStrings.STRING_MATCH_FLEXIBLE, match_value = ClientStrings.FLEXIBLE_MATCH_NUMERIC ) )
conversions = [ ( ClientStrings.STRING_CONVERSION_APPEND_TEXT, 'abc' ) ]
diff --git a/hydrus/test/TestClientSearch.py b/hydrus/test/TestClientSearch.py
new file mode 100644
index 000000000..c596a7468
--- /dev/null
+++ b/hydrus/test/TestClientSearch.py
@@ -0,0 +1,1884 @@
+import collections
+import os
+import unittest
+
+from hydrus.core import HydrusConstants as HC
+from hydrus.core import HydrusData
+from hydrus.core import HydrusGlobals as HG
+from hydrus.core import HydrusTags
+
+from hydrus.client import ClientConstants as CC
+from hydrus.client.media import ClientMediaManagers
+from hydrus.client.metadata import ClientContentUpdates
+from hydrus.client.metadata import ClientTags
+from hydrus.client.metadata import ClientTagsHandling
+from hydrus.client.search import ClientNumberTest
+from hydrus.client.search import ClientSearchAutocomplete
+from hydrus.client.search import ClientSearchParseSystemPredicates
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
+
+from hydrus.test import HelperFunctions
+
+class TestPredicates( unittest.TestCase ):
+
+ def test_metadata_conditional( self ):
+
+ # presumably this will not be false one day
+ system_predicate = ClientSearchPredicate.SYSTEM_PREDICATE_INBOX
+
+ self.assertFalse( system_predicate.CanTestMediaResult() )
+
+ # filetypes
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.IMAGE_JPEG } )
+
+ self.assertTrue( system_predicate.CanTestMediaResult() )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.IMAGE_JPEG } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.IMAGE_JPEG )
+
+ self.assertTrue( system_predicate.TestMediaResult( fake_media_result ) )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.IMAGE_JPEG } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.IMAGE_PNG )
+
+ self.assertFalse( system_predicate.TestMediaResult( fake_media_result ) )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.IMAGE_JPEG, HC.APPLICATION_PDF } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.IMAGE_JPEG )
+
+ self.assertTrue( system_predicate.TestMediaResult( fake_media_result ) )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.IMAGE_JPEG, HC.APPLICATION_PDF } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.IMAGE_PNG )
+
+ self.assertFalse( system_predicate.TestMediaResult( fake_media_result ) )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.GENERAL_IMAGE, HC.GENERAL_VIDEO } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.IMAGE_JPEG )
+
+ self.assertTrue( system_predicate.TestMediaResult( fake_media_result ) )
+
+ #
+
+ system_predicate = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, value = { HC.GENERAL_IMAGE, HC.GENERAL_VIDEO } )
+ fake_media_result = HelperFunctions.GetFakeMediaResult( HydrusData.GenerateKey(), mime = HC.ANIMATION_GIF )
+
+ self.assertFalse( system_predicate.TestMediaResult( fake_media_result ) )
+
+
+
+class TestAutocompletePredGubbins( unittest.TestCase ):
+
+ def test_parsed_autocomplete_text( self ):
+
+ def bool_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
+
+ self.assertEqual( pat.IsAcceptableForFileSearches(), values[0] )
+ self.assertEqual( pat.IsAcceptableForTagSearches(), values[1] )
+ self.assertEqual( pat.IsEmpty(), values[2] )
+ self.assertEqual( pat.IsExplicitWildcard( True ), values[3] )
+ self.assertEqual( pat.IsNamespaceSearch(), values[4] )
+ self.assertEqual( pat.IsTagSearch( True ), values[5] )
+ self.assertEqual( pat.inclusive, values[6] )
+
+
+ def search_text_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
+
+ self.assertEqual( pat.GetSearchText( False ), values[0] )
+ self.assertEqual( pat.GetSearchText( True ), values[1] )
+
+
+ def read_predicate_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
+
+ self.assertEqual( pat.GetImmediateFileSearchPredicate( True ), values[0] )
+ self.assertEqual( pat.GetNonTagFileSearchPredicates( True ), values[1] )
+
+
+ def write_predicate_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
+
+ self.assertEqual( pat.GetAddTagPredicate(), values[0] )
+
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ '', '' ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
+ search_text_tests( parsed_autocomplete_text, [ '', '' ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' ), [] ] )
+ write_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' ) ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, False ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus', inclusive = False ), [] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus*', 'samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 'samus*' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 'samus*' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'character:samus', 'character:samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus' ), [] ] )
+ write_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus' ) ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-character:samus ', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, False ] )
+ search_text_tests( parsed_autocomplete_text, [ 'character:samus', 'character:samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus', inclusive = False ), [] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 's*s', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 's*s', 's*s*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-s*s', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, False ] )
+ search_text_tests( parsed_autocomplete_text, [ 's*s', 's*s*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s', inclusive = False ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s', inclusive = False ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'metroid' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'metroid' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-metroid:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, False ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'metroid', inclusive = False ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'metroid', inclusive = False ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 's*s a*n', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 's*s a*n', 's*s a*n*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s a*n' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 's*s a*n' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( ' samus ', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' ), [] ] )
+ write_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' ) ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '[samus]', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, '[samus]' ), [] ] )
+ write_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, '[samus]' ) ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'creator-id:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'creator-id' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'creator-id' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'creator-id:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, False, False, True, True, False, True ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'creator-id' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'creator-id' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'n*n g*s e*n:as*ka', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'n*n g*s e*n:as*ka', 'n*n g*s e*n:as*ka*' ] )
+ read_predicate_tests( parsed_autocomplete_text, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 'n*n g*s e*n:as*ka' ), [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 'n*n g*s e*n:as*ka' ) ] ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'system:samus ', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, True ] )
+ search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
+
+ #
+ #
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = True
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, True, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
+
+ #
+ #
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = True
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, True, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
+
+ #
+ #
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
+
+ #
+ #
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = True
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, True, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ False, True, False, True, False, False, True ] )
+
+ #
+
+ parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
+
+ bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
+
+
+ def test_predicate_results_cache_init( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheInit()
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+
+ def test_predicate_results_cache_system( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ predicates = [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX ) ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheSystem( predicates )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+
+ def test_predicate_results_cache_subtag_normal( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ #
+
+ predicates = [ samus, samus_aran, character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'samus', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus, samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus*' ) ), { samus, samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samas br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus ar*' ) ), { samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus aran*' ) ), { samus_aran, character_samus_aran } )
+
+
+ def test_predicate_results_cache_subtag_exact( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ samus ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'samus', True )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus } )
+
+
+ def test_predicate_results_cache_full_normal( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:samus', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'characte:samus aran*' ) ), set() )
+
+
+ def test_predicate_results_cache_namespace_explicit_fetch_all( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:*', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ #
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
+
+
+ def test_predicate_results_cache_namespace_bare_fetch_all( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ #
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = True
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
+
+
+ def test_predicate_results_cache_namespaces_into_full_tags( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'char', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ #
+
+ search_namespaces_into_full_tags = True
+ namespace_bare_fetch_all_allowed = True
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
+
+
+ def test_predicate_results_cache_fetch_all_madness( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ search_namespaces_into_full_tags = False
+ namespace_bare_fetch_all_allowed = False
+ namespace_fetch_all_allowed = False
+ fetch_all_allowed = False
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ samus = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus' )
+ samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'samus aran' )
+ character_samus_aran = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' )
+
+ predicates = [ samus, samus_aran, character_samus_aran ]
+
+ predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, '*', False )
+
+ self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
+
+ #
+
+ search_namespaces_into_full_tags = True
+ namespace_bare_fetch_all_allowed = True
+ namespace_fetch_all_allowed = True
+ fetch_all_allowed = True
+
+ tag_autocomplete_options.SetTuple(
+ tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
+ tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
+ tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
+ search_namespaces_into_full_tags,
+ namespace_bare_fetch_all_allowed,
+ namespace_fetch_all_allowed,
+ fetch_all_allowed
+ )
+
+ pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
+ pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
+ pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
+ pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
+ pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
+ pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
+ pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
+ pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
+ pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
+
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), True )
+ self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), True )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
+
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus, samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus*' ) ), { samus, samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samas br*' ) ), set() )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus ar*' ) ), { samus_aran, character_samus_aran } )
+ self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus aran*' ) ), { samus_aran, character_samus_aran } )
+
+
+ def test_predicate_counts( self ):
+
+ # quick test for counts and __hash__
+
+ p_c = ClientSearchPredicate.PredicateCount( 1, 2, 3, 4 )
+
+ self.assertEqual( p_c.min_current_count, 1 )
+ self.assertEqual( p_c.min_pending_count, 2 )
+ self.assertEqual( p_c.max_current_count, 3 )
+ self.assertEqual( p_c.max_pending_count, 4 )
+
+ self.assertNotEqual( p_c, ClientSearchPredicate.PredicateCount( 1, 2, 3, 5 ) )
+ self.assertNotEqual( p_c, ClientSearchPredicate.PredicateCount( 1, 5, 3, 4 ) )
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 1, 2, 3, 4 ) )
+
+ #
+
+ null = ClientSearchPredicate.PredicateCount.STATICCreateNullCount()
+
+ self.assertEqual( null, ClientSearchPredicate.PredicateCount( 0, 0, 0, 0 ) )
+ self.assertEqual( null.GetMinCount(), 0 )
+ self.assertEqual( null.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
+ self.assertEqual( null.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
+ self.assertEqual( null.HasZeroCount(), True )
+ self.assertEqual( null.HasNonZeroCount(), False )
+ self.assertEqual( null.GetSuffixString(), '' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 3, 0, 3, 0 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 3, 0, 3, 0 ) )
+ self.assertEqual( p_c.GetMinCount(), 3 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 3 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(3)' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 0, 5, 0, 5 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 0, 5, 0, 5 ) )
+ self.assertEqual( p_c.GetMinCount(), 5 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 5 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(+5)' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 100, 0, 150, 0 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 100, 0, 150, 0 ) )
+ self.assertEqual( p_c.GetMinCount(), 100 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 100 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(100-150)' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 0, 80, 0, 85 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 0, 80, 0, 85 ) )
+ self.assertEqual( p_c.GetMinCount(), 80 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 80 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(+80-85)' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 0, 0, 1500, 0 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 0, 0, 1500, 0 ) )
+ self.assertEqual( p_c.GetMinCount(), 0 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(0-1,500)' )
+
+ #
+
+ p_c = ClientSearchPredicate.PredicateCount( 1, 2, 3, 4 )
+
+ self.assertEqual( p_c, ClientSearchPredicate.PredicateCount( 1, 2, 3, 4 ) )
+ self.assertEqual( p_c.GetMinCount(), 3 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
+ self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 2 )
+ self.assertEqual( p_c.HasZeroCount(), False )
+ self.assertEqual( p_c.HasNonZeroCount(), True )
+ self.assertEqual( p_c.GetSuffixString(), '(1-3) (+2-4)' )
+
+ #
+
+ p_c_1 = ClientSearchPredicate.PredicateCount( 10, 2, 12, 4 )
+ p_c_2 = ClientSearchPredicate.PredicateCount( 1, 0, 2, 4 )
+
+ p_c_1.AddCounts( p_c_2 )
+
+ self.assertEqual( p_c_1, ClientSearchPredicate.PredicateCount( 10, 2, 14, 8 ) )
+
+
+ def test_predicate_strings_and_namespaces( self ):
+
+ render_for_user = False
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'tag' )
+
+ self.assertEqual( p.ToString(), 'tag' )
+ self.assertEqual( p.GetNamespace(), '' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'tag', True, count = ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 2 ) )
+
+ self.assertEqual( p.ToString( with_count = False ), 'tag' )
+ self.assertEqual( p.ToString( with_count = True ), 'tag (1) (+2)' )
+ self.assertEqual( p.GetNamespace(), '' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'tag', False )
+
+ self.assertEqual( p.ToString(), '-tag' )
+ self.assertEqual( p.GetNamespace(), '' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'tag', False, count = ClientSearchPredicate.PredicateCount.STATICCreateStaticCount( 1, 2 ) )
+
+ self.assertEqual( p.ToString( with_count = False ), '-tag' )
+ self.assertEqual( p.ToString( with_count = True ), '-tag (1) (+2)' )
+ self.assertEqual( p.GetNamespace(), '' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ #
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 1, 2, 3, 4 ) ) )
+
+ self.assertEqual( p.ToString(), 'system:import time: since 1 year 2 months ago' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 1, 2, 3, 4 ) ) )
+
+ self.assertEqual( p.ToString(), 'system:import time: around 1 year 2 months ago' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 1, 2, 3, 4 ) ) )
+
+ self.assertEqual( p.ToString(), 'system:import time: before 1 year 2 months ago' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1000 ) )
+
+ self.assertEqual( p.ToString(), 'system:archive (1,000)' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_DURATION, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 200 ) )
+
+ self.assertEqual( p.ToString(), 'system:duration < 200 milliseconds' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 2000 ) )
+
+ self.assertEqual( p.ToString(), 'system:everything (2,000)' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:is currently in my files' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:is deleted from my files' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:is not pending to my files' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:is not petitioned from my files' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True )
+
+ self.assertEqual( p.ToString(), 'system:has audio' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False )
+
+ self.assertEqual( p.ToString(), 'system:no audio' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True )
+
+ self.assertEqual( p.ToString(), 'system:has transparency' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False )
+
+ self.assertEqual( p.ToString(), 'system:no transparency' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True )
+
+ self.assertEqual( p.ToString(), 'system:has exif' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False )
+
+ self.assertEqual( p.ToString(), 'system:no exif' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True )
+
+ self.assertEqual( p.ToString(), 'system:has human-readable embedded metadata' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False )
+
+ self.assertEqual( p.ToString(), 'system:no human-readable embedded metadata' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True )
+
+ self.assertEqual( p.ToString(), 'system:has icc profile' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False )
+
+ self.assertEqual( p.ToString(), 'system:no icc profile' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True )
+
+ self.assertEqual( p.ToString(), 'system:has forced filetype' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False )
+
+ self.assertEqual( p.ToString(), 'system:no forced filetype' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HASH, ( ( bytes.fromhex( 'abcd' ), ), 'sha256' ) )
+
+ self.assertEqual( p.ToString(), 'system:hash is abcd' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 2000 ) )
+
+ self.assertEqual( p.ToString(), 'system:height < 2,000' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 1000 ) )
+
+ self.assertEqual( p.ToString(), 'system:inbox (1,000)' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LIMIT, 2000 )
+
+ self.assertEqual( p.ToString(), 'system:limit is 2,000' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_LOCAL, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 100 ) )
+
+ self.assertEqual( p.ToString(), 'system:local (100)' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, set( HC.IMAGES ).intersection( HC.SEARCHABLE_MIMES ) )
+
+ self.assertEqual( p.ToString(), 'system:filetype is image' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.VIDEO_WEBM, ) )
+
+ self.assertEqual( p.ToString(), 'system:filetype is webm' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.VIDEO_WEBM, HC.ANIMATION_GIF ) )
+
+ self.assertEqual( p.ToString(), 'system:filetype is animated gif, webm' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_MIME, ( HC.GENERAL_AUDIO, HC.GENERAL_VIDEO ) )
+
+ self.assertEqual( p.ToString(), 'system:filetype is audio, video' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, count = ClientSearchPredicate.PredicateCount.STATICCreateCurrentCount( 100 ) )
+
+ self.assertEqual( p.ToString(), 'system:not local (100)' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '<', 2 ) )
+
+ self.assertEqual( p.ToString(), 'system:number of tags < 2' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 2 ) )
+
+ self.assertEqual( p.ToString(), 'system:number of character tags < 2' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 5 ) )
+
+ self.assertEqual( p.ToString(), 'system:number of urls < 5' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 5000 ) )
+
+ self.assertEqual( p.ToString(), 'system:number of words < 5,000' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ from hydrus.test import TestController
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.2, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:rating for example local rating numerical service > 1/5' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ) )
+
+ self.assertEqual( p.ToString(), 'system:rating for example local rating inc/dec service > 3' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 16, 9 ) )
+
+ self.assertEqual( p.ToString(), 'system:ratio = 16:9' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( bytes.fromhex( 'abcd' ), ), 5 ) )
+
+ self.assertEqual( p.ToString(), 'system:similar to 1 files with distance of 5' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( os.urandom( 32 ), ), ( os.urandom( 32 ), ), 2 ) )
+
+ self.assertEqual( p.ToString(), 'system:similar to data (1 pixel, 1 perceptual hashes) with distance of 2' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5, 1048576 ) )
+
+ self.assertEqual( p.ToString(), 'system:filesize > 5MB' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_WIDTH, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '=', 1920 ) )
+
+ self.assertEqual( p.ToString(), 'system:width = 1,920' )
+ self.assertEqual( p.GetNamespace(), 'system' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ #
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_NAMESPACE, 'series' )
+
+ self.assertEqual( p.ToString(), 'series:*anything*' )
+ self.assertEqual( p.GetNamespace(), 'series' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'series', False )
+
+ self.assertEqual( p.ToString(), '-series' )
+ self.assertEqual( p.GetNamespace(), '' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ #
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_WILDCARD, 'a*i:o*' )
+
+ self.assertEqual( p.ToString(), 'a*i:o* (wildcard search)' )
+ self.assertEqual( p.GetNamespace(), '*' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'a*i:o*', False )
+
+ self.assertEqual( p.ToString(), '-a*i:o*' )
+ self.assertEqual( p.GetNamespace(), '*' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ #
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_PARENT, 'series:game of thrones' )
+
+ self.assertEqual( p.ToString(), ' series:game of thrones' )
+ self.assertEqual( p.GetNamespace(), 'series' )
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
+
+ #
+
+ p = ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_OR_CONTAINER, [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientNumberTest.NumberTest.STATICCreateFromCharacters( '<', 2000 ) ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'blue eyes' ), ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'character:samus aran' ) ] )
+
+ self.assertEqual( p.ToString(), 'blue eyes OR character:samus aran OR system:height < 2,000' )
+ self.assertEqual( p.GetNamespace(), '' )
+
+ or_texts_and_namespaces = []
+
+ or_texts_and_namespaces.append( ( 'blue eyes', 'namespace', '' ) )
+ or_texts_and_namespaces.append( ( ' OR ', 'or', 'system' ) )
+ or_texts_and_namespaces.append( ( 'character:samus aran', 'namespace', 'character' ) )
+ or_texts_and_namespaces.append( ( ' OR ', 'or', 'system' ) )
+ or_texts_and_namespaces.append( ( 'system:height < 2,000', 'namespace', 'system' ) )
+
+
+ self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), or_texts_and_namespaces )
+
+
+ def test_system_predicate_parsing( self ):
+
+ for ( expected_result_text, sys_pred_text ) in [
+ ( 'system:similar to 4 files with distance of 3', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c08 e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c09 e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c10, e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c11 with distance 3" ),
+ ( 'system:similar to 1 files with distance of 5', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00 distance 5" ),
+ ( 'system:similar to 1 files with distance of 4', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00" ),
+ ( 'system:similar to 1 files with distance of 5', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00 with distance of 5" ),
+ ( 'system:similar to data (2 pixel hashes)', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92 distance 4" ),
+ ( 'system:similar to data (2 pixel hashes)', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92" ),
+ ( 'system:similar to data (2 perceptual hashes) with distance of 4', "system:similar to data 0702790ffeae5c8a 51ad07c228ab7469 distance 4" ),
+ ( 'system:similar to data (2 perceptual hashes) with distance of 8', "system:similar to data 0702790ffeae5c8a 51ad07c228ab7469" ),
+ ( 'system:similar to data (2 pixel, 2 perceptual hashes) with distance of 4', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92 51ad07c228ab7469 0702790ffeae5c8a distance 4" ),
+ ( 'system:everything', "system:everything" ),
+ ( 'system:inbox', "system:inbox " ),
+ ( 'system:archive', "system:archive " ),
+ ( 'system:archive', "system:archived " ),
+ ( 'system:archive', "system:archived" ),
+ ( 'system:duration: has duration', "system:has duration" ),
+ ( 'system:duration: has duration', "system:has_duration" ),
+ ( 'system:duration: no duration', " system:no_duration" ),
+ ( 'system:duration: no duration', "system:no duration" ),
+ ( 'system:duration: has duration', "system:duration: has duration" ),
+ ( 'system:duration: no duration', "system:duration: no duration" ),
+ ( 'system:is the best quality file of its duplicate group', "system:is the best quality file of its group" ),
+ ( 'system:is not the best quality file of its duplicate group', "system:isn't the best quality file of its duplicate group" ),
+ ( 'system:is not the best quality file of its duplicate group', 'system:is not the best quality file of its duplicate group' ),
+ ( 'system:has audio', "system:has_audio" ),
+ ( 'system:no audio', "system:no audio" ),
+ ( 'system:has tags', "system:has tags" ),
+ ( 'system:untagged', "system:no tags" ),
+ ( 'system:untagged', "system:untagged" ),
+ ( 'system:has human-readable embedded metadata', "system:has human readable embedded metadata" ),
+ ( 'system:no human-readable embedded metadata', "system:no human readable embedded metadata" ),
+ ( 'system:has human-readable embedded metadata', "system:has embedded metadata" ),
+ ( 'system:no human-readable embedded metadata', "system:no embedded metadata" ),
+ ( 'system:has icc profile', "system:has icc profile" ),
+ ( 'system:no icc profile', "system:no icc profile" ),
+ ( 'system:has forced filetype', "system:has forced filetype" ),
+ ( 'system:no forced filetype', "system:no forced filetype" ),
+ ( 'system:number of tags > 5', "system:number of tags > 5" ),
+ ( 'system:number of character tags > 5', "system:number of character tags > 5" ),
+ ( f'system:number of tags {HC.UNICODE_APPROX_EQUAL} 10', "system:number of tags ~= 10" ),
+ ( 'system:has tags', "system:number of tags > 0 " ),
+ ( 'system:number of urls < 2', 'system:number of urls < 2' ),
+ ( 'system:number of urls < 2', 'system:num urls < 2' ),
+ ( 'system:number of urls: has urls', 'system:num urls > 0' ),
+ ( 'system:number of urls: has urls', 'system:num urls: has urls' ),
+ ( 'system:number of urls: no urls', 'system:num urls = 0' ),
+ ( 'system:number of urls: no urls', 'system:number of urls: no urls' ),
+ ( 'system:number of urls < 2', 'system:number of urls < 2' ),
+ ( 'system:number of urls < 2', 'system:num urls < 2' ),
+ ( 'system:number of words: has words', 'system:num words > 0' ),
+ ( 'system:number of words: has words', 'system:num words: has words' ),
+ ( 'system:number of words: no words', 'system:num words = 0' ),
+ ( 'system:number of words: no words', 'system:number of words: no words' ),
+ ( 'system:height = 600', "system:height = 600px" ),
+ ( 'system:height = 800', "system:height is 800" ),
+ ( 'system:height > 900', "system:height > 900" ),
+ ( 'system:width < 200', "system:width < 200" ),
+ ( 'system:width > 1,000', "system:width > 1000 pixels" ),
+ ( f'system:filesize {HC.UNICODE_APPROX_EQUAL} 50KB', "system:filesize ~= 50 kilobytes" ),
+ ( 'system:filesize > 10MB', "system:filesize > 10megabytes" ),
+ ( 'system:filesize < 1GB', "system:file size < 1 GB" ),
+ ( 'system:filesize > 0B', "system:file size > 0 B" ),
+ ( 'system:limit is 5,000', "system:limit is 5000" ),
+ ( 'system:limit is 100', "system:limit = 100" ),
+ ( 'system:filetype is jpeg', "system:filetype is jpeg" ),
+ ( 'system:filetype is apng, jpeg, png', "system:filetype = image/jpg, image/png, apng" ),
+ ( 'system:filetype is image', "system:filetype is image" ),
+ ( 'system:filetype is animated gif, static gif, jpeg', "system:filetype = static gif, animated gif, jpeg" ),
+ ( 'system:hash is in 3 hashes', "system:hash = cf09faad262075f96bf9a30052b8ec224e096948a4f3a2776df5fa5a777bcfd8 a1b0ab771d11d9a6d1f993efee9d253d3aa78914387a7c8ceab520af88ab3de2 98a7d2f4735a5fcc70e7c94e2dadcc6ea45123fb2035b9cfe7ad1d78e48cae9e" ),
+ ( 'system:hash (md5) is in 3 hashes', "system:hash = ada7a31713ba24652c52e52c6f212e47 546fd4b8c39fc53e77e2f28b59cd1b18, cec888bacb79825621738454a4c9d226 md5" ),
+ ( 'system:hash (md5) is 666d0a395c8d4eebb5b15a0771972a01', "system:hash (md5) = 666d0a395c8d4eebb5b15a0771972a01" ),
+ ( 'system:hash (md5) is 123fec741ebe7596c1faf8d7689693b8', "system:Hash = 123feC741ebe7596c1faf8d7689693b8 md5" ),
+ ( 'system:hash (sha1) is not 2496baf1ded134b5ff7e44f72155240b9561ab5a', "system:Hash (sha1) != 2496baf1ded134b5ff7e44f72155240b9561ab5a" ),
+ ( 'system:hash is not b49f25453c6351403d62cc4d065321106c90f98b5653e83d289dbe0d55ba8c94', "system:Hash is not b49f25453c6351403d62cc4d065321106c90f98b5653e83d289dbe0d55ba8c94 sha256" ),
+ ( 'system:hash is 4d4ff3d42459f824295a36138782c444028f533b6ae5f0f67b27e9bf3c93de5d', "system:hash = 4d4ff3d42459f824295a36138782c444028f533b6ae5f0f67b27e9bf3c93de5d" ),
+ ( 'system:archived time: since 60 days ago', "system:archived date < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:archive date < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:archived time < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:archive time < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:date archived < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:time archived < 60 days" ),
+ ( 'system:archived time: since 60 days ago', "system:archived < 60 days" ),
+ ( 'system:modified time: since 60 days ago', "system:modified date < 60 days" ),
+ ( 'system:modified time: since 2011-06-04', "system:modified date > 2011-06-04" ),
+ ( 'system:modified time: before 60 days 4 hours ago', "system:date modified > 60 days 4 hours" ),
+ ( 'system:modified time: since 1 day ago', "system:date modified < 1 day" ),
+ ( 'system:modified time: since 1 day ago', "system:time modified < 1 day" ),
+ ( 'system:modified time: since 1 day ago', "system:modified date < 1 day" ),
+ ( 'system:modified time: since 1 day ago', "system:modified time < 1 day" ),
+ ( 'system:last viewed time: since 60 days ago', "system:last viewed time < 60 days" ),
+ ( 'system:last viewed time: since 60 days ago', "system:last viewed date < 60 days" ),
+ ( 'system:last viewed time: since 60 days ago', "system:last view time < 60 days" ),
+ ( 'system:last viewed time: since 60 days ago', "system:last view date < 60 days" ),
+ ( 'system:last viewed time: since 60 days ago', "system:time last viewed < 60 days" ),
+ ( 'system:last viewed time: since 60 days ago', "system:date last viewed < 60 days" ),
+ ( 'system:import time: since 60 days ago', "system:time_imported < 60 days" ),
+ ( 'system:import time: since 2011-06-04', "system:time imported > 2011-06-04" ),
+ ( 'system:import time: before 60 days 4 hours ago', "system:time imported > 60 days 4 hours" ),
+ ( 'system:import time: before 60 days 4 hours ago', "system:time imported > 60 days 4 hours" ),
+ ( 'system:import time: since 1 day ago', "system:time imported < 1 day" ),
+ ( 'system:import time: a month either side of 2011-01-03', " system:time imported ~= 2011-1-3 " ),
+ ( 'system:import time: a month either side of 1996-05-02', "system:time imported ~= 1996-05-2" ),
+ ( 'system:import time: since 60 days ago', "system:import_time < 60 days" ),
+ ( 'system:import time: since 2011-06-04', "system:import time > 2011-06-04" ),
+ ( 'system:import time: before 60 days 4 hours ago', "system:import time > 60 days 4 hours" ),
+ ( 'system:import time: around 1 day ago', "system:import time = 1 day" ),
+ ( 'system:import time: a month either side of 2011-01-03', " system:import time ~= 2011-1-3 " ),
+ ( 'system:import time: a month either side of 1996-05-02', "system:import time ~= 1996-05-2" ),
+ ( 'system:import time: since 1 day ago', "system:import time < 1 day" ),
+ ( 'system:import time: since 1 day ago', "system:imported time < 1 day" ),
+ ( 'system:import time: since 1 day ago', "system:import date < 1 day" ),
+ ( 'system:import time: since 1 day ago', "system:imported date < 1 day" ),
+ ( 'system:import time: since 1 day ago', "system:time imported < 1 day" ),
+ ( 'system:import time: since 1 day ago', "system:date imported < 1 day" ),
+ ( 'system:import time: a month either side of 2020-01-03', "system:import time: the month of 2020-01-03" ),
+ ( 'system:import time: on the day of 2020-01-03', "system:import time: the day of 2020-01-03" ),
+ ( 'system:import time: around 7 days ago', "system:date imported around 7 days ago" ),
+ ( 'system:duration < 5 seconds', "system:duration < 5 seconds" ),
+ ( f'system:duration {HC.UNICODE_APPROX_EQUAL} 11 seconds {HC.UNICODE_PLUS_OR_MINUS}15%', "system:duration ~= 5 sec 6000 msecs" ),
+ ( 'system:duration > 3 milliseconds', "system:duration > 3 milliseconds" ),
+ ( 'system:is pending to my files', "system:file service is pending to my files" ),
+ ( 'system:is pending to my files', "system:file service is pending to MY FILES" ),
+ ( 'system:is currently in my files', " system:file service currently in my files" ),
+ ( 'system:is not currently in my files', "system:file service isn't currently in my files" ),
+ ( 'system:is not pending to my files', "system:file service is not pending to my files" ),
+ ( 'system:num file relationships - has less than 3 alternates', "system:num file relationships < 3 alternates" ),
+ ( 'system:num file relationships - has more than 3 not related/false positive', "system:number of file relationships > 3 false positives" ),
+ ( 'system:ratio wider than 16:9', "system:ratio is wider than 16:9 " ),
+ ( 'system:ratio = 16:9', "system:ratio is 16:9" ),
+ ( 'system:ratio is portrait', "system:ratio taller than 1:1" ),
+ ( 'system:ratio is square', "system:ratio is square" ),
+ ( 'system:ratio is portrait', "system:ratio is portrait" ),
+ ( 'system:ratio is landscape', "system:ratio is landscape" ),
+ ( 'system:number of pixels > 50 pixels', "system:num pixels > 50 px" ),
+ ( 'system:number of pixels < 1 megapixels', "system:num pixels < 1 megapixels " ),
+ ( f'system:number of pixels {HC.UNICODE_APPROX_EQUAL} 5 kilopixels', "system:num pixels ~= 5 kilopixel" ),
+ ( f'system:media views {HC.UNICODE_APPROX_EQUAL} 10', "system:media views ~= 10" ),
+ ( 'system:all views > 0', "system:all views > 0" ),
+ ( 'system:preview views < 10', "system:preview views < 10 " ),
+ ( 'system:media viewtime < 1 day 1 hour', "system:media viewtime < 1 days 1 hour 0 minutes" ),
+ ( 'system:all viewtime > 1 hour 1 minute', "system:all viewtime > 1 hours 100 seconds" ),
+ ( f'system:preview viewtime {HC.UNICODE_APPROX_EQUAL} 2 days 7 hours', "system:preview viewtime ~= 1 day 30 hours 100 minutes 90s" ),
+ ( 'system:has url matching regex index\\.php', " system:has url matching regex index\\.php" ),
+ ( 'system:does not have url matching regex index\\.php', "system:does not have a url matching regex index\\.php" ),
+ ( 'system:has url https://safebooru.donmai.us/posts/4695284', "system:has_url https://safebooru.donmai.us/posts/4695284" ),
+ ( 'system:does not have url https://safebooru.donmai.us/posts/4695284', " system:doesn't have url https://safebooru.donmai.us/posts/4695284 " ),
+ ( 'system:has url with domain safebooru.com', "system:has domain safebooru.com" ),
+ ( 'system:does not have url with domain safebooru.com', "system:doesn't have domain safebooru.com" ),
+ ( 'system:has url with class safebooru file page', "system:has url with class safebooru file page" ),
+ ( 'system:does not have url with class safebooru file page', "system:doesn't have a url with url class safebooru file page " ),
+ ( 'system:tag as number: page less than 5', "system:tag as number page < 5" ),
+ ( 'system:tag as number: page less than 5', "system:tag as number: page less than 5" ),
+ ( 'system:number of notes: has notes', 'system:has note' ),
+ ( 'system:number of notes: has notes', 'system:has notes' ),
+ ( 'system:number of notes: no notes', 'system:no note' ),
+ ( 'system:number of notes: no notes', 'system:has no note' ),
+ ( 'system:number of notes: no notes', 'system:no notes' ),
+ ( 'system:number of notes: no notes', 'system:does not have notes' ),
+ ( 'system:number of notes: no notes', 'system:does not have a note' ),
+ ( 'system:number of notes = 5', 'system:num notes = 5' ),
+ ( 'system:number of notes > 1', 'system:number of notes > 1' ),
+ ( 'system:number of notes: has notes', 'system:number of notes > 0' ),
+ ( 'system:number of notes: no notes', 'system:number of notes = 0' ),
+ ( 'system:has note with name "test"', 'system:has note with name test' ),
+ ( 'system:has note with name "test"', 'system:has a note with name test' ),
+ ( 'system:has note with name "test"', 'system:note with name test' ),
+ ( 'system:has note with name "test"', 'system:note with name "test"' ),
+ ( 'system:does not have note with name "test"', 'system:no note with name test' ),
+ ( 'system:does not have note with name "test"', 'system:does not have note with name test' ),
+ ( 'system:does not have note with name "test"', 'system:doesn\'t have note with name test' ),
+ ( 'system:does not have note with name "test"', 'system:does not have a note with name test' ),
+ ( 'system:does not have note with name "test"', 'system:does not have a note with name "test"' ),
+ ( 'system:has a rating for example local rating numerical service', 'system:has rating example local rating numerical service' ),
+ ( 'system:has a rating for example local rating numerical service', 'system:has a rating for example local rating numerical service' ),
+ ( 'system:does not have a rating for example local rating numerical service', 'system:no rating example local rating numerical service' ),
+ ( 'system:does not have a rating for example local rating numerical service', 'system:does not have a rating for example local rating numerical service' ),
+ ( 'system:rating for example local rating numerical service = 3/5', 'system:rating for example local rating numerical service = 3/5' ),
+ ( 'system:rating for example local rating numerical service = 3/5', 'system:rating for example local rating numerical service is 3/5' ),
+ ( f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5', f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5' ),
+ ( f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5', 'system:rating for example local rating numerical service about 3/5' ),
+ ( 'system:rating for example local rating numerical service < 3/5', 'system:rating for example local rating numerical service < 3/5' ),
+ ( 'system:rating for example local rating numerical service < 3/5', 'system:rating for example local rating numerical service less than 3/5' ),
+ ( 'system:rating for example local rating numerical service > 3/5', 'system:rating for example local rating numerical service > 3/5' ),
+ ( 'system:rating for example local rating numerical service > 3/5', 'system:rating for example local rating numerical service more than 3/5' ),
+ ( 'system:rating for example local rating like service = like', 'system:rating for example local rating like service = like' ),
+ ( 'system:rating for example local rating like service = dislike', 'system:rating for example local rating like service = dislike' ),
+ ( 'system:rating for example local rating inc/dec service = 123', 'system:rating for example local rating inc/dec service = 123' ),
+ ( 'system:rating for example local rating inc/dec service > 123', 'system:rating for example local rating inc/dec service > 123' ),
+ ( 'system:rating for example local rating inc/dec service > 123', 'system:rating example local rating inc/dec service more than 123' ),
+ ( 'system:rating for example local rating inc/dec service < 123', 'system:rating for example local rating inc/dec service < 123' ),
+ ( 'system:rating for example local rating inc/dec service < 123', 'system:rating for example local rating inc/dec service less than 123' ),
+ ( f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123', f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123' ),
+ ( f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123', 'system:rating for example local rating inc/dec service about 123' ),
+ ]:
+
+ ( sys_pred, ) = ClientSearchParseSystemPredicates.ParseSystemPredicateStringsToPredicates( ( sys_pred_text, ) )
+
+ self.assertEqual( sys_pred.ToString(), expected_result_text )
+
+
+
+ def test_tag_import_options_simple( self ):
+
+ tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
+
+ self.assertTrue( tag_autocomplete_options.FetchResultsAutomatically() )
+ self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), 2 )
+
+ #
+
+ tag_autocomplete_options.SetFetchResultsAutomatically( False )
+
+ self.assertFalse( tag_autocomplete_options.FetchResultsAutomatically() )
+
+ tag_autocomplete_options.SetFetchResultsAutomatically( True )
+
+ self.assertTrue( tag_autocomplete_options.FetchResultsAutomatically() )
+
+ tag_autocomplete_options.SetExactMatchCharacterThreshold( None )
+
+ self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), None )
+
+ tag_autocomplete_options.SetExactMatchCharacterThreshold( 2 )
+
+ self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), 2 )
+
+
diff --git a/hydrus/test/TestClientTags.py b/hydrus/test/TestClientTags.py
index a1c1ed612..e453a6e95 100644
--- a/hydrus/test/TestClientTags.py
+++ b/hydrus/test/TestClientTags.py
@@ -12,9 +12,11 @@
from hydrus.client.metadata import ClientContentUpdates
from hydrus.client.metadata import ClientTags
from hydrus.client.metadata import ClientTagsHandling
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientNumberTest
from hydrus.client.search import ClientSearchAutocomplete
from hydrus.client.search import ClientSearchParseSystemPredicates
+from hydrus.client.search import ClientSearchPredicate
+from hydrus.client.search import ClientSearchTagContext
class TestMergeTagsManagers( unittest.TestCase ):
@@ -201,25 +203,25 @@ def test_get_namespace_slice( self ):
def test_get_num_tags( self ):
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._first_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._first_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 8 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._first_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._first_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 8 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._first_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._first_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 8 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._first_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._first_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 8 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._second_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._second_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 2 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._second_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._second_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 3 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._second_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._second_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 2 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._second_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._second_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 3 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._third_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._third_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._third_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = self._third_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._third_key, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._third_key, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._third_key, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = self._third_key, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 10 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
- self.assertEqual( self._tags_manager.GetNumTags( ClientSearch.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 11 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = False, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 0 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = False ), ClientTags.TAG_DISPLAY_STORAGE ), 10 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = False, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 1 )
+ self.assertEqual( self._tags_manager.GetNumTags( ClientSearchTagContext.TagContext( service_key = CC.COMBINED_TAG_SERVICE_KEY, include_current_tags = True, include_pending_tags = True ), ClientTags.TAG_DISPLAY_STORAGE ), 11 )
def test_get_pending( self ):
@@ -418,6 +420,7 @@ def test_reset_service( self ):
self.assertEqual( self._other_tags_manager.GetPetitioned( self._reset_service_key, ClientTags.TAG_DISPLAY_STORAGE ), set() )
+
class TestTagDisplayManager( unittest.TestCase ):
def test_tag_filtering( self ):
@@ -451,1809 +454,6 @@ def test_tag_filtering( self ):
self.assertEqual( selection_tags, filter_pages.Filter( tags ) )
-class TestTagObjects( unittest.TestCase ):
-
- def test_parsed_autocomplete_text( self ):
-
- def bool_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
-
- self.assertEqual( pat.IsAcceptableForFileSearches(), values[0] )
- self.assertEqual( pat.IsAcceptableForTagSearches(), values[1] )
- self.assertEqual( pat.IsEmpty(), values[2] )
- self.assertEqual( pat.IsExplicitWildcard( True ), values[3] )
- self.assertEqual( pat.IsNamespaceSearch(), values[4] )
- self.assertEqual( pat.IsTagSearch( True ), values[5] )
- self.assertEqual( pat.inclusive, values[6] )
-
-
- def search_text_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
-
- self.assertEqual( pat.GetSearchText( False ), values[0] )
- self.assertEqual( pat.GetSearchText( True ), values[1] )
-
-
- def read_predicate_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
-
- self.assertEqual( pat.GetImmediateFileSearchPredicate( True ), values[0] )
- self.assertEqual( pat.GetNonTagFileSearchPredicates( True ), values[1] )
-
-
- def write_predicate_tests( pat: ClientSearchAutocomplete.ParsedAutocompleteText, values ):
-
- self.assertEqual( pat.GetAddTagPredicate(), values[0] )
-
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ '', '' ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
- search_text_tests( parsed_autocomplete_text, [ '', '' ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' ), [] ] )
- write_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' ) ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, False ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus', inclusive = False ), [] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus*', 'samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 'samus*' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 'samus*' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'character:samus', 'character:samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus' ), [] ] )
- write_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus' ) ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-character:samus ', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, False ] )
- search_text_tests( parsed_autocomplete_text, [ 'character:samus', 'character:samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus', inclusive = False ), [] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 's*s', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ 's*s', 's*s*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-s*s', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, False ] )
- search_text_tests( parsed_autocomplete_text, [ 's*s', 's*s*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s', inclusive = False ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s', inclusive = False ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'metroid' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'metroid' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-metroid:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, False ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'metroid', inclusive = False ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'metroid', inclusive = False ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 's*s a*n', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ 's*s a*n', 's*s a*n*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s a*n' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 's*s a*n' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( ' samus ', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' ), [] ] )
- write_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' ) ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '[samus]', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, '[samus]' ), [] ] )
- write_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, '[samus]' ) ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'creator-id:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'creator-id' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'creator-id' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'creator-id:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, False, False, True, True, False, True ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'creator-id' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'creator-id' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'n*n g*s e*n:as*ka', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'n*n g*s e*n:as*ka', 'n*n g*s e*n:as*ka*' ] )
- read_predicate_tests( parsed_autocomplete_text, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 'n*n g*s e*n:as*ka' ), [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 'n*n g*s e*n:as*ka' ) ] ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'system:samus ', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, True ] )
- search_text_tests( parsed_autocomplete_text, [ 'samus', 'samus*' ] )
-
- #
- #
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = True
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, True, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
-
- #
- #
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = True
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, True, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
-
- #
- #
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = True
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, False, False, False, True, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
-
- #
- #
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = True
- fetch_all_allowed = True
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, True, False, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '-', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, False, False, False, False, False, False ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, False, False, True, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, True, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( '*:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ False, True, False, True, False, False, True ] )
-
- #
-
- parsed_autocomplete_text = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:*', tag_autocomplete_options, True )
-
- bool_tests( parsed_autocomplete_text, [ True, True, False, True, True, False, True ] )
-
-
- def test_predicate_results_cache_init( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheInit()
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
-
- def test_predicate_results_cache_system( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- predicates = [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX ) ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheSystem( predicates )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
-
- def test_predicate_results_cache_subtag_normal( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- #
-
- predicates = [ samus, samus_aran, character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'samus', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus, samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus*' ) ), { samus, samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samas br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus ar*' ) ), { samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus aran*' ) ), { samus_aran, character_samus_aran } )
-
-
- def test_predicate_results_cache_subtag_exact( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ samus ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'samus', True )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus } )
-
-
- def test_predicate_results_cache_full_normal( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:samus', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'characte:samus aran*' ) ), set() )
-
-
- def test_predicate_results_cache_namespace_explicit_fetch_all( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:*', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- #
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = True
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
-
-
- def test_predicate_results_cache_namespace_bare_fetch_all( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'character:', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- #
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = True
- namespace_fetch_all_allowed = True
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
-
-
- def test_predicate_results_cache_namespaces_into_full_tags( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, 'char', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- #
-
- search_namespaces_into_full_tags = True
- namespace_bare_fetch_all_allowed = True
- namespace_fetch_all_allowed = True
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
-
-
- def test_predicate_results_cache_fetch_all_madness( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- search_namespaces_into_full_tags = False
- namespace_bare_fetch_all_allowed = False
- namespace_fetch_all_allowed = False
- fetch_all_allowed = False
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- samus = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus' )
- samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'samus aran' )
- character_samus_aran = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' )
-
- predicates = [ samus, samus_aran, character_samus_aran ]
-
- predicate_results_cache = ClientSearchAutocomplete.PredicateResultsCacheTag( predicates, '*', False )
-
- self.assertEqual( predicate_results_cache.GetPredicates(), predicates )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), False )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), False )
-
- #
-
- search_namespaces_into_full_tags = True
- namespace_bare_fetch_all_allowed = True
- namespace_fetch_all_allowed = True
- fetch_all_allowed = True
-
- tag_autocomplete_options.SetTuple(
- tag_autocomplete_options.GetWriteAutocompleteTagDomain(),
- tag_autocomplete_options.OverridesWriteAutocompleteLocationContext(),
- tag_autocomplete_options.GetWriteAutocompleteLocationContext(),
- search_namespaces_into_full_tags,
- namespace_bare_fetch_all_allowed,
- namespace_fetch_all_allowed,
- fetch_all_allowed
- )
-
- pat_empty = ClientSearchAutocomplete.ParsedAutocompleteText( '', tag_autocomplete_options, True )
- pat_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus', tag_autocomplete_options, True )
- pat_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus ar', tag_autocomplete_options, True )
- pat_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'samus br', tag_autocomplete_options, True )
- pat_character_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus', tag_autocomplete_options, True )
- pat_character_samus_ar = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus ar', tag_autocomplete_options, True )
- pat_character_samus_br = ClientSearchAutocomplete.ParsedAutocompleteText( 'character:samus br', tag_autocomplete_options, True )
- pat_metroid = ClientSearchAutocomplete.ParsedAutocompleteText( 'metroid', tag_autocomplete_options, True )
- pat_series_samus = ClientSearchAutocomplete.ParsedAutocompleteText( 'series:samus', tag_autocomplete_options, True )
-
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_empty, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_ar, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_character_samus_br, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_metroid, False ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, True ), True )
- self.assertEqual( predicate_results_cache.CanServeTagResults( pat_series_samus, False ), True )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus ar*' ) ), { character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'character:samus aran*' ) ), { character_samus_aran } )
-
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus' ) ), { samus, samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus*' ) ), { samus, samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samas br*' ) ), set() )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus ar*' ) ), { samus_aran, character_samus_aran } )
- self.assertEqual( set( predicate_results_cache.FilterPredicates( CC.COMBINED_TAG_SERVICE_KEY, 'samus aran*' ) ), { samus_aran, character_samus_aran } )
-
-
- def test_predicate_counts( self ):
-
- # quick test for counts and __hash__
-
- p_c = ClientSearch.PredicateCount( 1, 2, 3, 4 )
-
- self.assertEqual( p_c.min_current_count, 1 )
- self.assertEqual( p_c.min_pending_count, 2 )
- self.assertEqual( p_c.max_current_count, 3 )
- self.assertEqual( p_c.max_pending_count, 4 )
-
- self.assertNotEqual( p_c, ClientSearch.PredicateCount( 1, 2, 3, 5 ) )
- self.assertNotEqual( p_c, ClientSearch.PredicateCount( 1, 5, 3, 4 ) )
- self.assertEqual( p_c, ClientSearch.PredicateCount( 1, 2, 3, 4 ) )
-
- #
-
- null = ClientSearch.PredicateCount.STATICCreateNullCount()
-
- self.assertEqual( null, ClientSearch.PredicateCount( 0, 0, 0, 0 ) )
- self.assertEqual( null.GetMinCount(), 0 )
- self.assertEqual( null.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
- self.assertEqual( null.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
- self.assertEqual( null.HasZeroCount(), True )
- self.assertEqual( null.HasNonZeroCount(), False )
- self.assertEqual( null.GetSuffixString(), '' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 3, 0, 3, 0 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 3, 0, 3, 0 ) )
- self.assertEqual( p_c.GetMinCount(), 3 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 3 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(3)' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 0, 5, 0, 5 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 0, 5, 0, 5 ) )
- self.assertEqual( p_c.GetMinCount(), 5 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 5 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(+5)' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 100, 0, 150, 0 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 100, 0, 150, 0 ) )
- self.assertEqual( p_c.GetMinCount(), 100 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 100 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(100-150)' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 0, 80, 0, 85 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 0, 80, 0, 85 ) )
- self.assertEqual( p_c.GetMinCount(), 80 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 80 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(+80-85)' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 0, 0, 1500, 0 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 0, 0, 1500, 0 ) )
- self.assertEqual( p_c.GetMinCount(), 0 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 0 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 0 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(0-1,500)' )
-
- #
-
- p_c = ClientSearch.PredicateCount( 1, 2, 3, 4 )
-
- self.assertEqual( p_c, ClientSearch.PredicateCount( 1, 2, 3, 4 ) )
- self.assertEqual( p_c.GetMinCount(), 3 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_CURRENT ), 1 )
- self.assertEqual( p_c.GetMinCount( HC.CONTENT_STATUS_PENDING ), 2 )
- self.assertEqual( p_c.HasZeroCount(), False )
- self.assertEqual( p_c.HasNonZeroCount(), True )
- self.assertEqual( p_c.GetSuffixString(), '(1-3) (+2-4)' )
-
- #
-
- p_c_1 = ClientSearch.PredicateCount( 10, 2, 12, 4 )
- p_c_2 = ClientSearch.PredicateCount( 1, 0, 2, 4 )
-
- p_c_1.AddCounts( p_c_2 )
-
- self.assertEqual( p_c_1, ClientSearch.PredicateCount( 10, 2, 14, 8 ) )
-
-
- def test_predicate_strings_and_namespaces( self ):
-
- render_for_user = False
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'tag' )
-
- self.assertEqual( p.ToString(), 'tag' )
- self.assertEqual( p.GetNamespace(), '' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'tag', True, count = ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 2 ) )
-
- self.assertEqual( p.ToString( with_count = False ), 'tag' )
- self.assertEqual( p.ToString( with_count = True ), 'tag (1) (+2)' )
- self.assertEqual( p.GetNamespace(), '' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'tag', False )
-
- self.assertEqual( p.ToString(), '-tag' )
- self.assertEqual( p.GetNamespace(), '' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'tag', False, count = ClientSearch.PredicateCount.STATICCreateStaticCount( 1, 2 ) )
-
- self.assertEqual( p.ToString( with_count = False ), '-tag' )
- self.assertEqual( p.ToString( with_count = True ), '-tag (1) (+2)' )
- self.assertEqual( p.GetNamespace(), '' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- #
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '<', 'delta', ( 1, 2, 3, 4 ) ) )
-
- self.assertEqual( p.ToString(), 'system:import time: since 1 year 2 months ago' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( HC.UNICODE_APPROX_EQUAL, 'delta', ( 1, 2, 3, 4 ) ) )
-
- self.assertEqual( p.ToString(), 'system:import time: around 1 year 2 months ago' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_AGE, ( '>', 'delta', ( 1, 2, 3, 4 ) ) )
-
- self.assertEqual( p.ToString(), 'system:import time: before 1 year 2 months ago' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_ARCHIVE, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1000 ) )
-
- self.assertEqual( p.ToString(), 'system:archive (1,000)' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_DURATION, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 200 ) )
-
- self.assertEqual( p.ToString(), 'system:duration < 200 milliseconds' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_EVERYTHING, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 2000 ) )
-
- self.assertEqual( p.ToString(), 'system:everything (2,000)' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_CURRENT, CC.LOCAL_FILE_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:is currently in my files' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( True, HC.CONTENT_STATUS_DELETED, CC.LOCAL_FILE_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:is deleted from my files' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PENDING, CC.LOCAL_FILE_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:is not pending to my files' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_FILE_SERVICE, ( False, HC.CONTENT_STATUS_PETITIONED, CC.LOCAL_FILE_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:is not petitioned from my files' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, True )
-
- self.assertEqual( p.ToString(), 'system:has audio' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_AUDIO, False )
-
- self.assertEqual( p.ToString(), 'system:no audio' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, True )
-
- self.assertEqual( p.ToString(), 'system:has transparency' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_TRANSPARENCY, False )
-
- self.assertEqual( p.ToString(), 'system:no transparency' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, True )
-
- self.assertEqual( p.ToString(), 'system:has exif' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_EXIF, False )
-
- self.assertEqual( p.ToString(), 'system:no exif' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, True )
-
- self.assertEqual( p.ToString(), 'system:has human-readable embedded metadata' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_HUMAN_READABLE_EMBEDDED_METADATA, False )
-
- self.assertEqual( p.ToString(), 'system:no human-readable embedded metadata' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, True )
-
- self.assertEqual( p.ToString(), 'system:has icc profile' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_ICC_PROFILE, False )
-
- self.assertEqual( p.ToString(), 'system:no icc profile' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, True )
-
- self.assertEqual( p.ToString(), 'system:has forced filetype' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HAS_FORCED_FILETYPE, False )
-
- self.assertEqual( p.ToString(), 'system:no forced filetype' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HASH, ( ( bytes.fromhex( 'abcd' ), ), 'sha256' ) )
-
- self.assertEqual( p.ToString(), 'system:hash is abcd' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 2000 ) )
-
- self.assertEqual( p.ToString(), 'system:height < 2,000' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_INBOX, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 1000 ) )
-
- self.assertEqual( p.ToString(), 'system:inbox (1,000)' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LIMIT, 2000 )
-
- self.assertEqual( p.ToString(), 'system:limit is 2,000' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_LOCAL, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 100 ) )
-
- self.assertEqual( p.ToString(), 'system:local (100)' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, set( HC.IMAGES ).intersection( HC.SEARCHABLE_MIMES ) )
-
- self.assertEqual( p.ToString(), 'system:filetype is image' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.VIDEO_WEBM, ) )
-
- self.assertEqual( p.ToString(), 'system:filetype is webm' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.VIDEO_WEBM, HC.ANIMATION_GIF ) )
-
- self.assertEqual( p.ToString(), 'system:filetype is animated gif, webm' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_MIME, ( HC.GENERAL_AUDIO, HC.GENERAL_VIDEO ) )
-
- self.assertEqual( p.ToString(), 'system:filetype is audio, video' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NOT_LOCAL, count = ClientSearch.PredicateCount.STATICCreateCurrentCount( 100 ) )
-
- self.assertEqual( p.ToString(), 'system:not local (100)' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( '*', '<', 2 ) )
-
- self.assertEqual( p.ToString(), 'system:number of tags < 2' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_TAGS, ( 'character', '<', 2 ) )
-
- self.assertEqual( p.ToString(), 'system:number of character tags < 2' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_URLS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 5 ) )
-
- self.assertEqual( p.ToString(), 'system:number of urls < 5' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_NUM_WORDS, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 5000 ) )
-
- self.assertEqual( p.ToString(), 'system:number of words < 5,000' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- from hydrus.test import TestController
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 0.2, TestController.LOCAL_RATING_NUMERICAL_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:rating for example local rating numerical service > 1/5' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATING, ( '>', 3, TestController.LOCAL_RATING_INCDEC_SERVICE_KEY ) )
-
- self.assertEqual( p.ToString(), 'system:rating for example local rating inc/dec service > 3' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_RATIO, ( '=', 16, 9 ) )
-
- self.assertEqual( p.ToString(), 'system:ratio = 16:9' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_FILES, ( ( bytes.fromhex( 'abcd' ), ), 5 ) )
-
- self.assertEqual( p.ToString(), 'system:similar to 1 files with distance of 5' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIMILAR_TO_DATA, ( ( os.urandom( 32 ), ), ( os.urandom( 32 ), ), 2 ) )
-
- self.assertEqual( p.ToString(), 'system:similar to data (1 pixel, 1 perceptual hashes) with distance of 2' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_SIZE, ( '>', 5, 1048576 ) )
-
- self.assertEqual( p.ToString(), 'system:filesize > 5MB' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_WIDTH, ClientSearch.NumberTest.STATICCreateFromCharacters( '=', 1920 ) )
-
- self.assertEqual( p.ToString(), 'system:width = 1,920' )
- self.assertEqual( p.GetNamespace(), 'system' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- #
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_NAMESPACE, 'series' )
-
- self.assertEqual( p.ToString(), 'series:*anything*' )
- self.assertEqual( p.GetNamespace(), 'series' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'series', False )
-
- self.assertEqual( p.ToString(), '-series' )
- self.assertEqual( p.GetNamespace(), '' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- #
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_WILDCARD, 'a*i:o*' )
-
- self.assertEqual( p.ToString(), 'a*i:o* (wildcard search)' )
- self.assertEqual( p.GetNamespace(), '*' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'a*i:o*', False )
-
- self.assertEqual( p.ToString(), '-a*i:o*' )
- self.assertEqual( p.GetNamespace(), '*' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- #
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_PARENT, 'series:game of thrones' )
-
- self.assertEqual( p.ToString(), ' series:game of thrones' )
- self.assertEqual( p.GetNamespace(), 'series' )
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), [ ( p.ToString(), 'namespace', p.GetNamespace() ) ] )
-
- #
-
- p = ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_OR_CONTAINER, [ ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_SYSTEM_HEIGHT, ClientSearch.NumberTest.STATICCreateFromCharacters( '<', 2000 ) ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'blue eyes' ), ClientSearch.Predicate( ClientSearch.PREDICATE_TYPE_TAG, 'character:samus aran' ) ] )
-
- self.assertEqual( p.ToString(), 'blue eyes OR character:samus aran OR system:height < 2,000' )
- self.assertEqual( p.GetNamespace(), '' )
-
- or_texts_and_namespaces = []
-
- or_texts_and_namespaces.append( ( 'blue eyes', 'namespace', '' ) )
- or_texts_and_namespaces.append( ( ' OR ', 'or', 'system' ) )
- or_texts_and_namespaces.append( ( 'character:samus aran', 'namespace', 'character' ) )
- or_texts_and_namespaces.append( ( ' OR ', 'or', 'system' ) )
- or_texts_and_namespaces.append( ( 'system:height < 2,000', 'namespace', 'system' ) )
-
-
- self.assertEqual( p.GetTextsAndNamespaces( render_for_user ), or_texts_and_namespaces )
-
-
- def test_system_predicate_parsing( self ):
-
- for ( expected_result_text, sys_pred_text ) in [
- ( 'system:similar to 4 files with distance of 3', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c08 e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c09 e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c10, e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c11 with distance 3" ),
- ( 'system:similar to 1 files with distance of 5', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00 distance 5" ),
- ( 'system:similar to 1 files with distance of 4', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00" ),
- ( 'system:similar to 1 files with distance of 5', "system:similar to e2c1592ce2a3338767bb7990738ae06357cbdfe917669da9a0d04069f9759c00 with distance of 5" ),
- ( 'system:similar to data (2 pixel hashes)', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92 distance 4" ),
- ( 'system:similar to data (2 pixel hashes)', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92" ),
- ( 'system:similar to data (2 perceptual hashes) with distance of 4', "system:similar to data 0702790ffeae5c8a 51ad07c228ab7469 distance 4" ),
- ( 'system:similar to data (2 perceptual hashes) with distance of 8', "system:similar to data 0702790ffeae5c8a 51ad07c228ab7469" ),
- ( 'system:similar to data (2 pixel, 2 perceptual hashes) with distance of 4', "system:similar to data b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd91 b51d75120456d6e2155416f26416a96290b0a524bf1582af50b4fcf46dedcd92 51ad07c228ab7469 0702790ffeae5c8a distance 4" ),
- ( 'system:everything', "system:everything" ),
- ( 'system:inbox', "system:inbox " ),
- ( 'system:archive', "system:archive " ),
- ( 'system:archive', "system:archived " ),
- ( 'system:archive', "system:archived" ),
- ( 'system:duration: has duration', "system:has duration" ),
- ( 'system:duration: has duration', "system:has_duration" ),
- ( 'system:duration: no duration', " system:no_duration" ),
- ( 'system:duration: no duration', "system:no duration" ),
- ( 'system:duration: has duration', "system:duration: has duration" ),
- ( 'system:duration: no duration', "system:duration: no duration" ),
- ( 'system:is the best quality file of its duplicate group', "system:is the best quality file of its group" ),
- ( 'system:is not the best quality file of its duplicate group', "system:isn't the best quality file of its duplicate group" ),
- ( 'system:is not the best quality file of its duplicate group', 'system:is not the best quality file of its duplicate group' ),
- ( 'system:has audio', "system:has_audio" ),
- ( 'system:no audio', "system:no audio" ),
- ( 'system:has tags', "system:has tags" ),
- ( 'system:untagged', "system:no tags" ),
- ( 'system:untagged', "system:untagged" ),
- ( 'system:has human-readable embedded metadata', "system:has human readable embedded metadata" ),
- ( 'system:no human-readable embedded metadata', "system:no human readable embedded metadata" ),
- ( 'system:has human-readable embedded metadata', "system:has embedded metadata" ),
- ( 'system:no human-readable embedded metadata', "system:no embedded metadata" ),
- ( 'system:has icc profile', "system:has icc profile" ),
- ( 'system:no icc profile', "system:no icc profile" ),
- ( 'system:has forced filetype', "system:has forced filetype" ),
- ( 'system:no forced filetype', "system:no forced filetype" ),
- ( 'system:number of tags > 5', "system:number of tags > 5" ),
- ( 'system:number of character tags > 5', "system:number of character tags > 5" ),
- ( f'system:number of tags {HC.UNICODE_APPROX_EQUAL} 10', "system:number of tags ~= 10" ),
- ( 'system:has tags', "system:number of tags > 0 " ),
- ( 'system:number of urls < 2', 'system:number of urls < 2' ),
- ( 'system:number of urls < 2', 'system:num urls < 2' ),
- ( 'system:number of urls: has urls', 'system:num urls > 0' ),
- ( 'system:number of urls: has urls', 'system:num urls: has urls' ),
- ( 'system:number of urls: no urls', 'system:num urls = 0' ),
- ( 'system:number of urls: no urls', 'system:number of urls: no urls' ),
- ( 'system:number of urls < 2', 'system:number of urls < 2' ),
- ( 'system:number of urls < 2', 'system:num urls < 2' ),
- ( 'system:number of words: has words', 'system:num words > 0' ),
- ( 'system:number of words: has words', 'system:num words: has words' ),
- ( 'system:number of words: no words', 'system:num words = 0' ),
- ( 'system:number of words: no words', 'system:number of words: no words' ),
- ( 'system:height = 600', "system:height = 600px" ),
- ( 'system:height = 800', "system:height is 800" ),
- ( 'system:height > 900', "system:height > 900" ),
- ( 'system:width < 200', "system:width < 200" ),
- ( 'system:width > 1,000', "system:width > 1000 pixels" ),
- ( f'system:filesize {HC.UNICODE_APPROX_EQUAL} 50KB', "system:filesize ~= 50 kilobytes" ),
- ( 'system:filesize > 10MB', "system:filesize > 10megabytes" ),
- ( 'system:filesize < 1GB', "system:file size < 1 GB" ),
- ( 'system:filesize > 0B', "system:file size > 0 B" ),
- ( 'system:limit is 5,000', "system:limit is 5000" ),
- ( 'system:limit is 100', "system:limit = 100" ),
- ( 'system:filetype is jpeg', "system:filetype is jpeg" ),
- ( 'system:filetype is apng, jpeg, png', "system:filetype = image/jpg, image/png, apng" ),
- ( 'system:filetype is image', "system:filetype is image" ),
- ( 'system:filetype is animated gif, static gif, jpeg', "system:filetype = static gif, animated gif, jpeg" ),
- ( 'system:hash is in 3 hashes', "system:hash = cf09faad262075f96bf9a30052b8ec224e096948a4f3a2776df5fa5a777bcfd8 a1b0ab771d11d9a6d1f993efee9d253d3aa78914387a7c8ceab520af88ab3de2 98a7d2f4735a5fcc70e7c94e2dadcc6ea45123fb2035b9cfe7ad1d78e48cae9e" ),
- ( 'system:hash (md5) is in 3 hashes', "system:hash = ada7a31713ba24652c52e52c6f212e47 546fd4b8c39fc53e77e2f28b59cd1b18, cec888bacb79825621738454a4c9d226 md5" ),
- ( 'system:hash (md5) is 666d0a395c8d4eebb5b15a0771972a01', "system:hash (md5) = 666d0a395c8d4eebb5b15a0771972a01" ),
- ( 'system:hash (md5) is 123fec741ebe7596c1faf8d7689693b8', "system:Hash = 123feC741ebe7596c1faf8d7689693b8 md5" ),
- ( 'system:hash (sha1) is not 2496baf1ded134b5ff7e44f72155240b9561ab5a', "system:Hash (sha1) != 2496baf1ded134b5ff7e44f72155240b9561ab5a" ),
- ( 'system:hash is not b49f25453c6351403d62cc4d065321106c90f98b5653e83d289dbe0d55ba8c94', "system:Hash is not b49f25453c6351403d62cc4d065321106c90f98b5653e83d289dbe0d55ba8c94 sha256" ),
- ( 'system:hash is 4d4ff3d42459f824295a36138782c444028f533b6ae5f0f67b27e9bf3c93de5d', "system:hash = 4d4ff3d42459f824295a36138782c444028f533b6ae5f0f67b27e9bf3c93de5d" ),
- ( 'system:archived time: since 60 days ago', "system:archived date < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:archive date < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:archived time < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:archive time < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:date archived < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:time archived < 60 days" ),
- ( 'system:archived time: since 60 days ago', "system:archived < 60 days" ),
- ( 'system:modified time: since 60 days ago', "system:modified date < 60 days" ),
- ( 'system:modified time: since 2011-06-04', "system:modified date > 2011-06-04" ),
- ( 'system:modified time: before 60 days 4 hours ago', "system:date modified > 60 days 4 hours" ),
- ( 'system:modified time: since 1 day ago', "system:date modified < 1 day" ),
- ( 'system:modified time: since 1 day ago', "system:time modified < 1 day" ),
- ( 'system:modified time: since 1 day ago', "system:modified date < 1 day" ),
- ( 'system:modified time: since 1 day ago', "system:modified time < 1 day" ),
- ( 'system:last viewed time: since 60 days ago', "system:last viewed time < 60 days" ),
- ( 'system:last viewed time: since 60 days ago', "system:last viewed date < 60 days" ),
- ( 'system:last viewed time: since 60 days ago', "system:last view time < 60 days" ),
- ( 'system:last viewed time: since 60 days ago', "system:last view date < 60 days" ),
- ( 'system:last viewed time: since 60 days ago', "system:time last viewed < 60 days" ),
- ( 'system:last viewed time: since 60 days ago', "system:date last viewed < 60 days" ),
- ( 'system:import time: since 60 days ago', "system:time_imported < 60 days" ),
- ( 'system:import time: since 2011-06-04', "system:time imported > 2011-06-04" ),
- ( 'system:import time: before 60 days 4 hours ago', "system:time imported > 60 days 4 hours" ),
- ( 'system:import time: before 60 days 4 hours ago', "system:time imported > 60 days 4 hours" ),
- ( 'system:import time: since 1 day ago', "system:time imported < 1 day" ),
- ( 'system:import time: a month either side of 2011-01-03', " system:time imported ~= 2011-1-3 " ),
- ( 'system:import time: a month either side of 1996-05-02', "system:time imported ~= 1996-05-2" ),
- ( 'system:import time: since 60 days ago', "system:import_time < 60 days" ),
- ( 'system:import time: since 2011-06-04', "system:import time > 2011-06-04" ),
- ( 'system:import time: before 60 days 4 hours ago', "system:import time > 60 days 4 hours" ),
- ( 'system:import time: around 1 day ago', "system:import time = 1 day" ),
- ( 'system:import time: a month either side of 2011-01-03', " system:import time ~= 2011-1-3 " ),
- ( 'system:import time: a month either side of 1996-05-02', "system:import time ~= 1996-05-2" ),
- ( 'system:import time: since 1 day ago', "system:import time < 1 day" ),
- ( 'system:import time: since 1 day ago', "system:imported time < 1 day" ),
- ( 'system:import time: since 1 day ago', "system:import date < 1 day" ),
- ( 'system:import time: since 1 day ago', "system:imported date < 1 day" ),
- ( 'system:import time: since 1 day ago', "system:time imported < 1 day" ),
- ( 'system:import time: since 1 day ago', "system:date imported < 1 day" ),
- ( 'system:import time: a month either side of 2020-01-03', "system:import time: the month of 2020-01-03" ),
- ( 'system:import time: on the day of 2020-01-03', "system:import time: the day of 2020-01-03" ),
- ( 'system:import time: around 7 days ago', "system:date imported around 7 days ago" ),
- ( 'system:duration < 5 seconds', "system:duration < 5 seconds" ),
- ( f'system:duration {HC.UNICODE_APPROX_EQUAL} 11 seconds {HC.UNICODE_PLUS_OR_MINUS}15%', "system:duration ~= 5 sec 6000 msecs" ),
- ( 'system:duration > 3 milliseconds', "system:duration > 3 milliseconds" ),
- ( 'system:is pending to my files', "system:file service is pending to my files" ),
- ( 'system:is pending to my files', "system:file service is pending to MY FILES" ),
- ( 'system:is currently in my files', " system:file service currently in my files" ),
- ( 'system:is not currently in my files', "system:file service isn't currently in my files" ),
- ( 'system:is not pending to my files', "system:file service is not pending to my files" ),
- ( 'system:num file relationships - has less than 3 alternates', "system:num file relationships < 3 alternates" ),
- ( 'system:num file relationships - has more than 3 not related/false positive', "system:number of file relationships > 3 false positives" ),
- ( 'system:ratio wider than 16:9', "system:ratio is wider than 16:9 " ),
- ( 'system:ratio = 16:9', "system:ratio is 16:9" ),
- ( 'system:ratio is portrait', "system:ratio taller than 1:1" ),
- ( 'system:ratio is square', "system:ratio is square" ),
- ( 'system:ratio is portrait', "system:ratio is portrait" ),
- ( 'system:ratio is landscape', "system:ratio is landscape" ),
- ( 'system:number of pixels > 50 pixels', "system:num pixels > 50 px" ),
- ( 'system:number of pixels < 1 megapixels', "system:num pixels < 1 megapixels " ),
- ( f'system:number of pixels {HC.UNICODE_APPROX_EQUAL} 5 kilopixels', "system:num pixels ~= 5 kilopixel" ),
- ( f'system:media views {HC.UNICODE_APPROX_EQUAL} 10', "system:media views ~= 10" ),
- ( 'system:all views > 0', "system:all views > 0" ),
- ( 'system:preview views < 10', "system:preview views < 10 " ),
- ( 'system:media viewtime < 1 day 1 hour', "system:media viewtime < 1 days 1 hour 0 minutes" ),
- ( 'system:all viewtime > 1 hour 1 minute', "system:all viewtime > 1 hours 100 seconds" ),
- ( f'system:preview viewtime {HC.UNICODE_APPROX_EQUAL} 2 days 7 hours', "system:preview viewtime ~= 1 day 30 hours 100 minutes 90s" ),
- ( 'system:has url matching regex index\\.php', " system:has url matching regex index\\.php" ),
- ( 'system:does not have url matching regex index\\.php', "system:does not have a url matching regex index\\.php" ),
- ( 'system:has url https://safebooru.donmai.us/posts/4695284', "system:has_url https://safebooru.donmai.us/posts/4695284" ),
- ( 'system:does not have url https://safebooru.donmai.us/posts/4695284', " system:doesn't have url https://safebooru.donmai.us/posts/4695284 " ),
- ( 'system:has url with domain safebooru.com', "system:has domain safebooru.com" ),
- ( 'system:does not have url with domain safebooru.com', "system:doesn't have domain safebooru.com" ),
- ( 'system:has url with class safebooru file page', "system:has url with class safebooru file page" ),
- ( 'system:does not have url with class safebooru file page', "system:doesn't have a url with url class safebooru file page " ),
- ( 'system:tag as number: page less than 5', "system:tag as number page < 5" ),
- ( 'system:tag as number: page less than 5', "system:tag as number: page less than 5" ),
- ( 'system:number of notes: has notes', 'system:has note' ),
- ( 'system:number of notes: has notes', 'system:has notes' ),
- ( 'system:number of notes: no notes', 'system:no note' ),
- ( 'system:number of notes: no notes', 'system:has no note' ),
- ( 'system:number of notes: no notes', 'system:no notes' ),
- ( 'system:number of notes: no notes', 'system:does not have notes' ),
- ( 'system:number of notes: no notes', 'system:does not have a note' ),
- ( 'system:number of notes = 5', 'system:num notes = 5' ),
- ( 'system:number of notes > 1', 'system:number of notes > 1' ),
- ( 'system:number of notes: has notes', 'system:number of notes > 0' ),
- ( 'system:number of notes: no notes', 'system:number of notes = 0' ),
- ( 'system:has note with name "test"', 'system:has note with name test' ),
- ( 'system:has note with name "test"', 'system:has a note with name test' ),
- ( 'system:has note with name "test"', 'system:note with name test' ),
- ( 'system:has note with name "test"', 'system:note with name "test"' ),
- ( 'system:does not have note with name "test"', 'system:no note with name test' ),
- ( 'system:does not have note with name "test"', 'system:does not have note with name test' ),
- ( 'system:does not have note with name "test"', 'system:doesn\'t have note with name test' ),
- ( 'system:does not have note with name "test"', 'system:does not have a note with name test' ),
- ( 'system:does not have note with name "test"', 'system:does not have a note with name "test"' ),
- ( 'system:has a rating for example local rating numerical service', 'system:has rating example local rating numerical service' ),
- ( 'system:has a rating for example local rating numerical service', 'system:has a rating for example local rating numerical service' ),
- ( 'system:does not have a rating for example local rating numerical service', 'system:no rating example local rating numerical service' ),
- ( 'system:does not have a rating for example local rating numerical service', 'system:does not have a rating for example local rating numerical service' ),
- ( 'system:rating for example local rating numerical service = 3/5', 'system:rating for example local rating numerical service = 3/5' ),
- ( 'system:rating for example local rating numerical service = 3/5', 'system:rating for example local rating numerical service is 3/5' ),
- ( f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5', f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5' ),
- ( f'system:rating for example local rating numerical service {HC.UNICODE_APPROX_EQUAL} 3/5', 'system:rating for example local rating numerical service about 3/5' ),
- ( 'system:rating for example local rating numerical service < 3/5', 'system:rating for example local rating numerical service < 3/5' ),
- ( 'system:rating for example local rating numerical service < 3/5', 'system:rating for example local rating numerical service less than 3/5' ),
- ( 'system:rating for example local rating numerical service > 3/5', 'system:rating for example local rating numerical service > 3/5' ),
- ( 'system:rating for example local rating numerical service > 3/5', 'system:rating for example local rating numerical service more than 3/5' ),
- ( 'system:rating for example local rating like service = like', 'system:rating for example local rating like service = like' ),
- ( 'system:rating for example local rating like service = dislike', 'system:rating for example local rating like service = dislike' ),
- ( 'system:rating for example local rating inc/dec service = 123', 'system:rating for example local rating inc/dec service = 123' ),
- ( 'system:rating for example local rating inc/dec service > 123', 'system:rating for example local rating inc/dec service > 123' ),
- ( 'system:rating for example local rating inc/dec service > 123', 'system:rating example local rating inc/dec service more than 123' ),
- ( 'system:rating for example local rating inc/dec service < 123', 'system:rating for example local rating inc/dec service < 123' ),
- ( 'system:rating for example local rating inc/dec service < 123', 'system:rating for example local rating inc/dec service less than 123' ),
- ( f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123', f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123' ),
- ( f'system:rating for example local rating inc/dec service {HC.UNICODE_APPROX_EQUAL} 123', 'system:rating for example local rating inc/dec service about 123' ),
- ]:
-
- ( sys_pred, ) = ClientSearchParseSystemPredicates.ParseSystemPredicateStringsToPredicates( ( sys_pred_text, ) )
-
- self.assertEqual( sys_pred.ToString(), expected_result_text )
-
-
-
- def test_tag_import_options_simple( self ):
-
- tag_autocomplete_options = ClientTagsHandling.TagAutocompleteOptions( CC.COMBINED_TAG_SERVICE_KEY )
-
- self.assertTrue( tag_autocomplete_options.FetchResultsAutomatically() )
- self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), 2 )
-
- #
-
- tag_autocomplete_options.SetFetchResultsAutomatically( False )
-
- self.assertFalse( tag_autocomplete_options.FetchResultsAutomatically() )
-
- tag_autocomplete_options.SetFetchResultsAutomatically( True )
-
- self.assertTrue( tag_autocomplete_options.FetchResultsAutomatically() )
-
- tag_autocomplete_options.SetExactMatchCharacterThreshold( None )
-
- self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), None )
-
- tag_autocomplete_options.SetExactMatchCharacterThreshold( 2 )
-
- self.assertEqual( tag_autocomplete_options.GetExactMatchCharacterThreshold(), 2 )
-
-
class TestTagRendering( unittest.TestCase ):
diff --git a/hydrus/test/TestController.py b/hydrus/test/TestController.py
index d8d41168c..cff6e219c 100644
--- a/hydrus/test/TestController.py
+++ b/hydrus/test/TestController.py
@@ -59,6 +59,7 @@
from hydrus.test import TestClientMigration
from hydrus.test import TestClientNetworking
from hydrus.test import TestClientParsing
+from hydrus.test import TestClientSearch
from hydrus.test import TestClientTags
from hydrus.test import TestClientThreading
from hydrus.test import TestDialogs
@@ -780,6 +781,7 @@ def Run( self, window ):
TestClientFileStorage,
TestClientImportOptions,
TestClientParsing,
+ TestClientSearch,
TestClientTags,
TestClientThreading,
TestHydrusSerialisable,
@@ -821,6 +823,7 @@ def Run( self, window ):
TestClientFileStorage,
TestClientImportOptions,
TestClientParsing,
+ TestClientSearch,
TestClientTags,
TestClientThreading,
TestHydrusData,
@@ -831,6 +834,10 @@ def Run( self, window ):
TestHydrusSessions
]
+ module_lookup[ 'search' ] = [
+ TestClientSearch
+ ]
+
module_lookup[ 'tags_fast' ] = [
TestClientTags
]
diff --git a/hydrus/test/TestHydrusSerialisable.py b/hydrus/test/TestHydrusSerialisable.py
index 34660c9e4..cf8a018c3 100644
--- a/hydrus/test/TestHydrusSerialisable.py
+++ b/hydrus/test/TestHydrusSerialisable.py
@@ -20,7 +20,7 @@
from hydrus.client.media import ClientMediaManagers
from hydrus.client.media import ClientMediaResult
from hydrus.client.metadata import ClientContentUpdates
-from hydrus.client.search import ClientSearch
+from hydrus.client.search import ClientSearchPredicate
from hydrus.test import HelperFunctions as HF
from hydrus.test import TestController as TC
@@ -99,9 +99,9 @@ def test( obj, dupe_obj ):
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[ ClientSearchPredicate.Predicate( ClientSearchPredicate.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 ) ] )
+ d[ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'test pred 2' ) ] = HydrusSerialisable.SerialisableList( [ ClientSearchPredicate.Predicate( ClientSearchPredicate.PREDICATE_TYPE_TAG, 'test' + str( i ) ) for i in range( 10 ) ] )
self.assertEqual( len( list(d.keys()) ), 7 )
diff --git a/static/default/url_classes/x post.png b/static/default/url_classes/x post.png
index 7f0ae94d3..f03d1f109 100644
Binary files a/static/default/url_classes/x post.png and b/static/default/url_classes/x post.png differ