本文整理汇总了Python中arelle.Locale.format_string方法的典型用法代码示例。如果您正苦于以下问题:Python Locale.format_string方法的具体用法?Python Locale.format_string怎么用?Python Locale.format_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arelle.Locale
的用法示例。
在下文中一共展示了Locale.format_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: backgroundProfileFormula
# 需要导入模块: from arelle import Locale [as 别名]
# 或者: from arelle.Locale import format_string [as 别名]
def backgroundProfileFormula(cntlr, profileReportFile, maxRunTime, excludeCompileTime):
from arelle import Locale, XPathParser, ValidateXbrlDimensions, ValidateFormula
# build grammar before profiling (if this is the first pass, so it doesn't count in profile statistics)
XPathParser.initializeParser(cntlr.modelManager)
# load dimension defaults
ValidateXbrlDimensions.loadDimensionDefaults(cntlr.modelManager)
import cProfile, pstats, sys, time
# a minimal validation class for formula validator parameters that are needed
class Validate:
def __init__(self, modelXbrl, maxRunTime):
self.modelXbrl = modelXbrl
self.parameters = None
self.validateSBRNL = False
self.maxFormulaRunTime = maxRunTime
def close(self):
self.__dict__.clear()
val = Validate(cntlr.modelManager.modelXbrl, maxRunTime)
formulaOptions = val.modelXbrl.modelManager.formulaOptions
if excludeCompileTime:
startedAt = time.time()
cntlr.addToLog(_("pre-compiling formulas before profiling"))
val.validateFormulaCompileOnly = True
ValidateFormula.validate(val)
del val.validateFormulaCompileOnly
cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale,
_("formula pre-compiling completed in %.2f secs"),
time.time() - startedAt))
cntlr.addToLog(_("executing formulas for profiling"))
else:
cntlr.addToLog(_("compiling and executing formulas for profiling"))
startedAt = time.time()
statsFile = profileReportFile + ".bin"
cProfile.runctx("ValidateFormula.validate(val)", globals(), locals(), statsFile)
cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale,
_("formula profiling completed in %.2f secs"),
time.time() - startedAt))
# dereference val
val.close()
# specify a file for log
priorStdOut = sys.stdout
sys.stdout = open(profileReportFile, "w")
statObj = pstats.Stats(statsFile)
statObj.strip_dirs()
statObj.sort_stats("time")
statObj.print_stats()
statObj.print_callees()
statObj.print_callers()
sys.stdout.flush()
sys.stdout.close()
del statObj
sys.stdout = priorStdOut
os.remove(statsFile)
示例2: profilerCommandLineRun
# 需要导入模块: from arelle import Locale [as 别名]
# 或者: from arelle.Locale import format_string [as 别名]
def profilerCommandLineRun(cntlr, options, sourceZipStream=None, **kwargs):
from arelle import Locale
import cProfile, pstats, sys, time
profileReportFile = getattr(options, "profilerReportFile", None)
if profileReportFile and not getattr(cntlr, "blockNestedProfiling", False):
startedAt = time.time()
cntlr.addToLog(_("invoking command processing under profiler"))
statsFile = profileReportFile + ".bin"
cntlr.blockNestedProfiling = True
cProfile.runctx("cntlr.run(options, sourceZipStream)", globals(), locals(), statsFile)
cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale,
_("profiled command processing completed in %.2f secs"),
time.time() - startedAt))
# specify a file for log
priorStdOut = sys.stdout
sys.stdout = open(profileReportFile, "w")
statObj = pstats.Stats(statsFile)
statObj.strip_dirs()
statObj.sort_stats("time")
statObj.print_stats()
statObj.print_callees()
statObj.print_callers()
sys.stdout.flush()
sys.stdout.close()
del statObj
sys.stdout = priorStdOut
os.remove(statsFile)
del cntlr.blockNestedProfiling
sys.exit() # raise SYSTEM_EXIT to stop outer execution
示例3: savePickle
# 需要导入模块: from arelle import Locale [as 别名]
# 或者: from arelle.Locale import format_string [as 别名]
def savePickle(cntlr, modelXbrl, pickleFile):
if modelXbrl.fileSource.isArchive:
return
import io, time, pickle
from arelle import Locale
startedAt = time.time()
fh = io.open(pickleFile, u"wb")
try:
pickle.dump(modelXbrl, fh)
except Exception, ex:
cntlr.addToLog(u"Exception " + unicode(ex))
fh.close()
cntlr.addToLog(Locale.format_string(cntlr.modelManager.locale,
_(u"profiled command processing completed in %.2f secs"),
time.time() - startedAt))
def savePickleMenuEntender(cntlr, menu):
# Extend menu with an item for the save infoset plugin
menu.add_command(label=u"Save pickled modelXbrl",
underline=0,
command=lambda: savePickleMenuCommand(cntlr) )
def savePickleMenuCommand(cntlr):
# save Infoset menu item has been invoked
from arelle.ModelDocument import Type
if cntlr.modelManager is None or cntlr.modelManager.modelXbrl is None or cntlr.modelManager.modelXbrl.modelDocument.type != Type.INSTANCE:
cntlr.addToLog(u"No instance loaded.")
return