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()