Exemplo n.º 1
0
def pretty_diff(diff):
    added = {}
    removed = {}
    for s in diff:
        fn = s[1:]
        name, version = egginst.name_version_fn(fn)
        if s.startswith('-'):
            removed[name.lower()] = version
        elif s.startswith('+'):
            added[name.lower()] = version
    changed = set(added) & set(removed)
    for name in sorted(changed):
        yield ' %s  (%s -> %s)' % (name, removed[name], added[name])
    for name in sorted(set(removed) - changed):
        yield '-%s-%s' % (name, removed[name])
    for name in sorted(set(added) - changed):
        yield '+%s-%s' % (name, added[name])
Exemplo n.º 2
0
def get_installed(prefix, pat=None):
    results = []
    for fn in egginst.get_installed(prefix):
        if pat and not pat.search(fn[:-4]):
            continue
        lst = list(egginst.name_version_fn(fn))
        info = get_installed_info(prefix, cname_fn(fn))
        if info is None:
            lst.append('-')
        else:
            path = join(info['meta_dir'], '__enpkg__.txt')
            if isfile(path):
                d = {}
                execfile(path, d)
                lst.append(shorten_repo(d['repo']))
            else:
                lst.append('-')
        results.append(tuple(lst))
    return results
Exemplo n.º 3
0
def get_installed(prefix, pat=None):
    results = []
    for fn in egginst.get_installed(prefix):
        if pat and not pat.search(fn[:-4]):
            continue
        lst = list(egginst.name_version_fn(fn))
        info = get_installed_info(prefix, cname_fn(fn))
        if info is None:
            lst.append('-')
        else:
            path = join(info['meta_dir'], '__enpkg__.txt')
            if isfile(path):
                d = {}
                execfile(path, d)
                lst.append(shorten_repo(d['repo']))
            else:
                lst.append('-')
        results.append(tuple(lst))
    return results
Exemplo n.º 4
0
def print_installed(pat=None):
    fmt = '%-20s %-20s %s'
    print fmt % ('Project name', 'Version', 'Repository')
    print 60 * '='
    for fn in egginst.get_installed():
        if pat and not pat.search(fn[:-4]):
            continue
        lst = list(egginst.name_version_fn(fn))
        info = get_installed_info(cname_fn(fn))
        if info is None:
            lst.append('')
        else:
            path = join(info['meta_dir'], '__enpkg__.txt')
            if isfile(path):
                d = {}
                execfile(path, d)
                lst.append(shorten_repo(d['repo']))
            else:
                lst.append('')
        print fmt % tuple(lst)
Exemplo n.º 5
0
def print_installed(pat=None):
    fmt = '%-20s %-20s %s'
    print fmt % ('Project name', 'Version', 'Repository')
    print 60 * '='
    for fn in egginst.get_installed():
        if pat and not pat.search(fn[:-4]):
            continue
        lst = list(egginst.name_version_fn(fn))
        info = get_installed_info(cname_fn(fn))
        if info is None:
            lst.append('')
        else:
            path = join(info['meta_dir'], '__enpkg__.txt')
            if isfile(path):
                d = {}
                execfile(path, d)
                lst.append(shorten_repo(d['repo']))
            else:
                lst.append('')
        print fmt % tuple(lst)
Exemplo n.º 6
0
def get_installed_info(prefix, cname):
    """
    return a dictionary with information about the package specified by the
    canonical name found in prefix, or None if the package is not found
    """
    meta_dir = join(prefix, 'EGG-INFO', cname)
    meta_txt = join(meta_dir, '__egginst__.txt')
    if not isfile(meta_txt):
        return None

    d = {}
    execfile(meta_txt, d)
    res = {}
    res['egg_name'] = d['egg_name']
    res['name'], res['version'] = name_version_fn(d['egg_name'])
    res['mtime'] = time.ctime(getmtime(meta_txt))
    res['meta_dir'] = meta_dir

    meta2_txt = join(meta_dir, '__enpkg__.txt')
    if isfile(meta2_txt):
        d = {}
        execfile(meta2_txt, d)
        res['repo'] = shorten_repo(d['repo'])
    return res