def render_versions_html(pkg_conf, vers, repo_links=True, show_commands=False): first = True pkgs = pkg_conf['packages'] html = "<div class='versions'>\n" for pkg in pkgs: rlss = pkg['releases'] pkg_name = pkg['name'] if first: first = False else: html += "\n" html += ("<div class=\"package\" id=\"pkg-%s\"><h2 class=\"package\">" "%s</h2>\n" % (pkg_name, pkg_name)) for rls in rlss: html += "<div class=\"release\"><h3 class=\"release\">%s</h3>\n" \ % rls['name'] max_ver = util.release_latest_version(rls, vers, pkg_name) # print all release versions for repo in rls['repos']: tags = core.repo_tags(repo, pkg_conf) repo_name = repo['repo'] repo_title = util.get_repo_title(pkg_conf, repo_name) if repo_links: repo_link = util.get_repo_link(pkg_conf, repo_name) if repo_link: repo_title += " <a href=\"%s\">→</a>" % repo_link cls = ["repo"] + map(lambda x: "repo-%s" % x, tags) html += "<div class=\"%s\">\n<h4 class=\"repo\">%s</h4>\n" \ % (" ".join(cls), repo_title) html += "<table class=\"branches\">\n" for branch in repo['branches']: try: ver = vers[pkg_name][repo_name][branch] ver_str = render_version_html(ver, max_ver) if show_commands and 'cmd' in ver: ver_str += '<br><code>$ %s</code>' % ver['cmd'] except KeyError: ver_str = '<span class="ver-unknown">??</span>' html += ("<tr><td class=\"branch\">%s:</td>" "<td class=\"version\">%s</td></tr>\n" % (branch, ver_str)) html += "</table>\n</div>\n" html += "</div>\n" html += "</div>\n" html += "</div>\n" return html
def print_versions(pkg_conf, vers, show_commands=False, color=True, string_output=False): t = _get_term(color) pp = UberPrinter(string_output=string_output) first = True pkgs = pkg_conf['packages'] for pkg in pkgs: rlss = pkg['releases'] pkg_name = pkg['name'] if first: first = False else: pp.puts("") pp.puts(t.bold("%s" % pkg_name), shift=1) for rls in rlss: pp.puts("[%s]" % t.bold(rls['name']), shift=1) max_ver = util.release_latest_version(rls, vers, pkg_name) # print all release versions for repo in rls['repos']: repo_name = repo['repo'] repo_title = util.get_repo_title(pkg_conf, repo_name) pp.puts(t.bold(repo_title), shift=1) for branch in repo['branches']: try: ver = vers[pkg_name][repo_name][branch] ver_str = render_version(ver, color=color, max_ver=max_ver) except KeyError: ver_str = t.yellow('??') if show_commands and 'cmd' in ver: pp.puts("$ %s" % ver['cmd']) pp.puts("%s: %s" % (branch, ver_str)) pp.shift(-1) pp.shift(-1) pp.shift(-1) pp.shift(-1) if string_output: return pp.s