예제 #1
0
def _initExportTpl(tplFile):
    """
	初始化导出模板
	"""
    exists = False
    for root in CustomConfig().tplRoots:
        fullName = os.path.join(root, tplFile)
        if os.path.exists(script2sys(fullName)):
            exists = True
            break
    if not exists:
        Printer.dout("theme", "errTplFileUnxist", tpl=tplFile)
        engine.exit(1)
    else:
        _printTplMsg(fullName)

    tplFile = os.path.splitext(tplFile)[0]
    tplFile = tplFile.replace("\\", ".").replace("/", ".")
    try:
        tplFile = script2sys(tplFile)
        tplModule = __import__(tplFile, globals(), locals(), [tplFile])  # 导出模板
        return tplModule
    except BaseException, err:
        if not _isDebug(): print err.sysMsg
        else: sys.excepthook(BaseException, err, sys.exc_traceback)
        messageBox(err.scriptMsg, "ERROR", MB_OK, MB_ICONSTOP)
예제 #2
0
def onAppExit(exitCode):
    """
	程序退出时调用
	"""
    if exitCode == 0:
        Printer.dout("theme", "tipsExportSuccess")
    else:
        Printer.printNewline()
        Printer.dout("theme", "tipsExportFail")
예제 #3
0
def onBeginWriteConfigItem(writeTracer):
    """
	写入配置选项
	"""
    Printer.printNewline()
    name = writeTracer.owner.outItemInfo.name
    Printer.dout("export", "tipsWriteOut", name=name)
    if CustomConfig().query("custom/showProgress", bool):
        global _cappedPrint
        _cappedPrint = Printer.capPrinter(False)
예제 #4
0
def onEndScanDataSource(dsrcTracer):
    """
	结束一个数据源的扫描
	"""
    if CustomConfig().query("custom/showProgress", bool):
        Printer.uncapPrinter()
        global _cappedPrint
        _cappedPrint = None

    # 打印空行(键)
    if len(dsrcTracer.emptyRows):
        Printer.printNewline()
        Printer.dout("export", "warnEmptyRows", rows=dsrcTracer.emptyRows)
예제 #5
0
def onBeginLoadDataSource(loadTracer):
    """
	开始加载数据源时被调用
	"""
    Printer.dout("theme", "tipsLoadDataSource", src=loadTracer.getSrcText())
    if CustomConfig().query("custom/showProgress", bool):
        global _cappedPrint
        _cappedPrint = Printer.capPrinter(True)
        pbarLen = CustomConfig().query("custom/pbarLen", int)
        _cappedPrint.pbarLen = pbarLen
        _cappedPrint.pbarChr = CustomConfig().query("custom/pbarChar")
        _cappedPrint.fmt = Printer.dtext("theme",
                                         "tipsLoadDataSourceProgress",
                                         pbarLen=pbarLen)
예제 #6
0
def onBeginScanDataSource(dsrcTracer):
    """
	开始扫描数据源
	"""
    global _firstScanData
    if _firstScanData:
        _firstScanData = False
    else:
        Printer.printNewline()

    srcText = dsrcTracer.dsrc.getSrcText()
    Printer.dout("export", "tipsScanSrcData", path=srcText)
    if CustomConfig().query("custom/showProgress", bool):
        global _cappedPrint
        _cappedPrint = Printer.capPrinter(False)
예제 #7
0
def enter():
    """
	argv[1]		导出模板路径
	"""
    args = sys.argv[1:]
    if len(args) < 1 or len(args[0]) == 0:
        Printer.dout("theme", "errorArgs")
        engine.exit(1)
    tplRoot = sys2script(args[0])

    # 初始化环境变量
    _initEnvironment()
    # 打印版本信息
    _printAppMsg()
    # 初始化导出模板
    tplModule = _initExportTpl(tplRoot)

    try:
        exporter.export(tplModule)
    except BaseException, err:
        if not _isDebug(): print err.sysMsg
        else: sys.excepthook(BaseException, err, sys.exc_traceback)
        messageBox(err.scriptMsg, "ERROR", MB_OK, MB_ICONSTOP)
        engine.exit(1)
예제 #8
0
def onEndExportConfigItem(exportItemTracer):
    """
	结束一个配置的导出
	"""
    # 打印重复键
    if len(exportItemTracer.dbKeys):
        Printer.printNewline()
        s = ""
        for key, count in exportItemTracer.dbKeys.iteritems():
            s += "[%s(%i)] " % (key, count)
        Printer.dout("export", "warnDBKey", keys=s)

    # 打印记录数
    Printer.printNewline()
    Printer.dout("export",
                 "tipsRowCount",
                 count=exportItemTracer.outItemInfo.rowCount)  # 记录总数
    Printer.dout("export",
                 "tipsEmptyRowCount",
                 count=exportItemTracer.emptyCount)  # 空行数(包括空键)
    Printer.dout("export",
                 "tipsDBRowCount",
                 count=len(exportItemTracer.dbKeys))  # 重复键的行数
    Printer.dout("export", "tipsIgnorCount",
                 count=exportItemTracer.ignorCount)  # 忽略的行数
    Printer.dout("export", "tipsValidCount",
                 count=len(exportItemTracer.datas))  # 有效行数

    # 打印导出时间
    writeTracer = exportItemTracer.writeTracer
    Printer.dout("theme",
                 "tipsReadTableWaste",
                 v=exportItemTracer.loadDSrcsTime)  # 加载数据耗时
    Printer.dout("theme", "tipsExplainWaste",
                 v=exportItemTracer.scanDSrcsTime)  # 扫描数据耗时
    Printer.dout("theme", "tipsWriteOutWaste",
                 v=exportItemTracer.writeTime)  # 写入配置耗时
    Printer.dout("theme", "tipsTotalWaste",
                 v=exportItemTracer.wasteTime)  # 总耗时
    Printer.printNewline()
예제 #9
0
def onLocalMsg(key, tag, **attrs):
    """
	语言配置中信息回调
	"""
    Printer.dout(key, tag, **attrs)