How to use __contains__ method in Molotov

Best Python code snippet using molotov_python

scanner.py

Source:scanner.py Github

copy

Full Screen

...29 self.error_writer = fw.ErrorWriter()30 self.symbol_writer = fw.SymbolWriter()31 self.id_list = []32 def update_start_with_char(self):33 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':34 self.current_state = 'wspace'35 if self.current_char == '\n':36 self.lineno += 137 self.current_token_lexeme += self.current_char38 elif Scanner.digit.__contains__(self.current_char):39 self.current_state = 'num'40 self.current_token_lexeme += self.current_char41 elif Scanner.letter.__contains__(self.current_char):42 self.current_state = 'word'43 self.current_token_lexeme += self.current_char44 elif Scanner.symbol.__contains__(self.current_char):45 self.current_state = 'symbol'46 self.current_token_lexeme += self.current_char47 elif '='.__contains__(self.current_char):48 self.current_state = 'equal'49 self.current_token_lexeme += self.current_char50 elif '*'.__contains__(self.current_char):51 self.current_state = 'star'52 self.current_token_lexeme += self.current_char53 elif '/'.__contains__(self.current_char):54 self.current_state = 'slash'55 self.current_token_lexeme += self.current_char56 else:57 self.current_state = 'start'58 self.current_token_lexeme += self.current_char59 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')60 self.current_token_lexeme = ''61 def update_num_with_char(self):62 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':63 self.reset_state_return()64 elif Scanner.digit.__contains__(self.current_char):65 self.current_state = 'num'66 self.current_token_lexeme += self.current_char67 elif Scanner.letter.__contains__(self.current_char):68 self.current_state = 'start'69 self.current_token_lexeme += self.current_char70 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid number)')71 self.current_token_lexeme = ''72 elif Scanner.symbol.__contains__(self.current_char):73 self.reset_state_return()74 elif '='.__contains__(self.current_char):75 self.reset_state_return()76 elif '*'.__contains__(self.current_char):77 self.reset_state_return()78 elif '/'.__contains__(self.current_char):79 self.reset_state_return()80 else:81 self.current_state = 'start'82 self.current_token_lexeme += self.current_char83 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid number)')84 self.current_token_lexeme = ''85 def update_word_with_char(self):86 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':87 self.reset_state_return()88 elif Scanner.digit.__contains__(self.current_char):89 self.current_state = 'word'90 self.current_token_lexeme += self.current_char91 elif Scanner.letter.__contains__(self.current_char):92 self.current_state = 'word'93 self.current_token_lexeme += self.current_char94 elif Scanner.symbol.__contains__(self.current_char):95 self.reset_state_return()96 elif '='.__contains__(self.current_char):97 self.reset_state_return()98 elif '*'.__contains__(self.current_char):99 self.reset_state_return()100 elif '/'.__contains__(self.current_char):101 self.reset_state_return()102 else:103 self.current_state = 'start'104 self.current_token_lexeme += self.current_char105 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')106 self.current_token_lexeme = ''107 def update_equal_with_char(self):108 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':109 self.reset_state_return()110 elif Scanner.digit.__contains__(self.current_char):111 self.reset_state_return()112 elif Scanner.letter.__contains__(self.current_char):113 self.reset_state_return()114 elif Scanner.symbol.__contains__(self.current_char):115 self.reset_state_return()116 elif '='.__contains__(self.current_char):117 self.current_state = 'twoequal'118 self.current_token_lexeme += self.current_char119 elif '*'.__contains__(self.current_char):120 self.reset_state_return()121 elif '/'.__contains__(self.current_char):122 self.reset_state_return()123 else:124 self.current_state = 'start'125 self.current_token_lexeme += self.current_char126 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')127 self.current_token_lexeme = ''128 def update_two_equal_with_char(self):129 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':130 self.reset_state_return()131 elif Scanner.digit.__contains__(self.current_char):132 self.reset_state_return()133 elif Scanner.letter.__contains__(self.current_char):134 self.reset_state_return()135 elif Scanner.symbol.__contains__(self.current_char):136 self.reset_state_return()137 elif '='.__contains__(self.current_char):138 self.reset_state_return()139 elif '*'.__contains__(self.current_char):140 self.reset_state_return()141 elif '/'.__contains__(self.current_char):142 self.reset_state_return()143 else:144 self.current_state = 'start'145 self.current_token_lexeme += self.current_char146 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')147 self.current_token_lexeme = ''148 def update_symbol_with_char(self):149 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':150 self.reset_state_return()151 elif Scanner.digit.__contains__(self.current_char):152 self.reset_state_return()153 elif Scanner.letter.__contains__(self.current_char):154 self.reset_state_return()155 elif Scanner.symbol.__contains__(self.current_char):156 self.reset_state_return()157 elif '='.__contains__(self.current_char):158 self.reset_state_return()159 elif '*'.__contains__(self.current_char):160 self.reset_state_return()161 elif '/'.__contains__(self.current_char):162 self.reset_state_return()163 else:164 self.reset_state_return()165 # self.current_state = 'start'166 # self.current_token_lexeme += self.current_char167 # self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')168 # self.current_token_lexeme = ''169 def update_slash_with_char(self):170 self.read_again = True171 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':172 self.current_state = 'start'173 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')174 self.current_token_lexeme = ''175 elif Scanner.digit.__contains__(self.current_char):176 self.current_state = 'start'177 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')178 self.current_token_lexeme = ''179 elif Scanner.letter.__contains__(self.current_char):180 self.current_state = 'start'181 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')182 self.current_token_lexeme = ''183 elif Scanner.symbol.__contains__(self.current_char):184 self.current_state = 'start'185 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')186 self.current_token_lexeme = ''187 elif '='.__contains__(self.current_char):188 self.current_state = 'start'189 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')190 self.current_token_lexeme = ''191 elif '*'.__contains__(self.current_char):192 self.current_state = 'bcmt'193 self.current_token_lexeme += self.current_char194 self.read_again = False195 elif '/'.__contains__(self.current_char):196 self.current_state = 'lcmt'197 self.current_token_lexeme += self.current_char198 self.read_again = False199 else:200 self.current_state = 'start'201 self.current_token_lexeme += self.current_char202 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')203 self.current_token_lexeme = ''204 self.read_again = False205 def update_bcmt_with_char(self):206 self.current_token_lexeme += self.current_char207 if self.current_char == '\n':208 self.lineno += 1209 if '*'.__contains__(self.current_char) and self.current_char != '':210 self.current_state = 'bcmt*'211 def update_bcmt_star_with_char(self):212 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':213 self.current_state = 'bcmt'214 self.current_token_lexeme += self.current_char215 elif Scanner.digit.__contains__(self.current_char):216 self.current_state = 'bcmt'217 self.current_token_lexeme += self.current_char218 elif Scanner.letter.__contains__(self.current_char):219 self.current_state = 'bcmt'220 self.current_token_lexeme += self.current_char221 elif Scanner.symbol.__contains__(self.current_char):222 self.current_state = 'bcmt'223 self.current_token_lexeme += self.current_char224 elif '='.__contains__(self.current_char):225 self.current_state = 'bcmt'226 self.current_token_lexeme += self.current_char227 elif '*'.__contains__(self.current_char):228 self.current_state = 'bcmt*'229 self.current_token_lexeme += self.current_char230 elif '/'.__contains__(self.current_char):231 self.reset_state_return()232 self.skip_one_char = True233 else:234 self.current_state = 'bcmt'235 self.current_token_lexeme += self.current_char236 def update_lcmt_with_char(self):237 if '\n'.__contains__(self.current_char):238 self.reset_state_return()239 else:240 self.current_token_lexeme += self.current_char241 def update_white_space_with_char(self):242 if Scanner.wspace.__contains__(self.current_char):243 self.current_state = 'wspace'244 if self.current_char == '\n':245 self.lineno += 1246 self.current_token_lexeme += self.current_char247 elif Scanner.digit.__contains__(self.current_char):248 self.reset_state_return()249 elif Scanner.letter.__contains__(self.current_char):250 self.reset_state_return()251 elif Scanner.symbol.__contains__(self.current_char):252 self.reset_state_return()253 elif '='.__contains__(self.current_char):254 self.reset_state_return()255 elif '*'.__contains__(self.current_char):256 self.reset_state_return()257 # or self.current_char == ''?????258 elif '/'.__contains__(self.current_char):259 self.reset_state_return()260 else:261 self.current_state = 'start'262 self.error_writer.write_error(self.lineno, '(' + self.current_char + ', Invalid input)')263 self.current_token_lexeme = ''264 def update_star_with_char(self):265 if Scanner.wspace.__contains__(self.current_char) or self.current_char == '':266 self.reset_state_return()267 elif Scanner.digit.__contains__(self.current_char):268 self.reset_state_return()269 elif Scanner.letter.__contains__(self.current_char):270 self.reset_state_return()271 elif Scanner.symbol.__contains__(self.current_char):272 self.reset_state_return()273 elif '='.__contains__(self.current_char):274 self.reset_state_return()275 elif '*'.__contains__(self.current_char):276 self.reset_state_return()277 elif '/'.__contains__(self.current_char):278 self.current_state = 'start'279 self.current_token_lexeme += self.current_char280 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Unmatched comment)')281 self.current_token_lexeme = ''282 else:283 self.current_state = 'start'284 self.current_token_lexeme += self.current_char285 self.error_writer.write_error(self.lineno, '(' + self.current_token_lexeme + ', Invalid input)')286 self.current_token_lexeme = ''287 def update_state(self):288 if self.current_state == 'start':289 self.update_start_with_char()290 elif self.current_state == 'num':291 self.update_num_with_char()...

Full Screen

Full Screen

vectorize.py

Source:vectorize.py Github

copy

Full Screen

...6print(data)7for index, row in data.iterrows():8 9 xss_string = row['Sentence']10 if xss_string.__contains__('script'):11 feature_vector.append(1)12 else:13 feature_vector.append(0)14 if xss_string.__contains__('&'):15 feature_vector.append(1)16 else:17 feature_vector.append(0)18 if xss_string.__contains__('%'):19 feature_vector.append(1)20 else:21 feature_vector.append(0)22 if xss_string.__contains__('/'):23 feature_vector.append(1)24 else:25 feature_vector.append(0)26 if xss_string.__contains__('\\'):27 feature_vector.append(1)28 else:29 feature_vector.append(0)30 if xss_string.__contains__('+'):31 feature_vector.append(1)32 else:33 feature_vector.append(0)34 if xss_string.__contains__('document'):35 feature_vector.append(1)36 else:37 feature_vector.append(0)38 if xss_string.__contains__('window'):39 feature_vector.append(1)40 else:41 feature_vector.append(0)42 if xss_string.__contains__('onload'):43 feature_vector.append(1)44 else:45 feature_vector.append(0)46 if xss_string.__contains__('onerror'):47 feature_vector.append(1)48 else:49 feature_vector.append(0)50 if xss_string.__contains__('div'):51 feature_vector.append(1)52 else:53 feature_vector.append(0)54 if xss_string.__contains__('iframe'):55 feature_vector.append(1)56 else:57 feature_vector.append(0)58 if xss_string.__contains__('img'):59 feature_vector.append(1)60 else:61 feature_vector.append(0)62 if xss_string.__contains__('src'):63 feature_vector.append(1)64 else:65 feature_vector.append(0)66 if xss_string.__contains__('var'):67 feature_vector.append(1)68 else:69 feature_vector.append(0)70 if xss_string.__contains__('eval'):71 feature_vector.append(1)72 else:73 feature_vector.append(0)74 if xss_string.__contains__('href'):75 feature_vector.append(1)76 else:77 feature_vector.append(0)78 if xss_string.__contains__('cookie'):79 feature_vector.append(1)80 else:81 feature_vector.append(0)82 if xss_string.__contains__('fromCharCode'):83 feature_vector.append(1)84 else:85 feature_vector.append(0)86 if xss_string.__contains__('?'):87 feature_vector.append(1)88 else:89 feature_vector.append(0)90 if xss_string.__contains__(';'):91 feature_vector.append(1)92 else:93 feature_vector.append(0)94 if xss_string.__contains__('http'):95 feature_vector.append(1)96 else:97 feature_vector.append(0)98 if xss_string.__contains__('js'):99 feature_vector.append(1)100 else:101 feature_vector.append(0)102 if xss_string.__contains__('#'):103 feature_vector.append(1)104 else:105 feature_vector.append(0)106 if xss_string.__contains__('='):107 feature_vector.append(1)108 else:109 feature_vector.append(0)110 if xss_string.__contains__('['):111 feature_vector.append(1)112 else:113 feature_vector.append(0)114 if xss_string.__contains__(']'):115 feature_vector.append(1)116 else:117 feature_vector.append(0)118 if xss_string.__contains__('$'):119 feature_vector.append(1)120 else:121 feature_vector.append(0)122 if xss_string.__contains__('('):123 feature_vector.append(1)124 else:125 feature_vector.append(0)126 if xss_string.__contains__(')'):127 feature_vector.append(1)128 else:129 feature_vector.append(0)130 if xss_string.__contains__('*'):131 feature_vector.append(1)132 else:133 feature_vector.append(0)134 if xss_string.__contains__(','):135 feature_vector.append(1)136 else:137 feature_vector.append(0)138 if xss_string.__contains__('-'):139 feature_vector.append(1)140 else:141 feature_vector.append(0)142 if xss_string.__contains__('<'):143 feature_vector.append(1)144 else:145 feature_vector.append(0)146 if xss_string.__contains__('>'):147 feature_vector.append(1)148 else:149 feature_vector.append(0)150 if xss_string.__contains__('location'):151 feature_vector.append(1)152 else:153 feature_vector.append(0)154 if xss_string.__contains__('search'):155 feature_vector.append(1)156 else:157 feature_vector.append(0)158 if xss_string.__contains__('&#'):159 feature_vector.append(1)160 else:161 feature_vector.append(0)162 if xss_string.__contains__(':'):163 feature_vector.append(1)164 else:165 feature_vector.append(0)166 if xss_string.__contains__('.'):167 feature_vector.append(1)168 else:169 feature_vector.append(0)170 if xss_string.__contains__(' '):171 feature_vector.append(1)172 else:173 feature_vector.append(0)174 if xss_string.__contains__('"'):175 feature_vector.append(1)176 else:177 feature_vector.append(0)178 if xss_string.__contains__('//'):179 feature_vector.append(1)180 else:181 feature_vector.append(0)182 if xss_string.__contains__('|'):183 feature_vector.append(1)184 else:185 feature_vector.append(0)186 if xss_string.__contains__('&#166;'):187 feature_vector.append(1)188 else:189 feature_vector.append(0)190 if xss_string.__contains__('alert'):191 feature_vector.append(1)192 else:193 feature_vector.append(0)194 feature_vector.append(row['Label'])195 with open('E:\\Documents\\major_project\\app\\xss-attack-ml\\data\\vectorized_dataset.csv', 'a') as f_object:196 # Pass this file object to csv.writer()197 # and get a writer object198 writer_object = writer(f_object)199 200 writer_object.writerow(feature_vector)201 202 #Close the file object...

Full Screen

Full Screen

TicTacToe.py

Source:TicTacToe.py Github

copy

Full Screen

...8384def win_check(piece, board):85 global game_win86 if piece == 'x':87 if player_x.__contains__('7') and player_x.__contains__('8') and player_x.__contains__('9'):88 game_win = True89 print('you win')90 elif player_x.__contains__('4') and player_x.__contains__('5') and player_x.__contains__('6'):91 game_win = True92 print('you win')93 elif player_x.__contains__('1') and player_x.__contains__('2') and player_x.__contains__('3'):94 game_win = True95 print('you win')96 elif player_x.__contains__('7') and player_x.__contains__('4') and player_x.__contains__('1'):97 game_win = True98 print('you win')99 elif player_x.__contains__('8') and player_x.__contains__('5') and player_x.__contains__('2'):100 game_win = True101 print('you win')102 elif player_x.__contains__('9') and player_x.__contains__('6') and player_x.__contains__('3'):103 game_win = True104 print('you win')105 elif player_x.__contains__('7') and player_x.__contains__('5') and player_x.__contains__('3'):106 game_win = True107 print('you win')108 elif player_x.__contains__('9') and player_x.__contains__('5') and player_x.__contains__('1'):109 game_win = True110 print('you win')111 elif piece == 'o':112 if player_o.__contains__('7') and player_o.__contains__('8') and player_o.__contains__('9'):113 game_win = True114 print('you win')115 elif player_o.__contains__('4') and player_o.__contains__('5') and player_o.__contains__('6'):116 game_win = True117 print('you win')118 elif player_o.__contains__('1') and player_o.__contains__('2') and player_o.__contains__('3'):119 game_win = True120 print('you win')121 elif player_o.__contains__('7') and player_o.__contains__('4') and player_o.__contains__('1'):122 game_win = True123 print('you win')124 elif player_o.__contains__('8') and player_o.__contains__('5') and player_o.__contains__('2'):125 game_win = True126 print('you win')127 elif player_o.__contains__('9') and player_o.__contains__('6') and player_o.__contains__('3'):128 game_win = True129 print('you win')130 elif player_o.__contains__('7') and player_o.__contains__('5') and player_o.__contains__('3'):131 game_win = True132 print('you win')133 elif player_o.__contains__('9') and player_o.__contains__('5') and player_o.__contains__('1'):134 game_win = True135 print('you win')136137138139140141142def game():143 global turn144 global gameBoard145 while not game_win:146 piece = player_piece()147 num = player_move(turn) ...

Full Screen

Full Screen

set_test.py

Source:set_test.py Github

copy

Full Screen

...12 def test_contains_and_len(self):13 s = Set()14 assert s.size == 015 assert len(s) == 016 assert s.__contains__(2) == False17 s.add(2)18 s.add(4)19 assert s.size == 220 assert len(s) == 221 assert s.__contains__(2) == True22 assert s.__contains__(3) == False23 s.remove(2)24 assert s.size == 125 assert len(s) == 126 assert s.__contains__(2) == False27 assert s.__contains__(4) == True28 def test_add(self):29 s = Set([1, 3, 5, 9])30 assert s.size == 431 assert len(s) == 432 assert s.__contains__(5) == True33 assert s.__contains__(4) == False34 s.add(4)35 assert s.size == 536 assert len(s) == 537 assert s.__contains__(4) == True38 assert s.__contains__(6) == False39 assert s.__contains__('4') == False40 s.add('a')41 assert s.size == 642 assert len(s) == 643 assert s.__contains__('a') == True44 def test_remove(self):45 s = Set([3, 6, 8, 10, 'a', None, 'i', 2.5])46 assert s.size == 847 assert len(s) == 848 s.remove(8)49 assert s.size == 750 assert len(s) == 751 assert s.__contains__(8) == False 52 assert s.__contains__(None) == True53 assert s.__contains__(2.5) == True54 assert s.__contains__(7) == False55 s.remove('a')56 assert s.__contains__('a') == False57 assert s.size == 658 assert len(s) == 659 s.remove('None')60 s.remove(2.5)61 assert s.__contains__('None') == False62 assert s.__contains__(2.5) == False63 assert s.__contains__(3) == True64 assert s.size == 465 assert len(s) == 466 def test_union(self):67 a = Set([1, 2, 3, 4, 5])68 b = Set([4, 5, 6, 7, 8])69 a_union_b = a.union(b)70 assert a_union_b.__contains__(8) == True71 assert a_union_b.__contains__(2) == True72 assert a_union_b.__contains__(4) == True73 assert a_union_b.__contains__(0) == False74 assert a_union_b.__contains__(9) == False75 def test_intersection(self):76 a = Set([1, 2, 3, 4, 5])77 b = Set([4, 5, 6, 7, 8])78 a_intersection_b = a.intersection(b)79 assert a_intersection_b.__contains__(1) == False80 assert a_intersection_b.__contains__(8) == False81 assert a_intersection_b.__contains__(4) == True82 assert a_intersection_b.__contains__(5) == True83 a.add('a')84 b.add('a')85 a.add(2.5)86 a_intersection_b = a.intersection(b)87 assert a_intersection_b.__contains__('a') == True88 assert a_intersection_b.__contains__(2.5) == False89 def test_difference(self):90 a = Set([1, 2, 3, 4, 5])91 b = Set([4, 5, 6, 7, 8])92 a_difference_b = a.difference(b)93 assert a_difference_b.__contains__(4) == False94 assert a_difference_b.__contains__(5) == False95 assert a_difference_b.__contains__(1) == True96 assert a_difference_b.__contains__(2) == True97 b.remove(4)98 a_difference_b = a.difference(b)99 assert a_difference_b.__contains__(4) == True100 def test_is_subset(self):101 a = Set([1, 2, 3])102 b = Set([1, 2, 4, 5])103 assert a.is_subset(b) == False104 b.add(3)105 assert a.is_subset(b) == True106 a.remove(3)107 assert a.is_subset(b) == True108 a.add(3)109 a.add(4)110 a.add(5)111 assert a.is_subset(b) == True112 a.add('b')113 assert a.is_subset(b) == False

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Molotov automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful