55simple.
66"""
77import copy
8-
98from abc import ABCMeta , abstractmethod
109from collections import defaultdict
1110
@@ -148,7 +147,12 @@ def _field_data(self, block, name):
148147 if scope not in self ._scope_mappings :
149148 raise InvalidScopeError (scope )
150149
151- return self ._scope_mappings [scope ]
150+ scope_mapping = self ._scope_mappings [scope ]
151+
152+ if scope_mapping is None :
153+ raise InvalidScopeError (scope )
154+
155+ return scope_mapping
152156
153157 def get (self , block , name ):
154158 return self ._field_data (block , name ).get (block , name )
@@ -161,8 +165,10 @@ def set_many(self, block, update_dict):
161165 for key , value in update_dict .items ():
162166 update_dicts [self ._field_data (block , key )][key ] = value
163167 for field_data , new_update_dict in update_dicts .items ():
164- if field_data is not None : # Ignore fields from scopes that are not loaded
168+ try :
165169 field_data .set_many (block , new_update_dict )
170+ except InvalidScopeError :
171+ pass # Ignore fields that are not in the scope_mappings
166172
167173 def delete (self , block , name ):
168174 self ._field_data (block , name ).delete (block , name )
0 commit comments