Package cssutils :: Module util :: Class Base |
[hide private]
[frames] | no frames]

# Class Base

source code

    object --+
             |
            Base

Known Subclasses:
  - Base2
  - , css.cssvalue.CSSValue
  - , css.cssstyledeclaration.CSSStyleDeclaration
  - , stylesheets.stylesheet.StyleSheet
  - , css.property.Property
  - , css.selectorlist.SelectorList
  - , stylesheets.medialist.MediaList
  - , stylesheets.mediaquery.MediaQuery

Base class for most CSS and StyleSheets classes

Superceded by Base2 which is used for new seq handling class. See cssutils.util.Base2

Contains helper methods for inheriting classes helping parsing

`_normalize` is static as used by Preferences.

Nested Classes | [hide private]
| _prods most attributes are set later

Instance Methods | [hide private]
__escapes(...) sub(repl, string[, count = 0]) --> newstring Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. | source code
__unicodes(...) sub(repl, string[, count = 0]) --> newstring Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. | source code
_checkReadonly(self) raises xml.dom.NoModificationAllowedErr if rule/... | source code
_splitNamespacesOff(self, text_namespaces_tuple) returns tuple (text, dict-of-namespaces) or if no namespaces are in cssText returns (cssText, {}) | source code
_tokenize2(self, textortokens) returns tokens of textortokens which may already be tokens in which case simply returns input | source code
_nexttoken(self, tokenizer, default=None) returns next token in generator tokenizer or the default value | source code
_type(self, token) returns type of Tokenizer token | source code
_tokenvalue(self, token, normalize=False) returns value of Tokenizer token | source code
_stringtokenvalue(self, token) for STRING returns the actual content without surrounding "" or '' and without respective escapes, e.g.: | source code
_uritokenvalue(self, token) for URI returns the actual content without surrounding url() or url(""), url('') and without respective escapes, e.g.: | source code
_tokensupto2(self, tokenizer, starttoken=None, blockstartonly=False, blockendonly=False, mediaendonly=False, importmediaqueryendonly=False, mediaqueryendonly=False, semicolon=False, propertynameendonly=False, propertyvalueendonly=False, propertypriorityendonly=False, selectorattendonly=False, funcendonly=False, listseponly=False, separateEnd=False) returns tokens upto end of atrule and end index end is defined by parameters, might be ; } ) or other | source code
_valuestr(self, t) returns string value of t (t may be a string, a list of token tuples or a single tuple in format (type, value, line, col). | source code
_adddefaultproductions(self, productions, new=None) adds default productions if not already present, used by _parse only | source code
_parse(self, expected, seq, tokenizer, productions, default=None, new=None) (seq, tokenizer, token) | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__init__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Static Methods | [hide private]
_normalize(x) normalizes x, namely: | source code

Class Variables | [hide private]
| __tokenizer2 = `Tokenizer()`
| _log = `cssutils.log`
| _SHORTHANDPROPERTIES = ``{``u'``background``'``:` `[``]``,` `u'``border``'``:` `[``]``,` `u'``bo``...``

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### _normalize(x) Static Method | source code
normalizes x, namely: remove any before non unicode sequences (0-9a-zA-Z) so for x=="color" return "color" (unicode escape sequences should have been resolved by the tokenizer already) lowercase

### _checkReadonly(self) | source code
raises xml.dom.NoModificationAllowedErr if rule/... is readonly

### _splitNamespacesOff(self, text_namespaces_tuple) | source code
returns tuple (text, dict-of-namespaces) or if no namespaces are in cssText returns (cssText, {}) used in Selector, SelectorList, CSSStyleRule, CSSMediaRule and CSSStyleSheet

### _tokensupto2(self, tokenizer, starttoken=None, blockstartonly=False, blockendonly=False, mediaendonly=False, importmediaqueryendonly=False, mediaqueryendonly=False, semicolon=False, propertynameendonly=False, propertyvalueendonly=False, propertypriorityendonly=False, selectorattendonly=False, funcendonly=False, listseponly=False, separateEnd=False) | source code
returns tokens upto end of atrule and end index end is defined by parameters, might be ; } ) or other default looks for ending "}" and ";"

### _valuestr(self, t) | source code
returns string value of t (t may be a string, a list of token tuples or a single tuple in format (type, value, line, col). Mainly used to get a string value of t for error messages.

### _adddefaultproductions(self, productions, new=None) | source code
adds default productions if not already present, used by _parse only each production should return the next expected token normaly a name like "uri" or "EOF" some have no expectation like S or COMMENT, so simply return the current value of self.__expected

### _parse(self, expected, seq, tokenizer, productions, default=None, new=None) | source code
puts parsed tokens in seq by calling a production with (seq, tokenizer, token) expected a name what token or value is expected next, e.g. 'uri' seq to add rules etc to tokenizer call tokenizer.next() to get next token productions callbacks {tokentype: callback} default default callback if tokentype not in productions new used to init default productions returns (wellformed, expected) which the last prod might have set

Class Variable Details | [hide private]

  ### _SHORTHANDPROPERTIES Value:
      {u'background': [],
       u'border': [],
       u'border-bottom': [],
       u'border-color': [],
       u'border-left': [],
       u'border-right': [],
       u'border-style': [],
       u'border-top': [],
      ...