コード例 #1
0
def load_menu_properties():
    """加载导航栏配置"""
    if os.path.exists("config/menu.ini"):
        path = "config/menu.ini"
    else:
        path = "config/menu.default.ini"

    menu_list = []
    # menu_config = config.Properties(path)
    # for title in menu_config.get_properties():
    #     group = dict(title=title)
    #     group["children"] = []
    #     children = menu_config.get_properties()[title]
    #     for item in children:
    #         url = children[item]
    #         group["children"].append(dict(name=item, url=url))
    #     menu_list.append(group)

    cf = ConfigParser()
    cf.read(path, encoding="utf-8")
    names = cf.sections()
    for name in names:
        group = dict(title=name)
        options = cf.options(name)
        group["children"] = []
        for option in options:
            url = cf.get(name, option)
            group["children"].append(dict(name=option, url=url))
        menu_list.append(group)

    global MENU_LIST
    MENU_LIST = menu_list
コード例 #2
0
    def update_settings(self, config_text):
        from xutils import ConfigParser

        nav_list = []

        cf = ConfigParser()
        cf.read_string(config_text)
        names = cf.sections()

        options = cf.options('NAV_LIST')
        for option in options:
            value = cf.get('NAV_LIST', option)
            nav_list.append(Storage(name = option, url = value))

        # 处理导航        
        xconfig.NAV_LIST = nav_list
コード例 #3
0
ファイル: xtemplate.py プロジェクト: burushi/xnote
def load_menu_properties():
    """加载导航栏配置"""
    if os.path.exists("config/menu.ini"):
        path = "config/menu.ini"
    else:
        path = "config/menu.default.ini"

    menu_list = []
    cf = ConfigParser()
    cf.read(path, encoding="utf-8")
    names = cf.sections()
    for name in names:
        group = dict(title=name)
        options = cf.options(name)
        group["children"] = []
        for option in options:
            url = cf.get(name, option)
            group["children"].append(dict(name=option, url=url))
        menu_list.append(group)

    global MENU_LIST
    MENU_LIST = menu_list