Example #1
0
    def processSecondLevelDir(self, _filepath):
        _files = listdir(_filepath)

        for _file in _files:
            _lastpath = _filepath + '/' + _file

            #判断是否是文件夹
            if osPath.isdir(_lastpath):
                # 递归搜索
                self.processSecondLevelDir(_lastpath)
            else:
                # to process each file

                # ignore the files which not .xlsx or .xls file
                if not (".xls" in _file):
                    continue
                else:
                    # ignore the temporary files
                    if "~$" in _file:
                        ErrorList.addError(
                            Warning(
                                _lastpath,
                                "find \'~$\' in the file name, do use \'~$\' for file name in case we see it as temporary files"
                            ))
                        continue

                    Logger.addPrefabLog(Logger.LOG_TYPE_DO, _lastpath)
                    self.processInfoWithTime(_lastpath)
Example #2
0
 def save(self, outPath=""):
     Logger.addPrefabLog(Logger.LOG_TYPE_SAVE, outPath)
     try:
         print("正在保存文件...")
         if outPath == "":
             self.updateBook.save(self.updatePath)
         else:
             self.updateBook.save(outPath)
         print("保存文件成功!!")
     except:
         processException()
Example #3
0
def doCommand():
    # forever loop
    while True:
        # split the command and remove the none
        cmdLine = input(">>-->")
        Logger.addLog("COMMAND: " + cmdLine)
        if cmdLine == "": continue

        cmdList = cmdLine.strip().split(" ")
        for cmdIteration in cmdList:
            if cmdIteration == '': cmdList.remove(cmdIteration)

        # we have no different cmd now, so ignore it
        # cmd = cmdList[0]

        index = 1
        result = {}
        while index < len(cmdList):
            # if it is the path Argument, then save it
            if cmdList[index] in pathArguDict:
                index += 1
                if index >= len(cmdList):
                    Logger.addLog("DATA NONE: " + cmdList[index - 1])
                    print("data none!!" + cmdList[index - 1])
                    break
                elif cmdList[index - 1] != "-sa" and not utils.is_excel_file(
                        cmdList[index]):
                    Logger.addLog("DATA ERROR, NOT EXCEL FILE : " +
                                  cmdList[index - 1])
                    print("DATA ERROR!!NOT EXCEL FILE!!" + cmdList[index - 1])
                    break
                else:
                    Logger.addLog("COMMAND: {}, DATA: {}".format(
                        cmdList[index - 1], cmdList[index]))
                    result[pathArguDict[cmdList[index - 1]]] = cmdList[index]
                    index += 1

            elif cmdList[index] in systemArguDict:
                Logger.addLog("COMMAND: {}".format(cmdList[index]))
                systemArguDict[cmdList[index]]()
                break

            else:
                Logger.addLog("COMMAND ERROR:" + cmdList[index])
                print("command error! " + cmdList[index])
                break

        # 处理金额和退款
        if "salePath" in result and "summaryPath" in result:
            Logger.addLog("process SA ")
            try:
                summary = load_workbook(result["summaryPath"])
            except:
                processException()

            # get the notfound table
            notfoundPath = result[
                "notfoundTable"] if "notfoundPath" in result else ""
            NF = notfound.NotFound(notfoundPath)
            notfoundTable = NF.getNotfoundTable()

            # process salesAmount
            SA = saleAmount.SaleAmount(summary, notfoundTable)
            SA.processDir(result["salePath"])

            if "refundPath" in result:
                # process refund
                Logger.addLog("process RF ")
                RF = refund.Refund(summary, notfoundTable)
                RF.processRefundInfo(result["refundPath"])

            # save file
            savePath = result[
                "savePath"] if "savePath" in result else "summary.xlsx"
            summary.save(savePath)
            Logger.addPrefabLog(Logger.LOG_TYPE_SAVE, savePath)
            NF.save()

        # 处理退款
        elif "summaryPath" in result and "refundPath" in result:
            Logger.addLog("process RF ")
            try:
                summary = load_workbook(result["summaryPath"])
            except:
                processException()

            # get the notfound table
            notfoundPath = result[
                "notfoundTable"] if "notfoundPath" in result else ""
            NF = notfound.NotFound(notfoundPath)
            notfoundTable = NF.getNotfoundTable()

            # process refund
            RF = refund.Refund(summary, notfoundTable)
            RF.processRefundInfo(result["refundPath"])

            # save file
            savePath = result[
                "savePath"] if "savePath" in result else "summary.xlsx"
            summary.save(savePath)
            NF.save()
            Logger.addPrefabLog(Logger.LOG_TYPE_SAVE, savePath)

        # 更新成本
        elif "originPath" in result and "updatePath" in result:
            Logger.addLog("process PF ")
            PF = profit.Profit(result["originPath"], result["updatePath"])
            PF.processProfitUpdate()

            savePath = result["savePath"] if "savePath" in result else ""
            PF.save(savePath)

        # print
        if len(result) != 0: ErrorList.printErrorList()
Example #4
0
 def save(self, notfoundOutPath = ""):
     Logger.addPrefabLog(Logger.LOG_TYPE_SAVE, notfoundOutPath)
     if notfoundOutPath == "":
         self.notfoundBook.save(self.path)
     else:
         self.notfoundBook.save(notfoundOutPath)