本文整理汇总了Python中datasource.bases.BaseHub.BaseHub.stripPythonComments方法的典型用法代码示例。如果您正苦于以下问题:Python BaseHub.stripPythonComments方法的具体用法?Python BaseHub.stripPythonComments怎么用?Python BaseHub.stripPythonComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datasource.bases.BaseHub.BaseHub
的用法示例。
在下文中一共展示了BaseHub.stripPythonComments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import stripPythonComments [as 别名]
def handle(self, *args, **options):
##Load data views##
views_file_obj = open("%s%s" % (settings.ROOT, "/templates/data/views.json"))
try:
data_view_file = views_file_obj.read()
finally:
views_file_obj.close()
##Strip out comments and newlines##
t = BaseHub.stripPythonComments(data_view_file)
data_views = BaseHub.deserializeJson(data_view_file)
Command.build_nav(data_views)
#Uncomment to see datastructure for debugging
#pp = pprint.PrettyPrinter(indent=3)
#self.stdout.write( pp.pformat(data_views) )
menu_file_obj = open("%s%s" % (settings.ROOT, "/media/html/nav_menu.html"), 'w+')
try:
menu_file_obj.write( '<ul class="dv-viewtext">\n%s\n</ul>' % (dv_unorderedlist(data_views)) )
finally:
menu_file_obj.close()
##Write out json for the nav_lookup_hash##
jstring = json.dumps( Command.nav_lookup_hash, ensure_ascii=False )
html = """<input id="dv_nav_json" type="hidden" value="{{ json_data }}" />"""
t = Template(html)
c = Context({ 'json_data':jstring })
templateString = t.render(c)
nav_lookup_file_obj = open("%s%s" % (settings.ROOT, "/templates/graphs.navlookup.html"), 'w+')
try:
nav_lookup_file_obj.write(templateString)
finally:
nav_lookup_file_obj.close()