[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / generate_index.py
blob4061165b13c43661cb33b0b5f007df97daf90d18
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import collections
7 import easy_template
9 def CmpByName(x, y):
10 return cmp(x['NAME'], y['NAME'])
12 class LandingPage(object):
13 def __init__(self):
14 self.section_list = ['Getting Started', 'API', 'Demo', 'Tutorial']
15 self.section_map = collections.defaultdict(list)
17 def GeneratePage(self, template_path):
18 with open(template_path) as template_file:
19 template = template_file.read()
21 sec_map = {}
22 for section_name in self.section_map:
23 items = self.section_map[section_name]
24 items = sorted(items, cmp=CmpByName)
25 sec_map[section_name] = items
27 template_dict = { 'section_map': sec_map }
28 return easy_template.RunTemplateString(template, template_dict)
30 def AddDesc(self, desc):
31 group = desc['GROUP']
32 assert group in self.section_list
33 self.section_map[group].append(desc)