<s> """<STR_LIT>""" <EOL> import abc <EOL> import os <EOL> class FileIO ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , resolver_context ) : <EOL> """<STR_LIT>""" <EOL> super ( FileIO , self ) . __init__ ( ) <EOL> self . _is_cached = False <EOL> self . _is_open = False <EOL> self . _resolver_context = resolver_context <EOL> @ abc . abstractmethod <EOL> def _Close ( self ) : <EOL> """<STR_LIT>""" <EOL> @ abc . abstractmethod <EOL> def _Open ( self , path_spec = None , mode = '<STR_LIT:rb>' ) : <EOL> """<STR_LIT>""" <EOL> def open ( self , path_spec = None , mode = '<STR_LIT:rb>' ) : <EOL> """<STR_LIT>""" <EOL> if self . _is_open and not self . _is_cached : <EOL> raise IOError ( u'<STR_LIT>' ) <EOL> if mode != '<STR_LIT:rb>' : <EOL> raise ValueError ( u'<STR_LIT>' . format ( mode ) ) <EOL> if not self . _is_open : <EOL> self . _Open ( path_spec = path_spec , mode = mode ) <EOL> self . _is_open = True <EOL> if path_spec and not self . _resolver_context . GetFileObject ( path_spec ) : <EOL> self . _resolver_context . CacheFileObject ( path_spec , self ) <EOL> self . _is_cached = True <EOL> if self . _is_cached : <EOL> self . _resolver_context . GrabFileObject ( path_spec ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _is_open : <EOL> raise IOError ( u'<STR_LIT>' ) <EOL> if not self . _is_cached : <EOL> close_file_object = True <EOL> elif self . _resolver_context . ReleaseFileObject ( self ) : <EOL> self . _is_cached = False <EOL> close_file_object = True <EOL> else : <EOL> close_file_object = False <EOL> if close_file_object : <EOL> self . _Close ( ) <EOL> self . _is_open = False <EOL> @ abc . abstractmethod <EOL> def read ( self , size = None ) : <EOL> """<STR_LIT>""" <EOL> @ abc . abstractmethod <EOL> def seek ( self , offset , whence = os . SEEK_SET ) : <EOL> """<STR_LIT>""" <EOL> @ abc . abstractmethod <EOL> def get_offset ( self ) : <EOL> """<STR_LIT>""" <EOL> def tell ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . get_offset ( ) <EOL> @ abc . abstractmethod <EOL> def get_size ( self ) : <EOL> """<STR_LIT>""" <EOL> def seekable ( self ) : <EOL> """<STR_LIT>""" <EOL> return True </s>
