summaryrefslogtreecommitdiff
path: root/scripts/menus-compile.py
blob: 7c9fd64f192768436344abbf0d1d03a09f7b3db5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json, os, sys

from bs4 import BeautifulSoup as bs4

config_file = sys.argv[1]
base_directory = sys.argv[2]
menu_directory = sys.argv[3]

for menu_item in json.load(file(config_file)):
    href = os.path.relpath(
        os.path.join(base_directory, menu_item['url']),
        menu_directory
    )
    link = bs4('<a class="btn btn-default"></a>', 'html.parser')
    link.a['href'] = href
    link.a['title'] = menu_item['header']
    link.a.string = menu_item['label']
    print link.a