repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
notebook
notebook/app.py
.py
"""Jupyter notebook application.""" from __future__ import annotations import os import re import typing as t from pathlib import Path from jupyter_client.utils import ensure_async # type:ignore[attr-defined] from jupyter_core.paths import jupyter_config_dir from jupyter_server.base.handlers import JupyterHandler f...
367
13,736
notebook
notebook/_version.py
.py
"""Version info for notebook.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import re from collections import namedtuple # Use "hatch version xx.yy.zz" to handle version changes __version__ = "7.7.0a1" # PEP440 version parser _version_regex = re.compile( ...
41
988
notebook
notebook/__main__.py
.py
"""CLI entry point for notebook.""" import sys from notebook.app import main sys.exit(main()) # type:ignore[no-untyped-call]
8
129
notebook
notebook/__init__.py
.py
from __future__ import annotations from typing import Any from ._version import __version__, version_info # noqa: F401 def _jupyter_server_extension_paths() -> list[dict[str, str]]: return [{"module": "notebook"}] def _jupyter_server_extension_points() -> list[dict[str, Any]]: # Deferred import to avoid ...
21
623
jupyterlab
clean.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os import subprocess here = os.path.abspath(os.path.dirname(__file__)) # Workaround for https://github.com/git-for-windows/git/issues/607 if os.name == "nt": for root, dnames, _ in os.walk(here): ...
44
1,331
jupyterlab
buildapi.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. # Custom build target that removes .js.map files for published # dist files. import glob import json import os import subprocess from collections.abc import Sequence from hatch_jupyter_builder import npm_builder from ...
48
1,364
jupyterlab
conftest.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from __future__ import annotations from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.nodes impor...
48
1,392
jupyterlab
jupyterlab/debuglog.py
.py
"""A mixin for adding a debug log file.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import contextlib import logging import os import sys import tempfile import traceback import warnings from collections.abc import Iterator from typing import Protocol, cast ...
81
2,602
jupyterlab
jupyterlab/utils.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import functools import warnings from collections.abc import Callable from typing import ParamSpec, TypeVar P = ParamSpec("P") R = TypeVar("R") class jupyterlab_deprecation(Warning): # noqa """Create our own de...
78
2,578
jupyterlab
jupyterlab/labhubapp.py
.py
"""A JupyterHub EntryPoint that defaults to use JupyterLab""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os import sys from collections.abc import Sequence from jupyter_server.serverapp import ServerApp from traitlets import default from .labapp impor...
68
2,165
jupyterlab
jupyterlab/__init__.py
.py
"""Server extension for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from ._version import __version__ # noqa from .serverextension import load_jupyter_server_extension # noqa from .handlers.announcements import ( CheckForUpdate, # noqa ...
23
661
jupyterlab
jupyterlab/serverextension.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyter_server.serverapp import ServerApp from jupyter_server.utils import url_path_join from tornado.web import RedirectHandler def load_jupyter_server_extension(serverapp: ServerApp): from .labapp import L...
73
2,592
jupyterlab
jupyterlab/labextensions.py
.py
"""Jupyter LabExtension Entry Points.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os import subprocess import sys from collections.abc import Sequence from copy import copy from jupyter_core.application import JupyterApp, base_aliases, base_flags fro...
547
18,538
jupyterlab
jupyterlab/federated_labextensions.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from typing import Any from jupyter_builder.federated_extensions import ( build_labextension as _build_labextension, ) from jupyter_builder.federated_extensions import ( develop_labextension as _develop_labext...
48
1,453
jupyterlab
jupyterlab/labapp.py
.py
"""A tornado based Jupyter lab server.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import dataclasses import json import os import sys from collections.abc import Sequence from jupyter_core.application import JupyterApp, NoStart, base_aliases, base_flags fr...
964
34,834
jupyterlab
jupyterlab/pytest_plugin.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import urllib.parse from collections.abc import Awaitable, Mapping from pathlib import Path from typing import Any, Protocol import pytest from jupyter_server.serverapp import ServerApp from jupyter_server.utils impor...
153
4,579
jupyterlab
jupyterlab/commands.py
.py
"""JupyterLab command handler""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import contextlib import errno import hashlib import itertools import json import logging import os import os.path as osp import re import shutil import site import stat import subproce...
2,785
98,953
jupyterlab
jupyterlab/coreconfig.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os import os.path as osp from itertools import filterfalse from typing import TypedDict, overload HERE = os.path.dirname(os.path.abspath(__file__)) def pjoin(*args: str | os.PathLike[str]) -> str:...
197
6,241
jupyterlab
jupyterlab/upgrade_extension.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import configparser import json import re import shutil import subprocess import sys try: import tomllib except ImportError: import tomli as tomllib from importlib.resources import files from pathlib import P...
344
12,544
jupyterlab
jupyterlab/browser_check.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """ This module is meant to run JupyterLab in a headless browser, making sure the application launches and starts up without errors. """ import asyncio import inspect import logging import os import shutil import subp...
233
8,033
jupyterlab
jupyterlab/extensions/manager.py
.py
"""Base classes for the extension manager.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import re from dataclasses import dataclass, field, fields, replace from pathlib import Path import tornado from jupyterlab_server.translation_utils import tr...
712
27,539
jupyterlab
jupyterlab/extensions/__init__.py
.py
"""Extension manager for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from importlib.metadata import entry_points from traitlets.config import Configurable from .manager import ActionResult, ExtensionManager, ExtensionPackage # noqa: F401 from ...
40
1,117
jupyterlab
jupyterlab/extensions/pypi.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Extension manager using pip as package manager and PyPi.org as packages source.""" import asyncio import http.client import io import json import math import re import sys import tempfile import xmlrpc.client from ...
719
27,560
jupyterlab
jupyterlab/extensions/readonly.py
.py
"""Extension manager without installation capabilities.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import sys from jupyterlab_server.translation_utils import translator from .manager import ActionResult, ExtensionManager, ExtensionManagerMetadata, Extensi...
85
2,895
jupyterlab
jupyterlab/handlers/plugin_manager_handler.py
.py
"""Tornado handlers for plugin management.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import dataclasses import json from jupyter_server.base.handlers import APIHandler from tornado import web from jupyterlab.extensions.manager import PluginManager clas...
65
1,915
jupyterlab
jupyterlab/handlers/extension_manager_handler.py
.py
"""Tornado handlers for extension management.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import dataclasses import json from urllib.parse import urlencode, urlunparse from jupyter_server.base.handlers import APIHandler from tornado import web from jupyter...
147
5,291
jupyterlab
jupyterlab/handlers/error_handler.py
.py
"""An error handler for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ExtensionHandlerMixin from tornado import web TEMPLATE = """ <!DOCTYPE HTML>...
40
970
jupyterlab
jupyterlab/handlers/announcements.py
.py
"""Announcements handler for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import abc import hashlib import json import xml.etree.ElementTree as ET from collections.abc import Awaitable from dataclasses import asdict, dataclass, field from datetime...
295
10,010
jupyterlab
jupyterlab/handlers/build_handler.py
.py
"""Tornado handlers for frontend config storage.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import logging from asyncio import Future from collections.abc import Generator from concurrent.futures import ThreadPoolExecutor from threading import Ev...
199
6,353
jupyterlab
jupyterlab/tests/test_jupyterlab.py
.py
"""Test installation of JupyterLab extensions""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import glob import json import logging import os import platform import shutil import subprocess import sys from os.path import join as pjoin from pathlib import Path fr...
810
31,248
jupyterlab
jupyterlab/tests/test_registry.py
.py
"""Test yarn registry replacement""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import logging import subprocess from os.path import join as pjoin from unittest.mock import patch from jupyterlab import commands from .test_jupyterlab import AppHandlerTest c...
113
4,323
jupyterlab
jupyterlab/tests/test_app.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """A lab app that runs a sub process for a demo or a test.""" import atexit import json import os import shutil import sys import tempfile from importlib.resources import files from os import path as osp from os.path ...
228
7,139
jupyterlab
jupyterlab/tests/__init__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from typing import NamedTuple class Response(NamedTuple): """Fake tornado response.""" body: bytes def fake_client_factory(): class FakeClient: """Fake AsyncHTTPClient body can be set ...
26
500
jupyterlab
jupyterlab/tests/test_custom_css_handler.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os import pytest CUSTOM_CSS = """body #top-panel-wrapper, #jp-top-bar { background-color: #aecad4 !important; } body h1 { font-size: 22px; margin-bottom: 40px; color: #10929e; text-decoration: under...
38
1,066
jupyterlab
jupyterlab/tests/echo_kernel.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import logging from ipykernel.kernelapp import IPKernelApp from ipykernel.kernelbase import Kernel class EchoKernel(Kernel): implementation = "Echo" implementation_version = "1.0" language = "echo" l...
54
1,555
jupyterlab
jupyterlab/tests/test_plugin_manager_handler.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import pytest from jupyterlab_server.config import get_static_page_config from tornado.httpclient import HTTPClientError from jupyterlab.commands import get_app_info, lock_extension, unlock_extension from...
160
5,665
jupyterlab
jupyterlab/tests/test_announcements.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import hashlib import json from unittest.mock import patch from . import fake_client_factory FAKE_ATOM_FEED = b"""<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https...
232
14,346
jupyterlab
jupyterlab/tests/test_extensions.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import sys from unittest.mock import AsyncMock, Mock, patch import pytest from tornado import web from traitlets.config import Config, Configurable from jupyterlab.extensions import PyPIExtensionManager, ...
666
25,825
jupyterlab
jupyterlab/tests/test_build_api.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Test the kernels service API.""" import asyncio import json import os from tempfile import TemporaryDirectory import pytest import tornado def expected_http_error(error, expected_code, expected_message=None): ...
120
3,605
jupyterlab
jupyterlab/tests/conftest.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import pytest from jupyterlab import __version__ from jupyterlab.handlers.announcements import ( CheckForUpdate, CheckForUpdateHandler, NewsHandler, check_update_handler_path, news_handler_path, ) ...
48
1,327
jupyterlab
jupyterlab/tests/mock_packages/service-manager-extension/mock_service_manager_package.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os.path as osp HERE = osp.abspath(osp.dirname(__file__)) with open(osp.join(HERE, "package.json")) as fid: data = json.load(fid) def _jupyter_labextension_paths(): return [{"src": data["j...
15
383
jupyterlab
jupyterlab/tests/mock_packages/interop/provider/jlab_mock_provider.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os.path as osp HERE = osp.abspath(osp.dirname(__file__)) with open(osp.join(HERE, "static", "package.json")) as fid: data = json.load(fid) def _jupyter_labextension_paths(): return [{"src...
15
393
jupyterlab
jupyterlab/tests/mock_packages/test-hyphens/test_hyphens/__init__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. def _jupyter_labextension_paths(): return [{"src": "labextension", "dest": "test-hyphens"}]
7
199
jupyterlab
jupyterlab/tests/mock_packages/test-hyphens-underscore/test_hyphens_underscore/__init__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. def _jupyter_labextension_paths(): return [{"src": "labextension", "dest": "test-hyphens-underscore"}]
7
210
jupyterlab
jupyterlab/tests/mock_packages/test_no_hyphens/test_no_hyphens/__init__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. def _jupyter_labextension_paths(): return [{"src": "labextension", "dest": "test_no_hyphens"}]
7
202
jupyterlab
jupyterlab/galata/__init__.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import getpass import os from pathlib import Path from tempfile import NamedTemporaryFile, mkdtemp from traitlets.config import Config def configure_jupyter_server(c: Config): """Helper to configure the Jupyter ...
50
1,764
jupyterlab
packages/services/examples/browser-require/main.py
.py
""" Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. """ import os import os.path as osp from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin from jupyter_server.utils impo...
67
2,321
jupyterlab
packages/services/examples/node/main.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os.path as osp from jupyterlab_server.process import which from jupyterlab_server.process_app import ProcessApp HERE = osp.dirname(osp.realpath(__file__)) def _jupyter_server_extension_points() -...
40
1,154
jupyterlab
packages/services/examples/typescript-browser-with-output/main.py
.py
""" Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. """ import json import os import os.path as osp from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin from jupyter_serve...
73
2,501
jupyterlab
packages/services/examples/browser/main.py
.py
""" Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. """ import json import os import os.path as osp from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ExtensionHandlerJinjaMixin, ExtensionHandlerMixin from jupyter_serve...
73
2,501
jupyterlab
packages/extensionmanager-extension/examples/listings/main.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import os HERE = os.path.dirname(__file__) os.environ["JUPYTERLAB_SETTINGS_DIR"] = str(os.path.join(HERE, "settings")) import json # noqa from jupyter_server.base.handlers import FileFindHandler # noqa from jupyt...
41
1,130
jupyterlab
packages/ui-components/examples/simple-windowed-list/main.py
.py
""" An example demonstrating a stand-alone windowed list. Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyter_server....
80
2,598
jupyterlab
binder/jupyter_config.py
.py
"""An INSECURE configuration for Jupyter Server, intended only for mybinder.org.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import logging common = [ "--no-browser", "--debug", "--port={port}", "--ServerApp.ip=127.0.0.1", '--IdentityProv...
54
1,265
jupyterlab
docs/source/_ext/typedoc_links.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """ Sphinx extension for TypeDoc cross-references. Provides semantic roles for linking to TypeDoc-generated API documentation. """ import os from collections.abc import Callable from pathlib import Path from typing im...
157
5,019
jupyterlab
docs/source/_ext/spelling_filters.py
.py
#!/usr/bin/env python3 # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Custom filters for ``sphinxcontrib.spelling``.""" from __future__ import annotations import re from enchant.tokenize import Filter # Ignore identifier-like words common in docs code snippe...
40
1,016
jupyterlab
docs/source/_ext/shellcheck_builder.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Sphinx builder to lint shell snippets with shellcheck.""" from __future__ import annotations import json import os import subprocess import textwrap from pathlib import Path from shutil import which from typing im...
187
6,026
jupyterlab
scripts/watch_packages.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterlab.commands import watch_packages if __name__ == "__main__": procs = watch_packages() procs[0].wait()
9
226
jupyterlab
scripts/ensure_typedoc_links.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Provide consistent URL destinations for TypeDoc.""" import sys from pathlib import Path HERE = Path(__file__).parent.resolve() ROOT = HERE.parent #: a basic HTTP redirect REDIRECT = """<meta http-equiv="refresh" co...
67
2,066
jupyterlab
scripts/unpack_snapshots.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. #!/usr/bin/env python3 """ Process Playwright test reports and unpack snapshots to their correct locations. This script reads JSON test reports from Playwright's JSON reporter and extracts snapshot files from the test...
294
9,470
jupyterlab
scripts/milestone_check.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. # Generate a GitHub token at https://github.com/settings/tokens # Invoke this script using something like: # python scripts/milestone_check.py import os import subprocess import sys import requests ranges = { "0...
249
6,786
jupyterlab
scripts/i18n_check.py
.py
"""Handle a hash digest of the translatable strings.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from hashlib import sha256 from pathlib import Path from tempfile import TemporaryDirectory import polib from jupyterlab_translate.api import extract_language_pa...
31
1,026
jupyterlab
scripts/analyze_flaky_tests.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Analyze recent Galata workflow runs for hard-failing and flaky tests.""" from __future__ import annotations import argparse import html import json import os import re import sys from collections import Counter fro...
552
18,335
jupyterlab
scripts/watch_dev.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterlab.commands import watch_dev if __name__ == "__main__": procs = watch_dev() procs[0].wait()
9
216
jupyterlab
galata/update_snapshots.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import argparse import hashlib import json import shutil from pathlib import Path parser = argparse.ArgumentParser(description="Update Galata Snapshot images.") parser.add_argument("report", help="Path to the galata-r...
43
1,492
jupyterlab
galata/jupyter_server_csp_test_config.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterlab.galata import configure_jupyter_server configure_jupyter_server(c) c.LabApp.dev_mode = True c.ServerApp.allow_origin = "null" c.ServerApp.tornado_settings = {"headers": {"Content-Security-Policy": "san...
10
342
jupyterlab
galata/test/jupyterlab/notebooks/code_script.py
.py
a = 1 b = 2 c = a + b print(c == (a + b))
5
42
jupyterlab
galata/test/jupyterlab/notebooks/completer_panel.py
.py
def option_1(): """Documentation of 1st option. This docstring is intentionally long to fill the documentation panel box. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vel auctor felis. Phasellus non risus maximus tortor molestie consectetur. Suspendisse in mauris eget nunc im...
16
580
jupyterlab
galata/test/documentation/add.py
.py
def add(x, y): return x + y
3
32
jupyterlab
examples/example_check.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """ This file is mean to be called with a path to an example directory as its argument. We import the application entry point for the example and add instrument them with a Playwright test that makes sure there are no...
160
5,509
jupyterlab
examples/test_examples.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """ This file is meant to be used to test all of the example here and and in ../packages/services/examples. We import each of the applications and add instrument them with a Playwright test that makes sure there are n...
72
2,326
jupyterlab
examples/terminal/main.py
.py
""" An example demonstrating a stand-alone "terminal". Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyter_server.bas...
83
2,787
jupyterlab
examples/localization/main.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """A standalone application demonstrating localization.""" from __future__ import annotations import json import os from jupyter_server.base.handlers import APIHandler, JupyterHandler from jupyter_server.extension.h...
127
4,289
jupyterlab
examples/console/main.py
.py
""" An example demonstrating a stand-alone "console". Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyterlab_server i...
53
1,476
jupyterlab
examples/notebook/main.py
.py
""" An example demonstrating a stand-alone "notebook". Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyter_server.bas...
80
2,561
jupyterlab
examples/federated/main.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os from jupyterlab_server import LabServerApp HERE = os.path.abspath(os.path.dirname(__file__)) # Turn off the Jupyter configuration system so configuration files on disk do # not affect this app....
48
1,664
jupyterlab
examples/cell/main.py
.py
""" An example demonstrating a stand-alone "notebook". Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyter_server.bas...
80
2,595
jupyterlab
examples/app/main.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. import json import os from jupyterlab_server import LabServerApp HERE = os.path.dirname(__file__) # Turn off the Jupyter configuration system so configuration files on disk do # not affect this app. This helps this ...
46
1,478
jupyterlab
examples/filebrowser/main.py
.py
""" An example demonstrating a stand-alone "filebrowser". Copyright (c) Jupyter Development Team. Distributed under the terms of the Modified BSD License. Example ------- To run the example, see the instructions in the README to build it. Then run ``python main.py``. """ import json import os from jupyterlab_serv...
54
1,511
ipython
setupbase.py
.py
# encoding: utf-8 """ This module defines the things that are used in setup.py for building IPython This includes: * The basic arguments to setup * Functions for finding things like packages, package data, etc. * A function for checking dependencies. """ # Copyright (c) IPython Development Team. # Distri...
213
7,218
ipython
setup.py
.py
# -*- coding: utf-8 -*- """Setup script for IPython. Under Posix environments it works like a typical setup.py script. Under Windows, the command sdist is not supported, since IPython requires utilities which are not available under Windows.""" #------------------------------------------------------------------------...
102
3,233
ipython
conftest.py
.py
"""pytest configuration shared by the test modules and the doctests.""" import pytest @pytest.fixture(autouse=True) def stop_script_magics_event_loop(): """Shut the ``%%script`` background event loop down after every test. ``ScriptMagics`` starts an asyncio loop in a daemon thread the first time a scrip...
29
1,117
ipython
tools/fixup_whats_new_pr.py
.py
""" This tool is used during CI testing to make sure sphinx raise no error. During development, we like to have whatsnew/pr/*.rst documents to track individual new features. Unfortunately they other either: - have no title (sphinx complains) - are not included in any toctree (sphinx complain) This fix-them up by ...
41
1,174
ipython
tools/gen_latex_symbols.py
.py
# coding: utf-8 # This script autogenerates `IPython.core.latex_symbols.py`, which contains a # single dict , named `latex_symbols`. The keys in this dict are latex symbols, # such as `\\alpha` and the values in the dict are the unicode equivalents for # those. Most importantly, only unicode symbols that are valid ide...
100
2,939
ipython
tools/importtime_average.py
.py
#!/usr/bin/env python3 """Average several ``python -X importtime`` runs into a single report. ``python -X importtime`` prints, to *stderr*, one line per imported module:: import time: self [us] | cumulative | imported package import time: 146 | 146 | _io import time: 846 | 1223 ...
310
11,098
ipython
tools/update_whatsnew.py
.py
#!/usr/bin/env python """Update the What's New doc (development version) This collects the snippets from whatsnew/pr/, moves their content into whatsnew/development.rst (chronologically ordered), and deletes the snippets. """ import io import sys from pathlib import Path from subprocess import check_call, check_outpu...
82
2,475
ipython
tools/retar.py
.py
""" Un-targz and retargz a targz file to ensure reproducible build. usage: $ export SOURCE_DATE_EPOCH=$(date +%s) # or $ export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) ... $ python retar.py <tarfile.gz> The process of creating an sdist can be non-reproducible: - directory created dur...
88
2,060
ipython
tools/toollib.py
.py
"""Various utilities common to IPython release and maintenance tools. """ # Library imports import os import sys from pathlib import Path # Useful shorthands cd = os.chdir # Build commands # Source dists build_command = "{python} -m build".format(python=sys.executable) # Utility functions def sh(cmd): """Run ...
38
982
ipython
tools/tests/inline_figshow.py
.py
"""Manual test for figure.show() in the inline matplotlib backend. This script should be loaded for interactive use (via %load) into a qtconsole or notebook initialized with the inline backend. Expected behavior: only *one* copy of the figure is shown. For further details: https://github.com/ipython/ipython/issues/...
24
583
ipython
tools/tests/heartbeat/hb_gil.py
.py
""" Run this script in the qtconsole with one of: %load hb_gil.py or %run hb_gil.py Holding the GIL for too long could disrupt the heartbeat. See Issue #1260: https://github.com/ipython/ipython/issues/1260 """ import sys import time from cython import inline def gilsleep(t): """gil-holding sleep wit...
32
574
ipython
tools/tests/embed/embed3.py
.py
"""This tests passing local_ns and global_ns (for backwards compatibility only) at activation of an embedded shell.""" from IPython.terminal.embed import InteractiveShellEmbed user_ns = dict(cookie='monster') ISE = InteractiveShellEmbed(banner1='check cookie in locals, and globals empty') ISE(local_ns=user_ns, global_...
8
327
ipython
tools/tests/embed/embed_no_flufl.py
.py
"""This tests that future compiler flags are passed to the embedded IPython.""" from IPython import embed import __future__ embed(banner1='', header='check 1 <> 2 cause SyntaxError') embed(banner1='', header='check 1 <> 2 == True', compile_flags=__future__.barry_as_FLUFL.compiler_flag)
7
293
ipython
tools/tests/embed/embed1.py
.py
"""This tests standard embedding, automatically detecting the module and local namespaces.""" f = set([1,2,3,4,5]) def bar(foo): import IPython IPython.embed(banner1='check f in globals, foo in locals') bar(f)
11
221
ipython
tools/tests/embed/embed_flufl.py
.py
"""This tests that future compiler flags are passed to the embedded IPython.""" from __future__ import barry_as_FLUFL from IPython import embed embed(banner1='', header='check 1 <> 2 == True') embed(banner1='', header='check 1 <> 2 cause SyntaxError', compile_flags=0)
6
269
ipython
tools/tests/embed/embed2.py
.py
"""This tests passing a dict for the user_ns at shell instantiation.""" from IPython import embed user_ns = dict(cookie='monster') embed(user_ns=user_ns, banner1="check 'cookie' present, locals and globals equivalent")
6
220
ipython
docs/autogen_api.py
.py
#!/usr/bin/env python """Script to auto-generate our API docs. """ import os import sys pjoin = os.path.join here = os.path.abspath(os.path.dirname(__file__)) sys.path.append(pjoin(os.path.abspath(here), 'sphinxext')) from apigen import ApiDocWriter source = pjoin(here, 'source') #********************************...
70
2,408
ipython
docs/autogen_config.py
.py
#!/usr/bin/env python import inspect from pathlib import Path from IPython.terminal.ipapp import TerminalIPythonApp from traitlets import Undefined from collections import defaultdict here = (Path(__file__)).parent options = here / "source" / "config" / "options" generated = options / "config-generated.txt" import t...
123
3,819
ipython
docs/autogen_shortcuts.py
.py
from __future__ import annotations from dataclasses import dataclass from inspect import getsource from pathlib import Path from typing import cast from html import escape as html_escape import re from prompt_toolkit.keys import KEY_ALIASES from prompt_toolkit.key_binding import KeyBindingsBase from prompt_toolkit.fi...
230
6,816
ipython
docs/autogen_magics.py
.py
from pathlib import Path from IPython.core.alias import Alias from IPython.core.interactiveshell import InteractiveShell from IPython.core.magic import MagicAlias from IPython.utils.text import dedent, indent def _strip_underline(line): chars = set(line.strip()) if len(chars) == 1 and ("-" in chars or "=" in ...
74
2,224
ipython
docs/sphinxext/configtraits.py
.py
"""Directives and roles for documenting traitlets config options. :: .. configtrait:: Application.log_datefmt Description goes here. Cross reference like this: :configtrait:`Application.log_datefmt`. """ def setup(app): app.add_object_type("configtrait", "configtrait", objname="Config option")...
17
414
ipython
docs/sphinxext/apigen.py
.py
"""Attempt to generate templates for module reference with Sphinx XXX - we exclude extension modules To include extension modules, first identify them as valid in the ``_uri2path`` method, then handle them in the ``_parse_module`` script. We get functions and classes by parsing the text of .py files. Alternatively w...
464
17,168