@@ -186,6 +186,12 @@ def ensure_per_project_customization(self):
186
186
'label' : 'project parameter'
187
187
}, True )
188
188
189
+ def ensure_support_for_additional_filter_presets (self ):
190
+ """Wrapper for ensure_support"""
191
+ return self ._ensure_support ({
192
+ 'version' : (7 , 0 , 0 ),
193
+ 'label' : 'additional_filter_presets parameter'
194
+ }, True )
189
195
190
196
def __str__ (self ):
191
197
return "ServerCapabilities: host %s, version %s, is_dev %s" \
@@ -528,7 +534,8 @@ def info(self):
528
534
return self ._call_rpc ("info" , None , include_auth_params = False )
529
535
530
536
def find_one (self , entity_type , filters , fields = None , order = None ,
531
- filter_operator = None , retired_only = False , include_archived_projects = True ):
537
+ filter_operator = None , retired_only = False , include_archived_projects = True ,
538
+ additional_filter_presets = None ):
532
539
"""Calls the find() method and returns the first result, or None.
533
540
534
541
:param entity_type: Required, entity type (string) to find.
@@ -553,20 +560,32 @@ def find_one(self, entity_type, filters, fields=None, order=None,
553
560
:param retired_only: Optional, flag to return only entities that have
554
561
been retried. Defaults to False which returns only entities which
555
562
have not been retired.
556
-
563
+
564
+ :param additional_filter_presets: Optional list of presets to
565
+ further filter the result set, list has the form:
566
+ [{"preset_name": <preset_name>, <optional_param1>: <optional_value1>, ... }]
567
+
568
+ Note that these filters are ANDed together and ANDed with the 'filter'
569
+ argument.
570
+
571
+ For details on supported presets and the format of this parameter,
572
+ please consult the API documentation:
573
+ https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Filter-Syntax
574
+
557
575
:returns: Dictionary of requested Shotgun fields and values.
558
576
"""
559
577
560
578
results = self .find (entity_type , filters , fields , order ,
561
- filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects )
579
+ filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects ,
580
+ additional_filter_presets = additional_filter_presets )
562
581
563
582
if results :
564
583
return results [0 ]
565
584
return None
566
585
567
586
def find (self , entity_type , filters , fields = None , order = None ,
568
587
filter_operator = None , limit = 0 , retired_only = False , page = 0 ,
569
- include_archived_projects = True ):
588
+ include_archived_projects = True , additional_filter_presets = None ):
570
589
"""Find entities matching the given filters.
571
590
572
591
:param entity_type: Required, entity type (string) to find.
@@ -593,7 +612,18 @@ def find(self, entity_type, filters, fields=None, order=None,
593
612
have not been retired.
594
613
595
614
:param include_archived_projects: Optional, flag to include entities
596
- whose projects have been archived
615
+ whose projects have been archived.
616
+
617
+ :param additional_filter_presets: Optional list of presets to
618
+ further filter the result set, list has the form:
619
+ [{"preset_name": <preset_name>, <optional_param1>: <optional_value1>, ... }]
620
+
621
+ Note that these filters are ANDed together and ANDed with the 'filter'
622
+ argument.
623
+
624
+ For details on supported presets and the format of this parameter,
625
+ please consult the API documentation:
626
+ https://github.com/shotgunsoftware/python-api/wiki/Reference%3A-Filter-Syntax
597
627
598
628
:returns: list of the dicts for each entity with the requested fields,
599
629
and their id and type.
@@ -617,13 +647,16 @@ def find(self, entity_type, filters, fields=None, order=None,
617
647
# So we only need to check the server version if it is False
618
648
self .server_caps .ensure_include_archived_projects ()
619
649
650
+ if additional_filter_presets :
651
+ self .server_caps .ensure_support_for_additional_filter_presets ()
620
652
621
653
params = self ._construct_read_parameters (entity_type ,
622
654
fields ,
623
655
filters ,
624
656
retired_only ,
625
657
order ,
626
- include_archived_projects )
658
+ include_archived_projects ,
659
+ additional_filter_presets )
627
660
628
661
if limit and limit <= self .config .records_per_page :
629
662
params ["paging" ]["entities_per_page" ] = limit
@@ -667,7 +700,8 @@ def _construct_read_parameters(self,
667
700
filters ,
668
701
retired_only ,
669
702
order ,
670
- include_archived_projects ):
703
+ include_archived_projects ,
704
+ additional_filter_presets ):
671
705
params = {}
672
706
params ["type" ] = entity_type
673
707
params ["return_fields" ] = fields or ["id" ]
@@ -677,6 +711,9 @@ def _construct_read_parameters(self,
677
711
params ["paging" ] = { "entities_per_page" : self .config .records_per_page ,
678
712
"current_page" : 1 }
679
713
714
+ if additional_filter_presets :
715
+ params ["additional_filter_presets" ] = additional_filter_presets ;
716
+
680
717
if include_archived_projects is False :
681
718
# Defaults to True on the server, so only pass it if it's False
682
719
params ["include_archived_projects" ] = False
@@ -695,7 +732,6 @@ def _construct_read_parameters(self,
695
732
params ['sorts' ] = sort_list
696
733
return params
697
734
698
-
699
735
def _add_project_param (self , params , project_entity ):
700
736
701
737
if project_entity and self .server_caps .ensure_per_project_customization ():
@@ -1909,8 +1945,7 @@ def text_search(self, text, entity_types, project_ids=None, limit=None):
1909
1945
1910
1946
api_entity_types = {}
1911
1947
for (entity_type , filter_list ) in entity_types .iteritems ():
1912
-
1913
-
1948
+
1914
1949
if isinstance (filter_list , (list , tuple )):
1915
1950
resolved_filters = _translate_filters (filter_list , filter_operator = None )
1916
1951
api_entity_types [entity_type ] = resolved_filters
0 commit comments