Advertisement
Guest User

Untitled

a guest
May 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1.     def get_package_lists(self):
  2.         """Returns a pair consisting of all packages, followed by a dictionary
  3.        mapping each package name to "static" or "dynamic".
  4.        """
  5.         # Filter the packages into static and dynamic parts. If a package is
  6.         # dynamically loaded, all of its dependencies must also be dynamically
  7.         # loaded. We use a simple greedy algorithm.
  8.         package_types = dict()
  9.         packages = []
  10.  
  11.         for plugins, package_type in (self.static_plugins, 'static'), \
  12.                                      (self.dynamic_plugins, 'dynamic'):
  13.             roots = dict()
  14.             for name in plugins:
  15.                 roots[name] = self.get_package(name)
  16.  
  17.             for package in self.get_dependencies(roots.values()):
  18.                 package_types[package] = package_type
  19.  
  20.                 if package not in packages:
  21.                     packages.append(package)
  22.  
  23.         return [(package, package_types[package])
  24.                 for package in packages]
  25.  
  26.         # I like that return value better.  Alternatively:
  27.         #return packages, [packages_types[__] for __ in packages]
  28.         # Or, whatever.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement