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 represents a CSS style sheet.

Properties

CSSOM

cssRules
of type CSSRuleList, (DOM readonly)
ownerRule
of type CSSRule, readonly (NOT IMPLEMENTED YET)

Inherits properties from stylesheet.StyleSheet

cssutils

cssText: string
a textual representation of the stylesheet
prefixes: set
A set of declared prefixes via @namespace rules. Each CSSStyleRule is checked if it uses additional prefixes which are not declared. If they do they are "invalidated".

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): _prods

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
 
_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
 
_getsetOwnerRuleDummy(self)
NOT IMPLEMENTED YET
source code
 
replaceUrls(self, replacer)
EXPERIMENTAL
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
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

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

Static Methods [hide private]

Inherited from util.Base (private): _normalize

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

Inherited from util.Base (private): _SHORTHANDPROPERTIES, _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.

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. For an index < 0 no INDEX_SIZE_ERR is raised but rules for normal Python lists are used. E.g. deleteRule(-1) removes the last rule in cssRules.

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 CSSRule 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: (self) 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

CSSOM

The ownerRule attribute, on getting, must return the CSSImportRule that caused this style sheet to be imported (if any). Otherwise, if no CSSImportRule caused it to be imported the attribute must return null.

replaceUrls(self, replacer)

source code 

EXPERIMENTAL

Utility method to replace all url(urlstring) values in CSSImportRules and CSSStyleDeclaration objects (properties).

replacer must be a function which is called with a single argument urlstring which is the current value of url() excluding url( and ). It still may have surrounding single or double quotes though.

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.

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

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
Set Method:
cssutils.css.cssstylesheet.CSSStyleSheet._getsetOwnerRuleDummy(self) - NOT IMPLEMENTED YET
Delete Method:
None