Package pdi :: Module core :: Class Component
[show private | hide private]
[frames | no frames]

Class Component

object --+
         |
        Component

Known Subclasses:
VUnknown, VCalendar, VTodo, VEvent, VJournal, VCard, VWhacky

The mama of all components. Inherit from this class only if you intend to create a completely new standard.
Method Summary
  __init__(self, parent)
a new object with type S, a subtype of T __new__(S, ...)
  __str__(self)
Serialize this component as well as it's properties and subcomponents.
pdi.core.Component addComponent(self, component, lineNumber)
Add a subcomponent to this component.
  addComponents(self, componentList)
Candy method for adding several components at one time.
  addProperties(self, propertyList)
Candy method for adding several properties at one time.
pdi.core.Property addProperty(self, property, lineNumber)
Add a property to this component.
string getName(self)
Return the name of this component.
  interpret(self, key, value, lineNumber)
Interprets a symbol and value.
pdi.core.Component parseLine(self, data, lineNumber)
This parses one line of data.
  registerComponents(self, componentList, rule)
Register all valid (or invalid, depending on rule) components.
  registerProperties(self, propertyList, rule)
Register valid (or invalid, depending on rule) properties.
  registerPropertyTypes(self, propertyTypes)
Register available property types.
  validate(self, lineNumber)
This will make sure that all mandatory components and properties are present.

Instance Variable Summary
  begin - The line number where this component started.
  classes - Internal dictionary for keeping track valid classes for components and properties.
  components - A list of all subcomponents under this component.
  componentsMay - Internal list for keeping track components that may occur.
  componentsMust - Internal list for keeping track of mandatory components.
  componentsNot - Internal list for keeping track of disallowed components.
  componentsRecommended - Internal list for keeping track of recommended compoennts.
  componentTracker - Internal dictionary for keeping track of what subcomponent classes has been added.
  end - The line number where this component ended.
  ignoreWarnings - Set this baby to true to supress warnings.
  parent - Internal instance of a pdi.core.Componentfor keeping track of the parent.
  properties - A dictionary of all properties where the uppercased name is the key and an instance of the property is the value.
  propertiesMay - Internal list for keeping track of properties that may occur.
  propertiesMust - Internal list for keeping track of mandatory properties.
  propertiesNot - Internal list for keeping track of disallowed properties.
  propertiesRecommended - Internal list for keeping track of recommended properties.

Method Details

__init__(self, parent=None)
(Constructor)

Parameters:
parent - The parent component, if any. May be omitted or None if it is a top-level component.
           (type=pdi.core.Component)

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

__str__(self)
(Informal representation operator)

Serialize this component as well as it's properties and subcomponents.

addComponent(self, component, lineNumber=None)

Add a subcomponent to this component.
Parameters:
component - The subcomponent to add.
           (type=pdi.core.Component)
lineNumber - The line currently parsed. Used internally when parsing files. May be omitted or None.
           (type=number)
Returns:
The subcomponent you just added.
           (type=pdi.core.Component)
Raises:
InvalidComponentError - If the subcomponent you tried to add is not valid for the component.

addComponents(self, componentList)

Candy method for adding several components at one time.
Parameters:
componentList - A list of pdi.core.Component instances.
           (type=list)
Raises:
InvalidComponentError - If any subcomponent you tried to add is not valid for the component.

addProperties(self, propertyList)

Candy method for adding several properties at one time.
Parameters:
propertyList - A list of pdi.core.Property instances.
           (type=list)
Raises:
InvalidPropertyError - If any property you tried to add is not valid for the component.

addProperty(self, property, lineNumber=None)

Add a property to this component. The property will also be validated and warnings issued as the property implementation sees fit.
Parameters:
property - The property to add.
           (type=pdi.core.Property)
lineNumber - The line currently parsed. Used internally when parsing files. May be omitted or None.
           (type=number)
Returns:
The property you just added.
           (type=pdi.core.Property)
Raises:
InvalidPropertyError - If the property you tried to add is not valid for the component.

getName(self)

Return the name of this component. This is the uppercased class name unless an unknown component.
Returns:
The components name (usually the uppercased class name, but not always). It has to be uppercased.
           (type=string)

interpret(self, key, value, lineNumber=-1)

Interprets a symbol and value.

parseLine(self, data, lineNumber)

This parses one line of data.
Parameters:
data - A line of data.
           (type=string)
lineNumber - The line we are currently parsing. Needed for exceptions, warnings and debugging in general.
           (type=number)
Returns:
The next component that needs parsing. Can be a child, parent or self.
           (type=pdi.core.Component)
Raises:
ParseError - Raised if parsed data is whack!
ComponentError - Raised if a component is invalid. This probably indicates an internal error.
InvalidComponentError - Raised if a disallowed component is found.
MissingComponentError - Raised if a mandatory component is not found.
InvalidPropertyError - Raised if a disallowed property is found.
MissingPropertyError - Raised if a mandatory property is not found.
PropertyValueError - Raised if a property fails to validate itself.

registerComponents(self, componentList, rule=20)

Register all valid (or invalid, depending on rule) components. All components that are supposed to be valid should be registered with this method, otherwise they become instances of UnknownComponent.
Parameters:
componentList - A list with pdi.core.Component derived classes that are valid (or invalid).
           (type=list)
rule - A pdi.core.RULE_MUST, pdi.core.RULE_MAY, pdi.core.RULE_RECOMMEND or pdi.core.RULE_NOT.
           (type=number)

registerProperties(self, propertyList, rule=20)

Register valid (or invalid, depending on rule) properties.
Parameters:
propertyList - A list of strings containing the uppercased names of the properties.
           (type=list)
rule - A pdi.core.RULE_MUST, pdi.core.RULE_MAY, pdi.core.RULE_RECOMMEND or pdi.core.RULE_NOT.
           (type=number)

registerPropertyTypes(self, propertyTypes)

Register available property types. Properties without a type or a type that has not been registered will be instansiated as UnknownProperty.
Parameters:
propertyTypes - A list of pdi.core.Property derived classes.
           (type=list)

validate(self, lineNumber=None)

This will make sure that all mandatory components and properties are present. The validation is recursive, so you only need to call it for the top component.
Parameters:
lineNumber - The line currently parsed. Used internally when parsing files. May be omitted or None.
           (type=number)
Raises:
MissingComponentError - A mandatory component is missing.
MissingPropertyError - A mandatory property is missing.

Instance Variable Details

begin

The line number where this component started. None if it never was started == very bad!

classes

Internal dictionary for keeping track valid classes for components and properties.

components

A list of all subcomponents under this component.

componentsMay

Internal list for keeping track components that may occur.

componentsMust

Internal list for keeping track of mandatory components.

componentsNot

Internal list for keeping track of disallowed components.

componentsRecommended

Internal list for keeping track of recommended compoennts.

componentTracker

Internal dictionary for keeping track of what subcomponent classes has been added.

end

The line number where this component ended. None if it never was ended == very bad, will raise an exception.

ignoreWarnings

Set this baby to true to supress warnings.

parent

Internal instance of a pdi.core.Component for keeping track of the parent.

properties

A dictionary of all properties where the uppercased name is the key and an instance of the property is the value.

propertiesMay

Internal list for keeping track of properties that may occur.

propertiesMust

Internal list for keeping track of mandatory properties.

propertiesNot

Internal list for keeping track of disallowed properties.

propertiesRecommended

Internal list for keeping track of recommended properties.

Generated by Epydoc 1.1 on Sun Nov 24 14:33:25 2002 http://epydoc.sf.net