-
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 fc65622
Showing
5 changed files
with
23 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,33 @@ | ||
# 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) -> Map: | ||
""" | ||
Adds an stdin Map in the cell outputs, and returns its ID. | ||
Adds an stdin output Map in the cell outputs, and returns it. | ||
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 | ||
outputs.append(stdin_output) | ||
return stdin_output |
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