<commit_before>#!/usr/bin/env python
'''
A WSGI app to start a REST interface to Salt

This WSGI app can be used with any WSGI-compliant server. See the rest_cherrypy
netapi module to see how this app is run with the CherryPy WSGI server.

Apache's mod_wsgi instructions
------------------------------

Add the path to this script as a WSGIScriptAlias in the Apache configuration
for your site. For example a virtual host configuration may look something
like::

    <VirtualHost *:80>
        ServerName example.com
        ServerAlias *.example.com

        ServerAdmin <EMAIL>

        LogLevel warn
        ErrorLog /var/www/example.com/logs/error.log
        CustomLog /var/www/example.com/logs/access.log combined

        DocumentRoot /var/www/example.com/htdocs

        WSGIScriptAlias / /path/to/saltapi/netapi/rest_cherrypy/app.wsgi
    </VirtualHost>

'''
# pylint: disable=C0103

import cherrypy

from . import app

def bootstrap_app():
    '''
    Grab the opts dict of the master config by trying to import Salt
    '''
    import salt.client
    opts = salt.client.LocalClient().opts
    return app.get_app(opts)

def get_application(*args):
    '''
    Returns a WSGI application function. If you supply the WSGI app and config
    it will use that, otherwise it will try to obtain them from a local Salt
    installation
    '''
    opts_tuple = args

    def wsgi_app(environ, start_response):
        root, _, conf = opts_tuple or bootstrap_app()

        cherrypy.tree.mount(root, '/', conf)
        return cherrypy.tree(environ, start_response)

    return wsgi_app

application = get_application()
<commit_msg>Fixed docstring for consistency with the actual file name<commit_after>#!/usr/bin/env python
'''
A WSGI app to start a REST interface to Salt

This WSGI app can be used with any WSGI-compliant server. See the rest_cherrypy
netapi module to see how this app is run with the CherryPy WSGI server.

Apache's mod_wsgi instructions
------------------------------

Add the path to this script as a WSGIScriptAlias in the Apache configuration
for your site. For example a virtual host configuration may look something
like::

    <VirtualHost *:80>
        ServerName example.com
        ServerAlias *.example.com

        ServerAdmin <EMAIL>

        LogLevel warn
        ErrorLog /var/www/example.com/logs/error.log
        CustomLog /var/www/example.com/logs/access.log combined

        DocumentRoot /var/www/example.com/htdocs

        WSGIScriptAlias / /path/to/saltapi/netapi/rest_cherrypy/wsgi.py
    </VirtualHost>

'''
# pylint: disable=C0103

import cherrypy

from . import app

def bootstrap_app():
    '''
    Grab the opts dict of the master config by trying to import Salt
    '''
    import salt.client
    opts = salt.client.LocalClient().opts
    return app.get_app(opts)

def get_application(*args):
    '''
    Returns a WSGI application function. If you supply the WSGI app and config
    it will use that, otherwise it will try to obtain them from a local Salt
    installation
    '''
    opts_tuple = args

    def wsgi_app(environ, start_response):
        root, _, conf = opts_tuple or bootstrap_app()

        cherrypy.tree.mount(root, '/', conf)
        return cherrypy.tree(environ, start_response)

    return wsgi_app

application = get_application()

{'fraction_non_alphanumeric': 0.0918706557872469, 'fraction_numerical': 0.003626473254759746, 'mean_word_length': 2.80897583429229, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6327887', 'n_tokens_mistral': 1002, 'n_tokens_neox': 939, 'n_words': 340}