<s> import re <EOL> class RobotStatements ( object ) : <EOL> def append ( self , linenumber , raw_text , cells ) : <EOL> """<STR_LIT>""" <EOL> self . rows . append ( Row ( linenumber , raw_text , cells ) ) <EOL> @ property <EOL> def path ( self ) : <EOL> return self . parent . path <EOL> @ property <EOL> def steps ( self ) : <EOL> '''<STR_LIT>''' <EOL> steps = [ ] <EOL> for statement in self . statements : <EOL> if ( ( not statement . is_comment ( ) ) and <EOL> ( not statement . is_setting ( ) ) ) : <EOL> steps . append ( statement ) <EOL> return steps <EOL> @ property <EOL> def settings ( self ) : <EOL> '''<STR_LIT>''' <EOL> return [ statement for statement in self . statements if statement . is_setting ( ) ] <EOL> @ property <EOL> def statements ( self ) : <EOL> '''<STR_LIT>''' <EOL> if len ( self . rows ) == <NUM_LIT:0> : <EOL> return [ ] <EOL> current_statement = Statement ( self . rows [ <NUM_LIT:0> ] ) <EOL> current_statement . startline = self . rows [ <NUM_LIT:0> ] . linenumber <EOL> current_statement . endline = self . rows [ <NUM_LIT:0> ] . linenumber <EOL> statements = [ ] <EOL> for row in self . rows [ <NUM_LIT:1> : ] : <EOL> if len ( row ) > <NUM_LIT:1> and row [ <NUM_LIT:0> ] == "<STR_LIT>" and row [ <NUM_LIT:1> ] == "<STR_LIT>" : <EOL> current_statement += row [ <NUM_LIT:2> : ] <EOL> current_statement . endline = row . linenumber <EOL> else : <EOL> if len ( current_statement ) > <NUM_LIT:0> : <EOL> statements . append ( current_statement ) <EOL> current_statement = Statement ( row ) <EOL> current_statement . startline = row . linenumber <EOL> current_statement . endline = row . linenumber <EOL> if len ( current_statement ) > <NUM_LIT:0> : <EOL> statements . append ( current_statement ) <EOL> return statements <EOL> class Row ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , linenumber , raw_text , cells ) : <EOL> self . linenumber = linenumber <EOL> self . raw_text = raw_text <EOL> self . cells = cells <EOL> def dump ( self ) : <EOL> print "<STR_LIT:|>" + "<STR_LIT>" . join ( [ cell . strip ( ) for cell in self . cells ] ) <EOL> def __len__ ( self ) : <EOL> return len ( self . cells ) <EOL> def __setitem__ ( self , key , value ) : <EOL> self . cells [ key ] = value <EOL> return self . cells [ key ] <EOL> def __getitem__ ( self , key ) : <EOL> return self . cells [ key ] <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . linenumber , str ( self . cells ) ) <EOL> def __contains__ ( self , key ) : <EOL> return key in self . cells <EOL> class Comment ( Row ) : <EOL> pass <EOL> class Statement ( list ) : <EOL> '''<STR_LIT>''' <EOL> startline = None <EOL> endline = None <EOL> def is_setting ( self ) : <EOL> if ( ( len ( self ) > <NUM_LIT:1> ) and <EOL> ( re . match ( r'<STR_LIT>' , self [ <NUM_LIT:1> ] ) ) ) : <EOL> return True <EOL> return False <EOL> def is_comment ( self ) : <EOL> '''<STR_LIT>''' <EOL> for cell in self [ : ] : <EOL> if cell == "<STR_LIT>" : <EOL> continue <EOL> if cell . lstrip ( ) . startswith ( "<STR_LIT:#>" ) : <EOL> return True <EOL> return False <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . startline , self . endline , list . __repr__ ( self ) ) </s>
