<s> import contextlib <EOL> import os <EOL> import shutil <EOL> import stat <EOL> try : <EOL> import ConfigParser as configparser <EOL> except ImportError : <EOL> import configparser <EOL> @ contextlib . contextmanager <EOL> def open_config ( filename ) : <EOL> cfg = configparser . SafeConfigParser ( ) <EOL> cfg . read ( filename ) <EOL> yield cfg <EOL> with open ( filename , '<STR_LIT:w>' ) as fp : <EOL> cfg . write ( fp ) <EOL> def rmtree ( path ) : <EOL> """<STR_LIT>""" <EOL> def onerror ( func , path , exc_info ) : <EOL> if not os . access ( path , os . W_OK ) : <EOL> os . chmod ( path , stat . S_IWUSR ) <EOL> func ( path ) <EOL> else : <EOL> raise <EOL> return shutil . rmtree ( path , onerror = onerror ) </s>
