t-time.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:t-time 作者: theandrewbailey 项目源码 文件源码
def formatOutputVars(self):
        """create output variable object for insertion into template."""
        self.outputVars={"title":self.agencyName,"headerTitle":self.agencyName,"generationDate":email.utils.formatdate(localtime=True)}
        routeSelect=""
        tableTemplate="\t<section id='{0}'>\n\t\t<h1>{1}</h1>\n{2}\t</section>\n"
        activeTemplate="\t\t<table><caption>{0}</caption><thead></thead><tbody></tbody></table>\n"
        tables=""
        for routename in self.selectedRoutes if len(self.selectedRoutes)>0 else self.routesByName.keys():
            route=self.routesByName[routename]
            routeSelect+="\t<input type='radio' name='line' value='{1}' id='radio-{1}'/><label for='radio-{1}'>{0}</label>\n".format(route.shortname,route.id)
            routetables=""
            for line in sorted(route.stops.keys()):
                routetables+=activeTemplate.format(line)
            tables+=tableTemplate.format(route.id,route.longname,routetables)
        self.outputVars["ttimesettings"]=removeSpaces(json.dumps({"selectedRoutes":self.selectedRoutes,"excludeStops":self.excludeStops,"_12hourClock":self._12hourClock}))
        self.outputVars["html"]=routeSelect+tables
        self.outputVars["javascript"]="const dates={0};\nconst routes={1};\nconst _12hourClock={2};\n".format(removeSpaces(self.dates.__str__()),removeSpaces(self.routes.__str__().replace("'\\x00'","null")),str(self._12hourClock).lower())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号