<s> NT_OS = dict ( <EOL> O_RDONLY = <NUM_LIT> , <EOL> O_WRONLY = <NUM_LIT> , <EOL> O_RDWR = <NUM_LIT> , <EOL> O_APPEND = <NUM_LIT> , <EOL> O_CREAT = <NUM_LIT> , <EOL> O_TRUNC = <NUM_LIT> , <EOL> O_TEXT = <NUM_LIT> , <EOL> O_BINARY = <NUM_LIT> <EOL> ) <EOL> def _patch_os ( defs = None ) : <EOL> """<STR_LIT>""" <EOL> import os <EOL> if defs is None : <EOL> defs = NT_OS <EOL> olddefs = { } <EOL> for name , value in defs . iteritems ( ) : <EOL> try : <EOL> olddefs [ name ] = getattr ( os , name ) <EOL> except AttributeError : <EOL> pass <EOL> setattr ( os , name , value ) <EOL> return olddefs <EOL> def patch_os ( ) : <EOL> return _patch_os ( ) <EOL> def unpatch_os ( olddefs ) : <EOL> _patch_os ( olddefs ) </s>
