本文整理汇总了Python中Cheetah.Template.Template.index方法的典型用法代码示例。如果您正苦于以下问题:Python Template.index方法的具体用法?Python Template.index怎么用?Python Template.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cheetah.Template.Template
的用法示例。
在下文中一共展示了Template.index方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writePushPop
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import index [as 别名]
def writePushPop(self, cmd, segment, index):
"""Write a push or pop command to the file as assembly. cmd tells whether to push or pop, segment
tells which segment of memory to operate on, index is a non negative int that tells the offset to use"""
self.outFile.write("//" + cmd + " " + segment + " " + str(index) + "\n")
#local, argument, this, that = common
if self.commonSegments.count(segment) > 0:
template = Template(self.pushPopTemplates[cmd + "_COMMON"])
template.index = str(index)
template.segment = self.segmentTranslation[segment]
elif segment == "TEMP" or segment == "POINTER" or segment == "STATE":
template = Template(self.pushPopTemplates[cmd + "_DIRECT"])
if segment == "TEMP":
template.index = str(5 + index)
elif segment == "POINTER":
template.index = str(3 + index)
else:
template.index = str(index)
elif segment == "STATIC":
template = Template(self.pushPopTemplates[cmd + "_STATIC"])
template.varName = self.curVmFile + "." + str(index)
#constant
else:# segment == "CONSTANT":
template = Template(self.pushPopTemplates[cmd + "_CONSTANT"])
template.const = str(index)
#print template
self.outFile.write(str(template))
示例2: player
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import index [as 别名]
def player(self, index, quality='low'):
index = int(index)
if quality == 'low':
width = 320
elif quality == 'hi':
width = 720
elif quality == 'hd':
width = 1280
else:
width = 480
resolution = self.videos[index]['resolution']
scale = float(width) / resolution[0]
resolution = (width, int(resolution[1] * scale))
template = Template(file=os.path.join(self._path, 'templates/player.tmpl'))
template.index = index
template.meta = self.videos[index]
template.quality = quality
template.width = resolution[0]
template.height = resolution[1]
template.player_h = template.height + 24
return template.respond()
示例3: process
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import index [as 别名]
def process(self):
def assignGlobalProperties(template):
template.projectname = self.projectname
template.projectdescription = self.projectdescription
template.projecturl = self.projecturl
template.ydn = self.ydn
template.version = self.version
template.modules = self.modules
template.modulenames = self.modulenames
template.modulename = self.modulename
template.moduletitle = self.moduletitle
template.cleansedmodulename = self.cleansedmodulename
template.moduledesc = self.moduledesc
template.year = datetime.date.today().strftime('%Y')
template.filename = self.filename
if self.filename:
template.filepath = os.path.join(self.inpath, self.filename)
template.filepath_highlighted = template.filepath + self.newext
template.pagetype = self.pagetype
template.classmap = self.classmap
template.classnames = self.classnames
template.filenames = self.filenames
template.classname = self.classname
template.requires = ""
template.optional = ""
template.properties = ""
template.methods = ""
template.events = ""
template.configs = ""
template.extends = ""
template.uses = ""
template.index = False # is this the index page
def transferToTemplate(prop, dict, template, valOverride=''):
val = ""
if prop in dict:
val = unicode(dict[prop])
if valOverride:
val = valOverride
setattr(template, prop, val)
def transferToDict(prop, dict1, dict2, default="", skipOverrideIfNoMatch=False):
val = ""
if prop in dict1:
val = unicode(dict1[prop])
if not val:
val = default
else:
if skipOverrideIfNoMatch:
pass
else:
val = default
dict2[prop] = val
def shouldShow(item):
if const.STATIC not in item and \
(self.showprivate or const.PRIVATE not in item):
return True
else:
return False
def shouldShowClass(item):
if self.showprivate or const.PRIVATE not in item:
return True
else:
return False
def soft_sort(x, y):
return cmp(x.lower(), y.lower())
def getPropsFromSuperclass(superc, classes, dict):
# get inherited data
if shouldShowClass(superc):
supercname = superc[const.NAME]
if const.PROPERTIES in superc:
inhdef = dict[const.PROPERTIES][supercname] = []
keys = superc[const.PROPERTIES].keys()
keys.sort(soft_sort)
for prop in keys:
superprop = superc[const.PROPERTIES][prop]
if shouldShow(superprop):
if const.PRIVATE in superprop: access = const.PRIVATE
elif const.PROTECTED in superprop: access = const.PROTECTED
else:access = ""
inhdef.append({const.NAME: prop, const.ACCESS: access, const.DEPRECATED: const.DEPRECATED in superprop})
if const.METHODS in superc:
inhdef = dict[const.METHODS][supercname] = []
keys = superc[const.METHODS].keys()
keys.sort(soft_sort)
for method in keys:
supermethod = superc[const.METHODS][method]
if shouldShow(supermethod):
#.........这里部分代码省略.........
示例4: process
# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import index [as 别名]
def process(self):
def assignGlobalProperties(template):
template.projectname = self.projectname
template.projecturl = self.projecturl
template.copyrighttag = self.copyrighttag
template.ydn = self.ydn
template.version = self.version
template.modules = self.modules
template.modulenames = self.modulenames
template.cleansedmodulenames = self.cleansedmodulenames
template.modulename = self.modulename
template.moduletitle = self.moduletitle
template.cleansedmodulename = self.cleansedmodulename
template.moduledesc = self.moduledesc
template.year = datetime.date.today().strftime("%Y")
template.filename = self.filename
if self.filename:
template.filepath = os.path.join(self.inpath, self.filename)
template.highlightcontent = codecs.open(
os.path.join(self.inpath, self.filename + self.newext), "r", "utf-8"
).read()
template.pagetype = self.pagetype
template.classmap = self.classmap
template.classnames = self.classnames
template.filenames = self.filenames
template.classname = self.classname
template.requires = ""
template.optional = ""
template.properties = ""
template.methods = ""
template.events = ""
template.configs = ""
template.extends = ""
template.uses = ""
template.index = False # is this the index page
def transferToTemplate(prop, dict, template, valOverride=""):
val = ""
if prop in dict:
if type(dict[prop]).__name__ == "unicode":
val = markdown(dict[prop])
else:
val = dict[prop]
if valOverride:
val = valOverride
setattr(template, prop, val)
def transferToDict(prop, dict1, dict2, default="", skipOverrideIfNoMatch=False):
val = ""
if prop in dict1:
val = dict1[prop]
if not val:
val = default
if prop == DESCRIPTION:
val = markdown(val)
else:
if skipOverrideIfNoMatch:
pass
else:
val = default
dict2[prop] = val
def shouldShow(item):
if STATIC not in item and (self.showprivate or PRIVATE not in item):
return True
else:
return False
def shouldShowClass(item):
if self.showprivate or PRIVATE not in item:
return True
else:
return False
def soft_sort(x, y):
return cmp(x.lower(), y.lower())
def getPropsFromSuperclass(superc, classes, dict):
# get inherited data
if shouldShowClass(superc):
supercname = superc[NAME]
if PROPERTIES in superc:
inhdef = dict[PROPERTIES][supercname] = []
keys = superc[PROPERTIES].keys()
keys.sort(soft_sort)
for prop in keys:
superprop = superc[PROPERTIES][prop]
if shouldShow(superprop):
if PRIVATE in superprop:
access = PRIVATE
elif PROTECTED in superprop:
access = PROTECTED
else:
access = ""
#.........这里部分代码省略.........