<commit_before>"""
Contains postprocessor for serving nbconvert output.
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

import os
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

from IPython.utils.traitlets import Unicode

from .base import PostProcessorBase

#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class ServePostProcessor(PostProcessorBase):
    """Post processor designed to serve files"""


    build_directory = Unicode(".", config=True, 
                              help="""Directory to write output to.  Leave blank
                              to output to the current directory""")

    def call(self, input):
        """
        Simple implementation to serve the build directory.
        """
        
        try:
            os.chdir(self.build_directory)
            httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
            sa = httpd.socket.getsockname()
            print("Serving " + input[2:] + " on http://" + sa[0] + ":" + str(sa[1]))
            print("Use Control-C to stop this server.")
            httpd.serve_forever()
        except KeyboardInterrupt:
            print("The server is shut down.")<commit_msg>Added webbroser to auto open the slideshow.<commit_after>"""
Contains postprocessor for serving nbconvert output.
"""
#-----------------------------------------------------------------------------
#Copyright (c) 2013, the IPython Development Team.
#
#Distributed under the terms of the Modified BSD License.
#
#The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

import os
import webbrowser

from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

from IPython.utils.traitlets import Unicode

from .base import PostProcessorBase

#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class ServePostProcessor(PostProcessorBase):
    """Post processor designed to serve files"""


    build_directory = Unicode(".", config=True, 
                              help="""Directory to write output to.  Leave blank
                              to output to the current directory""")

    def call(self, input):
        """
        Simple implementation to serve the build directory.
        """
        
        try:
            os.chdir(self.build_directory)
            httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler)
            sa = httpd.socket.getsockname()
            name = input[2:]
            url = "http://" + sa[0] + ":" + str(sa[1]) + "/" + name
            webbrowser.open(url, new=2)
            print("Serving " + name + " on " + url)
            print("Use Control-C to stop this server.")
            httpd.serve_forever()
        except KeyboardInterrupt:
            print("The server is shut down.")
{'fraction_non_alphanumeric': 0.32050941894401697, 'fraction_numerical': 0.009286282833642877, 'mean_word_length': 1.160458452722063, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3213442', 'n_tokens_mistral': 806, 'n_tokens_neox': 773, 'n_words': 248}