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: 2007-12-27 15:19:41 +0100 (Do, 27 Dez 2007) $'
11 __version__ = '$LastChangedRevision: 730 $'
12
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 """
34 "nothing is set as this must also be defined later"
35 pass
36
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
46
47 length = property(_getLength,
48 doc="(DOM) The number of CSSRules in the list.")
49
50 - def item(self, index):
51 """
52 (DOM)
53 Used to retrieve a CSS rule by ordinal index. The order in this
54 collection represents the order of the rules in the CSS style
55 sheet. If index is greater than or equal to the number of rules in
56 the list, this returns None.
57
58 Returns CSSRule, the style rule at the index position in the
59 CSSRuleList, or None if that is not a valid index.
60 """
61 try:
62 return self[index]
63 except IndexError:
64 return None
65