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=None):
00013 package_name = get_unicode(macro.request, arg1)
00014 opt_distro = get_unicode(macro.request, arg2)
00015 if not package_name:
00016 return "ERROR in PackageHeader. Usage: [[PackageHeader(package_name opt_distro)]]"
00017 if ' ' in package_name:
00018
00019 splits = package_name.split(' ')
00020 if len(splits) > 2:
00021 return "ERROR in PackageHeader. Usage: [[PackageHeader(pkg_name opt_distro)]]"
00022 package_name, distro = splits
00023
00024 try:
00025 data = load_package_manifest(package_name, opt_distro)
00026 except UtilException, e:
00027 name = package_name
00028 return CONTRIBUTE_TMPL%locals()
00029
00030 stack_name = data.get('stack', None)
00031 nav = get_nav(macro, stack_name, list(set(data.get('siblings', []))))
00032 desc = get_description(macro, data, 'package')
00033 links = get_package_links(macro, package_name, data)
00034
00035 return macro.formatter.rawHTML(nav) + links + desc
00036