def on_query_file_import(self, widget): """Import query file and launch all parsed queries""" Gtk_Main.Gtk_Main().statusbar.change_message("Import query path file ...") filename = self.open_filechooser("Import query path file") if not filename: Gtk_Main.Gtk_Main().statusbar.change_message("Ready") return query_path = QueryPathParser(filename) result = query_path.parse() if result: Gtk_DialogBox(result, gtk.MESSAGE_ERROR) else: query_path.run() Gtk_QueryPath.treeview_output(query_path) Gtk_Main.Gtk_Main().lateral_pane.help_message.change_message(Gtk_Message.ON_IMPORT_QUERY_FILE)
def on_query_file_import(self, widget): """Import query file and launch all parsed queries""" Gtk_Main.Gtk_Main().statusbar.change_message( "Import query path file ...") filename = self.open_filechooser("Import query path file") if not filename: Gtk_Main.Gtk_Main().statusbar.change_message("Ready") return query_path = QueryPathParser(filename) result = query_path.parse() if result: Gtk_DialogBox(result, gtk.MESSAGE_ERROR) else: query_path.run() Gtk_QueryPath.treeview_output(query_path) Gtk_Main.Gtk_Main().lateral_pane.help_message.change_message( Gtk_Message.ON_IMPORT_QUERY_FILE)
def export_query_path(fd, ref): """Export query path result as text file""" result = ref.result fd.write(32 * '#' + '\n') fd.write("Query Path Import\n") fd.write(32 * '#' + '\n\n') for i in result: rule = i[0] path_data = i[1] fd.write(rule.to_string(' ') + '\n') if isinstance(path_data, str): fd.write('-- %s\n' % path_data) continue for data in path_data: fd.write('-- %s\n' % Gtk_QueryPath.path_to_string(data[0], ' ')) for r in data[1]: fd.write('---- %s\n' % r[1].to_string(' ')) fd.write('\n') fd.write(128 * '-' + '\n')