00001 import urllib2 00002 from MoinMoin.Page import Page 00003 from MoinMoin.wikiutil import get_unicode 00004 00005 from macroutils import load_stack_release, \ 00006 load_package_manifest, UtilException, load_stack_manifest, CONTRIBUTE_TMPL 00007 from headers import get_nav, get_stack_links, get_package_links, get_description 00008 00009 generates_headings = True 00010 dependencies = [] 00011 00012 def macro_PackageHeader(macro, arg1, arg2='en'): 00013 package_name = get_unicode(macro.request, arg1) 00014 lang = get_unicode(macro.request, arg2) 00015 if not package_name: 00016 return "ERROR in PackageHeader. Usage: [[PackageHeader(package_name opt_lang)]]" 00017 00018 try: 00019 data = load_package_manifest(package_name, lang) 00020 except UtilException, e: 00021 name = package_name 00022 return CONTRIBUTE_TMPL%locals() 00023 00024 nav = get_nav(macro, package_name, list(set(data.get('siblings', [])))) 00025 desc = get_description(macro, data, 'package') 00026 links = get_package_links(macro, package_name, data) 00027 00028 return macro.formatter.rawHTML(nav) + links + desc 00029