00001 from MoinMoin.Page import Page
00002 from MoinMoin.wikiutil import get_unicode
00003
00004 from macroutils import load_stack_release, \
00005 load_package_manifest, UtilException, load_stack_manifest
00006 from headers import get_nav, get_stack_links, get_package_links, get_description
00007
00008 generates_headings = True
00009 dependencies = []
00010
00011 def macro_StackageHeader(macro, arg1, arg2='ja'):
00012 stack_name = get_unicode(macro.request, arg1)
00013 lang = get_unicode(macro.request, arg2)
00014 if ' ' in stack_name:
00015
00016 splits = stack_name.split(' ')
00017 if len(splits) > 2:
00018 return "ERROR in StackHeader. Usage: [[StackHeader(pkg_name opt_lang)]]"
00019 stack_name, lang = splits
00020 if not stack_name:
00021 return "ERROR in StackHeader. Usage: [[StackHeader(pkg_name opt_lang)]]"
00022
00023 try:
00024 data = load_stack_manifest(stack_name, lang)
00025 except UtilException, e:
00026 return str(e)
00027
00028 packages = data.get('packages', [])
00029 is_unary = [stack_name] == packages
00030
00031 desc = get_description(macro, data, 'stack')
00032 nav = get_nav(macro, stack_name, packages)
00033 links = get_stack_links(macro, stack_name, data, packages, is_unary)
00034
00035 if is_unary:
00036 try:
00037 package_data = load_package_manifest(stack_name, lang)
00038 links += get_package_links(macro, stack_name, package_data)
00039 except:
00040 pass
00041
00042 return macro.formatter.rawHTML(nav) + macro.formatter.rawHTML(links) + desc
00043