Package CedarBackup2 :: Module util :: Class ObjectTypeList
[hide private]
[frames] | no frames]

Class ObjectTypeList

source code

object --+        
         |        
      list --+    
             |    
 UnorderedList --+
                 |
                ObjectTypeList

Class representing a list containing only objects with a certain type.

This is an unordered list.

We override the append, insert and extend methods to ensure that any item added to the list matches the type that is requested. The comparison uses the built-in isinstance, which should allow subclasses of of the requested type to be added to the list as well.

The objectName value will be used in exceptions, i.e. "Item must be a CollectDir object." if objectName is "CollectDir".

Instance Methods [hide private]
new list
__init__(self, objectType, objectName)
Initializes a typed list for a particular type.
source code
 
append(self, item)
Overrides the standard append method.
source code
 
insert(self, index, item)
Overrides the standard insert method.
source code
 
extend(self, seq)
Overrides the standard insert method.
source code

Inherited from UnorderedList: __eq__, __ge__, __gt__, __le__, __lt__, __ne__

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __getattribute__, __getitem__, __getslice__, __hash__, __iadd__, __imul__, __iter__, __len__, __mul__, __new__, __repr__, __reversed__, __rmul__, __setitem__, __setslice__, count, index, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, objectType, objectName)
(Constructor)

source code 

Initializes a typed list for a particular type.

Parameters:
  • objectType - Type that the list elements must match.
  • objectName - Short string containing the "name" of the type.
Returns: new list
Overrides: object.__init__

append(self, item)

source code 

Overrides the standard append method.

Raises:
  • ValueError - If item does not match requested type.
Overrides: list.append

insert(self, index, item)

source code 

Overrides the standard insert method.

Raises:
  • ValueError - If item does not match requested type.
Overrides: list.insert

extend(self, seq)

source code 

Overrides the standard insert method.

Raises:
  • ValueError - If item does not match requested type.
Overrides: list.extend