def build(self, is_main=False, is_method=False, is_class=False): ''' Copies the base java file, moves the changes into it and compiles it. If an Exception occurs, the change is rolled back. ''' shutil.copyfile(START_FILE, MAIN_FILE) self.parse_file(MAIN_FILE) # Attempt to compile the new change try: Util.compile_java([MAIN_FILE] + self.full_class_names) except Exception as e: if verbose_output == True: print 'Exception: %s' % e else: print 'An Exception occurred compiling the program' # Determine who caused the exception and remove the code if is_main is True: self.main_input.pop() elif is_method is True: self.methods.pop() self.method_names.pop() elif is_class is True: self.classes.pop() self.class_names.pop() filename = self.full_class_names.pop() Util.remove_file(filename) return if is_main is True: self.run()