package 'depends' and 'conflicts' variables are now sequences
authorTimo Savola <tsavola@movial.fi>
Fri, 25 Jul 2008 18:36:14 +0000 (21:36 +0300)
committerTimo Savola <tsavola@movial.fi>
Fri, 25 Jul 2008 18:37:03 +0000 (21:37 +0300)
whitespace-separated strings are supported for backward-compatibility.

matrix/components.py

index 973e6f8..d8d152d 100644 (file)
@@ -104,9 +104,16 @@ class Package(object):
                self.name = name
                self.component = component
 
-               self.depends = ''
-               self.conflicts = ''
-               self.architectures = []
+               self.depends = None
+               self.conflicts = None
+               self.architectures = None
+
+def to_seq(value):
+       if value is None:
+               return tuple()
+       if isinstance(value, str):
+               return value.split()
+       return value
 
 def init_packages(c, targets, packages):
        for path in glob(os.path.join(c.meta.path, '*.package')):
@@ -156,7 +163,7 @@ class Dependency(object):
 
 def init_depends(packages):
        for pkg in packages.itervalues():
-               for spec in pkg.depends.split():
+               for spec in to_seq(pkg.depends):
                        depname = Dependency(spec).name
                        deppkg = packages.get(depname)
 
@@ -173,13 +180,13 @@ def init_depends(packages):
 
        fail = False
        for pkg in packages.itervalues():
-               for spec in pkg.depends.split():
+               for spec in to_seq(pkg.depends):
                        if not Dependency(spec).check(packages):
                                fail = True
                                log.error('Dependency %s failed for %s' % \
                                          (spec, pkg.name))
 
-               for spec in pkg.conflicts.split():
+               for spec in to_seq(pkg.conflicts):
                        if Dependency(spec).check(packages):
                                fail = True
                                log.error('Package %s conflicts with %s' % \