本文整理汇总了Python中datasource.bases.BaseHub.BaseHub.strip_python_comments方法的典型用法代码示例。如果您正苦于以下问题:Python BaseHub.strip_python_comments方法的具体用法?Python BaseHub.strip_python_comments怎么用?Python BaseHub.strip_python_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datasource.bases.BaseHub.BaseHub
的用法示例。
在下文中一共展示了BaseHub.strip_python_comments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from datasource.bases.BaseHub import BaseHub [as 别名]
# 或者: from datasource.bases.BaseHub.BaseHub import strip_python_comments [as 别名]
def handle(self, *args, **options):
##Load data views##
views_file_obj = open("%s%s" % (settings.ROOT, "/datazilla/webapp/templates/data/views.json"))
try:
data_view_file = views_file_obj.read()
finally:
views_file_obj.close()
##Strip out comments and newlines##
t = BaseHub.strip_python_comments(data_view_file)
data_views = BaseHub.deserialize_json(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, "/datazilla/webapp/static/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 })
template_string = t.render(c)
nav_lookup_file_obj = open("%s%s" % (settings.ROOT, "/datazilla/webapp/templates/graphs.navlookup.html"), 'w+')
try:
nav_lookup_file_obj.write(template_string)
finally:
nav_lookup_file_obj.close()