apt-plus/command/list

41 lines
984 B
Plaintext
Raw Normal View History

#!/usr/bin/env python
import re;
from os import system as ossystem;
from os import path as ospath;
from sys import argv as sysargv;
# [1] get absolute path
path = ospath.dirname(ospath.dirname(ospath.realpath(__file__)));
# [3] search for manifest file
manifest="";
with open( "%s/manifest" % path, 'r' ) as f:
manifest=f.readline();
# [4] search for installed entries in manifest
pkgRegex = re.compile("^\s*\[(x| |\.)\]\s+(?:([a-zA-Z0-9_-]+)( \[deb\])?).*$", 0);
with open(manifest, 'r+') as f:
for line in f:
m = pkgRegex.search(line);
if ( m != None ):
# (1) Installed #
if m.group(1) == 'x':
print "\033[38;5;78m%s\033[0m" % (m.group(2)),
# (2) Removed (not config) #
elif m.group(1) == '.':
print "\033[38;5;208m%s\033[0m" % (m.group(2)),
# (3) purged #
elif m.group(1) == ' ':
print "\033[38;5;161m%s\033[0m" % (m.group(2)),
# (4) If from deb #
if m.group(3) != None:
print "\033[0;49;34m[deb]\033[0m";
else:
print;