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