~doctormo/apt-cat/trunk

« back to all changes in this revision

Viewing changes to bin/apt-cat

  • Committer: Martin Owens
  • Date: 2010-10-31 22:44:01 UTC
  • Revision ID: doctormo@gmail.com-20101031224401-1rix63auw5d4jfy8
Add in sub-category support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
sys.path.insert(1, '../')
24
24
sys.path.insert(1, './')
25
25
 
26
 
from ThemeFinding import (
 
26
from AptCategory import (
27
27
    iterate_packages, iterate_categories,
28
28
    NoCategoriesError, NoPackagesError, NoCategoryError
29
29
)
33
33
    sys.exit(1)
34
34
 
35
35
if sys.argv[1] == 'list':
 
36
    # If category is specified then only show sub-categories
 
37
    category = None
 
38
    if len(sys.argv) > 2:
 
39
        category = sys.argv[2]
36
40
    try:
37
 
        for cat in iterate_categories():
 
41
        for cat in iterate_categories(category=category):
38
42
            if cat.is_installed():
39
43
                print cat.cid
40
44
            else:
51
55
            else:
52
56
                print package.pid + "*"
53
57
    except NoPackagesError:
54
 
        sys.stderr.write("No packages in category %s\n")
 
58
        sys.stderr.write("No packages in category %s\n" % category)
55
59
        sys.exit(2)
56
60
    except NoCategoryError:
57
 
        sys.stderr.write("Category %s is not installed\n")
 
61
        sys.stderr.write("Category %s is not installed\n" % category)
58
62
        sys.exit(3)
59
63
 
60
64
sys.exit(0)