1.1 --- a/vContent.py Sat Mar 14 22:13:22 2009 +0100
1.2 +++ b/vContent.py Sun Mar 15 21:30:36 2009 +0100
1.3 @@ -380,7 +380,7 @@
1.4 empty list of children as part of the component's content.
1.5 """
1.6
1.7 - component = self.handleProperty(name, parameters, [])
1.8 + component = self.handleProperty(name, parameters)
1.9 self.components.append(component)
1.10 return component
1.11
1.12 @@ -388,19 +388,23 @@
1.13
1.14 """
1.15 End the component with the given 'name' by removing it from the active
1.16 - component stack.
1.17 + component stack. If only one component exists on the stack, retain it
1.18 + for later inspection.
1.19 """
1.20
1.21 if len(self.components) > 1:
1.22 return self.components.pop()
1.23 +
1.24 + # Or return the only element.
1.25 +
1.26 elif self.components:
1.27 - return self.components[-1]
1.28 + return self.components[0]
1.29
1.30 - def handleProperty(self, name, parameters, value):
1.31 + def handleProperty(self, name, parameters, value=None):
1.32
1.33 """
1.34 - Record the property with the given 'name', 'parameters' and 'value' as
1.35 - part of the current component's children.
1.36 + Record the property with the given 'name', 'parameters' and optional
1.37 + 'value' as part of the current component's children.
1.38 """
1.39
1.40 component = self.makeComponent(name, parameters, value)
1.41 @@ -417,13 +421,14 @@
1.42 component_name, component_parameters, component_children = self.components[-1]
1.43 component_children.append(component)
1.44
1.45 - def makeComponent(self, name, parameters, value):
1.46 + def makeComponent(self, name, parameters, value=None):
1.47
1.48 """
1.49 - Make a component object from the given 'name', 'parameters' and 'value'.
1.50 + Make a component object from the given 'name', 'parameters' and optional
1.51 + 'value'.
1.52 """
1.53
1.54 - return (name, parameters, value)
1.55 + return (name, parameters, value or [])
1.56
1.57 # Public methods.
1.58