Skip to content

Commit

Permalink
Initial import of tinycss
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed May 21, 2014
1 parent 062d38a commit d993534
Show file tree
Hide file tree
Showing 10 changed files with 2,481 additions and 0 deletions.
4 changes: 4 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ License: other
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

Files: src/tinycss/*
Copyright: Simon Sapin
License: BSD

Files: src/calibre/ebooks/readability/*
Copyright: Unknown
License: Apache 2.0
Expand Down
44 changes: 44 additions & 0 deletions src/tinycss/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# coding: utf8
"""
tinycss
-------
A CSS parser, and nothing else.
:copyright: (c) 2012 by Simon Sapin.
:license: BSD, see LICENSE for more details.
"""

import sys

from .version import VERSION
__version__ = VERSION

from .css21 import CSS21Parser
from .page3 import CSSPage3Parser


PARSER_MODULES = {
'page3': CSSPage3Parser,
}


def make_parser(*features, **kwargs):
"""Make a parser object with the chosen features.
:param features:
Positional arguments are base classes the new parser class will extend.
The string ``'page3'`` is accepted as short for
:class:`~page3.CSSPage3Parser`.
:param kwargs:
Keyword arguments are passed to the parser’s constructor.
:returns:
An instance of a new subclass of :class:`CSS21Parser`
"""
if features:
bases = tuple(PARSER_MODULES.get(f, f) for f in features)
parser_class = type('CustomCSSParser', bases + (CSS21Parser,), {})
else:
parser_class = CSS21Parser
return parser_class(**kwargs)
Loading

0 comments on commit d993534

Please sign in to comment.