当前位置: 首页>>代码示例>>Python>>正文


Python Template.filename方法代码示例

本文整理汇总了Python中Cheetah.Template.Template.filename方法的典型用法代码示例。如果您正苦于以下问题:Python Template.filename方法的具体用法?Python Template.filename怎么用?Python Template.filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cheetah.Template.Template的用法示例。


在下文中一共展示了Template.filename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import filename [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):
#.........这里部分代码省略.........
开发者ID:opolyo01,项目名称:mui-js,代码行数:103,代码来源:yuidoc_generate.py

示例2: process

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import filename [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 = ""
#.........这里部分代码省略.........
开发者ID:shane-tomlinson,项目名称:AFrame-JS,代码行数:103,代码来源:yuidoc_generate.py

示例3: Template

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import filename [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'
    #os.system('pause')
开发者ID:dyao-vu,项目名称:meta-core,代码行数:32,代码来源:process_nrmm.py

示例4: main

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import filename [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)
开发者ID:dyao-vu,项目名称:meta-core,代码行数:85,代码来源:process_nrmm.py

示例5: debug

# 需要导入模块: from Cheetah.Template import Template [as 别名]
# 或者: from Cheetah.Template.Template import filename [as 别名]
page.sparkbody = ""
page.sparkstop = """    });"""

page.title = "Mapper career statistics for '%s'"%args.userId
page.content = ''
page.swVersion = '0.01'
page.now = datetime.now()
page.year = page.now.year

print "Debug? ::%s"%args.debug

if args.debug:
    debug()

page.userId = args.userId
page.filename = args.fileName
page.dbname = args.dbName

def datalicense():
    page.datalicense = Template( file='./templates/legal.tmpl')
    page.datalicense.year = page.now.year
    page.datalicense.time = page.now.strftime("%Y-%m-%d %H:%M")
    page.datalicense.swVersion = '0.01'

def editorpiechart():
    """ create table and piechart of editors used by mapper """
    # select the editors and numbers of changesets per editor from the database
    cursor.execute(queries.editorpiechart, (args.userId,))
    dbresult=dict()
    dblist = cursor.fetchall()
    print "dblist:: %s"%dblist
开发者ID:timwaters,项目名称:UserStat,代码行数:33,代码来源:userstat.py


注:本文中的Cheetah.Template.Template.filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。