コード例 #1
0
ファイル: core.py プロジェクト: chkumar246/verwatch
def render_version(ver, max_ver=None, show_error=False, color=True):
    t = _get_term(color)
    s = ''
    if 'version' in ver:
        if 'epoch' in ver:
            e = str(ver['epoch'])
            s += t.cyan(e) + t.bold_black(':')
        v = ver['version']
        if max_ver and v == max_ver:
            s += t.green(v)
        else:
            s += t.yellow(v)
        if 'release' in ver:
            r = ver['release']
            s += t.bold_black('-') + t.cyan(r)
    else:
        if show_error:
            try:
                err_msg = ver['error']
            except KeyError:
                err_msg = ("BUG: No version fetched but fetcher didn't return "
                           "error. Fetcher bug!")
        else:
            err_msg = '!!'
        s = t.red(err_msg)
    if 'next' in ver:
        next_ver = ver['next']
        if not util.is_same_version(ver, next_ver):
            s += ' -> ' + render_version(next_ver, max_ver=max_ver, color=color)
    if 'was' in ver:
        was_ver = ver['was']
        s += '  (was: %s)' % render_version(was_ver, max_ver=max_ver,
                                            color=color)
    return s
コード例 #2
0
ファイル: html.py プロジェクト: chkumar246/verwatch
def render_version_html(ver, max_ver=None, show_error=False):
    s = ''
    if 'version' in ver:
        if 'epoch' in ver:
            s += ('<span class="ver-epoch ver-extra">%s</span>'
                  '<span class="ver-sep">:</span>' % ver['epoch'])
        v = ver['version']
        if max_ver and v == max_ver:
            s += '<span class="ver-new">%s</span>' % v
        else:
            s += '<span class="ver-old">%s</span>' % v
        if 'release' in ver:
            s += ('<span class="ver-sep">-</span>'
                  '<span class="ver-release ver-extra">%s</span>'
                  % ver['release'])
    else:
        if show_error:
            try:
                err_msg = ver['error']
            except KeyError:
                err_msg = ("BUG: No version fetched but fetcher didn't return "
                           "error. Fetcher bug!")
        else:
            err_msg = '!!'
        s += '<span class="ver-error">%s</span>' % err_msg
    if 'next' in ver:
        next_ver = ver['next']
        if not util.is_same_version(ver, next_ver):
            s += ' &nbsp; &rarr; &nbsp; ' + \
                 render_version_html(next_ver, max_ver)
    return s