CedarBackup2.util.RegexMatchList

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

# Class RegexMatchList

source code

    object --+
             |
          list --+
                 |
     UnorderedList --+
                     |
                    RegexMatchList

Class representing a list containing only strings that match a regular expression.

If `emptyAllowed` is passed in as `False`, then empty strings are explicitly disallowed, even if they happen to match the regular expression. (`None` values are always disallowed, since string operations are not permitted on `None`.)

This is an unordered list.

We override the `append`, `insert` and `extend` methods to ensure that any item added to the list matches the indicated regular expression.

Note: If you try to put values that are not strings into the list, you will likely get either TypeError or AttributeError exceptions as a result.

Instance Methods | [hide private]
new empty list |
__init__(self, valuesRegex, emptyAllowed=True, prefix=None) Initializes a list restricted to containing certain values. | 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__`, `__iadd__`, `__imul__`, `__iter__`, `__len__`, `__mul__`, `__new__`, `__repr__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `__sizeof__`, `count`, `index`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__format__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`, `__subclasshook__`

Class Variables | [hide private]
Inherited from `list`: `__hash__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, valuesRegex, emptyAllowed=True, prefix=None) (Constructor) | source code
Initializes a list restricted to containing certain values. Parameters: `valuesRegex` - Regular expression that must be matched, as a string `emptyAllowed` - Indicates whether empty or None values are allowed. `prefix` - Prefix to use in error messages (None results in prefix "Item") Returns: new empty list Overrides: object.__init__

### append(self, item) | source code
Overrides the standard `append` method. Raises: `ValueError` - If item is None `ValueError` - If item is empty and empty values are not allowed `ValueError` - If item does not match the configured regular expression Overrides: list.append

### insert(self, index, item) | source code
Overrides the standard `insert` method. Raises: `ValueError` - If item is None `ValueError` - If item is empty and empty values are not allowed `ValueError` - If item does not match the configured regular expression Overrides: list.insert

### extend(self, seq) | source code
Overrides the standard `insert` method. Raises: `ValueError` - If any item is None `ValueError` - If any item is empty and empty values are not allowed `ValueError` - If any item does not match the configured regular expression Overrides: list.extend