Package cssutils :: Package stylesheets :: Module medialist :: Class MediaList |
[hide private]
[frames] | no frames]

# Class MediaList

source code

    object --+
             |
     util.Base --+
                 |
    object --+   |
             |   |
          list --+
                 |
                MediaList

Provides the abstraction of an ordered collection of media, without defining or constraining how this collection is implemented.

A media is always an instance of MediaQuery.

An empty list is the same as a list that contains the medium "all".

# Properties

length:
  The number of MediaQuery objects in the list.
mediaText: of type DOMString
  The parsable textual representation of this MediaList
self: a list (cssutils)
  All MediaQueries in this MediaList
valid:
  if this list is valid

# Format

    medium [ COMMA S* medium ]*

New:

    <media_query> [, <media_query> ]*

Nested Classes | [hide private]
Inherited from `util.Base` (private): `_prods`

Instance Methods | [hide private]
__init__(self, mediaText=None, readonly=False) unicodestring of parsable comma separared media or a list of media | source code
_getLength(self) returns count of media in this list which is not the same as len(MediaListInstance) which also contains CSSComments | source code
_getMediaText(self) returns serialized property mediaText | source code
_setMediaText(self, mediaText) simple value or comma-separated list of media | source code
appendMedium(self, newMedium) (DOM) Adds the medium newMedium to the end of the list. | source code
deleteMedium(self, oldMedium) (DOM) Deletes the medium indicated by oldMedium from the list. | source code
item(self, index) (DOM) Returns the mediaType of the index'th element in the list. | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
Inherited from `util.Base` (private): `_checkReadonly`, `_getProductions`, `_newseq`, `_nexttoken`, `_parse`, `_tokenize2`, `_tokensupto2`, `_tokenvalue`, `_type`, `_valuestr` Inherited from `list`: `__add__`, `__contains__`, `__delitem__`, `__delslice__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__iadd__`, `__imul__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__mul__`, `__ne__`, `__new__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `append`, `count`, `extend`, `index`, `insert`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Static Methods | [hide private]
Inherited from `util.Base` (private): `_normalize`

Class Variables | [hide private]
Inherited from `util.Base` (private): `_SHORTHANDPROPERTIES`, `_log`

Properties | [hide private]
| length (DOM readonly) The number of media in the list.
| mediaText (DOM) The parsable textual representation of the media list.
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, mediaText=None, readonly=False) (Constructor) | source code
  mediaText unicodestring of parsable comma separared media or a list of media Returns:
      new list
Overrides: list.__init__

### _setMediaText(self, mediaText) | source code
mediaText simple value or comma-separated list of media DOMException SYNTAX_ERR: (MediaQuery) Raised if the specified string value has a syntax error and is unparsable. NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this media list is readonly.

### appendMedium(self, newMedium) | source code
(DOM) Adds the medium newMedium to the end of the list. If the newMedium is already used, it is first removed. newMedium a string or a MediaQuery object returns if newMedium is valid DOMException INVALID_CHARACTER_ERR: (self) If the medium contains characters that are invalid in the underlying style language. NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this list is readonly.

### deleteMedium(self, oldMedium) | source code
(DOM) Deletes the medium indicated by oldMedium from the list. DOMException NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this list is readonly. NOT_FOUND_ERR: (self) Raised if oldMedium is not in the list.

### item(self, index) | source code
(DOM) Returns the mediaType of the index'th element in the list. If index is greater than or equal to the number of media in the list, returns None.

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: list.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

Property Details | [hide private]

  ### length (DOM readonly) The number of media in the list. Get Method: cssutils.stylesheets.medialist.MediaList._getLength(self) - returns count of media in this list which is not the same as len(MediaListInstance) which also contains CSSComments Set Method:
      None
  Delete Method:
      None

  ### mediaText (DOM) The parsable textual representation of the media list. This is a comma-separated list of media. Get Method: cssutils.stylesheets.medialist.MediaList._getMediaText(self) - returns serialized property mediaText Set Method: cssutils.stylesheets.medialist.MediaList._setMediaText(self, mediaText) - simple value or comma-separated list of media Delete Method:
      None