本文整理汇总了Python中Cheetah.Template.Template.timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python Template.timestamp方法的具体用法?Python Template.timestamp怎么用?Python Template.timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cheetah.Template.Template
的用法示例。
在下文中一共展示了Template.timestamp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import timestamp [as 别名]
#.........这里部分代码省略.........
#sort is case insensitive and ignores puctuation for the search json file
def allprop_sort(x, y):
pat = re.compile(r"[\_\-\.]")
cx = x[const.NAME].lower()
cy = y[const.NAME].lower()
cx = pat.sub('', cx)
cy = pat.sub('', cy)
return cmp(cx, cy)
log.info("-------------------------------------------------------")
# copy the json file
# jsonname = self.cleansedmodulename + ".json"
jsonname = "raw.json"
log.info("Writing " + jsonname)
self.write(jsonname, self.rawdata)
for mname in self.modules:
log.info("Generating module splash for %s" %(mname))
m = self.modules[mname]
self.filename = ""
self.classname = ""
classes = self.data[const.CLASS_MAP]
self.classnames = []
for i in m[const.CLASS_LIST]:
if shouldShowClass(classes[i]):
self.classnames.append(i)
self.classnames.sort(soft_sort)
t = Template(file=os.path.join(self.templatepath, "main.tmpl"))
t.timestamp = time.time()
self.modulename = mname
self.moduletitle = mname
if const.TITLE in m:
self.moduletitle = m[const.TITLE]
self.cleansedmodulename = self.cleanseStr(mname)
if const.DESCRIPTION in m:
self.moduledesc = m[const.DESCRIPTION]
else:
log.warn("Missing module description for " + mname)
self.moduledesc = ''
self.filenames = m[const.FILE_LIST]
self.filenames.sort(soft_sort)
assignGlobalProperties(t)
transferToTemplate(const.REQUIRES, m, t)
transferToTemplate(const.OPTIONAL, m, t)
transferToTemplate(const.BETA, m, t, "Beta")
transferToTemplate(const.EXPERIMENTAL, m, t, "Experimental")
if len(m[const.SUBMODULES]) > 0:
strg = ', '.join(m[const.SUBMODULES])
else:
strg = 'none'
transferToTemplate(const.SUBMODULES, m, t, strg)
t.submodules = m[const.SUBMODULES]
示例2: main
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import timestamp [as 别名]
def main(argv):
link_files_to_cwd_then_remove([os.path.join(DATA_DIR, filename) for filename in os.listdir(DATA_DIR)])
link_files_to_cwd_then_remove([os.path.join(os.path.dirname(os.path.abspath(__file__)), filename) for filename in FANG_DATA])
# $FrontAxleWeight
# $RearAxleWeight
#
#
#
#
DefaultFrontAxleWeight=1000.0
DefaultRearAxleWeight=2000.0
DefaultFinalDriveRatio=4.67
DefaultFinalDriveEfficiency=0.98
##########################################
# parse metrics file
##########################################
#if not os.path.exists('summary.report.json'):
# print 'File does not exist: summary.report.json'
# sys.exit()
if (len(argv) > 1):
if not os.path.exists(argv[1]):
print 'Given metric file does not exist: {0}'.format(argv[1])
sys.exit(2)
else:
sys.stderr.write('Usage: %s testbench_manifest.json\n' % sys.argv[0])
sys.exit(2)
result_json = {}
# read current summary report, which contains the metrics
#with open('summary.report.json', 'r') as file_in:
with open(argv[1], 'r') as file_in:
result_json = json.load(file_in)
nameSpace = {'FrontAxleWeight':DefaultFrontAxleWeight, 'RearAxleWeight':DefaultRearAxleWeight, 'FinalDriveRatio':DefaultFinalDriveRatio, 'FinalDriveEfficiency':DefaultFinalDriveEfficiency}
if 'Metrics' in result_json:
for metric in result_json['Metrics']:
if 'Name' in metric and 'Value' in metric:
if metric['Name'] in nameSpace:
print metric['Name'] + ': '+ metric['Value']
nameSpace[metric['Name']] = float(metric['Value'])
else:
# create warning message
pass
else:
# create warning message
print 'no metric file'
sys.exit(3)
nameSpace.update({'vehicle_identifier':'M1 TANK WES Jan94', 'VEHICLE':'$VEHICLE', 'VEHICL':'$VEHICL', 'END':'$END', 'LFVDAT':'$LFVDAT'})
#print 'hit enter'
#os.system('pause')
##########################################
# LATER: Generate *.INP (points to *.VEH)
##########################################
##########################################
# create *.veh for OBSDP.exe
##########################################
templateDef = """ 1 ${vehicle_identifier} 2
"""
template_file = OBS_VEH_TEMPLATENAME
template_fullpath = os.path.join(template_path, template_file)
t = Template(file=template_fullpath, searchList=[nameSpace]) #searchList=[nameSpace])
now = datetime.datetime.now()
t.timestamp = now.strftime("%Y-%m-%d %H:%M")
t.filename = template_file
print t
absoutputfilename = OBS_VEH_FILENAME
try:
f = open(absoutputfilename, "wb")
except Exception, e:
self.log("Skipping Output: Could not open file for writing %s: %s" % (absoutputfilename, str(e)), 3)
示例3: process
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import timestamp [as 别名]
#.........这里部分代码省略.........
data[PARAMS] = "".join(result)
else:
data[PARAMS] = ""
return data
log.info("-------------------------------------------------------")
# copy the json file
# jsonname = self.cleansedmodulename + ".json"
jsonname = "raw.json"
log.info("Writing " + jsonname)
self.write(jsonname, self.rawdata, False)
for mname in self.modules:
log.info("Generating module splash for %s" % (mname))
m = self.modules[mname]
self.filename = ""
self.classname = ""
classes = self.data[CLASS_MAP]
self.classnames = []
for i in m[CLASS_LIST]:
if shouldShowClass(classes[i]):
self.classnames.append(i)
self.classnames.sort(soft_sort)
t = Template(file=os.path.join(self.templatepath, "main.tmpl"))
# @TODO add command line option for timestamp
# timestamp = time.time()
timestamp = ""
t.timestamp = timestamp
transferToTemplate(REQUIRES, m, t)
self.modulename = mname
self.moduletitle = mname
if TITLE in m:
self.moduletitle = m[TITLE]
self.cleansedmodulename = self.cleanseStr(mname)
if DESCRIPTION in m:
self.moduledesc = m[DESCRIPTION]
else:
log.warn("Missing module description for " + mname)
self.moduledesc = ""
self.filenames = m[FILE_LIST]
self.filenames.sort(soft_sort)
assignGlobalProperties(t)
transferToTemplate(REQUIRES, m, t)
transferToTemplate(OPTIONAL, m, t)
transferToTemplate(BETA, m, t, "Beta")
transferToTemplate(EXPERIMENTAL, m, t, "Experimental")
if len(m[SUBMODULES]) > 0:
strg = ", ".join(m[SUBMODULES])
else:
strg = "none"
示例4: Template
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import timestamp [as 别名]
##########################################
# LATER: Generate *.INP (points to *.STD)
##########################################
##########################################
# create *.STD
##########################################
template_file = NRMM_STD_TEMPLATENAME
template_fullpath = os.path.join(template_path, template_file)
t = Template(file=template_fullpath, searchList=[nameSpace]) #searchList=[nameSpace])
now = datetime.datetime.now()
t.timestamp = now.strftime("%Y-%m-%d %H:%M")
t.filename = template_file
print t
absoutputfilename = NRMM_STD_FILENAME
try:
f = open(absoutputfilename, "wb")
except Exception, e:
self.log("Skipping Output: Could not open file for writing %s: %s" % (absoutputfilename, str(e)), 3)
f.write(str(t))
f.close()
print 'wrote ' + absoutputfilename
#print 'hit enter'