All pastes #267544 Raw Edit

Mine

public python v1 · immutable
·published 2006-12-04 22:47 UTC
rendered paste body
#!/usr/bin/env python# -*- coding: utf-8 -*-### This program is free software; you can redistribute it and/or modify it under# the terms of the GNU General Public License as published by the Free# Software Foundation; either version 2 of the License, or (at your option)# any later version.## Please read the COPYING file.#from qt import *from convertergui import ConvertLitBaseimport sysimport stringimport osclass MyForm(ConvertLitBase):    def __init__(self,parent = None,name = None,modal = 0,fl = 0):        ConvertLitBase.__init__(self,parent,name,modal,fl)        self.filename = None        self.directory = None        self.file_n = None    # public slot    def browseFile(self):        filename = QFileDialog.getOpenFileName(\            QString.null,            self.trUtf8("LIT File (*.lit)"),            None, None,            self.trUtf8("Choose a LIT file"),            None, 1)        if unicode(filename) != '':            self.filename = unicode(filename)            self.lineEdit1.setText(filename)        else:            print "no file"    def selectDir(self):        directory = QFileDialog.getExistingDirectory(\            QString.null,            None, None,            self.trUtf8("Choose a directory to extract the files"),            1, 1)        if unicode(directory) != '':            self.directory = unicode(directory)            self.lineEdit1_2.setText(directory)        else:            print "no directory"    def convert(self, filename, file_name):        f = os.popen("clit %s %s" % (filename, file_name))        line = f.readline()        while line:            u = unicode( self.textBrowser2.text() )            u = u + line            self.textBrowser2.setText(u)            line = f.readline()        if self.checkBox2.isChecked():            os.system("kfmclient exec %s/*.html" % file_name)    def doConvert(self):        if self.filename is not None and self.directory is not None:            filedir = "%s" % self.filename             file_n = filedir.split("/")[-1]            file_n = file_n.split(".")[0]            file_name = "%s%s" % (self.directory, file_n)            if not os.path.exists(file_name):                os.system("mkdir %s" % file_name)                convert(self.filename, file_name)            else:                ask_over_write = QMessageBox.question(None,                    self.trUtf8("Warning"),                    self.trUtf8("""There is already a directory with the same name.                Do you want to continue?"""),                    self.trUtf8("&Yes"),                    self.trUtf8("&No"),                    self.trUtf8("&Browse"),                    0, -1)                if ask_over_write == False:                    convert(self.filename, file_name)                else:                    if ask_over_write == True:                        print "user skipped"                    else:                       directory = QFileDialog.getExistingDirectory(\                       QString.null,                       None, None,                       self.trUtf8("Choose a directory to extract the files"),                       1, 1)                       if unicode(directory) != '':                           self.directory = unicode(directory)                           self.lineEdit1_2.setText(directory)                       else:                           print "no directory"        else:            QMessageBox.warning(None,                self.trUtf8("Warning..."),                self.trUtf8("""You didn't select a file and/or a directory """),                QString.null,                QString.null,                QString.null,                0, -1)            passif __name__ == "__main__":    a = QApplication(sys.argv)    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))    w = MyForm()    a.setMainWidget(w)    w.show()    a.exec_loop()