Example #1
0
def ipython(**locals_):
    from IPython import start_ipython
    from traitlets.config import get_config

    c = get_config()
    c.TerminalInteractiveShell.banner2 = BANNER
    start_ipython(argv=[], config=c, user_ns=locals_)
def get_ipython_config(device):
    # import os, sys, IPython

    # os.environ['PYTHONSTARTUP'] = ''  # Prevent running this again
    c = config.get_config()
    c.TerminalInteractiveShell.confirm_exit = False
    c.TerminalInteractiveShell.logstart = True
    c.TerminalInteractiveShell.logfile = '%s-interactive_aci.ipython.log' %device
    return c
Example #3
0
def main(ipynb, kernel_name):
    print("running %s" % ipynb)
    nb = read(ipynb, as_version=4)

    config = get_config()
    config.BokehExecutePreprocessor.kernel_name = kernel_name
    print(config)
    ep = BokehExecutePreprocessor(config=config)
    ep.preprocess(nb, {'metadata': {'path': './'}})

    exportHtml = HTMLExporter()
    (body, resources) = exportHtml.from_notebook_node(nb)

    outfile = ipynb + ".html"
    open(outfile, 'w').write(body)
    print("wrote %s" % outfile)
Example #4
0
    def handle(self, *args, **options):

        User = get_user_model()
        helpers = [
            ("Date", "datetime, timedelta, time"),
            ("django.utils", "timezone, termcolors, dateformat, translation."),
            ("%quickref", "Quick reference."),
            ("User", "Django Auth Model"),
            ("help", "Python's own help system."),
            ("object?", "Details about 'object'"),
            ("object??", "More Details about 'object' "),
        ]
        registered_models = {}
        for model in apps.get_models():
            module = model.__module__
            name = model.__name__
            locals()[name] = model
            try:
                registered_models[module].append(name)
            except:
                registered_models[module] = [name]

        for module in registered_models:
            helpers.append((module, ", ".join(registered_models[module])))

        banner2 = "\n".join(["%s: %s" % (colorize(x, fg="yellow"), y) for x, y in helpers]) + "\n"
        banner = "Hi! \n\n" \
                 "Here some useful shortcuts (Crtl-D to exit):"

        c = get_config()

        c.InteractiveShell.banner1 = banner
        c.InteractiveShell.banner2 = banner2
        c.TerminalInteractiveShell.confirm_exit = False
        c.PromptManager.in_template = '$ '
        c.PromptManager.out_template = '> '

        embed(config=c)
Example #5
0
 def _config_default(self):
     return get_config()
Example #6
0
    background_color = '#002b36'


class SolarizedLight(Solarized):
    styles = {**solarized_common, **light}


class SolarizedDark(Solarized):
    styles = {**solarized_common, **dark}


def get_style_by_name(name, original=interactiveshell.get_style_by_name):
    if name.startswith('solarized'):
        return SolarizedDark if name.endswith('dark') else SolarizedLight
    else:
        return original(name)


interactiveshell.get_style_by_name = get_style_by_name
c = get_config()

c.TerminalInteractiveShell.highlighting_style = 'solarized_dark'
c.TerminalInteractiveShell.highlighting_style_overrides = {
    Token.Prompt: GREEN,
    Token.PromptNum: 'bold ' + GREEN,
    Token.OutPrompt: RED,
    Token.OutPromptNum: 'bold ' + RED,
}
c.TerminalInteractiveShell.true_color = True
c.TerminalInteractiveShell.editing_mode = 'vi'
Example #7
0
 def __init__(self, config=None):
     super(MetricaIdsMixin, self).__init__(config=get_config())