@@ -106,7 +106,7 @@ def main(client, campaign_id):
106106
107107 while page ['totalNumEntries' ] > offset :
108108 page = shared_criterion_service .get (selector )
109- if page [ 'entries' ] :
109+ if 'entries' in page :
110110 for shared_criterion in page ['entries' ]:
111111 if shared_criterion ['criterion' ]['type' ] == 'KEYWORD' :
112112 print ('Shared negative keyword with ID %d and text "%s" was'
@@ -129,21 +129,22 @@ def main(client, campaign_id):
129129 selector ['paging' ]['startIndex' ] = offset
130130
131131 # Finally, remove the criteria.
132- operations = [
133- {
134- 'operator' : 'REMOVE' ,
135- 'operand' : {
136- 'criterion' : {'id' : criterion ['criterionId' ]},
137- 'sharedSetId' : criterion ['sharedSetId' ]
138- }
139- } for criterion in criterion_ids
140- ]
141-
142- response = shared_criterion_service .mutate (operations )
143- if 'value' in response :
144- for criterion in response ['value' ]:
145- print ('Criterion ID %d was successfully removed from shared set ID'
146- '%d.' % (criterion ['criterion' ]['id' ], criterion ['sharedSetId' ]))
132+ if criterion_ids :
133+ operations = [
134+ {
135+ 'operator' : 'REMOVE' ,
136+ 'operand' : {
137+ 'criterion' : {'id' : criterion ['criterionId' ]},
138+ 'sharedSetId' : criterion ['sharedSetId' ]
139+ }
140+ } for criterion in criterion_ids
141+ ]
142+
143+ response = shared_criterion_service .mutate (operations )
144+ if 'value' in response :
145+ for criterion in response ['value' ]:
146+ print ('Criterion ID %d was successfully removed from shared set ID'
147+ '%d.' % (criterion ['criterion' ]['id' ], criterion ['sharedSetId' ]))
147148 else :
148149 print 'No shared criteria were removed.'
149150
0 commit comments