def __init__(self): xml = SimpleXML(Path.executeDirectory()) binSect = xml.openSection("bin.xml") if binSect is None: Listener().cbError("config file 'bin.xml' is not exist.") engine.exit(1) self.__binSect = binSect
def export(tplModule): """ 导出 """ outInfos = getattr(tplModule, "outInfos", None) if outInfos is None: outInfo = getattr(tplModule, "outInfo", None) if outInfo is None: raise ExportFixException("errNoConfigInfo", outInfo="outInfo", outInfos="outInfos") else: outInfos = [outInfo] Listener().cbBeginExport(tplModule) # 准备导出 for outInfo in outInfos: # 每个 outInfo 对应一个导出的配置文件 OutExporter(outInfo).run() # 准备导出其中一个配置 Listener().cbEndExport(tplModule) # 结束导出
def __initHeads(self, headRow): for col, cname in enumerate(self.iterRowText(headRow)): cname = cname.strip() if cname == "": continue c = self.name2col_.get(cname) if c is not None: # 列明重复 Listener().cbWarning(Local().formatLocalText("dataSource", "warnDBHeadName", \ col1=self.col2mark(c), col2=self.col2mark(col), name=cname)) self.name2col_[cname] = col
sheet=sheetName) return XLSXSheet(fileName, baseSheet, encoding) def close(self, save=False): """ 关闭 excel 程序 """ if save: for fileName, wbook in self.__wbooks.iteritems(): try: wbook.save(script2sys(fileName)) except Exception, err: raise ExcelFixException("errSave", file=fileName, msg=err.message) Listener().cbLocalMsg("excelApp", "tipsReleaseExcel") # -------------------------------------------------------------------- # global functions # -------------------------------------------------------------------- def onAppExit(exitCode): """ 程序退出时调用 """ XLSXApp.inst().close(False) XLSXApp.releaseInst() Listener().cbAppExit.bind(onAppExit)
Console.inst().setCursorPos(cx, cy) print fmt % _dsystext(_key, _name, **args) ProgressRecord.printer = CapPrinter() return ProgressRecord.printer def uncapPrinter(cappedPrinter=None): """ 解锁打印机 """ if cappedPrinter is None or cappedPrinter == ProgressRecord.printer: ProgressRecord.clear() return True return False def isPrinterCapped(): """ 指出打印机是否被锁 """ return ProgressRecord.running # -------------------------------------------------------------------- # exit callback # -------------------------------------------------------------------- def onAppExit(exitCode): """ 程序退出时,解锁打印机 """ uncapPrinter() Listener().cbAppExit.bind(onAppExit)
except Exception, err: sys.excepthook(Exception, err, sys.exc_traceback) engine.exit(1) # -------------------------------------------------------------------- # callbacks # -------------------------------------------------------------------- def onInfo(msg): """ 提示信息回调 """ Printer.dmsg("Info: %s" % msg) Listener().cbInfo.bind(onInfo) def onWarning(msg): """ 警告信息回调 """ Printer.dmsg("Warning: %s" % msg) Listener().cbWarning.bind(onWarning) def onError(msg): """ 错误信息回调
def onEndLoad(self, dsrc, loadTime): self.__dsrc = dsrc self.__loadTime = loadTime Listener().cbEndLoadDataSource(self)
def onLoadProgress(self, progress): Listener().cbLoadingDataSource(self, progress)
def onBeginLoad(self): Listener().cbBeginLoadDataSource(self) Listener().cbLoadingDataSource(self, 0.0)