<s> class SettingsOverride ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , settings_module , ** overrides ) : <EOL> self . settings_module = settings_module <EOL> self . overrides = overrides <EOL> def __enter__ ( self ) : <EOL> self . old = { } <EOL> for key , value in list ( self . overrides . items ( ) ) : <EOL> self . old [ key ] = getattr ( self . settings_module , key , None ) <EOL> setattr ( self . settings_module , key , value ) <EOL> def __exit__ ( self , _type , value , traceback ) : <EOL> for key , value in list ( self . old . items ( ) ) : <EOL> if value is not None : <EOL> setattr ( self . settings_module , key , value ) <EOL> else : <EOL> delattr ( self . settings_module , key ) </s>
