def _export(self, widget): model = self.export_combo.get_model() active = self.export_combo.get_active() option = model[active][0] start, end = self.hex_buffer.get_bounds() data = self.hex_buffer.get_text(start, end, False) # Remove comments from input clean_data = [] data = data.split('\n') for x in data: if x: if x[0] != ';': clean_data.append(x) data = ''.join(clean_data) if data: if 'Python' in option: output = 'buf = ""\n' data = [data[x:x + 2] for x in xrange(0, len(data), 2)] # Group every 10 elements for x in [data[i:i + 10] for i in xrange(0, len(data), 10)]: x = ["\\x" + str(i) for i in x] output += "buf += '" + "".join(x) + "'\n" else: output = 'char buf[] =\n' data = [data[x:x + 2] for x in xrange(0, len(data), 2)] # Group every 10 elements for x in [data[i:i + 10] for i in xrange(0, len(data), 10)]: x = ["\\x" + str(i) for i in x] output += '\t"' + "".join(x) + '"\n' output = output[:-1] output += ';\n' import search_dialog self.search_dialog = search_dialog.SearchDialog('Exported ' + option) self.search_dialog.output_buffer.set_text(output)
def create_search_dialog(self): import search_dialog self.search_dialog = search_dialog.SearchDialog() return False