Package cssutils :: Package css :: Module cssstylesheet :: Class CSSStyleSheet
[hide private]
[frames] | no frames]

Class CSSStyleSheet

source code

                   object --+        
                            |        
                    util.Base --+    
                                |    
stylesheets.stylesheet.StyleSheet --+
                                    |
                                   CSSStyleSheet

The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i.e., a style sheet whose content type is "text/css".

Properties

cssRules: of type CSSRuleList, (DOM readonly)
The list of all CSS rules contained within the style sheet. This includes both rule sets and at-rules.
namespaces: set
A set of declared namespaces via @namespace rules. Each CSSStyleRule is checked if it uses additional prefixes which are not declared. If they are "invalidated".
ownerRule: of type CSSRule, readonly
If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule. In that case, the ownerNode attribute in the StyleSheet interface will be None. If the style sheet comes from an element or a processing instruction, the ownerRule attribute will be None and the ownerNode attribute will contain the Node.

Inherits properties from stylesheet.StyleSheet

Format

stylesheet
: [ CHARSET_SYM S* STRING S* ';' ]?
[S|CDO|CDC]* [ import [S|CDO|CDC]* ]* [ namespace [S|CDO|CDC]* ]* # according to @namespace WD [ [ ruleset | media | page ] [S|CDO|CDC]* ]*


Nested Classes [hide private]

Inherited from util.Base (private): _ttypes

Instance Methods [hide private]
 
__init__(self, href=None, media=None, title=u'', disabled=None, ownerNode=None, parentStyleSheet=None, readonly=False)
This specifies the style sheet language for this style sheet.
source code
 
__checknamespaces(self, stylerule, namespaces)
checks if all namespaces used in stylerule have been declared
source code
 
_getCssText(self) source code
 
_setCssText(self, cssText)
(cssutils) Parses cssText and overwrites the whole stylesheet.
source code
 
deleteRule(self, index)
Used to delete a rule from the style sheet.
source code
 
insertRule(self, rule, index=None)
Used to insert a new rule into the style sheet.
source code
 
addRule(self, rule)
DEPRECATED, use appendRule instead
source code
 
_getsetOwnerRuleDummy(self)
NOT IMPLEMENTED YET If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule.
source code
 
setSerializer(self, cssserializer)
Sets Serializer used for output of this stylesheet
source code
 
setSerializerPref(self, pref, value)
Sets Preference of CSSSerializer used for output of this stylesheet.
source code

Inherited from util.Base (private): _checkReadonly, _tokenize, _tokensupto, _valuestr

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]

Inherited from util.Base (private): _normalize

Class Variables [hide private]
  type = 'text/css'

Inherited from util.Base (private): _log

Properties [hide private]
  cssText
  ownerRule
(DOM attribute) NOT IMPLEMENTED YET

Inherited from object: __class__

Method Details [hide private]

__init__(self, href=None, media=None, title=u'', disabled=None, ownerNode=None, parentStyleSheet=None, readonly=False)
(Constructor)

source code 
type: readonly
This specifies the style sheet language for this style sheet. The style sheet language is specified as a content type (e.g. "text/css"). The content type is often specified in the ownerNode. Also see the type attribute definition for the LINK element in HTML 4.0, and the type pseudo-attribute for the XML style sheet processing instruction.
href: readonly
If the style sheet is a linked style sheet, the value of this attribute is its location. For inline style sheets, the value of this attribute is None. See the href attribute definition for the LINK element in HTML 4.0, and the href pseudo-attribute for the XML style sheet processing instruction.
media: of type MediaList, readonly
The intended destination media for style information. The media is often specified in the ownerNode. If no media has been specified, the MediaList will be empty. See the media attribute definition for the LINK element in HTML 4.0, and the media pseudo-attribute for the XML style sheet processing instruction. Modifying the media list may cause a change to the attribute disabled.
title: readonly
The advisory title. The title is often specified in the ownerNode. See the title attribute definition for the LINK element in HTML 4.0, and the title pseudo-attribute for the XML style sheet processing instruction.
disabled: False if the style sheet is applied to the
document. True if it is not. Modifying this attribute may cause a new resolution of style for the document. A stylesheet only applies if both an appropriate medium definition is present and the disabled attribute is False. So, if the media doesn't apply to the current user agent, the disabled attribute is ignored.
ownerNode: of type Node, readonly
The node that associates this style sheet with the document. For HTML, this may be the corresponding LINK or STYLE element. For XML, it may be the linking processing instruction. For style sheets that are included by other style sheets, the value of this attribute is None.
parentStyleSheet: of type StyleSheet, readonly
For style sheet languages that support the concept of style sheet inclusion, this attribute represents the including style sheet, if one exists. If the style sheet is a top-level style sheet, or the style sheet language does not support inclusion, the value of this attribute is None.
Overrides: stylesheets.stylesheet.StyleSheet.__init__
(inherited documentation)

_setCssText(self, cssText)

source code 

(cssutils) Parses cssText and overwrites the whole stylesheet.

cssText
textual text to set

DOMException on setting

  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if the rule is readonly.
  • SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
  • NAMESPACE_ERR: If a namespace prefix is found which is not declared.

deleteRule(self, index)

source code 

Used to delete a rule from the style sheet.

index
of the rule to remove in the StyleSheet's rule list

DOMException

  • INDEX_SIZE_ERR: (self) Raised if the specified index does not correspond to a rule in the style sheet's rule list.
  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this style sheet is readonly.

insertRule(self, rule, index=None)

source code 

Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.

Rule may be a string or a valid CSSRule.

rule
a parsable DOMString (cssutils: or Rule object)
index
of the rule before the new rule will be inserted. If the specified index is equal to the length of the StyleSheet's rule collection, the rule will be added to the end of the style sheet. If index is not given or None rule will be appended to rule list.

returns the index within the stylesheet's rule collection

DOMException

  • HIERARCHY_REQUEST_ERR: (self) Raised if the rule cannot be inserted at the specified index e.g. if an @import rule is inserted after a standard rule set or other at-rule.
  • INDEX_SIZE_ERR: (not raised at all) Raised if the specified index is not a valid insertion point.
  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this style sheet is readonly.
  • SYNTAX_ERR: (rule) Raised if the specified rule has a syntax error and is unparsable.

_getsetOwnerRuleDummy(self)

source code 
NOT IMPLEMENTED YET If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule. In that case, the ownerNode attribute in the StyleSheet interface will be null. If the style sheet comes from an element or a processing instruction, the ownerRule attribute will be null and the ownerNode attribute will contain the Node.

setSerializerPref(self, pref, value)

source code 
Sets Preference of CSSSerializer used for output of this stylesheet. See cssutils.serialize.Preferences for possible preferences to be set.

Property Details [hide private]

cssText

Get Method:
cssutils.css.cssstylesheet.CSSStyleSheet._getCssText(self)
Set Method:
cssutils.css.cssstylesheet.CSSStyleSheet._setCssText(self, cssText) - (cssutils) Parses cssText and overwrites the whole stylesheet.
Delete Method:
'(cssutils) a textual representation of the stylesheet'

ownerRule

(DOM attribute) NOT IMPLEMENTED YET
Get Method:
cssutils.css.cssstylesheet.CSSStyleSheet._getsetOwnerRuleDummy(self) - NOT IMPLEMENTED YET If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule.
Set Method:
cssutils.css.cssstylesheet.CSSStyleSheet._getsetOwnerRuleDummy(self) - NOT IMPLEMENTED YET If this style sheet comes from an @import rule, the ownerRule attribute will contain the CSSImportRule.
Delete Method:
None