Commit 6c5909c9fa821b01e11b1da9c873aefdfd761e81

Authored by Tássia Camões Araújo
1 parent 3427dbf1
Exists in master and in 1 other branch add_vagrant

Renamed maximal_pkg_profile to no_auto_pkg_profile.

Implemented maximal_pkg_profile() for base User class.
Showing 1 changed file with 19 additions and 1 deletions   Show diff stats
src/user.py
... ... @@ -78,6 +78,24 @@ class User:
78 78 return tags_xapian_index.relevant_tags_from_db(self.pkg_profile,
79 79 profile_size)
80 80  
  81 + def maximal_pkg_profile(self):
  82 + """
  83 + Return list of packages that are not dependence of any other package in
  84 + the list.
  85 + """
  86 + cache = apt.Cache()
  87 + old_profile_size = len(self.pkg_profile)
  88 + for p in self.pkg_profile[:]: #iterate list copy
  89 + pkg = cache[p]
  90 + if pkg.candidate:
  91 + for dep in pkg.candidate.dependencies:
  92 + for or_dep in dep.or_dependencies:
  93 + if or_dep.name in self.pkg_profile:
  94 + self.pkg_profile.remove(or_dep.name)
  95 + profile_size = len(self.pkg_profile)
  96 + logging.info("Reduced packages profile size from %d to %d." %
  97 + (old_profile_size, profile_size))
  98 +
81 99 class LocalSystem(User):
82 100 """
83 101 Extend the class User to consider the packages installed on the local
... ... @@ -94,7 +112,7 @@ class LocalSystem(User):
94 112 item_score[pkg] = 1
95 113 User.__init__(self,item_score)
96 114  
97   - def maximal_pkg_profile(self):
  115 + def no_auto_pkg_profile(self):
98 116 """
99 117 Return list of packages voluntarily installed.
100 118 """
... ...