<commit_before>"""EasyEngine main application entry point."""
import sys

# this has to happen after you import sys, but before you import anything
# from Cement "source: https://github.com/datafolklabs/cement/issues/290"
if '--debug' in sys.argv:
    sys.argv.remove('--debug')
    TOGGLE_DEBUG = True
else:
    TOGGLE_DEBUG = False

from cement.core import foundation
from cement.utils.misc import init_defaults
from cement.core.exc import FrameworkError, CaughtSignal
from ee.core import exc

# Application default.  Should update config/ee.conf to reflect any
# changes, or additions here.
defaults = init_defaults('ee')

# All internal/external plugin configurations are loaded from here
defaults['ee']['plugin_config_dir'] = '/etc/ee/plugins.d'

# External plugins (generally, do not ship with application code)
defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins'

# External templates (generally, do not ship with application code)
defaults['ee']['template_dir'] = '/var/lib/ee/templates'


class EEApp(foundation.CementApp):
    class Meta:
        label = 'ee'

        config_defaults = defaults

        # All built-in application bootstrapping (always run)
        bootstrap = 'ee.cli.bootstrap'

        # Optional plugin bootstrapping (only run if plugin is enabled)
        plugin_bootstrap = 'ee.cli.plugins'

        # Internal templates (ship with application code)
        template_module = 'ee.cli.templates'

        # Internal plugins (ship with application code)
        plugin_bootstrap = 'ee.cli.plugins'

        extensions = ['mustache', 'json']

        # default output handler
        output_handler = 'mustache'

        debug = TOGGLE_DEBUG


class EETestApp(EEApp):
    """A test app that is better suited for testing."""
    class Meta:
        argv = []
        config_files = []


# Define the applicaiton object outside of main, as some libraries might wish
# to import it as a global (rather than passing it into another class/func)
app = EEApp()


def main():
    try:
        # Default our exit status to 0 (non-error)
        code = 0

        # Setup the application
        app.setup()

        # Run the application
        app.run()
    except exc.EEError as e:
        # Catch our application errors and exit 1 (error)
        code = 1
        print(e)
    except FrameworkError as e:
        # Catch framework errors and exit 1 (error)
        code = 1
        print(e)
    except CaughtSignal as e:
        # Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error)
        code = 0
        print(e)
    finally:
        # Print an exception (if it occurred) and --debug was passed
        if app.debug:
            import sys
            import traceback

            exc_type, exc_value, exc_traceback = sys.exc_info()
            if exc_traceback is not None:
                traceback.print_exc()

        # Close the application
        app.close(code)


def get_test_app(**kw):
    app = EEApp(**kw)
    return app

if __name__ == '__main__':
    main()<commit_msg>ee description modified<commit_after>"""EasyEngine main application entry point."""
import sys

# this has to happen after you import sys, but before you import anything
# from Cement "source: https://github.com/datafolklabs/cement/issues/290"
if '--debug' in sys.argv:
    sys.argv.remove('--debug')
    TOGGLE_DEBUG = True
else:
    TOGGLE_DEBUG = False

from cement.core import foundation
from cement.utils.misc import init_defaults
from cement.core.exc import FrameworkError, CaughtSignal
from ee.core import exc

# Application default.  Should update config/ee.conf to reflect any
# changes, or additions here.
defaults = init_defaults('ee')

# All internal/external plugin configurations are loaded from here
defaults['ee']['plugin_config_dir'] = '/etc/ee/plugins.d'

# External plugins (generally, do not ship with application code)
defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins'

# External templates (generally, do not ship with application code)
defaults['ee']['template_dir'] = '/var/lib/ee/templates'


class EEApp(foundation.CementApp):
    class Meta:
        label = 'ee'

        config_defaults = defaults

        # All built-in application bootstrapping (always run)
        bootstrap = 'ee.cli.bootstrap'

        # Optional plugin bootstrapping (only run if plugin is enabled)
        plugin_bootstrap = 'ee.cli.plugins'

        # Internal templates (ship with application code)
        template_module = 'ee.cli.templates'

        # Internal plugins (ship with application code)
        plugin_bootstrap = 'ee.cli.plugins'

        extensions = ['mustache', 'json']

        # default output handler
        output_handler = 'mustache'

        debug = TOGGLE_DEBUG


class EETestApp(EEApp):
    """A test app that is better suited for testing."""
    class Meta:
        argv = []
        config_files = []


# Define the applicaiton object outside of main, as some libraries might wish
# to import it as a global (rather than passing it into another class/func)
app = EEApp()


def main():
    try:
        # Default our exit status to 0 (non-error)
        code = 0

        # Setup the application
        app.setup()

        # Run the application
        app.run()
    except exc.EEError as e:
        # Catch our application errors and exit 1 (error)
        code = 1
        print(e)
    except FrameworkError as e:
        # Catch framework errors and exit 1 (error)
        code = 1
        print(e)
    except CaughtSignal as e:
        # Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error)
        code = 0
        print(e)
    finally:
        # Print an exception (if it occurred) and --debug was passed
        if app.debug:
            import sys
            import traceback

            exc_type, exc_value, exc_traceback = sys.exc_info()
            if exc_traceback is not None:
                traceback.print_exc()

        # # Close the application
    app.close(code)


def get_test_app(**kw):
    app = EEApp(**kw)
    return app

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.09116386416089681, 'fraction_numerical': 0.003626772172766238, 'mean_word_length': 2.6199284009546537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '7410667', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1663, 'n_words': 599}