def apply_pre_processing(self, file_contents): """ Applies the selected plugins in order to extract the raw data to be mutated :param file_contents: eeeh... the input file contents :) :return: extracted data """ data = file_contents for p in self.plugin_list: plugin = load_plugin(p) data, self.data_to_post = plugin.pre(data) return data
def apply_post_processing(self, mutated_buffer): """ Applies the selected plugins in *reverse* order to recreate the original file format :param mutated_buffer: eeeh... the mutated buffer :) :return: new file contents """ data = mutated_buffer for p in self.plugin_list[::-1]: # The plugins are applied in reverse order plugin = load_plugin(p) data = plugin.post(data, self.data_to_post) return data