config: ProvideComponent replaces PlatformProvidedComponent
authorTimo Savola <tsavola@movial.fi>
Fri, 30 May 2008 09:37:22 +0000 (12:37 +0300)
committerTimo Savola <tsavola@movial.fi>
Fri, 30 May 2008 10:28:17 +0000 (13:28 +0300)
ProvideComponent(name) can be called for an existing component.

matrix/config.py

index de7e41f..c535ba8 100644 (file)
@@ -51,18 +51,18 @@ class Board(object):
 
                config.boards[name] = self
 
-def Component(*args, **kwargs):
+def component(*args, **kwargs):
        import components
 
        c = components.Component(*args, **kwargs)
        config.components[c.name] = c
        return c
 
-def PlatformProvidedComponent(*args, **kwargs):
-       import components
-
-       c = components.PlatformProvidedComponent(*args, **kwargs)
-       config.components[c.name] = c
+def provide_component(name):
+       c = config.components.get(name)
+       if not c:
+               c = component(name)
+       c.cached = True
        return c
 
 def parse(pattern, required=False):
@@ -117,8 +117,8 @@ class Config(object):
 
 actions = dict(
        Board = Board,
-       Component = Component,
-       PlatformProvidedComponent = PlatformProvidedComponent,
+       Component = component,
+       ProvideComponent = provide_component,
        parse = parse,
 )