<s> from copy import deepcopy <EOL> class JavatarDict : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , global_dict = None , local_dict = None ) : <EOL> self . global_dict = global_dict or { } <EOL> self . local_dict = local_dict or { } <EOL> self . global_change = False <EOL> self . local_change = False <EOL> def get_dict ( self , customMerger = None ) : <EOL> """<STR_LIT>""" <EOL> global_dict = deepcopy ( self . global_dict ) <EOL> if customMerger is not None : <EOL> return customMerger ( global_dict , self . local_dict ) <EOL> for key in self . local_dict : <EOL> global_dict [ key ] = self . local_dict [ key ] <EOL> return global_dict <EOL> def has ( self , key , in_global = True , in_local = True ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> in_local and key in self . local_dict <EOL> ) or ( <EOL> in_global and key in self . global_dict <EOL> ) <EOL> def get ( self , key , default = None ) : <EOL> """<STR_LIT>""" <EOL> if self . has ( key , in_global = False , in_local = True ) : <EOL> return self . local_dict [ key ] <EOL> elif self . has ( key , in_global = True , in_local = False ) : <EOL> return self . global_dict [ key ] <EOL> else : <EOL> return default <EOL> def set ( self , key , val , to_global = False ) : <EOL> """<STR_LIT>""" <EOL> if val is None : <EOL> if self . has ( key , in_global = False , in_local = True ) : <EOL> del self . local_dict [ key ] <EOL> self . local_change = True <EOL> elif self . has ( key , in_global = True , in_local = False ) : <EOL> del self . global_dict [ key ] <EOL> self . global_change = True <EOL> else : <EOL> if to_global : <EOL> if key not in self . global_dict or self . global_dict [ key ] != val : <EOL> self . global_dict [ key ] = val <EOL> self . global_change = True <EOL> else : <EOL> if key not in self . local_dict or self . local_dict [ key ] != val : <EOL> self . local_dict [ key ] = val <EOL> self . local_change = True <EOL> def is_local_change ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . local_change <EOL> def is_global_change ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . global_change <EOL> def get_local_dict ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . local_dict <EOL> def get_global_dict ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . global_dict </s>
