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
jupytext
tests/external/contents_manager/test_contentsmanager_external.py
.py
import re import pytest from jupyter_server.utils import ensure_async import jupytext from jupytext.compare import compare_notebooks, notebook_model pytestmark = pytest.mark.asyncio @pytest.mark.requires_pandoc async def test_save_load_paired_md_pandoc_notebook(ipynb_py_R_jl_file, tmpdir, cm): if re.match(r".*...
54
1,782
jupytext
tests/external/cli/test_black.py
.py
import os from copy import deepcopy from shutil import copyfile import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import read, write from jupytext.cli import jupytext, pipe_notebook, system from jupytext.combine import black_invariant from jupytext.compare import compare, compare_...
288
8,843
jupytext
tests/external/cli/test_isort.py
.py
import pytest from jupytext import reads, writes from jupytext.cli import pipe_notebook from jupytext.compare import compare @pytest.mark.requires_isort def test_pipe_into_isort(): text_org = """# %% import numpy as np np.array([1,2,3]) # %% import pandas as pd pd.Series([1,2,3]) # %% # This is a comment on th...
42
786
jupytext
tests/external/cli/test_cli_check.py
.py
import pytest from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import write from jupytext.cli import jupytext @pytest.fixture def non_black_notebook(python_notebook): return new_notebook(metadata=python_notebook.metadata, cells=[new_code_cell("1+1")]) @pytest.mark.requires_black def tes...
32
1,049
jupytext
tests/external/round_trip/test_mirror_external.py
.py
import pytest from jupytext.compare import assert_conversion_same_as_mirror """--------------------------------------------------------------------------------- Part I: ipynb -> fmt -> ipynb ---------------------------------------------------------------------------------""" @pytest.mark.requires_pandoc def test_...
54
1,708
jupytext
tests/data/notebooks/inputs/hydrogen/hydrogen_latex_html_R_magics.py
.py
# %% 1 + 1 # %% import pandas as pd pd.Series({'A':5, 'B':2}).plot() # %% %matplotlib inline pd.Series({'A':5, 'B':2}).plot(figsize=(3,2)) # %% %%html <p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p> # %% %load_ext rpy2.ipython # %% %%R -w 400 -h 200 library(g...
27
438
jupytext
tests/data/notebooks/inputs/percent/hydrogen.py
.py
# %% import pandas as pd # %% Display a data frame df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}, index=pd.Index(['x0', 'x1'], name='x')) df # %% Pandas plot {"tags": ["parameters"]} df.plot(kind='bar')
11
222
jupytext
tests/data/notebooks/inputs/marimo/basic_marimo_example.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" This is a simple marimo notebook """) return @app.cell def _(): x = 1 return (x,) @app.cell def _(x): y = x+1 y return @app.cell def _(): import marimo as mo ...
36
376
jupytext
tests/data/notebooks/inputs/python/light_sample.py
.py
# --- # jupyter: # jupytext: # formats: ipynb,py:light # --- # # Sample notebook a = 1 b = 2 a + b
12
107
jupytext
tests/data/notebooks/inputs/sphinx/plot_notebook.py
.py
# -*- coding: utf-8 -*- """ Notebook styled examples ======================== The gallery is capable of transforming Python files into reStructuredText files with a notebook structure. For this to be used you need to respect some syntax rules. It makes a lot of sense to contrast this output rst file with the :downloa...
117
4,231
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/text_outputs_and_images.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains outputs of many different types: text, HTML, plots and errors. # # Text outputs # # Using `print`, `sys.stdout` and `sys.stderr` i...
64
1,186
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/Notebook_with_more_R_magic_111.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # region # %load_ext rpy2.ipython import pandas as pd df = pd.DataFrame( { "Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], "X":...
29
610
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/plotly_graphs.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains complex outputs, including plotly javascript graphs. # # Interactive plots # We use Plotly's connected mode to make the notebook l...
27
664
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vscode_folding_markers/jupyter_again.py
.py
# --- # jupyter: # jupytext: # cell_markers: region,endregion # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' impor...
25
367
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/convert_to_py_then_test_with_update83.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %%time print('asdf') """ Thanks for jupytext! """
18
168
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/text_outputs_and_images.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- """ This notebook contains outputs of many different types: text, HTML, plots and errors. """ ############################################################################### # # Text outputs # # Using `print...
71
1,470
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/Line_breaks_in_LateX_305.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- """ This cell uses no particular cell marker $$ \begin{align} \dot{x} & = \sigma(y-x)\\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{align} $$ """ ##########################################...
43
806
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/plotly_graphs.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- """ This notebook contains complex outputs, including plotly javascript graphs. """ ############################################################################### # # Interactive plots ####################...
30
782
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/nteract_with_parameter.py
.py
# --- # jupyter: # kernel_info: # name: python3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- param = 4 "" import pandas as pd "" df = pd.DataFrame({'A': [1, 2], 'B': [3 + param, 4]}, index=pd.Index(['x0', 'x1'], name='x')) df "" # %matplotlib ...
24
347
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/jupyterlab-slideshow_1441.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- """ > **Note** > > `slide` layer with a `top` of `30%` """
14
184
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/sample_rise_notebook_66.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- """ A markdown cell """ 1+1 ############################################################################### # Markdown cell two
17
242
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/jupyter_again.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' "" import yaml print(yaml.dump(yaml.load(c))) "" # ?nex...
25
322
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/jupyter.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- """ # Jupyter notebook This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells. We start with an addition: """ a = 1 b = 2 a + b ...
29
576
jupytext
tests/data/notebooks/outputs/ipynb_to_percent/text_outputs_and_images.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% [markdown] # This notebook contains outputs of many different types: text, HTML, plots and errors. # %% [markdown] # # Text outputs # # Using `print`, `sys.stdout` and `sys.stderr` # %% import sys prin...
74
1,250
jupytext
tests/data/notebooks/outputs/ipynb_to_percent/Notebook_with_more_R_magic_111.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% # %load_ext rpy2.ipython import pandas as pd df = pd.DataFrame( { "Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], "X": [4, 3, 5, 2, 1, 7, 7, 5, 9], "Y": [0, 4, 3, 6,...
25
527
jupytext
tests/data/notebooks/outputs/ipynb_to_percent/jupyter_again.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' # %% import yaml print(yaml.dump(yaml.load(c))) # ...
26
331
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/text_outputs_and_images.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains outputs of many different types: text, HTML, plots and errors. # # Text outputs # # Using `print`, `sys.stdout` and `sys.stderr` import s...
64
1,179
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/Notebook_with_more_R_magic_111.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # {{{ # %load_ext rpy2.ipython import pandas as pd df = pd.DataFrame( { "Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], "X": [4, 3, 5,...
29
585
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/plotly_graphs.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains complex outputs, including plotly javascript graphs. # # Interactive plots # We use Plotly's connected mode to make the notebook lighter ...
27
657
jupytext
tests/data/notebooks/outputs/ipynb_to_script_vim_folding_markers/jupyter_again.py
.py
# --- # jupyter: # jupytext: # cell_markers: '{{{,}}}' # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' import yaml ...
25
360
jupytext
tests/data/notebooks/outputs/ipynb_to_hydrogen/text_outputs_and_images.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% [markdown] # This notebook contains outputs of many different types: text, HTML, plots and errors. # %% [markdown] # # Text outputs # # Using `print`, `sys.stdout` and `sys.stderr` # %% import sys prin...
74
1,248
jupytext
tests/data/notebooks/outputs/ipynb_to_hydrogen/Notebook_with_more_R_magic_111.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% %load_ext rpy2.ipython import pandas as pd df = pd.DataFrame( { "Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], "X": [4, 3, 5, 2, 1, 7, 7, 5, 9], "Y": [0, 4, 3, 6, 7...
26
499
jupytext
tests/data/notebooks/outputs/ipynb_to_hydrogen/Notebook with html and latex cells.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% %%html <p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p> # %% %%latex $\frac{\pi}{2}$ # %% %load_ext rpy2.ipython # %% %%R library(ggplot2) ggplot...
29
497
jupytext
tests/data/notebooks/outputs/ipynb_to_hydrogen/nteract_with_parameter.py
.py
# --- # jupyter: # kernel_info: # name: python3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% inputHidden=false outputHidden=false tags=["parameters"] param = 4 # %% inputHidden=false outputHidden=false import pandas as pd # %% inputHidden=false outputHidden...
25
524
jupytext
tests/data/notebooks/outputs/ipynb_to_hydrogen/jupyter_again.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # %% c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' # %% import yaml print(yaml.dump(yaml.load(c))) # ...
26
329
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/Notebook with many hash signs.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" ################################################################## This is a notebook that contains many hash signs. Hopefully its python representation is not recognized as a Sphinx Gallery s...
50
1,136
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/text_outputs_and_images.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" This notebook contains outputs of many different types: text, HTML, plots and errors. """) return @app.cell(hide_code=True) def _(mo): mo.md(r""" # Text outputs Using `print`, `...
127
1,987
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/cat_variable.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell def _(): cat = 42 return if __name__ == "__main__": app.run()
15
150
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/Notebook with function and cell metadata 164.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell def _(): 1 + 1 return @app.cell(hide_code=True) def _(mo): mo.md(r""" A markdown cell And below, the cell for function f has non trivial cell metadata. And the next cell as well. """) return @app.function def f(x):...
55
610
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/Line_breaks_in_LateX_305.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" This cell uses no particular cell marker $$ \begin{align} \dot{x} & = \sigma(y-x)\\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{align} $$ """) re...
63
1,064
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/frozen_cell.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell def _(): # This is an unfrozen cell. Works as usual. print("I'm a regular cell so I run and print!") return @app.cell def _(): # This is an frozen cell print("I'm frozen so Im not executed :(") return if __name__ == "_...
23
344
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/plotly_graphs.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" This notebook contains complex outputs, including plotly javascript graphs. """) return @app.cell(hide_code=True) def _(mo): mo.md(r""" # Interactive plots """) return @app...
58
992
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/notebook_with_complex_metadata.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell def _(): return if __name__ == "__main__": app.run()
14
137
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/sample_rise_notebook_66.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" A markdown cell """) return @app.cell def _(): 1+1 return @app.cell(hide_code=True) def _(mo): mo.md(r""" Markdown cell two """) return @app.cell def _(): imp...
37
397
jupytext
tests/data/notebooks/outputs/ipynb_to_marimo/jupyter.py
.py
import marimo __generated_with = "0.17.8" app = marimo.App() @app.cell(hide_code=True) def _(mo): mo.md(r""" # Jupyter notebook This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells. We start with an addition: """) ret...
61
818
jupytext
tests/data/notebooks/outputs/ipynb_to_script/text_outputs_and_images.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains outputs of many different types: text, HTML, plots and errors. # # Text outputs # # Using `print`, `sys.stdout` and `sys.stderr` import sys print('using print') sys.stdout.write('us...
62
1,135
jupytext
tests/data/notebooks/outputs/ipynb_to_script/Notebook_with_more_R_magic_111.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # + # %load_ext rpy2.ipython import pandas as pd df = pd.DataFrame( { "Letter": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], "X": [4, 3, 5, 2, 1, 7, 7, 5, 9], "Y": [0, 4, 3, 6, ...
25
525
jupytext
tests/data/notebooks/outputs/ipynb_to_script/plotly_graphs.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # This notebook contains complex outputs, including plotly javascript graphs. # # Interactive plots # We use Plotly's connected mode to make the notebook lighter - when connected, the notebook downloads the...
25
613
jupytext
tests/data/notebooks/outputs/ipynb_to_script/jupyter_again.py
.py
# --- # jupyter: # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- c = ''' title: "Quick test" output: ioslides_presentation: widescreen: true smaller: true editor_options: chunk_output_type console ''' import yaml print(yaml.dump(yaml.load(c))) # ?next
23
316
jupytext
src/jupytext_config/labconfig.py
.py
""" helper to inspect / initialize jupyterlab labconfig settings that are required to open jupytext notebooks in jupyterlab by default when these settings are not present, a double click on a jupytext notebook will cause jupyterlab to open it in an editor, i.e. as a text file """ import json import logging from pathli...
83
2,473
jupytext
src/jupytext_config/__main__.py
.py
"""Main for Jupytext_config Call with (e.g.):: python -m jupytext_config list-default-viewer """ import sys from .jupytext_config import main if __name__ == "__main__": sys.exit(main())
14
199
jupytext
src/jupytext_config/jupytext_config.py
.py
""" the code for jupytext-config set-default-viewer and related subcommands """ import sys from argparse import ArgumentParser from pathlib import Path import jupyter_core.paths as jupyter_core_paths from .labconfig import LabConfig class SubCommand: """ a subcommand for jupytext-config """ def __...
97
2,660
jupytext
src/jupytext/header.py
.py
"""Parse header of text notebooks""" import logging import re import nbformat import yaml from nbformat.v4.nbbase import new_raw_cell from yaml.representer import SafeRepresenter from .languages import ( _SCRIPT_EXTENSIONS, comment_lines, default_language_from_metadata_and_ext, ) from .metadata_filter im...
342
12,122
jupytext
src/jupytext/compare.py
.py
"""Compare two Jupyter notebooks""" import difflib import json import os import re from jupytext.marimo import marimo_version from jupytext.paired_paths import full_path from .cell_metadata import _IGNORE_CELL_METADATA from .combine import combine_inputs_with_outputs from .formats import check_auto_ext, long_form_on...
412
15,096
jupytext
src/jupytext/kernels.py
.py
"""Find kernel specifications for a given language""" import os import sys from .languages import same_language from .reraise import reraise try: # I prefer not to take a dependency on jupyter_client from jupyter_client.kernelspec import find_kernel_specs, get_kernel_spec except ImportError as err: find_...
57
2,158
jupytext
src/jupytext/formats.py
.py
""" In this file the various text notebooks formats are defined. Please contribute new formats here! """ import os import re import warnings import nbformat import yaml from .cell_reader import ( DoublePercentScriptCellReader, HydrogenCellReader, LightScriptCellReader, MarkdownCellReader, RMarkdo...
829
30,958
jupytext
src/jupytext/combine.py
.py
"""Combine source and outputs from two notebooks""" import re from copy import copy from nbformat import NotebookNode from .cell_metadata import _IGNORE_CELL_METADATA from .formats import long_form_one_format from .header import _DEFAULT_NOTEBOOK_METADATA from .metadata_filter import restore_filtered_metadata _BLAN...
178
6,447
jupytext
src/jupytext/cell_reader.py
.py
"""Read notebook cells from their text representation""" import re from collections import defaultdict from copy import copy from itertools import count from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_raw_cell from .doxygen import doxygen_to_markdown from .languages import _SCRIPT_EXTENSIONS # ...
956
38,995
jupytext
src/jupytext/cell_to_text.py
.py
"""Export notebook cells as text""" import re import warnings from copy import copy from .cell_metadata import ( _IGNORE_CELL_METADATA, is_active, metadata_to_double_percent_options, metadata_to_rmd_options, metadata_to_text, ) from .cell_reader import LightScriptCellReader, MarkdownCellReader, RM...
543
21,348
jupytext
src/jupytext/languages.py
.py
"""Determine notebook or cell language""" import re # Jupyter magic commands that are also languages _JUPYTER_LANGUAGES = [ "R", "bash", "sh", "python", "python2", "python3", "coconut", "javascript", "js", "perl", "html", "latex", "markdown", "pypy", "ruby",...
228
8,149
jupytext
src/jupytext/pep8.py
.py
"""Determine how many blank lines should be inserted between two cells""" from .stringparser import StringParser def next_instruction_is_function_or_class(lines): """Is the first non-empty, non-commented line of the cell either a function or a class?""" parser = StringParser("python") for i, line in enum...
95
2,899
jupytext
src/jupytext/doxygen.py
.py
"""Convert Markdown equations to doxygen equations and back See https://github.com/mwouts/jupytext/issues/517""" import re def markdown_to_doxygen(string): """Markdown to Doxygen equations""" long_equations = re.sub(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", r"\\f[\g<1>\\f]", string, flags=re.DOTALL) inline_equatio...
19
661
jupytext
src/jupytext/__main__.py
.py
"""Main for Jupytext Call with (e.g.):: python -m jupytext my_notebook.ipynb --to Rmd """ import sys from .cli import jupytext if __name__ == "__main__": sys.exit(jupytext())
14
188
jupytext
src/jupytext/__init__.py
.py
"""Read and write Jupyter notebooks as text files""" from .formats import NOTEBOOK_EXTENSIONS, get_format_implementation, guess_format from .jupytext import read, reads, write, writes from .reraise import reraise from .version import __version__ try: from .sync_contentsmanager import build_sync_jupytext_contents_...
42
1,223
jupytext
src/jupytext/quarto.py
.py
"""Jupyter notebook to Quarto Markdown and back, using 'quarto convert'""" import json import os import shutil import subprocess import sys import tempfile # Copy nbformat reads and writes to avoid them being patched in the contents manager!! from nbformat import reads as ipynb_reads from nbformat import writes as ip...
164
5,995
jupytext
src/jupytext/version.py
.py
"""Jupytext's version number""" # Must match [N!]N(.N)*[{a|b|rc}N][.postN][.devN], cf. PEP 440 __version__ = "1.19.5"
5
119
jupytext
src/jupytext/metadata_filter.py
.py
"""Notebook and cell metadata filtering""" from copy import copy from .cell_metadata import _JUPYTEXT_CELL_METADATA, is_valid_metadata_key _DEFAULT_NOTEBOOK_METADATA = ",".join( [ # Preserve Jupytext section "jupytext", # Preserve kernel specs "kernelspec", # Kernel_info f...
257
9,534
jupytext
src/jupytext/marimo.py
.py
"""Jupyter notebook to Marimo py format and back, using Marimo""" import os from packaging.version import parse import tempfile import subprocess import nbformat MARIMO_MIN_VERSION = "0.16.3" class MarimoError(OSError): """An error related to Marimo""" def is_marimo_available(min_version=MARIMO_MIN_VERSION, m...
156
5,344
jupytext
src/jupytext/stringparser.py
.py
"""A simple file parser that can tell whether the first character of a line is quoted or not""" from .languages import _COMMENT class StringParser: """A simple file parser that can tell whether the first character of a line is quoted or not""" single = None triple = None triple_start = None ...
86
2,427
jupytext
src/jupytext/pandoc.py
.py
"""Jupyter notebook to Markdown and back, using Pandoc""" import os import subprocess import tempfile # Copy nbformat reads and writes to avoid them being patched in the contents manager!! from nbformat import reads as ipynb_reads from nbformat import writes as ipynb_writes from packaging.version import parse class...
119
3,673
jupytext
src/jupytext/myst.py
.py
""" This module contains round-trip conversion between myst formatted text documents and notebooks. """ import json import re import warnings from textwrap import dedent import nbformat as nbf import yaml from yaml.representer import SafeRepresenter from .cell_to_text import three_backticks_or_more from .metadata_fi...
423
14,922
jupytext
src/jupytext/pairs.py
.py
"""Functions to read or write paired notebooks""" from collections import namedtuple from .formats import long_form_multiple_formats, long_form_one_format from .paired_paths import paired_paths NotebookFile = namedtuple("notebook_file", "path fmt timestamp") class PairedFilesDiffer(ValueError): """An error whe...
56
2,226
jupytext
src/jupytext/cli.py
.py
"""`jupytext` as a command line tool""" import argparse import glob import json import os import re import shlex import subprocess import sys import warnings from copy import copy from tempfile import NamedTemporaryFile from typing import Optional from nbformat.sign import NotebookNotary from .combine import combine...
1,397
51,518
jupytext
src/jupytext/async_contentsmanager.py
.py
""" This module exposes the AsyncTextFileContentsManager that allows to open text files as notebooks """ import inspect import itertools import os try: import tomllib except ImportError: import tomli as tomllib from collections import namedtuple from datetime import timedelta import nbformat from tornado.we...
688
29,510
jupytext
src/jupytext/config.py
.py
"""Find and read Jupytext configuration files""" import json import os from pathlib import Path try: import tomllib except ImportError: import tomli as tomllib import warnings import yaml from traitlets import Bool, Dict, Enum, Float, List, Unicode, Union from traitlets.config import Configurable from trait...
528
20,567
jupytext
src/jupytext/cell_metadata.py
.py
""" Convert between text notebook metadata and jupyter cell metadata. Standard cell metadata are documented here: See also https://ipython.org/ipython-doc/3/notebook/nbformat.html#cell-metadata """ import ast import re from json import dumps, loads try: from json import JSONDecodeError except ImportError: JS...
490
16,823
jupytext
src/jupytext/paired_paths.py
.py
"""List all the paths associated to a given notebook""" import os from .config import find_jupytext_configuration_file from .formats import ( NOTEBOOK_EXTENSIONS, long_form_multiple_formats, long_form_one_format, short_form_multiple_formats, short_form_one_format, ) class InconsistentPath(ValueE...
333
11,566
jupytext
src/jupytext/async_pairs.py
.py
import jupytext from .combine import combine_inputs_with_outputs from .compare import compare from .formats import check_file_version, long_form_multiple_formats from .paired_paths import find_base_path_and_format, full_path from .pairs import PairedFilesDiffer async def read_pair(inputs, outputs, read_one_file, mus...
73
2,574
jupytext
src/jupytext/jupytext.py
.py
"""Read and write Jupyter notebooks as text files""" import logging import os import sys import warnings from copy import copy, deepcopy import nbformat from nbformat.v4.nbbase import NotebookNode, new_code_cell, new_notebook from nbformat.v4.rwbase import NotebookReader, NotebookWriter from .cell_metadata import _I...
592
23,870
jupytext
src/jupytext/reraise.py
.py
"""Raise the given error at evaluation time""" def reraise(error): """Return a function that raises the given error when evaluated""" def local_function(*args, **kwargs): raise error return local_function
11
229
jupytext
src/jupytext/magics.py
.py
"""Escape Jupyter magics when converting to other formats""" import re from .languages import _COMMENT, _SCRIPT_EXTENSIONS, usual_language_name from .stringparser import StringParser def get_comment(ext): return re.escape(_SCRIPT_EXTENSIONS[ext]["comment"]) # A magic expression is a line or cell or metakernel...
188
7,346
voila
setup.py
.py
# setup.py shim for use with applications that require it. __import__("setuptools").setup()
3
92
voila
hatch_build.py
.py
import os import sys from urllib.request import urlopen from hatchling.builders.hooks.plugin.interface import BuildHookInterface JUPYTERLAB_APPUTILS_VERSION = "3.2.8" JUPYTERLAB_THEME_LIGHT_VERSION = "3.2.8" CSS_FILES = [ ( f"https://unpkg.com/@jupyterlab/apputils@{JUPYTERLAB_APPUTILS_VERSION}/style/mate...
50
1,667
voila
voila/configuration.py
.py
############################################################################# # Copyright (c) 2018, QuantStack # # Copyright (c) 2018, Voilà Contributors # # # # Distri...
278
9,615
voila
voila/app.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
1,002
36,242
voila
voila/execute.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
155
5,278
voila
voila/utils.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
377
12,860
voila
voila/request_info_handler.py
.py
import logging from typing import Dict from tornado.websocket import WebSocketHandler class RequestInfoSocketHandler(WebSocketHandler): """A websocket handler used to provide the request info associated with kernel ids in preheat kernel mode. Class variables --------------- - _waiters : A dictio...
64
2,215
voila
voila/_version.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
48
1,491
voila
voila/__init__.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
44
1,618
voila
voila/voila_kernel_manager.py
.py
############################################################################# # Copyright (c) 2021, Voilà Contributors # # Copyright (c) 2021, QuantStack # # # # Distri...
462
19,132
voila
voila/shutdown_kernel_handler.py
.py
import tornado from jupyter_server.base.handlers import APIHandler from jupyter_core.utils import ensure_async class VoilaShutdownKernelHandler(APIHandler): """Handler to shut down kernel on page's `beforeunload` event.""" @tornado.web.authenticated async def post(self, kernel_id): await ensure_a...
14
424
voila
voila/treehandler.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
64
2,644
voila
voila/paths.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
167
6,238
voila
voila/handler.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
311
12,571
voila
voila/static_file_handler.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
114
4,642
voila
voila/notebook_renderer.py
.py
############################################################################# # Copyright (c) 2021, Voilà Contributors # # Copyright (c) 2021, QuantStack # # # # Distri...
424
18,201
voila
voila/voila_identity_provider.py
.py
from typing import Any, Optional from jupyter_server.auth.identity import IdentityProvider from jupyter_server.auth.login import LoginFormHandler class VoilaLoginHandler(LoginFormHandler): def static_url( self, path: str, include_host: Optional[bool] = None, **kwargs: Any ) -> str: settings = ...
22
663
voila
voila/server_extension.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
217
7,034
voila
voila/exporter.py
.py
############################################################################# # Copyright (c) 2018, Voilà Contributors # # Copyright (c) 2018, QuantStack # # # # Distri...
199
7,470