-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore stdin output when converting to JSON, change structure
- Loading branch information
1 parent
04ab4de
commit 7c55532
Showing
5 changed files
with
27 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,34 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from uuid import uuid4 | ||
from pycrdt import Array, Map, Text | ||
|
||
from pycrdt import Map, Text | ||
|
||
|
||
def add_stdin(cell: Map, prompt: str = "", password: bool = False) -> str: | ||
def add_stdin_output(outputs: Array, prompt: str = "", password: bool = False) -> int: | ||
""" | ||
Adds an stdin Map in the cell outputs, and returns its ID. | ||
Adds an stdin output Map in the cell outputs, and returns its index. | ||
Schema: | ||
.. code-block:: json | ||
{ | ||
"output_type": "stdin", | ||
"id": str, | ||
"submitted": bool, | ||
"password": bool | ||
"prompt": str, | ||
"input": Text | ||
"value": Text | ||
} | ||
""" | ||
idx = uuid4().hex | ||
stdin = Map( | ||
stdin_output = Map( | ||
{ | ||
"output_type": "stdin", | ||
"id": idx, | ||
"submitted": False, | ||
"password": password, | ||
"prompt": prompt, | ||
"input": Text(), | ||
"value": Text(), | ||
} | ||
) | ||
outputs = cell.get("outputs") | ||
outputs.append(stdin) | ||
return idx | ||
stdin_idx = len(outputs) | ||
outputs.append(stdin_output) | ||
return stdin_idx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters