Prettify error messages for invalid component names
[matrix.git] / matrix / matrix.py
index 0be3379..4bf796a 100644 (file)
@@ -198,15 +198,21 @@ def execute(args):
 def remove_tree(path):
        execute(['rm', '-rf', path])
 
+def find_component(name):
+       try:
+               return components.by_name[name]
+       except KeyError:
+               raise Error("Component " + name + " not found");
+
 def meta(targets):
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
                if not c.meta.exists():
                        c.meta.clone()
        
 def clone(targets):
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
                clone_component(c)
 
 def clone_component(c, overwrite=False):
@@ -232,7 +238,7 @@ def clean(targets):
        changed = False
 
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
                c.source.clean()
                cache.remove(c)
 
@@ -246,7 +252,7 @@ def for_each_repository(func, targets=None):
        ret = None
 
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
                if c.source.exists():
                        value = func(c.source)
                        if value:
@@ -277,7 +283,7 @@ def changes(targets):
        changed = False
 
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
 
                if c.source.exists():
                        if check_changes(c.source):
@@ -310,7 +316,7 @@ def source_dist(targets):
                os.makedirs(location)
 
        for name in targets:
-               c = components.by_name[name]
+               c = find_component(name)
                dist_changes(c, location)
                dist_sources(c, location)