<commit_before>'''  Provide a Bokeh Application Handler to build up documents by running
the code from ``main.py`` or `main.ipynb`` files in specified directories.

The directory may also optionally contain:

* A ``server_lifecyle.py`` module to provide lifecycle callbacks for the
  application and sessions.

* A ``static`` subdirectory containing app-specific static resources to
  serve.

* A ``theme.yaml`` file containing a Bokeh theme to automatically apply to
  all new documents.

* A ``tempates`` subdirectory containing templates for app display

A full directory layout might look like:

.. code-block:: none

    myapp
       |
       +---main.py
       +---server_lifecycle.py
       +---static
       +---theme.yaml
       +---templates
            +---index.html

'''
from __future__ import absolute_import, print_function

import logging
log = logging.getLogger(__name__)

from os.path import basename, dirname, exists, join

from jinja2 import Environment, FileSystemLoader

from .handler import Handler
from .script import ScriptHandler
from .server_lifecycle import ServerLifecycleHandler

class DirectoryHandler(Handler):
    ''' Load an application directory which modifies a Document.

    '''

    def __init__(self, *args, **kwargs):
        '''

        '''
        super(DirectoryHandler, self).__init__(*args, **kwargs)

        if 'filename' not in kwargs:
            raise ValueError('Must pass a filename to DirectoryHandler')<commit_msg>add kwargs documentation for DirectoryHandler (#7207)<commit_after>'''  Provide a Bokeh Application Handler to build up documents by running
the code from ``main.py`` or `main.ipynb`` files in specified directories.

The directory may also optionally contain:

* A ``server_lifecyle.py`` module to provide lifecycle callbacks for the
  application and sessions.

* A ``static`` subdirectory containing app-specific static resources to
  serve.

* A ``theme.yaml`` file containing a Bokeh theme to automatically apply to
  all new documents.

* A ``templates`` subdirectory containing templates for app display

A full directory layout might look like:

.. code-block:: none

    myapp
       |
       +---main.py
       +---server_lifecycle.py
       +---static
       +---theme.yaml
       +---templates
            +---index.html

'''
from __future__ import absolute_import, print_function

import logging
log = logging.getLogger(__name__)

from os.path import basename, dirname, exists, join

from jinja2 import Environment, FileSystemLoader

from .handler import Handler
from .script import ScriptHandler
from .server_lifecycle import ServerLifecycleHandler

class DirectoryHandler(Handler):
    ''' Load an application directory which modifies a Document.

    '''

    def __init__(self, *args, **kwargs):
        '''
        Keywords:
            filename (str) : a path to an application directory with either "main.py" or "main.ipynb"

            argv (list[str], optional) : a list of string arguments to make available as sys.argv to main.py
        '''
        super(DirectoryHandler, self).__init__(*args, **kwargs)

        if 'filename' not in kwargs:
            raise ValueError('Must pass a filename to DirectoryHandler')
{'fraction_non_alphanumeric': 0.09065420560747664, 'fraction_numerical': 0.001869158878504673, 'mean_word_length': 3.264276228419655, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7574919', 'n_tokens_mistral': 855, 'n_tokens_neox': 830, 'n_words': 331}