Package cssutils :: Package css :: Module cssrulelist |
[hide private]
[frames] | no frames]

# Source Code for Module cssutils.css.cssrulelist

     1  """
     2  CSSRuleList implements DOM Level 2 CSS CSSRuleList.
     3
     4  Partly also
     5      * http://dev.w3.org/csswg/cssom/#the-cssrulelist
     6  """
     7  __all__ = ['CSSRuleList']
     8  __docformat__ = 'restructuredtext'
     9  __author__ = '$LastChangedBy: cthedot $'
    10  __date__ = '$LastChangedDate: 2008-01-03 21:47:17 +0100 (Do, 03 Jan 2008) $'
    11  __version__ = '$LastChangedRevision: 797 $'
    12
    13 -class CSSRuleList(list):
    14      """
    15      The CSSRuleList object represents an (ordered) list of statements.
    16
    17      The items in the CSSRuleList are accessible via an integral index,
    18      starting from 0.
    19
    20      Subclasses a standard Python list so theoretically all standard list
    21      methods are available. Setting methods like ``__init__``, ``append``,
    22      ``extend`` or ``__setslice__`` are added later on instances of this
    23      class if so desired.
    24      E.g. CSSStyleSheet adds ``append`` which is not available in a simple
    25      instance of this class!
    26
    27      Properties
    28      ==========
    29      length: of type unsigned long, readonly
    30          The number of CSSRules in the list. The range of valid child rule
    31          indices is 0 to length-1 inclusive.
    32      """
    33 -    def __init__(self, *ignored):
    34          "nothing is set as this must also be defined later"
    35          pass
    36
    37 -    def __notimplemented(self, *ignored):
    38          "no direct setting possible"
    39          raise NotImplementedError(
    40              'Must be implemented by class using an instance of this class.')
    41
    42      append = extend =  __setitem__ = __setslice__ = __notimplemented
    43
    44 -    def item(self, index):
    45          """
    46          (DOM)
    47          Used to retrieve a CSS rule by ordinal index. The order in this
    48          collection represents the order of the rules in the CSS style
    49          sheet. If index is greater than or equal to the number of rules in
    50          the list, this returns None.
    51
    52          Returns CSSRule, the style rule at the index position in the
    53          CSSRuleList, or None if that is not a valid index.
    54          """
    55          try:
    56              return self[index]
    57          except IndexError:
    58              return None
    59
    60      length = property(lambda self: len(self),
    61          doc="(DOM) The number of CSSRules in the list.")
    62