<commit_before>from __future__ import print_function

import os
import six
import webbrowser

from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter

from bokeh import plotting
from bokeh.document import Document
from bokeh.embed import autoload_static
from bokeh.resources import Resources

# patch open and show and save to be no-ops
def noop(*args, **kwargs):
    pass

webbrowser.open = noop
plotting.save = noop
plotting.show = noop

oldfig = plotting.figure
def figure(*args, **kw):
    f = oldfig(*args, **kw)
    plotting.curdoc().context.children.append(f)
    return f
plotting.figure = figure

def page_desc(module_desc):
    module_path, name = module_desc['file'], module_desc['name']
    var_name = module_desc.get('var_name', None)

    plotting._default_document = Document()

    namespace = {}
    with open(module_path, "r") as module_file:
        code = compile(module_file.read(), module_path, "exec")
        eval(code, namespace)

    if var_name:
        if 'chart' in module_desc['file']:
            obj = namespace[var_name]
            objs = [obj.chart.plot]
        else:
            objs = [namespace[var_name]]
    else:
        objs = plotting.curdoc().context.children

    embed_snippet = ""
    for i, obj in enumerate(objs):
        filename = name + "." + str(i) + ".js"
        js, tag = autoload_static(
            obj,
            Resources(mode="server", root_url=HOSTED_STATIC_ROOT),
            os.path.join(DETAIL_URL_ROOT, filename)
        )
        embed_snippet += tag<commit_msg>fix for gallery issue<commit_after>from __future__ import print_function

import os
import six
import webbrowser

from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter

from bokeh import plotting
from bokeh.document import Document
from bokeh.embed import autoload_static
from bokeh.resources import Resources

# patch open and show and save to be no-ops
def noop(*args, **kwargs):
    pass

webbrowser.open = noop
plotting.save = noop
def show(obj=None):
    if obj:
        plotting._obj = obj
plotting.show = show

def page_desc(module_desc):
    module_path, name = module_desc['file'], module_desc['name']
    var_name = module_desc.get('var_name', None)

    plotting._default_document = Document()

    namespace = {}
    with open(module_path, "r") as module_file:
        code = compile(module_file.read(), module_path, "exec")
        eval(code, namespace)

    if var_name:
        if 'chart' in module_desc['file']:
            obj = namespace[var_name]
            objs = [obj.chart.plot]
        else:
            objs = [namespace[var_name]]
    else:
        objs = [plotting._obj]
    embed_snippet = ""
    for i, obj in enumerate(objs):
        filename = name + "." + str(i) + ".js"
        js, tag = autoload_static(
            obj,
            Resources(mode="server", root_url=HOSTED_STATIC_ROOT),
            os.path.join(DETAIL_URL_ROOT, filename)
        )
        embed_snippet += tag
{'fraction_non_alphanumeric': 0.1000651890482399, 'fraction_numerical': 0.0, 'mean_word_length': 3.0170157068062826, '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': '3272279', 'n_tokens_mistral': 971, 'n_tokens_neox': 941, 'n_words': 253}