1
- {"cells": [{"cell_type": "code", "execution_count": 1, "id": "spontaneous-llama", "metadata": {}, "outputs": [], "source": ["%load_ext literary.module"]}, {"cell_type": "markdown", "id": "solar-necessity", "metadata": {"tags": ["docstring"]}, "source": ["# Commandline Application"]}, {"cell_type": "code", "execution_count": 1, "id": "informed-raise", "metadata": {"execution": {"iopub.execute_input": "2022-05-12T11:23:58.033350Z", "iopub.status.busy": "2022-05-12T11:23:58.032705Z", "iopub.status.idle": "2022-05-12T11:23:58.368071Z", "shell.execute_reply": "2022-05-12T11:23:58.367446Z"}, "tags": ["export"]}, "outputs": [], "source": ["import sys\n", "\n", "from traitlets import default\n", "from traitlets.config import Application\n", "\n", "from .build import LiteraryBuildApp\n", "from .test import LiteraryTestApp"]}, {"cell_type": "code", "execution_count": 2, "id": "imported-thickness", "metadata": {"execution": {"iopub.execute_input": "2022-05-12T11:23:58.371025Z", "iopub.status.busy": "2022-05-12T11:23:58.370746Z", "iopub.status.idle": "2022-05-12T11:23:58.375871Z", "shell.execute_reply": "2022-05-12T11:23:58.375171Z"}, "tags": ["export"]}, "outputs": [], "source": ["class LiteraryLauncher(Application):\n", " description = \"Work with literate notebooks\"\n", " subcommands = {\n", " \"build\": (LiteraryBuildApp, \"Build a package from a series of notebooks\"),\n", " \"test\": (LiteraryTestApp, \"Run a series of notebook tests\"),\n", " }\n", "\n", " def start(self):\n", " \"\"\"Perform the App's actions as configured\"\"\"\n", " super().start()\n", "\n", " if self.subapp is None:\n", " sub_commands = \", \".join(sorted(self.subcommands))\n", " sys.exit(\"Please supply at least one subcommand: {}\".format(sub_commands))"]}, {"cell_type": "code", "execution_count": 3, "id": "sustainable-archive", "metadata": {"execution": {"iopub.execute_input": "2022-05-12T11:23:58.378526Z", "iopub.status.busy": "2022-05-12T11:23:58.378105Z", "iopub.status.idle": "2022-05-12T11:23:58.381525Z", "shell.execute_reply": "2022-05-12T11:23:58.381067Z"}, "tags": ["export"]}, "outputs": [], "source": ["launch_new_instance = LiteraryLauncher.launch_instance"]}, {"cell_type": "code", "execution_count": 4, "id": "7cd5310f-b1a4-4926-b909-b736e37d839c", "metadata": {"execution": {"iopub.execute_input": "2022-05-12T11:23:58.383872Z", "iopub.status.busy": "2022-05-12T11:23:58.383598Z", "iopub.status.idle": "2022-05-12T11:23:58.387073Z", "shell.execute_reply": "2022-05-12T11:23:58.386566Z"}, "tags": ["export"]}, "outputs": [], "source": ["if __name__ == \"__main__\" and not LiteraryLauncher.initialized():\n", " launch_new_instance()"]}], "metadata": {"jupytext": {"cell_metadata_filter": "-all", "main_language": "python", "notebook_metadata_filter": "-all"}, "kernelspec": {"display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3"}, "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.10.4"}}, "nbformat": 4, "nbformat_minor": 5}
1
+ {
2
+ "cells" : [
3
+ {
4
+ "cell_type" : " code" ,
5
+ "execution_count" : 1 ,
6
+ "id" : " spontaneous-llama" ,
7
+ "metadata" : {
8
+ "editable" : true ,
9
+ "slideshow" : {
10
+ "slide_type" : " "
11
+ },
12
+ "tags" : []
13
+ },
14
+ "outputs" : [],
15
+ "source" : [
16
+ " %load_ext literary.module"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type" : " markdown" ,
21
+ "id" : " solar-necessity" ,
22
+ "metadata" : {
23
+ "editable" : true ,
24
+ "slideshow" : {
25
+ "slide_type" : " "
26
+ },
27
+ "tags" : [
28
+ " docstring"
29
+ ]
30
+ },
31
+ "source" : [
32
+ " # Commandline Application"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type" : " code" ,
37
+ "execution_count" : 1 ,
38
+ "id" : " informed-raise" ,
39
+ "metadata" : {
40
+ "editable" : true ,
41
+ "execution" : {
42
+ "iopub.execute_input" : " 2022-05-12T11:23:58.033350Z" ,
43
+ "iopub.status.busy" : " 2022-05-12T11:23:58.032705Z" ,
44
+ "iopub.status.idle" : " 2022-05-12T11:23:58.368071Z" ,
45
+ "shell.execute_reply" : " 2022-05-12T11:23:58.367446Z"
46
+ },
47
+ "slideshow" : {
48
+ "slide_type" : " "
49
+ },
50
+ "tags" : [
51
+ " export"
52
+ ]
53
+ },
54
+ "outputs" : [],
55
+ "source" : [
56
+ " import sys\n " ,
57
+ " \n " ,
58
+ " from traitlets import default\n " ,
59
+ " from traitlets.config import Application\n " ,
60
+ " \n " ,
61
+ " from .build import LiteraryBuildApp\n " ,
62
+ " from .test import LiteraryTestApp"
63
+ ]
64
+ },
65
+ {
66
+ "cell_type" : " code" ,
67
+ "execution_count" : 2 ,
68
+ "id" : " imported-thickness" ,
69
+ "metadata" : {
70
+ "execution" : {
71
+ "iopub.execute_input" : " 2022-05-12T11:23:58.371025Z" ,
72
+ "iopub.status.busy" : " 2022-05-12T11:23:58.370746Z" ,
73
+ "iopub.status.idle" : " 2022-05-12T11:23:58.375871Z" ,
74
+ "shell.execute_reply" : " 2022-05-12T11:23:58.375171Z"
75
+ },
76
+ "tags" : [
77
+ " export"
78
+ ]
79
+ },
80
+ "outputs" : [],
81
+ "source" : [
82
+ " class LiteraryLauncher(Application):\n " ,
83
+ " description = \" Work with literate notebooks\"\n " ,
84
+ " subcommands = {\n " ,
85
+ " \" build\" : (LiteraryBuildApp, \" Build a package from a series of notebooks\" ),\n " ,
86
+ " \" test\" : (LiteraryTestApp, \" Run a series of notebook tests\" ),\n " ,
87
+ " }\n " ,
88
+ " \n " ,
89
+ " def start(self):\n " ,
90
+ " \"\"\" Perform the App's actions as configured\"\"\"\n " ,
91
+ " super().start()\n " ,
92
+ " \n " ,
93
+ " if self.subapp is None:\n " ,
94
+ " sub_commands = \" , \" .join(sorted(self.subcommands))\n " ,
95
+ " sys.exit(\" Please supply at least one subcommand: {}\" .format(sub_commands))"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type" : " code" ,
100
+ "execution_count" : 3 ,
101
+ "id" : " sustainable-archive" ,
102
+ "metadata" : {
103
+ "execution" : {
104
+ "iopub.execute_input" : " 2022-05-12T11:23:58.378526Z" ,
105
+ "iopub.status.busy" : " 2022-05-12T11:23:58.378105Z" ,
106
+ "iopub.status.idle" : " 2022-05-12T11:23:58.381525Z" ,
107
+ "shell.execute_reply" : " 2022-05-12T11:23:58.381067Z"
108
+ },
109
+ "tags" : [
110
+ " export"
111
+ ]
112
+ },
113
+ "outputs" : [],
114
+ "source" : [
115
+ " launch_new_instance = LiteraryLauncher.launch_instance"
116
+ ]
117
+ },
118
+ {
119
+ "cell_type" : " code" ,
120
+ "execution_count" : 4 ,
121
+ "id" : " 7cd5310f-b1a4-4926-b909-b736e37d839c" ,
122
+ "metadata" : {
123
+ "execution" : {
124
+ "iopub.execute_input" : " 2022-05-12T11:23:58.383872Z" ,
125
+ "iopub.status.busy" : " 2022-05-12T11:23:58.383598Z" ,
126
+ "iopub.status.idle" : " 2022-05-12T11:23:58.387073Z" ,
127
+ "shell.execute_reply" : " 2022-05-12T11:23:58.386566Z"
128
+ },
129
+ "tags" : [
130
+ " export"
131
+ ]
132
+ },
133
+ "outputs" : [],
134
+ "source" : [
135
+ " if __name__ == \" __main__\" and not LiteraryLauncher.initialized():\n " ,
136
+ " launch_new_instance()"
137
+ ]
138
+ }
139
+ ],
140
+ "metadata" : {
141
+ "jupytext" : {
142
+ "cell_metadata_filter" : " -all" ,
143
+ "main_language" : " python" ,
144
+ "notebook_metadata_filter" : " -all"
145
+ },
146
+ "kernelspec" : {
147
+ "display_name" : " Python 3 (ipykernel)" ,
148
+ "language" : " python" ,
149
+ "name" : " python3"
150
+ },
151
+ "language_info" : {
152
+ "codemirror_mode" : {
153
+ "name" : " ipython" ,
154
+ "version" : 3
155
+ },
156
+ "file_extension" : " .py" ,
157
+ "mimetype" : " text/x-python" ,
158
+ "name" : " python" ,
159
+ "nbconvert_exporter" : " python" ,
160
+ "pygments_lexer" : " ipython3" ,
161
+ "version" : " 3.13.5"
162
+ }
163
+ },
164
+ "nbformat" : 4 ,
165
+ "nbformat_minor" : 5
166
+ }
0 commit comments