# Path: nbinteract/exporters.py
# class InteractExporter(HTMLExporter):
#     """
#     nbconvert Exporter that converts a notebook to an HTML page with widgets
#     enabled.
#     """
#     spec = Unicode(
#         'SamLau95/nbinteract-image/master',
#         help='BinderHub spec for Jupyter image.'
#     ).tag(config=True)
# 
#     base_url = Unicode(
#         'https://mybinder.org', help='Base Binder URL.'
#     ).tag(config=True)
# 
#     provider = Unicode('gh', help='BinderHub provider.').tag(config=True)
# 
#     button_at_top = Bool(
#         True, 'If False, only widget cell buttons are generated.'
#     ).tag(config=True)
# 
#     def __init__(self, config=None, **kw):
#         """
#         Public constructor
# 
#         Kwargs:
#             config (traitlets.Config): User configuration instance.
# 
#             spec (str): BinderHub spec for Jupyter image. Must be in the
#                 format: `${username}/${repo}/${branch}` or
#                 `${username}/${repo}`, in which case `branch` defaults to
#                 `main`. Defaults to 'SamLau95/nbinteract-image/master'.
# 
#             base_url (str): Base Binder URL. Defaults to
#                 'https://mybinder.org'.
# 
#             provider (str): BinderHub provider. Defaults to 'gh' for GitHub.
# 
#             template_file (str):
#                 Template to use when exporting. Valid templates:
# 
#                 'full': Outputs a complete standalone HTML page with default
#                 styling. Automatically loads the nbinteract JS library.
# 
#                 'local': Like 'full', but uses a local copy of the JS package
#                 instead of the live one. Used for development only.
# 
#                 'partial': Outputs an HTML partial that can be embedded in
#                 another page. Automatically loads the nbinteract JS library.
# 
#                 'plain': Outputs an HTML partial to embed in another page. The
#                 partial does not include the nbinteract JS library; the
#                 embedding page must load and initialize the nbinteract JS
#                 library itself.
# 
#             button_at_top (bool): If True (default), generates a button to
#                 start widgets at the top of the notebook as well as one button
#                 per widget cell. If False, only widget cell buttons are
#                 generated.
# 
#             extra_loaders (list[Jinja Loader]): ordered list of Jinja loader to
#                 find templates. Will be tried in order before the default
#                 FileSystem ones.
#         """
#         # nbconvert 6 expects the full path for 5.x style .tpl files
#         if 'template_file' in kw:
#             kw['template_file'] = os.path.join(
#                 os.path.dirname(__file__), 'templates',
#                 kw['template_file'] + '.tpl')
#         if config is not None:
#             if config.InteractExporter.has_key('template_file'):
#                 config.InteractExporter.template_file = os.path.join(
#                     os.path.dirname(__file__), 'templates',
#                     config.InteractExporter.template_file + '.tpl')
# 
#         super(InteractExporter, self).__init__(config=config, **kw)
# 
#         # Set variables that will be available in the template
#         self.environment.globals['spec'] = self.spec
#         self.environment.globals['base_url'] = self.base_url
#         self.environment.globals['provider'] = self.provider
#         self.environment.globals['button_at_top'] = self.button_at_top
# 
#     @default('template_file')
#     def _template_file_default(self):
#         return os.path.join(
#             os.path.dirname(__file__), 'templates', 'full.tpl')
# 
#     @validate('spec')
#     def _valid_spec(self, proposal):
#         spec = proposal['value']
#         spec_parts = len(spec.split(SPEC_DIVIDER))
#         if spec_parts == 3:
#             return spec
#         elif spec_parts == 2:
#             return spec + '/main'
#         else:
#             raise TraitError(
#                 'spec must contain two or three components but only got '
#                 '{} (original spec: {})'.format(spec_parts, spec)
#             )


from docopt import docopt, DocoptExit
from glob import glob
from textwrap import wrap
from collections import defaultdict
from traitlets.config import Config
from .exporters import InteractExporter
import os
import re
import sys
import subprocess
import json
import fnmatch
import nbformat
    if not recursive:
        return glob('{}/*.ipynb'.format(notebook_or_folder))

    # Recursive case
    return [
        os.path.join(folder, filename)
        for folder, _, filenames in os.walk(notebook_or_folder)
        # Skip folders that start with .
        if not os.path.basename(folder).startswith('.')
        for filename in fnmatch.filter(filenames, '*.ipynb')
    ]


def init_exporter(extract_images, execute, **exporter_config):
    """
    Returns an initialized exporter.
    """
    config = Config(InteractExporter=exporter_config)

    preprocessors = []
    if extract_images:
        # Use ExtractOutputPreprocessor to extract the images to separate files
        preprocessors.append(
            'nbconvert.preprocessors.ExtractOutputPreprocessor'
        )
    if execute:
        # Use the NbiExecutePreprocessor to correctly generate widget output
        # for interact() calls.
        preprocessors.append('nbinteract.preprocessors.NbiExecutePreprocessor')


# Path: nbinteract/exporters.py
# class InteractExporter(HTMLExporter):
#     """
#     nbconvert Exporter that converts a notebook to an HTML page with widgets
#     enabled.
#     """
#     spec = Unicode(
#         'SamLau95/nbinteract-image/master',
#         help='BinderHub spec for Jupyter image.'
#     ).tag(config=True)
# 
#     base_url = Unicode(
#         'https://mybinder.org', help='Base Binder URL.'
#     ).tag(config=True)
# 
#     provider = Unicode('gh', help='BinderHub provider.').tag(config=True)
# 
#     button_at_top = Bool(
#         True, 'If False, only widget cell buttons are generated.'
#     ).tag(config=True)
# 
#     def __init__(self, config=None, **kw):
#         """
#         Public constructor
# 
#         Kwargs:
#             config (traitlets.Config): User configuration instance.
# 
#             spec (str): BinderHub spec for Jupyter image. Must be in the
#                 format: `${username}/${repo}/${branch}` or
#                 `${username}/${repo}`, in which case `branch` defaults to
#                 `main`. Defaults to 'SamLau95/nbinteract-image/master'.
# 
#             base_url (str): Base Binder URL. Defaults to
#                 'https://mybinder.org'.
# 
#             provider (str): BinderHub provider. Defaults to 'gh' for GitHub.
# 
#             template_file (str):
#                 Template to use when exporting. Valid templates:
# 
#                 'full': Outputs a complete standalone HTML page with default
#                 styling. Automatically loads the nbinteract JS library.
# 
#                 'local': Like 'full', but uses a local copy of the JS package
#                 instead of the live one. Used for development only.
# 
#                 'partial': Outputs an HTML partial that can be embedded in
#                 another page. Automatically loads the nbinteract JS library.
# 
#                 'plain': Outputs an HTML partial to embed in another page. The
#                 partial does not include the nbinteract JS library; the
#                 embedding page must load and initialize the nbinteract JS
#                 library itself.
# 
#             button_at_top (bool): If True (default), generates a button to
#                 start widgets at the top of the notebook as well as one button
#                 per widget cell. If False, only widget cell buttons are
#                 generated.
# 
#             extra_loaders (list[Jinja Loader]): ordered list of Jinja loader to
#                 find templates. Will be tried in order before the default
#                 FileSystem ones.
#         """
#         # nbconvert 6 expects the full path for 5.x style .tpl files
#         if 'template_file' in kw:
#             kw['template_file'] = os.path.join(
#                 os.path.dirname(__file__), 'templates',
#                 kw['template_file'] + '.tpl')
#         if config is not None:
#             if config.InteractExporter.has_key('template_file'):
#                 config.InteractExporter.template_file = os.path.join(
#                     os.path.dirname(__file__), 'templates',
#                     config.InteractExporter.template_file + '.tpl')
# 
#         super(InteractExporter, self).__init__(config=config, **kw)
# 
#         # Set variables that will be available in the template
#         self.environment.globals['spec'] = self.spec
#         self.environment.globals['base_url'] = self.base_url
#         self.environment.globals['provider'] = self.provider
#         self.environment.globals['button_at_top'] = self.button_at_top
# 
#     @default('template_file')
#     def _template_file_default(self):
#         return os.path.join(
#             os.path.dirname(__file__), 'templates', 'full.tpl')
# 
#     @validate('spec')
#     def _valid_spec(self, proposal):
#         spec = proposal['value']
#         spec_parts = len(spec.split(SPEC_DIVIDER))
#         if spec_parts == 3:
#             return spec
#         elif spec_parts == 2:
#             return spec + '/main'
#         else:
#             raise TraitError(
#                 'spec must contain two or three components but only got '
#                 '{} (original spec: {})'.format(spec_parts, spec)
#             )


# Path: nbinteract/cli.py
from docopt import docopt, DocoptExit
from glob import glob
from textwrap import wrap
from collections import defaultdict
from traitlets.config import Config
from .exporters import InteractExporter
import os
import re
import sys
import subprocess
import json
import fnmatch
import nbformat

    if not recursive:
        return glob('{}/*.ipynb'.format(notebook_or_folder))

    # Recursive case
    return [
        os.path.join(folder, filename)
        for folder, _, filenames in os.walk(notebook_or_folder)
        # Skip folders that start with .
        if not os.path.basename(folder).startswith('.')
        for filename in fnmatch.filter(filenames, '*.ipynb')
    ]


def init_exporter(extract_images, execute, **exporter_config):
    """
    Returns an initialized exporter.
    """
    config = Config(InteractExporter=exporter_config)

    preprocessors = []
    if extract_images:
        # Use ExtractOutputPreprocessor to extract the images to separate files
        preprocessors.append(
            'nbconvert.preprocessors.ExtractOutputPreprocessor'
        )
    if execute:
        # Use the NbiExecutePreprocessor to correctly generate widget output
        # for interact() calls.
        preprocessors.append('nbinteract.preprocessors.NbiExecutePreprocessor')


    config.InteractExporter.preprocessors = preprocessors