<s> """<STR_LIT>""" <EOL> import vroom . controls <EOL> import vroom . test <EOL> class Manager ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , vim ) : <EOL> self . vim = vim <EOL> self . Unload ( ) <EOL> def Unload ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _loaded = False <EOL> self . _buffer = None <EOL> self . _data = [ ] <EOL> self . _line = None <EOL> self . _last_range = None <EOL> def Load ( self , buff ) : <EOL> """<STR_LIT>""" <EOL> if self . _loaded and buff is None : <EOL> return <EOL> self . Unload ( ) <EOL> self . _data = self . vim . GetBufferLines ( buff ) <EOL> self . _buffer = buff <EOL> self . _loaded = True <EOL> def View ( self , start , end ) : <EOL> """<STR_LIT>""" <EOL> self . _line = - <NUM_LIT:1> if self . _line is None else self . _line <EOL> if start == vroom . controls . SPECIAL_RANGE . CURRENT_LINE : <EOL> start = self . vim . GetCurrentLine ( ) - <NUM_LIT:1> <EOL> else : <EOL> start = ( self . _line + <NUM_LIT:1> ) if start is None else ( start - <NUM_LIT:1> ) <EOL> end = ( start + <NUM_LIT:1> ) if end is None else end ( start + <NUM_LIT:1> ) <EOL> end = len ( self . _data ) if end is <NUM_LIT:0> else end <EOL> self . _last_range = ( start , end ) <EOL> for i in range ( start , end ) : <EOL> self . _line = i <EOL> if i < len ( self . _data ) : <EOL> yield self . _data [ i ] <EOL> else : <EOL> raise NotEnoughOutput ( self . GetContext ( ) ) <EOL> def Verify ( <EOL> self , desired , buffer = None , range = None , mode = None ) : <EOL> """<STR_LIT>""" <EOL> self . Load ( buffer ) <EOL> start , end = range or ( None , None ) <EOL> for actual in self . View ( start , end ) : <EOL> if not vroom . test . Matches ( desired , mode , actual ) : <EOL> raise WrongOutput ( desired , mode , self . GetContext ( ) ) <EOL> def EnsureAtEnd ( self , buffer ) : <EOL> """<STR_LIT>""" <EOL> self . Load ( buffer ) <EOL> self . _last_range = ( len ( self . _data ) , len ( self . _data ) ) <EOL> if self . _line is None : <EOL> if self . _data == [ '<STR_LIT>' ] or not self . _data : <EOL> return <EOL> msg = '<STR_LIT>' <EOL> raise BadOutput ( self . GetContext ( ) , msg ) <EOL> if self . _line != len ( self . _data ) - <NUM_LIT:1> : <EOL> raise TooMuchOutput ( self . GetContext ( ) ) <EOL> def GetContext ( self ) : <EOL> """<STR_LIT>""" <EOL> if ( not self . _loaded ) or ( self . _last_range is None ) : <EOL> return None <EOL> ( start , end ) = self . _last_range <EOL> return { <EOL> '<STR_LIT>' : self . _buffer , <EOL> '<STR_LIT:data>' : self . _data , <EOL> '<STR_LIT>' : self . _line , <EOL> '<STR_LIT:start>' : start , <EOL> '<STR_LIT:end>' : end , <EOL> } <EOL> class BadOutput ( vroom . test . Failure ) : <EOL> """<STR_LIT>""" <EOL> DESCRIPTION = '<STR_LIT>' <EOL> def __init__ ( self , context , message = None ) : <EOL> self . context = context <EOL> super ( BadOutput , self ) . __init__ ( message or self . DESCRIPTION ) <EOL> class WrongOutput ( BadOutput ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , line , mode , context ) : <EOL> """<STR_LIT>""" <EOL> self . context = context <EOL> mode = mode or vroom . controls . DEFAULT_MODE <EOL> msg = '<STR_LIT>' % ( line , mode ) <EOL> super ( WrongOutput , self ) . __init__ ( context , msg ) <EOL> class TooMuchOutput ( BadOutput ) : <EOL> """<STR_LIT>""" <EOL> DESCRIPTION = '<STR_LIT>' <EOL> class NotEnoughOutput ( BadOutput ) : <EOL> """<STR_LIT>""" <EOL> DESCRIPTION = '<STR_LIT>' </s>
