# HG changeset patch # User Paul Boddie # Date 1224277945 -7200 # Node ID 0a6992ed6bc7fd80a7f06d50769f6aeae060bfce # Parent b5f2be07e2f8818f4a591be3dbdd9acaf70ea0e5 Renamed element to component and component to property in order to be consistent with RFC 2445. diff -r b5f2be07e2f8 -r 0a6992ed6bc7 vContent.py --- a/vContent.py Fri Oct 17 22:58:43 2008 +0200 +++ b/vContent.py Fri Oct 17 23:12:25 2008 +0200 @@ -266,7 +266,7 @@ if name == "BEGIN": self.names.append(value) - self.startElement(value, parameters) + self.startComponent(value, parameters) elif name == "END": start_name = self.names.pop() @@ -274,10 +274,10 @@ raise ParseError, "Mismatch in BEGIN and END declarations (%r and %r) at line %d." % ( start_name, value, f.line_number) - self.endElement(value) + self.endComponent(value) else: - self.handleComponent(name, parameters, value) + self.handleProperty(name, parameters, value) class Parser(ParserBase): @@ -285,36 +285,36 @@ def __init__(self): ParserBase.__init__(self) - self.elements = [] # also known as components + self.components = [] - def startElement(self, name, parameters): + def startComponent(self, name, parameters): """ - Add the element/component with the given 'name' and 'parameters', - recording an empty list of children as part of the element's content. + Add the component with the given 'name' and 'parameters', recording an + empty list of children as part of the component's content. """ - element = self.handleComponent(name, parameters, []) - self.elements.append(element) - return element + component = self.handleProperty(name, parameters, []) + self.components.append(component) + return component - def endElement(self, name): + def endComponent(self, name): """ - End the element with the given 'name' by removing it from the active - element stack. + End the component with the given 'name' by removing it from the active + component stack. """ - if len(self.elements) > 1: - return self.elements.pop() - elif self.elements: - return self.elements[-1] + if len(self.components) > 1: + return self.components.pop() + elif self.components: + return self.components[-1] - def handleComponent(self, name, parameters, value): + def handleProperty(self, name, parameters, value): """ Record the component with the given 'name', 'parameters' and 'value' as - part of the current element's children. + part of the current component's children. """ component = self.makeComponent(name, parameters, value) @@ -327,9 +327,9 @@ "Attach the given 'component' to its parent." - if self.elements: - element_name, element_parameters, element_children = self.elements[-1] - element_children.append(component) + if self.components: + component_name, component_parameters, component_children = self.components[-1] + component_children.append(component) def makeComponent(self, name, parameters, value): @@ -346,7 +346,7 @@ "Parse the contents of the file 'f'." ParserBase.parse(self, f) - return self.elements[0] + return self.components[0] # Public functions.