Last active
May 20, 2025 19:37
-
-
Save tonyfast/90be628ff99bc3093d166b46cf997f3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "2bdc7974-4db8-41a7-a941-15d7da1853e2", | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import jsonschema, jsonref, jsonpointer, bs4\n", | |
"builder = bs4.BeautifulSoup(features=(FEATURES := \"html.parser\"))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 87, | |
"id": "c9d9a5ef-20f2-4f69-a67b-e3e6a7197729", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/json": { | |
"$defs": { | |
"attachments": { | |
"readOnly": true, | |
"title": "cell source", | |
"type": "string" | |
}, | |
"cell": { | |
"description": "the primary notebook unit containing input source code and formatted output", | |
"properties": { | |
"cell_type": [ | |
"$oneOf", | |
"title", | |
"readOnly" | |
], | |
"id": [ | |
"description", | |
"title", | |
"type", | |
"@type" | |
], | |
"index": [ | |
"description", | |
"title", | |
"type", | |
"minimum" | |
], | |
"metadata": [ | |
"type", | |
"title", | |
"description" | |
], | |
"outputs": [ | |
"type", | |
"title", | |
"items" | |
], | |
"source": [ | |
"type", | |
"title", | |
"readOnly" | |
] | |
}, | |
"title": "cell", | |
"type": "object" | |
}, | |
"cell_type": { | |
"$oneOf": [ | |
[ | |
"type", | |
"title", | |
"description", | |
"const" | |
], | |
[ | |
"type", | |
"title", | |
"description", | |
"const" | |
], | |
[ | |
"type", | |
"title", | |
"description", | |
"const" | |
], | |
[ | |
"type", | |
"title", | |
"description", | |
"const" | |
] | |
], | |
"readOnly": true, | |
"title": "cell type" | |
}, | |
"code_cell": { | |
"const": "code", | |
"description": "", | |
"title": "code", | |
"type": "string" | |
}, | |
"completed_at": { | |
"description": "the time the response received from the kernel to the client\n", | |
"format": "datetime", | |
"title": "end time", | |
"type": [ | |
null, | |
"string" | |
], | |
"writeOnly": true | |
}, | |
"duration": { | |
"description": "the time the response received from the kernel to the client\n", | |
"format": "timedelta", | |
"title": "duration", | |
"type": [ | |
null, | |
"string" | |
], | |
"writeOnly": true | |
}, | |
"id": { | |
"@type": "@id", | |
"description": "a persistent unique identifier for a cell", | |
"title": "cell id", | |
"type": "string" | |
}, | |
"index": { | |
"description": "the ordinal cell number in the document", | |
"minimum": 1, | |
"title": "cell number", | |
"type": "integer" | |
}, | |
"kernel": { | |
"description": "", | |
"title": "", | |
"type": "object" | |
}, | |
"loc": { | |
"description": "lines of code in the source, including whitespace", | |
"minimum": 0, | |
"type": "integer", | |
"writeOnly": true | |
}, | |
"markdown_cell": { | |
"const": "markdown", | |
"description": "", | |
"title": "markdown", | |
"type": "string" | |
}, | |
"metadata": { | |
"description": "", | |
"title": "metadata", | |
"type": "dict" | |
}, | |
"notebook": { | |
"description": "", | |
"properties": { | |
"cells": { | |
"items": [ | |
"type", | |
"title", | |
"description", | |
"properties" | |
], | |
"type": "array" | |
} | |
}, | |
"type": "object" | |
}, | |
"outputs": { | |
"items": { | |
"properties": { | |
"data": { | |
"type": "object" | |
}, | |
"metadata": { | |
"type": "object" | |
}, | |
"output_type": { | |
"enum": [ | |
"display_data", | |
"stdout", | |
"stderr", | |
"stream" | |
] | |
}, | |
"text": { | |
"type": "string" | |
} | |
} | |
}, | |
"title": "outputs", | |
"type": "array" | |
}, | |
"raw_cell": { | |
"const": "raw", | |
"description": "", | |
"title": "raw", | |
"type": "string" | |
}, | |
"source": { | |
"readOnly": true, | |
"title": "cell source", | |
"type": "string" | |
}, | |
"started_at": { | |
"description": "the time the cell source was submitted by the client to the kernel\n", | |
"format": "datetime", | |
"title": "start time", | |
"type": [ | |
null, | |
"string" | |
], | |
"writeOnly": true | |
}, | |
"toolbar": { | |
"title": "cell toolbar", | |
"type": "array" | |
}, | |
"undefined_cell": { | |
"const": "undefined", | |
"description": "", | |
"title": "undefined", | |
"type": "string" | |
} | |
}, | |
"description": "the nonvisual description of a notebook interface\n", | |
"properties": { | |
"columns": { | |
"items": [ | |
{ | |
"items": [ | |
[ | |
"description", | |
"title", | |
"type", | |
"minimum" | |
], | |
[ | |
"description", | |
"title", | |
"type", | |
"@type" | |
] | |
] | |
}, | |
{ | |
"items": [ | |
[ | |
"$oneOf", | |
"title", | |
"readOnly" | |
], | |
[ | |
"type", | |
"title", | |
"readOnly" | |
], | |
[ | |
"type", | |
"title" | |
], | |
[ | |
"type", | |
"description", | |
"format", | |
"title", | |
"writeOnly" | |
], | |
[ | |
"type", | |
"format", | |
"title", | |
"description", | |
"writeOnly" | |
], | |
[ | |
"type", | |
"title", | |
"description", | |
"format", | |
"writeOnly" | |
], | |
[ | |
"type", | |
"title", | |
"items" | |
], | |
[ | |
"type", | |
"title", | |
"description" | |
], | |
[ | |
"type", | |
"title", | |
"readOnly" | |
] | |
] | |
} | |
] | |
} | |
} | |
}, | |
"text/plain": [ | |
"<IPython.core.display.JSON object>" | |
] | |
}, | |
"execution_count": 87, | |
"metadata": { | |
"application/json": { | |
"expanded": 0, | |
"root": "root" | |
} | |
}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"text/x-python": [ | |
"\n", | |
"\n", | |
"JSON(SCHEMA:=\n", | |
" jsonref.replace_refs(raw:=\n", | |
" (__import__(\"importlib\").metadata.EntryPoint(None, \"yaml:safe_load\", None).load()( # ```yaml\n", | |
"\"\"\"description: |\n", | |
" the nonvisual description of a notebook interface\n", | |
"properties:\n", | |
" columns: \n", | |
" items:\n", | |
" - items: \n", | |
" - $ref: \\\"#/$defs/index\\\"\n", | |
" - $ref: \\\"#/$defs/id\\\"\n", | |
" - items:\n", | |
" - $ref: \\\"#/$defs/cell_type\\\"\n", | |
" - $ref: \\\"#/$defs/source\\\"\n", | |
" - $ref: \\\"#/$defs/toolbar\\\"\n", | |
" - $ref: \\\"#/$defs/duration\\\"\n", | |
" - $ref: \\\"#/$defs/started_at\\\"\n", | |
" - $ref: \\\"#/$defs/completed_at\\\"\n", | |
" - $ref: \\\"#/$defs/outputs\\\"\n", | |
" - $ref: \\\"#/$defs/metadata\\\"\n", | |
" - $ref: \\\"#/$defs/attachments\\\"\n", | |
"$defs:\n", | |
" notebook:\n", | |
" type: object\n", | |
" description: \\\"\\\"\n", | |
" properties:\n", | |
" cells:\n", | |
" type: array\n", | |
" items:\n", | |
" $ref: \\\"#/$defs/cell\\\"\n", | |
" cell:\n", | |
" type: object\n", | |
" title: cell\n", | |
" description: the primary notebook unit containing input source code and formatted output\n", | |
" properties:\n", | |
" index: {$ref: \\\"#/$defs/index\\\"}\n", | |
" id: {$ref: \\\"#/$defs/id\\\"}\n", | |
" cell_type: {$ref: \\\"#/$defs/cell_type\\\"}\n", | |
" metadata: {$ref: \\\"#/$defs/metadata\\\"}\n", | |
" outputs: {$ref: \\\"#/$defs/outputs\\\"}\n", | |
" source: {$ref: \\\"#/$defs/source\\\"}\n", | |
" index:\n", | |
" description: the ordinal cell number in the document\n", | |
" title: cell number\n", | |
" type: integer\n", | |
" minimum: 1\n", | |
" id:\n", | |
" description: a persistent unique identifier for a cell\n", | |
" title: cell id\n", | |
" type: string\n", | |
" \\\"@type\\\": \\\"@id\\\"\n", | |
" cell_type:\n", | |
" $oneOf:\n", | |
" - $ref: \\\"#/$defs/code_cell\\\"\n", | |
" - $ref: \\\"#/$defs/markdown_cell\\\"\n", | |
" - $ref: \\\"#/$defs/raw_cell\\\"\n", | |
" - $ref: \\\"#/$defs/undefined_cell\\\"\n", | |
" title: cell type\n", | |
" readOnly: true\n", | |
" source: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" attachments: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" started_at:\n", | |
" type: [null, string]\n", | |
" format: datetime\n", | |
" title: start time\n", | |
" description: |\n", | |
" the time the cell source was submitted by the client to the kernel\n", | |
" writeOnly: true\n", | |
" duration:\n", | |
" type: [null, string]\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: timedelta\n", | |
" title: duration\n", | |
" writeOnly: true\n", | |
" completed_at:\n", | |
" type: [null, string]\n", | |
" title: end time\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: datetime\n", | |
" writeOnly: true\n", | |
" loc:\n", | |
" type: integer\n", | |
" minimum: 0\n", | |
" description: lines of code in the source, including whitespace\n", | |
" writeOnly: true\n", | |
" toolbar:\n", | |
" type: array\n", | |
" title: cell toolbar\n", | |
" code_cell:\n", | |
" type: string\n", | |
" title: code\n", | |
" description: \\\"\\\"\n", | |
" const: code\n", | |
" markdown_cell:\n", | |
" type: string\n", | |
" title: markdown\n", | |
" description: \\\"\\\"\n", | |
" const: markdown\n", | |
" raw_cell:\n", | |
" type: string\n", | |
" title: raw\n", | |
" description: \\\"\\\"\n", | |
" const: raw\n", | |
" undefined_cell:\n", | |
" type: string\n", | |
" title: undefined\n", | |
" description: \\\"\\\"\n", | |
" const: undefined\n", | |
" outputs:\n", | |
" type: array\n", | |
" title: outputs\n", | |
" items:\n", | |
" properties:\n", | |
" data: \n", | |
" type: object\n", | |
" metadata: \n", | |
" type: object\n", | |
" text: \n", | |
" type: string\n", | |
" output_type: \n", | |
" enum: [display_data, stdout, stderr, stream]\n", | |
" metadata: \n", | |
" type: dict\n", | |
" title: metadata\n", | |
" description: \\\"\\\"\n", | |
" kernel:\n", | |
" type: object\n", | |
" title: \\\"\\\"\n", | |
" description: \\\"\\\"\n", | |
"\n", | |
"\n", | |
"\"\"\")) # ```\n", | |
"\n", | |
", merge_props=True), expanded=0)\n", | |
"\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"%%\n", | |
"\n", | |
" JSON(SCHEMA:=\n", | |
" jsonref.replace_refs(raw:=\n", | |
"```yaml\n", | |
"description: |\n", | |
" the nonvisual description of a notebook interface\n", | |
"properties:\n", | |
" columns: \n", | |
" items:\n", | |
" - items: \n", | |
" - $ref: \"#/$defs/index\"\n", | |
" - $ref: \"#/$defs/id\"\n", | |
" - items:\n", | |
" - $ref: \"#/$defs/cell_type\"\n", | |
" - $ref: \"#/$defs/source\"\n", | |
" - $ref: \"#/$defs/toolbar\"\n", | |
" - $ref: \"#/$defs/duration\"\n", | |
" - $ref: \"#/$defs/started_at\"\n", | |
" - $ref: \"#/$defs/completed_at\"\n", | |
" - $ref: \"#/$defs/outputs\"\n", | |
" - $ref: \"#/$defs/metadata\"\n", | |
" - $ref: \"#/$defs/attachments\"\n", | |
"$defs:\n", | |
" notebook:\n", | |
" type: object\n", | |
" description: \"\"\n", | |
" properties:\n", | |
" cells:\n", | |
" type: array\n", | |
" items:\n", | |
" $ref: \"#/$defs/cell\"\n", | |
" cell:\n", | |
" type: object\n", | |
" title: cell\n", | |
" description: the primary notebook unit containing input source code and formatted output\n", | |
" properties:\n", | |
" index: {$ref: \"#/$defs/index\"}\n", | |
" id: {$ref: \"#/$defs/id\"}\n", | |
" cell_type: {$ref: \"#/$defs/cell_type\"}\n", | |
" metadata: {$ref: \"#/$defs/metadata\"}\n", | |
" outputs: {$ref: \"#/$defs/outputs\"}\n", | |
" source: {$ref: \"#/$defs/source\"}\n", | |
" index:\n", | |
" description: the ordinal cell number in the document\n", | |
" title: cell number\n", | |
" type: integer\n", | |
" minimum: 1\n", | |
" id:\n", | |
" description: a persistent unique identifier for a cell\n", | |
" title: cell id\n", | |
" type: string\n", | |
" \"@type\": \"@id\"\n", | |
" cell_type:\n", | |
" $oneOf:\n", | |
" - $ref: \"#/$defs/code_cell\"\n", | |
" - $ref: \"#/$defs/markdown_cell\"\n", | |
" - $ref: \"#/$defs/raw_cell\"\n", | |
" - $ref: \"#/$defs/undefined_cell\"\n", | |
" title: cell type\n", | |
" readOnly: true\n", | |
" source: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" attachments: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" started_at:\n", | |
" type: [null, string]\n", | |
" format: datetime\n", | |
" title: start time\n", | |
" description: |\n", | |
" the time the cell source was submitted by the client to the kernel\n", | |
" writeOnly: true\n", | |
" duration:\n", | |
" type: [null, string]\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: timedelta\n", | |
" title: duration\n", | |
" writeOnly: true\n", | |
" completed_at:\n", | |
" type: [null, string]\n", | |
" title: end time\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: datetime\n", | |
" writeOnly: true\n", | |
" loc:\n", | |
" type: integer\n", | |
" minimum: 0\n", | |
" description: lines of code in the source, including whitespace\n", | |
" writeOnly: true\n", | |
" toolbar:\n", | |
" type: array\n", | |
" title: cell toolbar\n", | |
" code_cell:\n", | |
" type: string\n", | |
" title: code\n", | |
" description: \"\"\n", | |
" const: code\n", | |
" markdown_cell:\n", | |
" type: string\n", | |
" title: markdown\n", | |
" description: \"\"\n", | |
" const: markdown\n", | |
" raw_cell:\n", | |
" type: string\n", | |
" title: raw\n", | |
" description: \"\"\n", | |
" const: raw\n", | |
" undefined_cell:\n", | |
" type: string\n", | |
" title: undefined\n", | |
" description: \"\"\n", | |
" const: undefined\n", | |
" outputs:\n", | |
" type: array\n", | |
" title: outputs\n", | |
" items:\n", | |
" properties:\n", | |
" data: \n", | |
" type: object\n", | |
" metadata: \n", | |
" type: object\n", | |
" text: \n", | |
" type: string\n", | |
" output_type: \n", | |
" enum: [display_data, stdout, stderr, stream]\n", | |
" metadata: \n", | |
" type: dict\n", | |
" title: metadata\n", | |
" description: \"\"\n", | |
" kernel:\n", | |
" type: object\n", | |
" title: \"\"\n", | |
" description: \"\"\n", | |
" \n", | |
"\n", | |
"```\n", | |
"\n", | |
" , merge_props=True), expanded=0)\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 88, | |
"id": "3b759856-57d4-4b20-9e1c-a3af8b248692", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"@singledispatch\n", | |
"def def_list(object, parent=None):\n", | |
" parent.append(str(object))\n", | |
"\n", | |
"@def_list.register\n", | |
"def def_list_list(object: list, parent=None):\n", | |
" for x in object:\n", | |
" dd = parent.append(new(\"dd\"))\n", | |
" def_list(x, dd)\n", | |
"\n", | |
"@def_list.register\n", | |
"def def_list_dict(object: dict, parent=None):\n", | |
" if parent is None: parent = dl = new(\"dl\")\n", | |
" else: dl = parent.append(new(\"dl\"))\n", | |
" for k, v in object.items():\n", | |
" dl.append(new(\"dt\", k, **{\"class\": [k]}))\n", | |
" if isinstance(v, list): def_list(v, dl)\n", | |
" elif k == \"$ref\": pass\n", | |
" else:\n", | |
" dd = dl.append(new(\"dd\"))\n", | |
" def_list(v, dd)\n", | |
" return parent" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ba766ce3-b3ff-45c6-b97e-803343a23a18", | |
"metadata": {}, | |
"source": [ | |
"It's a schema let us make a few things.\n", | |
"A table.\n", | |
"Style sheet.\n", | |
"input forms\n", | |
"help" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 89, | |
"id": "faab8094-d4d4-4a31-b992-6df6fcce95c7", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def new(tag, *elements, **attrs):\n", | |
" tag = builder.new_tag(tag, attrs=attrs)\n", | |
" tag.extend(elements)\n", | |
" return tag" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 90, | |
"id": "3be4a406-aaed-4b3f-a62d-fadc958ea44b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def new_template():\n", | |
" document = bs4.BeautifulSoup(features=\"html.parser\")\n", | |
" \n", | |
" head = document.append(new(\"head\"))\n", | |
" body = document.append(new(\"body\"))\n", | |
" \n", | |
" header = body.append(new(\"header\"))\n", | |
" main = body.append(new(\"main\"))\n", | |
" footer = body.append(new(\"footer\"))\n", | |
" \n", | |
" nb = main.append(new(\"section\", id=\"nb\"))\n", | |
" table = nb.append(new(\"table\"))\n", | |
" thead = table.append(new(\"thead\"))\n", | |
" cells = table.append(new(\"tbody\", id=\"cells\"))\n", | |
" metadata = main.append(new(\"dl\", id=\"metadata\"))\n", | |
" cell_template = table.append(new(\"template\", id=\"cell_template\"))\n", | |
" style = nb.append(new(\"style\"))\n", | |
" \n", | |
" schema = footer.append(new(\"aside\"))\n", | |
" schema = schema.append(new(\"dl\", id=\"schema\"))\n", | |
" \n", | |
" def klass(*x):\n", | |
" if len(x) == 1 and isinstance(x, str):\n", | |
" x = x[0].split()\n", | |
" return {\"class\": list(x)}\n", | |
" \n", | |
" thead_row = thead.append(new(\"tr\"))\n", | |
" cell_template_row = cell_template.append(new(\"tr\"))\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\n", | |
" ref = ref[\"$ref\"]\n", | |
" *_, key = ref.rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" thead_row.append(new(\"th\", s.get(\"title\"), scope=\"col\", **klass(key)))\n", | |
" th = new(\"th\", scope=\"row\", **klass(key))\n", | |
" cell_template_row.append(th)\n", | |
" style.append(\"\"\"th.%s {grid-area: %s;}\\n\"\"\" % (key, key))\n", | |
" \n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\n", | |
" ref = ref[\"$ref\"]\n", | |
" \n", | |
" *_, key = ref.rpartition(\"/\")\n", | |
" print(key)\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" thead_row.append(new(\"th\", s.get(\"title\", \"\"), scope=\"col\", **klass(key)))\n", | |
" td = new(\"td\", **klass(key))\n", | |
" match key:\n", | |
" case \"cell_type\":\n", | |
" select = td.append(new(\"select\"))\n", | |
" for s in SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]:\n", | |
" select.append(new(\"option\", s[\"title\"], value=s[\"title\"]))\n", | |
" case \"toolbar\":\n", | |
" form = td.append(new(\"form\"))\n", | |
" form.append(new(\"button\", \"run cell\", type=\"submit\", disabled=True))\n", | |
" case \"started_at\":\n", | |
" td.append(new(\"time\"))\n", | |
" case \"completed_at\": \n", | |
" td.append(new(\"time\"))\n", | |
" case \"duration\": \n", | |
" td.append(new(\"time\"))\n", | |
" case \"metadata\": \n", | |
" td.append(new(\"button\", \"?\", title=\"metadata\"))\n", | |
" td.append(new(\"dialog\"))\n", | |
" cell_template_row.append(td)\n", | |
" style.append(\"\"\"td.%s {grid-area: %s;}\\n\"\"\" % (key, key))\n", | |
" \n", | |
" schema.append(def_list(raw));\n", | |
" return document" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 91, | |
"id": "21639a97-0f81-4b82-a467-076a97b22deb", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"nb = json.loads(Path(\"Untitled13.ipynb\").read_text())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 92, | |
"id": "9c0d8c86-42f6-4616-93aa-c802b754904f", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cell_types = SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 93, | |
"id": "295e901e-621d-4307-9f01-cec1270103a7", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"cell_type\n", | |
"source\n", | |
"toolbar\n", | |
"duration\n", | |
"started_at\n", | |
"completed_at\n", | |
"outputs\n", | |
"metadata\n", | |
"attachments\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<head></head><body><header></header><main><section id=\"nb\"><table><thead><tr><th class=\"index\" scope=\"col\">cell number</th><th class=\"id\" scope=\"col\">cell id</th><th class=\"cell_type\" scope=\"col\">cell type</th><th class=\"source\" scope=\"col\">cell source</th><th class=\"toolbar\" scope=\"col\">cell toolbar</th><th class=\"duration\" scope=\"col\">duration</th><th class=\"started_at\" scope=\"col\">start time</th><th class=\"completed_at\" scope=\"col\">end time</th><th class=\"outputs\" scope=\"col\">outputs</th><th class=\"metadata\" scope=\"col\">metadata</th><th class=\"attachments\" scope=\"col\">cell source</th></tr></thead><tbody id=\"cells\"><tr id=\"2bdc7974-4db8-41a7-a941-15d7da1853e2\"><th class=\"index\" id=\"1\" scope=\"row\"><a href=\"#2bdc7974-4db8-41a7-a941-15d7da1853e2\">1</a></th><th class=\"id\" scope=\"row\"><a href=\"#2bdc7974-4db8-41a7-a941-15d7da1853e2\">2bdc7974-4db8-41a7-a941-15d7da1853e2</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"2\">import jsonschema, jsonref, jsonpointer, bs4\n", | |
"builder = bs4.BeautifulSoup(features=(FEATURES := \"html.parser\"))</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button title=\"metadata\">?</button><dialog><dl><dt class=\"scrolled\">scrolled</dt><dd>True</dd></dl></dialog></td><td class=\"attachments\"></td></tr><tr id=\"c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\"><th class=\"index\" id=\"2\" scope=\"row\"><a href=\"#c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\">2</a></th><th class=\"id\" scope=\"row\"><a href=\"#c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\">c9d9a5ef-20f2-4f69-a67b-e3e6a7197729</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"145\">%%\n", | |
"\n", | |
" JSON(SCHEMA:=\n", | |
" jsonref.replace_refs(raw:=\n", | |
"```yaml\n", | |
"description: |\n", | |
" the nonvisual description of a notebook interface\n", | |
"properties:\n", | |
" columns: \n", | |
" items:\n", | |
" - items: \n", | |
" - $ref: \"#/$defs/index\"\n", | |
" - $ref: \"#/$defs/id\"\n", | |
" - items:\n", | |
" - $ref: \"#/$defs/cell_type\"\n", | |
" - $ref: \"#/$defs/source\"\n", | |
" - $ref: \"#/$defs/toolbar\"\n", | |
" - $ref: \"#/$defs/duration\"\n", | |
" - $ref: \"#/$defs/started_at\"\n", | |
" - $ref: \"#/$defs/completed_at\"\n", | |
" - $ref: \"#/$defs/outputs\"\n", | |
" - $ref: \"#/$defs/metadata\"\n", | |
" - $ref: \"#/$defs/attachments\"\n", | |
"$defs:\n", | |
" notebook:\n", | |
" type: object\n", | |
" description: \"\"\n", | |
" properties:\n", | |
" cells:\n", | |
" type: array\n", | |
" items:\n", | |
" $ref: \"#/$defs/cell\"\n", | |
" cell:\n", | |
" type: object\n", | |
" title: cell\n", | |
" description: the primary notebook unit containing input source code and formatted output\n", | |
" properties:\n", | |
" index: {$ref: \"#/$defs/index\"}\n", | |
" id: {$ref: \"#/$defs/id\"}\n", | |
" cell_type: {$ref: \"#/$defs/cell_type\"}\n", | |
" metadata: {$ref: \"#/$defs/metadata\"}\n", | |
" outputs: {$ref: \"#/$defs/outputs\"}\n", | |
" source: {$ref: \"#/$defs/source\"}\n", | |
" index:\n", | |
" description: the ordinal cell number in the document\n", | |
" title: cell number\n", | |
" type: integer\n", | |
" minimum: 1\n", | |
" id:\n", | |
" description: a persistent unique identifier for a cell\n", | |
" title: cell id\n", | |
" type: string\n", | |
" \"@type\": \"@id\"\n", | |
" cell_type:\n", | |
" $oneOf:\n", | |
" - $ref: \"#/$defs/code_cell\"\n", | |
" - $ref: \"#/$defs/markdown_cell\"\n", | |
" - $ref: \"#/$defs/raw_cell\"\n", | |
" - $ref: \"#/$defs/undefined_cell\"\n", | |
" title: cell type\n", | |
" readOnly: true\n", | |
" source: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" attachments: \n", | |
" type: string\n", | |
" title: cell source\n", | |
" readOnly: true\n", | |
" started_at:\n", | |
" type: [null, string]\n", | |
" format: datetime\n", | |
" title: start time\n", | |
" description: |\n", | |
" the time the cell source was submitted by the client to the kernel\n", | |
" writeOnly: true\n", | |
" duration:\n", | |
" type: [null, string]\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: timedelta\n", | |
" title: duration\n", | |
" writeOnly: true\n", | |
" completed_at:\n", | |
" type: [null, string]\n", | |
" title: end time\n", | |
" description: |\n", | |
" the time the response received from the kernel to the client\n", | |
" format: datetime\n", | |
" writeOnly: true\n", | |
" loc:\n", | |
" type: integer\n", | |
" minimum: 0\n", | |
" description: lines of code in the source, including whitespace\n", | |
" writeOnly: true\n", | |
" toolbar:\n", | |
" type: array\n", | |
" title: cell toolbar\n", | |
" code_cell:\n", | |
" type: string\n", | |
" title: code\n", | |
" description: \"\"\n", | |
" const: code\n", | |
" markdown_cell:\n", | |
" type: string\n", | |
" title: markdown\n", | |
" description: \"\"\n", | |
" const: markdown\n", | |
" raw_cell:\n", | |
" type: string\n", | |
" title: raw\n", | |
" description: \"\"\n", | |
" const: raw\n", | |
" undefined_cell:\n", | |
" type: string\n", | |
" title: undefined\n", | |
" description: \"\"\n", | |
" const: undefined\n", | |
" outputs:\n", | |
" type: array\n", | |
" title: outputs\n", | |
" items:\n", | |
" properties:\n", | |
" data: \n", | |
" type: object\n", | |
" metadata: \n", | |
" type: object\n", | |
" text: \n", | |
" type: string\n", | |
" output_type: \n", | |
" enum: [display_data, stdout, stderr, stream]\n", | |
" metadata: \n", | |
" type: dict\n", | |
" title: metadata\n", | |
" description: \"\"\n", | |
" kernel:\n", | |
" type: object\n", | |
" title: \"\"\n", | |
" description: \"\"\n", | |
" \n", | |
"\n", | |
"```\n", | |
"\n", | |
" , merge_props=True), expanded=0)\n", | |
" </textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"3b759856-57d4-4b20-9e1c-a3af8b248692\"><th class=\"index\" id=\"3\" scope=\"row\"><a href=\"#3b759856-57d4-4b20-9e1c-a3af8b248692\">3</a></th><th class=\"id\" scope=\"row\"><a href=\"#3b759856-57d4-4b20-9e1c-a3af8b248692\">3b759856-57d4-4b20-9e1c-a3af8b248692</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"22\">@singledispatch\n", | |
"def def_list(object, parent=None):\n", | |
" parent.append(str(object))\n", | |
"\n", | |
"@def_list.register\n", | |
"def def_list_list(object: list, parent=None):\n", | |
" for x in object:\n", | |
" dd = parent.append(new(\"dd\"))\n", | |
" def_list(x, dd)\n", | |
"\n", | |
"@def_list.register\n", | |
"def def_list_dict(object: dict, parent=None):\n", | |
" if parent is None: parent = dl = new(\"dl\")\n", | |
" else: dl = parent.append(new(\"dl\"))\n", | |
" for k, v in object.items():\n", | |
" dl.append(new(\"dt\", k, **{\"class\": [k]}))\n", | |
" if isinstance(v, list): def_list(v, dl)\n", | |
" elif k == \"$ref\": pass\n", | |
" else:\n", | |
" dd = dl.append(new(\"dd\"))\n", | |
" def_list(v, dd)\n", | |
" return parent</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"ba766ce3-b3ff-45c6-b97e-803343a23a18\"><th class=\"index\" id=\"4\" scope=\"row\"><a href=\"#ba766ce3-b3ff-45c6-b97e-803343a23a18\">4</a></th><th class=\"id\" scope=\"row\"><a href=\"#ba766ce3-b3ff-45c6-b97e-803343a23a18\">ba766ce3-b3ff-45c6-b97e-803343a23a18</a></th><td class=\"cell_type\"><select><option value=\"code\">code</option><option selected=\"\" value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"5\">It's a schema let us make a few things.\n", | |
"A table.\n", | |
"Style sheet.\n", | |
"input forms\n", | |
"help</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"faab8094-d4d4-4a31-b992-6df6fcce95c7\"><th class=\"index\" id=\"5\" scope=\"row\"><a href=\"#faab8094-d4d4-4a31-b992-6df6fcce95c7\">5</a></th><th class=\"id\" scope=\"row\"><a href=\"#faab8094-d4d4-4a31-b992-6df6fcce95c7\">faab8094-d4d4-4a31-b992-6df6fcce95c7</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"4\">def new(tag, *elements, **attrs):\n", | |
" tag = builder.new_tag(tag, attrs=attrs)\n", | |
" tag.extend(elements)\n", | |
" return tag</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"3be4a406-aaed-4b3f-a62d-fadc958ea44b\"><th class=\"index\" id=\"6\" scope=\"row\"><a href=\"#3be4a406-aaed-4b3f-a62d-fadc958ea44b\">6</a></th><th class=\"id\" scope=\"row\"><a href=\"#3be4a406-aaed-4b3f-a62d-fadc958ea44b\">3be4a406-aaed-4b3f-a62d-fadc958ea44b</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"67\">def new_template():\n", | |
" document = bs4.BeautifulSoup(features=\"html.parser\")\n", | |
" \n", | |
" head = document.append(new(\"head\"))\n", | |
" body = document.append(new(\"body\"))\n", | |
" \n", | |
" header = body.append(new(\"header\"))\n", | |
" main = body.append(new(\"main\"))\n", | |
" footer = body.append(new(\"footer\"))\n", | |
" \n", | |
" nb = main.append(new(\"section\", id=\"nb\"))\n", | |
" table = nb.append(new(\"table\"))\n", | |
" thead = table.append(new(\"thead\"))\n", | |
" cells = table.append(new(\"tbody\", id=\"cells\"))\n", | |
" metadata = main.append(new(\"dl\", id=\"metadata\"))\n", | |
" cell_template = table.append(new(\"template\", id=\"cell_template\"))\n", | |
" style = nb.append(new(\"style\"))\n", | |
" \n", | |
" schema = footer.append(new(\"aside\"))\n", | |
" schema = schema.append(new(\"dl\", id=\"schema\"))\n", | |
" \n", | |
" def klass(*x):\n", | |
" if len(x) == 1 and isinstance(x, str):\n", | |
" x = x[0].split()\n", | |
" return {\"class\": list(x)}\n", | |
" \n", | |
" thead_row = thead.append(new(\"tr\"))\n", | |
" cell_template_row = cell_template.append(new(\"tr\"))\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\n", | |
" ref = ref[\"$ref\"]\n", | |
" *_, key = ref.rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" thead_row.append(new(\"th\", s.get(\"title\"), scope=\"col\", **klass(key)))\n", | |
" th = new(\"th\", scope=\"row\", **klass(key))\n", | |
" cell_template_row.append(th)\n", | |
" style.append(\"\"\"th.%s {grid-area: %s;}\\n\"\"\" % (key, key))\n", | |
" \n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\n", | |
" ref = ref[\"$ref\"]\n", | |
" \n", | |
" *_, key = ref.rpartition(\"/\")\n", | |
" print(key)\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" thead_row.append(new(\"th\", s.get(\"title\", \"\"), scope=\"col\", **klass(key)))\n", | |
" td = new(\"td\", **klass(key))\n", | |
" match key:\n", | |
" case \"cell_type\":\n", | |
" select = td.append(new(\"select\"))\n", | |
" for s in SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]:\n", | |
" select.append(new(\"option\", s[\"title\"], value=s[\"title\"]))\n", | |
" case \"toolbar\":\n", | |
" form = td.append(new(\"form\"))\n", | |
" form.append(new(\"button\", \"run cell\", type=\"submit\", disabled=True))\n", | |
" case \"started_at\":\n", | |
" td.append(new(\"time\"))\n", | |
" case \"completed_at\": \n", | |
" td.append(new(\"time\"))\n", | |
" case \"duration\": \n", | |
" td.append(new(\"time\"))\n", | |
" case \"metadata\": \n", | |
" td.append(new(\"button\", \"?\", title=\"metadata\"))\n", | |
" td.append(new(\"dialog\"))\n", | |
" cell_template_row.append(td)\n", | |
" style.append(\"\"\"td.%s {grid-area: %s;}\\n\"\"\" % (key, key))\n", | |
" \n", | |
" schema.append(def_list(raw));\n", | |
" return document</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"21639a97-0f81-4b82-a467-076a97b22deb\"><th class=\"index\" id=\"7\" scope=\"row\"><a href=\"#21639a97-0f81-4b82-a467-076a97b22deb\">7</a></th><th class=\"id\" scope=\"row\"><a href=\"#21639a97-0f81-4b82-a467-076a97b22deb\">21639a97-0f81-4b82-a467-076a97b22deb</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"1\">nb = json.loads(Path(\"Untitled13.ipynb\").read_text())</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"9c0d8c86-42f6-4616-93aa-c802b754904f\"><th class=\"index\" id=\"8\" scope=\"row\"><a href=\"#9c0d8c86-42f6-4616-93aa-c802b754904f\">8</a></th><th class=\"id\" scope=\"row\"><a href=\"#9c0d8c86-42f6-4616-93aa-c802b754904f\">9c0d8c86-42f6-4616-93aa-c802b754904f</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"1\">cell_types = SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"295e901e-621d-4307-9f01-cec1270103a7\"><th class=\"index\" id=\"9\" scope=\"row\"><a href=\"#295e901e-621d-4307-9f01-cec1270103a7\">9</a></th><th class=\"id\" scope=\"row\"><a href=\"#295e901e-621d-4307-9f01-cec1270103a7\">295e901e-621d-4307-9f01-cec1270103a7</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"51\">doc = new_template()\n", | |
"doc.select_one(\"#metadata\").append(def_list(nb[\"metadata\"]))\n", | |
"cells = doc.select_one(\"#cells\")\n", | |
"template = doc.select_one(\"#cell_template tr\")\n", | |
"for i, cell in enumerate(nb[\"cells\"], 1):\n", | |
" row = copy.deepcopy(template)\n", | |
" row.attrs[\"id\"] = cell[\"id\"]\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\n", | |
" *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" match key:\n", | |
" case \"index\":\n", | |
" index = row.select_one(\".index\")\n", | |
" index.attrs[\"id\"] = i\n", | |
" a = index.append(new(\"a\", str(i), href=F\"#{cell['id']}\"))\n", | |
" case \"id\":\n", | |
" a = row.select_one(\".id\").append(\n", | |
" new(\"a\", cell[\"id\"], href=F\"#{cell['id']}\")\n", | |
" )\n", | |
" start_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_input\")\n", | |
" end_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_reply\")\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\n", | |
" *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" match key:\n", | |
" case \"source\":\n", | |
" index = row.select_one(\".source\")\n", | |
" source = \"\".join(cell[\"source\"])\n", | |
" lines = count(io.StringIO(source))\n", | |
" a = index.append(new(\"textarea\", \"\".join(source), readonly=\"\", rows=lines))\n", | |
" case \"cell_type\":\n", | |
" row.select_one(F\"\"\".cell_type option[value=\"{cell[\"cell_type\"]}\"]\"\"\").attrs[\"selected\"] = \"\"\n", | |
" case \"started_at\":\n", | |
" if start_at:\n", | |
" time = row.select_one(\".started_at time\")\n", | |
" time.append(start_at)\n", | |
" case \"completed_at\":\n", | |
" if end_at:\n", | |
" time = row.select_one(\".end_at time\")\n", | |
" time.append(t)\n", | |
" case \"metadata\":\n", | |
" # remove attachments\n", | |
" if not cell[\"metadata\"]:\n", | |
" row.select_one(\".metadata button\")[\"hidden\"] = True\n", | |
" else:\n", | |
" row.select_one(\".metadata dialog\").append(def_list(cell[\"metadata\"]))\n", | |
" \n", | |
" \n", | |
" cells.append(row)\n", | |
"\n", | |
"HTML(doc)</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"f8d1690d-ae08-470a-aeeb-19f8f1096a6d\"><th class=\"index\" id=\"10\" scope=\"row\"><a href=\"#f8d1690d-ae08-470a-aeeb-19f8f1096a6d\">10</a></th><th class=\"id\" scope=\"row\"><a href=\"#f8d1690d-ae08-470a-aeeb-19f8f1096a6d\">f8d1690d-ae08-470a-aeeb-19f8f1096a6d</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"0\"></textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"8a1bcb93-a9d5-4da4-9acd-179608100ced\"><th class=\"index\" id=\"11\" scope=\"row\"><a href=\"#8a1bcb93-a9d5-4da4-9acd-179608100ced\">11</a></th><th class=\"id\" scope=\"row\"><a href=\"#8a1bcb93-a9d5-4da4-9acd-179608100ced\">8a1bcb93-a9d5-4da4-9acd-179608100ced</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"0\"></textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr></tbody><template id=\"cell_template\"><tr><th class=\"index\" scope=\"row\"></th><th class=\"id\" scope=\"row\"></th><td class=\"cell_type\"><select><option value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"></td><td class=\"toolbar\"><form><button disabled=\"True\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr></template></table><style>th.index {grid-area: index;}\n", | |
"th.id {grid-area: id;}\n", | |
"td.cell_type {grid-area: cell_type;}\n", | |
"td.source {grid-area: source;}\n", | |
"td.toolbar {grid-area: toolbar;}\n", | |
"td.duration {grid-area: duration;}\n", | |
"td.started_at {grid-area: started_at;}\n", | |
"td.completed_at {grid-area: completed_at;}\n", | |
"td.outputs {grid-area: outputs;}\n", | |
"td.metadata {grid-area: metadata;}\n", | |
"td.attachments {grid-area: attachments;}\n", | |
"</style></section><dl id=\"metadata\"><dl><dt class=\"kernelspec\">kernelspec</dt><dd><dl><dt class=\"display_name\">display_name</dt><dd>allYourBase</dd><dt class=\"language\">language</dt><dd>python</dd><dt class=\"name\">name</dt><dd>based</dd></dl></dd><dt class=\"language_info\">language_info</dt><dd><dl><dt class=\"codemirror_mode\">codemirror_mode</dt><dd><dl><dt class=\"name\">name</dt><dd>ipython</dd><dt class=\"version\">version</dt><dd>3</dd></dl></dd><dt class=\"file_extension\">file_extension</dt><dd>.py</dd><dt class=\"mimetype\">mimetype</dt><dd>text/x-python</dd><dt class=\"name\">name</dt><dd>python</dd><dt class=\"nbconvert_exporter\">nbconvert_exporter</dt><dd>python</dd><dt class=\"pygments_lexer\">pygments_lexer</dt><dd>ipython3</dd><dt class=\"version\">version</dt><dd>3.13.3</dd></dl></dd></dl></dl></main><footer><aside><dl id=\"schema\"><dl><dt class=\"description\">description</dt><dd>the nonvisual description of a notebook interface\n", | |
"</dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"columns\">columns</dt><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"$defs\">$defs</dt><dd><dl><dt class=\"notebook\">notebook</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"cells\">cells</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"cell\">cell</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"title\">title</dt><dd>cell</dd><dt class=\"description\">description</dt><dd>the primary notebook unit containing input source code and formatted output</dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"index\">index</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"id\">id</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"cell_type\">cell_type</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"outputs\">outputs</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"source\">source</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd><dt class=\"index\">index</dt><dd><dl><dt class=\"description\">description</dt><dd>the ordinal cell number in the document</dd><dt class=\"title\">title</dt><dd>cell number</dd><dt class=\"type\">type</dt><dd>integer</dd><dt class=\"minimum\">minimum</dt><dd>1</dd></dl></dd><dt class=\"id\">id</dt><dd><dl><dt class=\"description\">description</dt><dd>a persistent unique identifier for a cell</dd><dt class=\"title\">title</dt><dd>cell id</dd><dt class=\"type\">type</dt><dd>string</dd><dt class=\"@type\">@type</dt><dd>@id</dd></dl></dd><dt class=\"cell_type\">cell_type</dt><dd><dl><dt class=\"$oneOf\">$oneOf</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"title\">title</dt><dd>cell type</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"source\">source</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>cell source</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"attachments\">attachments</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>cell source</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"started_at\">started_at</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"format\">format</dt><dd>datetime</dd><dt class=\"title\">title</dt><dd>start time</dd><dt class=\"description\">description</dt><dd>the time the cell source was submitted by the client to the kernel\n", | |
"</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"duration\">duration</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"description\">description</dt><dd>the time the response received from the kernel to the client\n", | |
"</dd><dt class=\"format\">format</dt><dd>timedelta</dd><dt class=\"title\">title</dt><dd>duration</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"completed_at\">completed_at</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"title\">title</dt><dd>end time</dd><dt class=\"description\">description</dt><dd>the time the response received from the kernel to the client\n", | |
"</dd><dt class=\"format\">format</dt><dd>datetime</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"loc\">loc</dt><dd><dl><dt class=\"type\">type</dt><dd>integer</dd><dt class=\"minimum\">minimum</dt><dd>0</dd><dt class=\"description\">description</dt><dd>lines of code in the source, including whitespace</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"toolbar\">toolbar</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"title\">title</dt><dd>cell toolbar</dd></dl></dd><dt class=\"code_cell\">code_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>code</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>code</dd></dl></dd><dt class=\"markdown_cell\">markdown_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>markdown</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>markdown</dd></dl></dd><dt class=\"raw_cell\">raw_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>raw</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>raw</dd></dl></dd><dt class=\"undefined_cell\">undefined_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>undefined</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>undefined</dd></dl></dd><dt class=\"outputs\">outputs</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"title\">title</dt><dd>outputs</dd><dt class=\"items\">items</dt><dd><dl><dt class=\"properties\">properties</dt><dd><dl><dt class=\"data\">data</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd></dl></dd><dt class=\"text\">text</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd></dl></dd><dt class=\"output_type\">output_type</dt><dd><dl><dt class=\"enum\">enum</dt><dd>display_data</dd><dd>stdout</dd><dd>stderr</dd><dd>stream</dd></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"type\">type</dt><dd>dict</dd><dt class=\"title\">title</dt><dd>metadata</dd><dt class=\"description\">description</dt><dd></dd></dl></dd><dt class=\"kernel\">kernel</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"title\">title</dt><dd></dd><dt class=\"description\">description</dt><dd></dd></dl></dd></dl></dd></dl></dl></aside></footer></body>" | |
], | |
"text/plain": [ | |
"'<head></head><body><header></header><main><section id=\"nb\"><table><thead><tr><th class=\"index\" scope=\"col\">cell number</th><th class=\"id\" scope=\"col\">cell id</th><th class=\"cell_type\" scope=\"col\">cell type</th><th class=\"source\" scope=\"col\">cell source</th><th class=\"toolbar\" scope=\"col\">cell toolbar</th><th class=\"duration\" scope=\"col\">duration</th><th class=\"started_at\" scope=\"col\">start time</th><th class=\"completed_at\" scope=\"col\">end time</th><th class=\"outputs\" scope=\"col\">outputs</th><th class=\"metadata\" scope=\"col\">metadata</th><th class=\"attachments\" scope=\"col\">cell source</th></tr></thead><tbody id=\"cells\"><tr id=\"2bdc7974-4db8-41a7-a941-15d7da1853e2\"><th class=\"index\" id=\"1\" scope=\"row\"><a href=\"#2bdc7974-4db8-41a7-a941-15d7da1853e2\">1</a></th><th class=\"id\" scope=\"row\"><a href=\"#2bdc7974-4db8-41a7-a941-15d7da1853e2\">2bdc7974-4db8-41a7-a941-15d7da1853e2</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"2\">import jsonschema, jsonref, jsonpointer, bs4\\nbuilder = bs4.BeautifulSoup(features=(FEATURES := \"html.parser\"))</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button title=\"metadata\">?</button><dialog><dl><dt class=\"scrolled\">scrolled</dt><dd>True</dd></dl></dialog></td><td class=\"attachments\"></td></tr><tr id=\"c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\"><th class=\"index\" id=\"2\" scope=\"row\"><a href=\"#c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\">2</a></th><th class=\"id\" scope=\"row\"><a href=\"#c9d9a5ef-20f2-4f69-a67b-e3e6a7197729\">c9d9a5ef-20f2-4f69-a67b-e3e6a7197729</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"145\">%%\\n\\n JSON(SCHEMA:=\\n jsonref.replace_refs(raw:=\\n```yaml\\ndescription: |\\n the nonvisual description of a notebook interface\\nproperties:\\n columns: \\n items:\\n - items: \\n - $ref: \"#/$defs/index\"\\n - $ref: \"#/$defs/id\"\\n - items:\\n - $ref: \"#/$defs/cell_type\"\\n - $ref: \"#/$defs/source\"\\n - $ref: \"#/$defs/toolbar\"\\n - $ref: \"#/$defs/duration\"\\n - $ref: \"#/$defs/started_at\"\\n - $ref: \"#/$defs/completed_at\"\\n - $ref: \"#/$defs/outputs\"\\n - $ref: \"#/$defs/metadata\"\\n - $ref: \"#/$defs/attachments\"\\n$defs:\\n notebook:\\n type: object\\n description: \"\"\\n properties:\\n cells:\\n type: array\\n items:\\n $ref: \"#/$defs/cell\"\\n cell:\\n type: object\\n title: cell\\n description: the primary notebook unit containing input source code and formatted output\\n properties:\\n index: {$ref: \"#/$defs/index\"}\\n id: {$ref: \"#/$defs/id\"}\\n cell_type: {$ref: \"#/$defs/cell_type\"}\\n metadata: {$ref: \"#/$defs/metadata\"}\\n outputs: {$ref: \"#/$defs/outputs\"}\\n source: {$ref: \"#/$defs/source\"}\\n index:\\n description: the ordinal cell number in the document\\n title: cell number\\n type: integer\\n minimum: 1\\n id:\\n description: a persistent unique identifier for a cell\\n title: cell id\\n type: string\\n \"@type\": \"@id\"\\n cell_type:\\n $oneOf:\\n - $ref: \"#/$defs/code_cell\"\\n - $ref: \"#/$defs/markdown_cell\"\\n - $ref: \"#/$defs/raw_cell\"\\n - $ref: \"#/$defs/undefined_cell\"\\n title: cell type\\n readOnly: true\\n source: \\n type: string\\n title: cell source\\n readOnly: true\\n attachments: \\n type: string\\n title: cell source\\n readOnly: true\\n started_at:\\n type: [null, string]\\n format: datetime\\n title: start time\\n description: |\\n the time the cell source was submitted by the client to the kernel\\n writeOnly: true\\n duration:\\n type: [null, string]\\n description: |\\n the time the response received from the kernel to the client\\n format: timedelta\\n title: duration\\n writeOnly: true\\n completed_at:\\n type: [null, string]\\n title: end time\\n description: |\\n the time the response received from the kernel to the client\\n format: datetime\\n writeOnly: true\\n loc:\\n type: integer\\n minimum: 0\\n description: lines of code in the source, including whitespace\\n writeOnly: true\\n toolbar:\\n type: array\\n title: cell toolbar\\n code_cell:\\n type: string\\n title: code\\n description: \"\"\\n const: code\\n markdown_cell:\\n type: string\\n title: markdown\\n description: \"\"\\n const: markdown\\n raw_cell:\\n type: string\\n title: raw\\n description: \"\"\\n const: raw\\n undefined_cell:\\n type: string\\n title: undefined\\n description: \"\"\\n const: undefined\\n outputs:\\n type: array\\n title: outputs\\n items:\\n properties:\\n data: \\n type: object\\n metadata: \\n type: object\\n text: \\n type: string\\n output_type: \\n enum: [display_data, stdout, stderr, stream]\\n metadata: \\n type: dict\\n title: metadata\\n description: \"\"\\n kernel:\\n type: object\\n title: \"\"\\n description: \"\"\\n \\n\\n```\\n\\n , merge_props=True), expanded=0)\\n </textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"3b759856-57d4-4b20-9e1c-a3af8b248692\"><th class=\"index\" id=\"3\" scope=\"row\"><a href=\"#3b759856-57d4-4b20-9e1c-a3af8b248692\">3</a></th><th class=\"id\" scope=\"row\"><a href=\"#3b759856-57d4-4b20-9e1c-a3af8b248692\">3b759856-57d4-4b20-9e1c-a3af8b248692</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"22\">@singledispatch\\ndef def_list(object, parent=None):\\n parent.append(str(object))\\n\\n@def_list.register\\ndef def_list_list(object: list, parent=None):\\n for x in object:\\n dd = parent.append(new(\"dd\"))\\n def_list(x, dd)\\n\\n@def_list.register\\ndef def_list_dict(object: dict, parent=None):\\n if parent is None: parent = dl = new(\"dl\")\\n else: dl = parent.append(new(\"dl\"))\\n for k, v in object.items():\\n dl.append(new(\"dt\", k, **{\"class\": [k]}))\\n if isinstance(v, list): def_list(v, dl)\\n elif k == \"$ref\": pass\\n else:\\n dd = dl.append(new(\"dd\"))\\n def_list(v, dd)\\n return parent</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"ba766ce3-b3ff-45c6-b97e-803343a23a18\"><th class=\"index\" id=\"4\" scope=\"row\"><a href=\"#ba766ce3-b3ff-45c6-b97e-803343a23a18\">4</a></th><th class=\"id\" scope=\"row\"><a href=\"#ba766ce3-b3ff-45c6-b97e-803343a23a18\">ba766ce3-b3ff-45c6-b97e-803343a23a18</a></th><td class=\"cell_type\"><select><option value=\"code\">code</option><option selected=\"\" value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"5\">It\\'s a schema let us make a few things.\\nA table.\\nStyle sheet.\\ninput forms\\nhelp</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"faab8094-d4d4-4a31-b992-6df6fcce95c7\"><th class=\"index\" id=\"5\" scope=\"row\"><a href=\"#faab8094-d4d4-4a31-b992-6df6fcce95c7\">5</a></th><th class=\"id\" scope=\"row\"><a href=\"#faab8094-d4d4-4a31-b992-6df6fcce95c7\">faab8094-d4d4-4a31-b992-6df6fcce95c7</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"4\">def new(tag, *elements, **attrs):\\n tag = builder.new_tag(tag, attrs=attrs)\\n tag.extend(elements)\\n return tag</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"3be4a406-aaed-4b3f-a62d-fadc958ea44b\"><th class=\"index\" id=\"6\" scope=\"row\"><a href=\"#3be4a406-aaed-4b3f-a62d-fadc958ea44b\">6</a></th><th class=\"id\" scope=\"row\"><a href=\"#3be4a406-aaed-4b3f-a62d-fadc958ea44b\">3be4a406-aaed-4b3f-a62d-fadc958ea44b</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"67\">def new_template():\\n document = bs4.BeautifulSoup(features=\"html.parser\")\\n \\n head = document.append(new(\"head\"))\\n body = document.append(new(\"body\"))\\n \\n header = body.append(new(\"header\"))\\n main = body.append(new(\"main\"))\\n footer = body.append(new(\"footer\"))\\n \\n nb = main.append(new(\"section\", id=\"nb\"))\\n table = nb.append(new(\"table\"))\\n thead = table.append(new(\"thead\"))\\n cells = table.append(new(\"tbody\", id=\"cells\"))\\n metadata = main.append(new(\"dl\", id=\"metadata\"))\\n cell_template = table.append(new(\"template\", id=\"cell_template\"))\\n style = nb.append(new(\"style\"))\\n \\n schema = footer.append(new(\"aside\"))\\n schema = schema.append(new(\"dl\", id=\"schema\"))\\n \\n def klass(*x):\\n if len(x) == 1 and isinstance(x, str):\\n x = x[0].split()\\n return {\"class\": list(x)}\\n \\n thead_row = thead.append(new(\"tr\"))\\n cell_template_row = cell_template.append(new(\"tr\"))\\n for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\\n ref = ref[\"$ref\"]\\n *_, key = ref.rpartition(\"/\")\\n s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\\n thead_row.append(new(\"th\", s.get(\"title\"), scope=\"col\", **klass(key)))\\n th = new(\"th\", scope=\"row\", **klass(key))\\n cell_template_row.append(th)\\n style.append(\"\"\"th.%s {grid-area: %s;}\\\\n\"\"\" % (key, key))\\n \\n for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\\n ref = ref[\"$ref\"]\\n \\n *_, key = ref.rpartition(\"/\")\\n print(key)\\n s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\\n thead_row.append(new(\"th\", s.get(\"title\", \"\"), scope=\"col\", **klass(key)))\\n td = new(\"td\", **klass(key))\\n match key:\\n case \"cell_type\":\\n select = td.append(new(\"select\"))\\n for s in SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]:\\n select.append(new(\"option\", s[\"title\"], value=s[\"title\"]))\\n case \"toolbar\":\\n form = td.append(new(\"form\"))\\n form.append(new(\"button\", \"run cell\", type=\"submit\", disabled=True))\\n case \"started_at\":\\n td.append(new(\"time\"))\\n case \"completed_at\": \\n td.append(new(\"time\"))\\n case \"duration\": \\n td.append(new(\"time\"))\\n case \"metadata\": \\n td.append(new(\"button\", \"?\", title=\"metadata\"))\\n td.append(new(\"dialog\"))\\n cell_template_row.append(td)\\n style.append(\"\"\"td.%s {grid-area: %s;}\\\\n\"\"\" % (key, key))\\n \\n schema.append(def_list(raw));\\n return document</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"21639a97-0f81-4b82-a467-076a97b22deb\"><th class=\"index\" id=\"7\" scope=\"row\"><a href=\"#21639a97-0f81-4b82-a467-076a97b22deb\">7</a></th><th class=\"id\" scope=\"row\"><a href=\"#21639a97-0f81-4b82-a467-076a97b22deb\">21639a97-0f81-4b82-a467-076a97b22deb</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"1\">nb = json.loads(Path(\"Untitled13.ipynb\").read_text())</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"9c0d8c86-42f6-4616-93aa-c802b754904f\"><th class=\"index\" id=\"8\" scope=\"row\"><a href=\"#9c0d8c86-42f6-4616-93aa-c802b754904f\">8</a></th><th class=\"id\" scope=\"row\"><a href=\"#9c0d8c86-42f6-4616-93aa-c802b754904f\">9c0d8c86-42f6-4616-93aa-c802b754904f</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"1\">cell_types = SCHEMA[\"$defs\"][\"cell_type\"][\"$oneOf\"]</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"295e901e-621d-4307-9f01-cec1270103a7\"><th class=\"index\" id=\"9\" scope=\"row\"><a href=\"#295e901e-621d-4307-9f01-cec1270103a7\">9</a></th><th class=\"id\" scope=\"row\"><a href=\"#295e901e-621d-4307-9f01-cec1270103a7\">295e901e-621d-4307-9f01-cec1270103a7</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"51\">doc = new_template()\\ndoc.select_one(\"#metadata\").append(def_list(nb[\"metadata\"]))\\ncells = doc.select_one(\"#cells\")\\ntemplate = doc.select_one(\"#cell_template tr\")\\nfor i, cell in enumerate(nb[\"cells\"], 1):\\n row = copy.deepcopy(template)\\n row.attrs[\"id\"] = cell[\"id\"]\\n for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\\n *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\\n s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\\n match key:\\n case \"index\":\\n index = row.select_one(\".index\")\\n index.attrs[\"id\"] = i\\n a = index.append(new(\"a\", str(i), href=F\"#{cell[\\'id\\']}\"))\\n case \"id\":\\n a = row.select_one(\".id\").append(\\n new(\"a\", cell[\"id\"], href=F\"#{cell[\\'id\\']}\")\\n )\\n start_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_input\")\\n end_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_reply\")\\n for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\\n *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\\n s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\\n match key:\\n case \"source\":\\n index = row.select_one(\".source\")\\n source = \"\".join(cell[\"source\"])\\n lines = count(io.StringIO(source))\\n a = index.append(new(\"textarea\", \"\".join(source), readonly=\"\", rows=lines))\\n case \"cell_type\":\\n row.select_one(F\"\"\".cell_type option[value=\"{cell[\"cell_type\"]}\"]\"\"\").attrs[\"selected\"] = \"\"\\n case \"started_at\":\\n if start_at:\\n time = row.select_one(\".started_at time\")\\n time.append(start_at)\\n case \"completed_at\":\\n if end_at:\\n time = row.select_one(\".end_at time\")\\n time.append(t)\\n case \"metadata\":\\n # remove attachments\\n if not cell[\"metadata\"]:\\n row.select_one(\".metadata button\")[\"hidden\"] = True\\n else:\\n row.select_one(\".metadata dialog\").append(def_list(cell[\"metadata\"]))\\n \\n \\n cells.append(row)\\n\\nHTML(doc)</textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"f8d1690d-ae08-470a-aeeb-19f8f1096a6d\"><th class=\"index\" id=\"10\" scope=\"row\"><a href=\"#f8d1690d-ae08-470a-aeeb-19f8f1096a6d\">10</a></th><th class=\"id\" scope=\"row\"><a href=\"#f8d1690d-ae08-470a-aeeb-19f8f1096a6d\">f8d1690d-ae08-470a-aeeb-19f8f1096a6d</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"0\"></textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr><tr id=\"8a1bcb93-a9d5-4da4-9acd-179608100ced\"><th class=\"index\" id=\"11\" scope=\"row\"><a href=\"#8a1bcb93-a9d5-4da4-9acd-179608100ced\">11</a></th><th class=\"id\" scope=\"row\"><a href=\"#8a1bcb93-a9d5-4da4-9acd-179608100ced\">8a1bcb93-a9d5-4da4-9acd-179608100ced</a></th><td class=\"cell_type\"><select><option selected=\"\" value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"><textarea readonly=\"\" rows=\"0\"></textarea></td><td class=\"toolbar\"><form><button disabled=\"disabled\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button hidden=\"hidden\" title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr></tbody><template id=\"cell_template\"><tr><th class=\"index\" scope=\"row\"></th><th class=\"id\" scope=\"row\"></th><td class=\"cell_type\"><select><option value=\"code\">code</option><option value=\"markdown\">markdown</option><option value=\"raw\">raw</option><option value=\"undefined\">undefined</option></select></td><td class=\"source\"></td><td class=\"toolbar\"><form><button disabled=\"True\" type=\"submit\">run cell</button></form></td><td class=\"duration\"><time></time></td><td class=\"started_at\"><time></time></td><td class=\"completed_at\"><time></time></td><td class=\"outputs\"></td><td class=\"metadata\"><button title=\"metadata\">?</button><dialog></dialog></td><td class=\"attachments\"></td></tr></template></table><style>th.index {grid-area: index;}\\nth.id {grid-area: id;}\\ntd.cell_type {grid-area: cell_type;}\\ntd.source {grid-area: source;}\\ntd.toolbar {grid-area: toolbar;}\\ntd.duration {grid-area: duration;}\\ntd.started_at {grid-area: started_at;}\\ntd.completed_at {grid-area: completed_at;}\\ntd.outputs {grid-area: outputs;}\\ntd.metadata {grid-area: metadata;}\\ntd.attachments {grid-area: attachments;}\\n</style></section><dl id=\"metadata\"><dl><dt class=\"kernelspec\">kernelspec</dt><dd><dl><dt class=\"display_name\">display_name</dt><dd>allYourBase</dd><dt class=\"language\">language</dt><dd>python</dd><dt class=\"name\">name</dt><dd>based</dd></dl></dd><dt class=\"language_info\">language_info</dt><dd><dl><dt class=\"codemirror_mode\">codemirror_mode</dt><dd><dl><dt class=\"name\">name</dt><dd>ipython</dd><dt class=\"version\">version</dt><dd>3</dd></dl></dd><dt class=\"file_extension\">file_extension</dt><dd>.py</dd><dt class=\"mimetype\">mimetype</dt><dd>text/x-python</dd><dt class=\"name\">name</dt><dd>python</dd><dt class=\"nbconvert_exporter\">nbconvert_exporter</dt><dd>python</dd><dt class=\"pygments_lexer\">pygments_lexer</dt><dd>ipython3</dd><dt class=\"version\">version</dt><dd>3.13.3</dd></dl></dd></dl></dl></main><footer><aside><dl id=\"schema\"><dl><dt class=\"description\">description</dt><dd>the nonvisual description of a notebook interface\\n</dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"columns\">columns</dt><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd><dd><dl><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"$defs\">$defs</dt><dd><dl><dt class=\"notebook\">notebook</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"cells\">cells</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"items\">items</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"cell\">cell</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"title\">title</dt><dd>cell</dd><dt class=\"description\">description</dt><dd>the primary notebook unit containing input source code and formatted output</dd><dt class=\"properties\">properties</dt><dd><dl><dt class=\"index\">index</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"id\">id</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"cell_type\">cell_type</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"outputs\">outputs</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"source\">source</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd></dl></dd></dl></dd><dt class=\"index\">index</dt><dd><dl><dt class=\"description\">description</dt><dd>the ordinal cell number in the document</dd><dt class=\"title\">title</dt><dd>cell number</dd><dt class=\"type\">type</dt><dd>integer</dd><dt class=\"minimum\">minimum</dt><dd>1</dd></dl></dd><dt class=\"id\">id</dt><dd><dl><dt class=\"description\">description</dt><dd>a persistent unique identifier for a cell</dd><dt class=\"title\">title</dt><dd>cell id</dd><dt class=\"type\">type</dt><dd>string</dd><dt class=\"@type\">@type</dt><dd>@id</dd></dl></dd><dt class=\"cell_type\">cell_type</dt><dd><dl><dt class=\"$oneOf\">$oneOf</dt><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dd><dl><dt class=\"$ref\">$ref</dt></dl></dd><dt class=\"title\">title</dt><dd>cell type</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"source\">source</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>cell source</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"attachments\">attachments</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>cell source</dd><dt class=\"readOnly\">readOnly</dt><dd>True</dd></dl></dd><dt class=\"started_at\">started_at</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"format\">format</dt><dd>datetime</dd><dt class=\"title\">title</dt><dd>start time</dd><dt class=\"description\">description</dt><dd>the time the cell source was submitted by the client to the kernel\\n</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"duration\">duration</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"description\">description</dt><dd>the time the response received from the kernel to the client\\n</dd><dt class=\"format\">format</dt><dd>timedelta</dd><dt class=\"title\">title</dt><dd>duration</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"completed_at\">completed_at</dt><dd><dl><dt class=\"type\">type</dt><dd>None</dd><dd>string</dd><dt class=\"title\">title</dt><dd>end time</dd><dt class=\"description\">description</dt><dd>the time the response received from the kernel to the client\\n</dd><dt class=\"format\">format</dt><dd>datetime</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"loc\">loc</dt><dd><dl><dt class=\"type\">type</dt><dd>integer</dd><dt class=\"minimum\">minimum</dt><dd>0</dd><dt class=\"description\">description</dt><dd>lines of code in the source, including whitespace</dd><dt class=\"writeOnly\">writeOnly</dt><dd>True</dd></dl></dd><dt class=\"toolbar\">toolbar</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"title\">title</dt><dd>cell toolbar</dd></dl></dd><dt class=\"code_cell\">code_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>code</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>code</dd></dl></dd><dt class=\"markdown_cell\">markdown_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>markdown</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>markdown</dd></dl></dd><dt class=\"raw_cell\">raw_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>raw</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>raw</dd></dl></dd><dt class=\"undefined_cell\">undefined_cell</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd><dt class=\"title\">title</dt><dd>undefined</dd><dt class=\"description\">description</dt><dd></dd><dt class=\"const\">const</dt><dd>undefined</dd></dl></dd><dt class=\"outputs\">outputs</dt><dd><dl><dt class=\"type\">type</dt><dd>array</dd><dt class=\"title\">title</dt><dd>outputs</dd><dt class=\"items\">items</dt><dd><dl><dt class=\"properties\">properties</dt><dd><dl><dt class=\"data\">data</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd></dl></dd><dt class=\"text\">text</dt><dd><dl><dt class=\"type\">type</dt><dd>string</dd></dl></dd><dt class=\"output_type\">output_type</dt><dd><dl><dt class=\"enum\">enum</dt><dd>display_data</dd><dd>stdout</dd><dd>stderr</dd><dd>stream</dd></dl></dd></dl></dd></dl></dd></dl></dd><dt class=\"metadata\">metadata</dt><dd><dl><dt class=\"type\">type</dt><dd>dict</dd><dt class=\"title\">title</dt><dd>metadata</dd><dt class=\"description\">description</dt><dd></dd></dl></dd><dt class=\"kernel\">kernel</dt><dd><dl><dt class=\"type\">type</dt><dd>object</dd><dt class=\"title\">title</dt><dd></dd><dt class=\"description\">description</dt><dd></dd></dl></dd></dl></dd></dl></dl></aside></footer></body>'" | |
] | |
}, | |
"execution_count": 93, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"doc = new_template()\n", | |
"doc.select_one(\"#metadata\").append(def_list(nb[\"metadata\"]))\n", | |
"cells = doc.select_one(\"#cells\")\n", | |
"template = doc.select_one(\"#cell_template tr\")\n", | |
"for i, cell in enumerate(nb[\"cells\"], 1):\n", | |
" row = copy.deepcopy(template)\n", | |
" row.attrs[\"id\"] = cell[\"id\"]\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][0][\"items\"]:\n", | |
" *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" match key:\n", | |
" case \"index\":\n", | |
" index = row.select_one(\".index\")\n", | |
" index.attrs[\"id\"] = i\n", | |
" a = index.append(new(\"a\", str(i), href=F\"#{cell['id']}\"))\n", | |
" case \"id\":\n", | |
" a = row.select_one(\".id\").append(\n", | |
" new(\"a\", cell[\"id\"], href=F\"#{cell['id']}\")\n", | |
" )\n", | |
" start_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_input\")\n", | |
" end_at = cell[\"metadata\"].get(\"execution\", {}).get(\"iopub.execute_reply\")\n", | |
" for ref in raw[\"properties\"][\"columns\"][\"items\"][1][\"items\"]:\n", | |
" *_, key = (ref := ref[\"$ref\"]).rpartition(\"/\")\n", | |
" s = jsonpointer.resolve_pointer(raw, ref.lstrip(\"#\"))\n", | |
" match key:\n", | |
" case \"source\":\n", | |
" index = row.select_one(\".source\")\n", | |
" source = \"\".join(cell[\"source\"])\n", | |
" lines = count(io.StringIO(source))\n", | |
" a = index.append(new(\"textarea\", \"\".join(source), readonly=\"\", rows=lines))\n", | |
" case \"cell_type\":\n", | |
" row.select_one(F\"\"\".cell_type option[value=\"{cell[\"cell_type\"]}\"]\"\"\").attrs[\"selected\"] = \"\"\n", | |
" case \"started_at\":\n", | |
" if start_at:\n", | |
" time = row.select_one(\".started_at time\")\n", | |
" time.append(start_at)\n", | |
" case \"completed_at\":\n", | |
" if end_at:\n", | |
" time = row.select_one(\".end_at time\")\n", | |
" time.append(t)\n", | |
" case \"metadata\":\n", | |
" # remove attachments\n", | |
" if not cell[\"metadata\"]:\n", | |
" row.select_one(\".metadata button\")[\"hidden\"] = True\n", | |
" else:\n", | |
" row.select_one(\".metadata dialog\").append(def_list(cell[\"metadata\"]))\n", | |
" \n", | |
" \n", | |
" cells.append(row)\n", | |
"\n", | |
"HTML(doc)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "f8d1690d-ae08-470a-aeeb-19f8f1096a6d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "8a1bcb93-a9d5-4da4-9acd-179608100ced", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "8f33efc3-3bd1-4c9d-8e7a-126126136075", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "allYourBase", | |
"language": "python", | |
"name": "based" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.13.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment