How to use the serpextract.serpextract.pkg_resources.resource_stream function in serpextract

To help you get started, we’ve selected a few serpextract examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Parsely / serpextract / serpextract / serpextract.py View on Github external
def _get_piwik_engines():
    """
    Return the search engine parser definitions stored in this module. We don't
    cache this result since it's only supposed to be called once.
    """
    stream = pkg_resources.resource_stream
    with stream(__name__, 'search_engines.json') as json_stream:
        if PY3:
            if hasattr(json_stream, 'buffer'):
                json_stream = TextIOWrapper(json_stream.buffer, encoding='utf-8')
            else:
                json_stream = TextIOWrapper(json_stream, encoding='utf-8')
        _piwik_engines = json.load(json_stream)
    return _piwik_engines