self.rank = rank
- self.license = self.get_license()
-
def __str__(self):
return str(self.source)
def get_depends(self):
return self.depends
- def get_license(self):
- path = os.path.join(self.meta.path, 'info')
- if not os.path.exists(path):
- return 'None'
-
- f = open(path, 'r')
- for line in f:
- if (line.find('license') != -1) and (line.count('"') == 2):
- index_quote1 = line.find('"')
- index_quote2 = line.find('"', index_quote1 + 1)
- return line[index_quote1 + 1 : index_quote2].strip()
- return 'None'
+ def get_licenses(self):
+ l = set()
+ for p in self.packages.values():
+ l.add(p.license)
+ return l
class PlatformProvidedComponent(Component):
"""A Component that is provided by the platform.
self.depends = None
self.conflicts = None
self.architectures = None
+ self.license = 'Unknown'
def to_seq(value):
if value is None:
c.source.archive(name, path)
def print_licenses(targets):
- file = sys.stdout
-
meta(targets)
-
- for name in targets:
- c = find_component(name)
- print >> file, c.name + ' --> ' + c.license
-
- for dep in c.get_depends():
- print >> file, '\t' + dep.name + ' --> ' + dep.license
- print >> file, '\n'
+ try:
+ selected = set([components.by_name[i] for i in targets])
+ except KeyError, e:
+ raise Error("Component " + i + " not found")
+
+ components.fill_in_depends(selected)
+
+ by_license = {}
+
+ for c in selected:
+ for l in c.get_licenses():
+ if not by_license.has_key(l):
+ by_license[l] = []
+
+ by_license[l].append(c.name)
+
+ for l in by_license.keys():
+ print l
+
+ for c in by_license[l]:
+ print ' %s' % c
+ print