Beispiel #1
0
 def print_statement(self):
     self.humanoid_print('print(' + random.choice([
         Generators.get_statement(),
         Generators.generate_number(),
         Generators.generate_function_name(),
         Generators.generate_variable_name()
     ]) + ')')
     self.followup = False
Beispiel #2
0
 def except_statement(self):
     if random.randint(0, 1) is 0:
         self.humanoid_print('except:', matching_indent=True)
     else:
         self.humanoid_print('except ' + Generators.generate_exception() +
                             ' as e:',
                             matching_indent=True)
     self.tab = self.tab + 1
     self.followup = True
Beispiel #3
0
 def if_inline_statement(self):
     self.humanoid_print(Generators.generate_variable_name() + ' = ' +
                         Generators.generate_value() + ' if (' +
                         Generators.get_statement() + ') else ' +
                         Generators.generate_value())
     self.followup = False
Beispiel #4
0
 def if_statement(self):
     self.humanoid_print('if ' + Generators.get_statement() + ':')
     self.tab = self.tab + 1
     self.followup = True
Beispiel #5
0
 def comment_statement(self):
     comment = Generators.generate_comment()
     self.humanoid_print(comment)
Beispiel #6
0
 def execute_function_statement(self):
     self.humanoid_print(Generators.generate_function_name())
     self.followup = False
Beispiel #7
0
 def assign_var_value(self):
     random_var = Generators.generate_variable_name()
     output = random_var + ' = ' + Generators.generate_value()
     self.humanoid_print(output)
     self.followup = False
Beispiel #8
0
 def create_function(self):
     self.humanoid_print('def ' + Generators.generate_function_name() + ':')
     self.tab = self.tab + 1
     self.followup = True
Beispiel #9
0
 def create_loop(self):
     loop = Generators.generate_loop()
     self.humanoid_print(loop)
     self.tab = self.tab + 1
     self.followup = True