def __init__(self, parselet, selector_handler=None, strict=False, debug=False):
if debug:<EOL><INDENT>self.DEBUG = True<EOL><DEDENT>if strict:<EOL><INDENT>self.STRICT_MODE = True<EOL><DEDENT>self.parselet =  parselet<EOL>if not selector_handler:<EOL><INDENT>self.selector_handler = DefaultSelectorHandler(debug=self.DEBUG)<EOL><DEDENT>elif not(isinstance(selector_handler, SelectorHandler)):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.selector_handler = selector_handler<EOL><DEDENT>self.compile()<EOL>
Take a parselet and optional selector_handler
and build an abstract representation of the Parsley extraction
logic.

Four helper class methods can be used to instantiate a Parselet
from JSON/YAML rules: :meth:`.from_jsonstring`, :meth:`.from_jsonfile`,
:meth:`.from_yamlstring`, :meth:`.from_yamlfile`.

:param dict parselet: Parsley script as a Python dict object
:param boolean strict: Set to *True* is you want to
    enforce that missing required keys raise an Exception; default is False
    (i.e. lenient/non-strict mode)
:param selector_handler: an instance of :class:`selectors.SelectorHandler`
    optional selector handler instance;
    defaults to an instance of :class:`selectors.DefaultSelectorHandler`
:raises: :class:`.InvalidKeySyntax`

Example:

>>> import parslepy
>>> rules = {
...     "heading": "h1#main",
...     "news(li.newsitem)": [{
...         "title": ".",
...         "url": "a/@href"
...     }],
... }
>>> p = parslepy.Parselet(rules)
>>> type(p)
<class 'parslepy.base.Parselet'>

Use :meth:`~base.Parselet.extract` or :meth:`~base.Parselet.parse`
to get extracted content from documents.