Beispiel #1
0
    def __init__(self, app):
        # make sure multiple instantiation won't happen
        assert(MainWindow.instance is None)
        MainWindow.instance = self

        super(MainWindow, self).__init__()

        self.app = app
        
        self.ui = Cpp2CSharp.UI.ui_mainwindow.Ui_MainWindow()
        self.ui.setupUi(self)
        
        # 可停靠的窗口
        self.m_LoggerWin = LoggerWin.LoggerWin()
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.m_LoggerWin)
        
        # 左边可停靠窗口
        self.m_LeftFnWin = LeftFnWin.LeftFnWin()
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.m_LeftFnWin)
        
        # 显示初始化单件
        Config.Config.instance()
        Config.Config.instance().readInit('config.txt')

        # 实例化,共享数据
        IAppData.pInstance = AppData.AppData()
        Logger.instance()
        CodeConv.CodeConv.instance()
        
        self.m_qttimer = QtCore.QTimer()
        self.m_qttimer.timeout.connect(self.onTimer)
        self.m_qttimer.start( 1000 )
Beispiel #2
0
    def __init__(self, app):
        # make sure multiple instantiation won't happen
        assert (MainWindow.instance is None)
        MainWindow.instance = self

        super(MainWindow, self).__init__()

        self.app = app

        self.ui = Cpp2CSharp.UI.ui_mainwindow.Ui_MainWindow()
        self.ui.setupUi(self)

        # 可停靠的窗口
        self.m_LoggerWin = LoggerWin.LoggerWin()
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.m_LoggerWin)

        # 左边可停靠窗口
        self.m_LeftFnWin = LeftFnWin.LeftFnWin()
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.m_LeftFnWin)

        # 显示初始化单件
        Config.Config.instance()
        Config.Config.instance().readInit('config.txt')

        # 实例化,共享数据
        IAppData.pInstance = AppData.AppData()
        Logger.instance()
        CodeConv.CodeConv.instance()

        self.m_qttimer = QtCore.QTimer()
        self.m_qttimer.timeout.connect(self.onTimer)
        self.m_qttimer.start(1000)
Beispiel #3
0
 def traverseOneDirs(directoryName, filesInDirectory, handleDisp):
     Logger.instance().info(directoryName)
     for fname in filesInDirectory:
         fpath = os.path.join(directoryName, fname)
         if not os.path.isdir(fpath):
             if handleDisp is not None:
                 handleDisp(fname, fpath)
Beispiel #4
0
 def traverseOneDirs(directoryName, filesInDirectory, handleDisp):
     Logger.instance().info(directoryName)
     for fname in filesInDirectory:
         fpath = os.path.join(directoryName, fname)
         if not os.path.isdir(fpath):
             if handleDisp is not None:
                 handleDisp(fname, fpath)
Beispiel #5
0
 def onBtnClkConv(self):
     #直接启动线程
     if AppData.instance().m_bConvOver:
         AppData.instance().m_convThread = ConvThread("ConvThread")
         AppData.instance().m_convThread.start()
     else:
         Logger.instance().info('Convthread is runing')
Beispiel #6
0
    def run(self):
        AppData.instance().m_bConvOver = False
        Logger.instance().info("File Conv Start")
        
        Utils.makeDir(Config.instance().m_tmpCodePath)
        Utils.makeDir(Config.instance().m_destCodePath)
        
        Utils.traverseDirs(Config.instance().m_srcCodePath, CodeConv.pInstance.convCpp2CSharp)

        Logger.instance().info("File Conv End")
        AppData.instance().m_bConvOver = True
Beispiel #7
0
    def run(self):
        AppData.instance().m_bConvOver = False
        Logger.instance().info("File Conv Start")

        Utils.makeDir(Config.instance().m_tmpCodePath)
        Utils.makeDir(Config.instance().m_destCodePath)

        Utils.traverseDirs(Config.instance().m_srcCodePath,
                           CodeConv.pInstance.convCpp2CSharp)

        Logger.instance().info("File Conv End")
        AppData.instance().m_bConvOver = True
Beispiel #8
0
 def parseCpp(self, filePathName):
     with open(filePathName, 'r', encoding = 'utf8') as fHandle:
         tokenParseData = TokenParseData.TokenParseData('')
         try:
             tokenParseData.m_fileStr = fHandle.read();       # 读取所有的内容
         except Exception as e:
             Utils.logStackInfo()
             Logger.instance().info("{0} 文件解析错误".format(filePathName))
             return
         
             
         Utils.skipSpaceAndBr(tokenParseData)          # 删除左边的空格
         while len(tokenParseData.m_fileStr):
             oneToken = Utils.getToken(tokenParseData)
             if oneToken == "#ifndef":
                 Utils.skipCurLine(tokenParseData)
             elif oneToken == "#define":
                 Utils.skipCurLine(tokenParseData)
             elif oneToken == "#include":
                 Utils.skipCurLine(tokenParseData)
             elif oneToken[0:3] == "/**":
                 self.m_curCppElem = CppMultiComment.CppMultiComment()
                 self.m_pStack.push(self.m_curCppElem)
                 self.m_curCppElem.parseCppElem(tokenParseData)
             elif oneToken[0:2] == "//":
                 Utils.skipCurLine(tokenParseData)
             elif oneToken == "struct":
                 self.m_curCppElem = CppStructItem.CppStructItem()
                 self.m_curCppElem.parseCppElem(tokenParseData)
 
             
             Utils.skipSpaceAndBr(tokenParseData)          # 删除左边的空格
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
Beispiel #9
0
    def copyFile(srcfilename, destfilename):
        if os.path.isfile(srcfilename):
            try:
                shutil.copyfile(srcfilename, destfilename)
                Logger.instance().info("copy file success: " + srcfilename)
            except:
                # 错误输出
                Logger.instance().info("copy file error: " + srcfilename)
                typeerr, value, tb = sys.exc_info()
                errstr = traceback.format_exception(typeerr, value, tb)
                Logger.instance().info(''.join(errstr))

        else:
            Logger.instance().info("cannot find file: " + srcfilename)
Beispiel #10
0
    def copyFile(srcfilename, destfilename):
        if os.path.isfile(srcfilename):
            try:
                shutil.copyfile(srcfilename, destfilename)
                Logger.instance().info("copy file success: " + srcfilename)
            except:
                # 错误输出
                Logger.instance().info("copy file error: " + srcfilename)
                typeerr, value, tb = sys.exc_info()
                errstr = traceback.format_exception(typeerr, value, tb)
                Logger.instance().info("".join(errstr))

        else:
            Logger.instance().info("cannot find file: " + srcfilename)
Beispiel #11
0
 def logStackInfo():
     typeerr, value, tb = sys.exc_info()
     errstr = traceback.format_exception(typeerr, value, tb)
     Logger.instance().info(''.join(errstr))
Beispiel #12
0
 def traverseDirs(rootDir, handleDisp):
     for root, dirs, files in os.walk(rootDir):
         Logger.instance().info(''.join(dirs))
         Utils.traverseOneDirs(root, files, handleDisp)
Beispiel #13
0
 def convCpp2CSharp(self, fineName, filePathName):
     if fineName in Config.pInstance.m_fileNameList:
         Logger.instance().info(filePathName)
         
         cppFile = CppFile.CppFile()
         cppFile.parseCpp(filePathName)
Beispiel #14
0
 def onTimer(self):
     listdata = []
     Logger.instance().getlogger(listdata)
     for dataitem in listdata:
         self.m_LoggerWin.ui.textEdit.appendPlainText(dataitem)
Beispiel #15
0
 def onTimer(self):
     listdata = []
     Logger.instance().getlogger(listdata)
     for dataitem in listdata:
         self.m_LoggerWin.ui.textEdit.appendPlainText(dataitem)
Beispiel #16
0
 def logStackInfo():
     typeerr, value, tb = sys.exc_info()
     errstr = traceback.format_exception(typeerr, value, tb)
     Logger.instance().info("".join(errstr))
Beispiel #17
0
 def traverseDirs(rootDir, handleDisp):
     for root, dirs, files in os.walk(rootDir):
         Logger.instance().info("".join(dirs))
         Utils.traverseOneDirs(root, files, handleDisp)
Beispiel #18
0
 def onBtnClkTest(self):
     Logger.instance().info('test button')