#NEWLINE# def starts_with( self , prefix ) : #NEWLINE# #INDENT# 'Asserts that val is string or iterable and starts with prefix.' #NEWLINE# if ( prefix is None ) : #NEWLINE# #INDENT# raise TypeError ( 'given prefix arg must not be none' ) #NEWLINE# #UNINDENT# if isinstance ( self . val , str_types ) : #NEWLINE# #INDENT# if ( not isinstance ( prefix , str_types ) ) : #NEWLINE# #INDENT# raise TypeError ( 'given prefix arg must be a string' ) #NEWLINE# #UNINDENT# if ( len ( prefix ) == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'given prefix arg must not be empty' ) #NEWLINE# #UNINDENT# if ( not self . val . startswith ( prefix ) ) : #NEWLINE# #INDENT# self . _err ( ( 'Expected <%s> to start with <%s>, but did not.' % ( self . val , prefix ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( self . val , collections . Iterable ) : #NEWLINE# #INDENT# if ( len ( self . val ) == 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'val must not be empty' ) #NEWLINE# #UNINDENT# for i in self . val : #NEWLINE# #INDENT# if ( i != prefix ) : #NEWLINE# #INDENT# self . _err ( ( 'Expected %s to start with <%s>, but did not.' % ( self . val , prefix ) ) ) #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'val is not a string or iterable' ) #NEWLINE# #UNINDENT# #UNINDENT# return self