quizzy 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- quizzy/__main__.py +2 -8
- quizzy/app.py +36 -13
- {quizzy-0.3.0.dist-info → quizzy-0.4.0.dist-info}/METADATA +3 -2
- quizzy-0.4.0.dist-info/RECORD +10 -0
- quizzy-0.3.0.dist-info/RECORD +0 -10
- {quizzy-0.3.0.dist-info → quizzy-0.4.0.dist-info}/WHEEL +0 -0
- {quizzy-0.3.0.dist-info → quizzy-0.4.0.dist-info}/entry_points.txt +0 -0
- {quizzy-0.3.0.dist-info → quizzy-0.4.0.dist-info}/licenses/LICENSE +0 -0
quizzy/__main__.py
CHANGED
quizzy/app.py
CHANGED
@@ -2,22 +2,18 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import argparse
|
4
4
|
import pathlib
|
5
|
+
import shlex
|
6
|
+
import sys
|
7
|
+
from typing import NoReturn
|
5
8
|
|
6
9
|
from textual import app, binding, containers, log, message, reactive, screen, widgets
|
10
|
+
from textual_serve import server
|
7
11
|
|
8
12
|
from quizzy import __version__, models
|
9
13
|
|
10
14
|
NoCorrectAnswerType = type("NoCorrectAnswerType", (object,), {})
|
11
15
|
NoCorrectAnswer = NoCorrectAnswerType()
|
12
16
|
|
13
|
-
|
14
|
-
def get_arg_parser() -> argparse.ArgumentParser:
|
15
|
-
parser = argparse.ArgumentParser(prog=__name__.split(".")[0], description="A terminal quiz app")
|
16
|
-
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
17
|
-
parser.add_argument("quizfile", type=pathlib.Path, help="Quiz file")
|
18
|
-
return parser
|
19
|
-
|
20
|
-
|
21
17
|
QuestionScreenResult = models.Team | NoCorrectAnswerType | None
|
22
18
|
|
23
19
|
|
@@ -230,12 +226,9 @@ class QuestionBoard(containers.HorizontalGroup):
|
|
230
226
|
class QuizzyApp(app.App[None]):
|
231
227
|
CSS_PATH = "quizzy.tcss"
|
232
228
|
|
233
|
-
def __init__(self) -> None:
|
229
|
+
def __init__(self, config: models.Config) -> None:
|
234
230
|
super().__init__()
|
235
|
-
|
236
|
-
namespace = parser.parse_args()
|
237
|
-
|
238
|
-
self.config = models.load_config(namespace.quizfile)
|
231
|
+
self.config = config
|
239
232
|
self.scoreboard_widget = Scoreboard(self.config.teams)
|
240
233
|
|
241
234
|
def compose(self) -> app.ComposeResult:
|
@@ -248,3 +241,33 @@ class QuizzyApp(app.App[None]):
|
|
248
241
|
|
249
242
|
def on_mount(self) -> None:
|
250
243
|
self.theme = "textual-light"
|
244
|
+
|
245
|
+
|
246
|
+
def get_arg_parser() -> argparse.ArgumentParser:
|
247
|
+
parser = argparse.ArgumentParser(prog=__name__.split(".")[0], description="A terminal quiz app")
|
248
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
249
|
+
|
250
|
+
serve_group = parser.add_argument_group("Serve options")
|
251
|
+
serve_group.add_argument("--serve", action="store_true", help="Serve the app through the browser")
|
252
|
+
serve_group.add_argument("--host", default="localhost", help="Host to serve the app on")
|
253
|
+
serve_group.add_argument("--port", type=int, default=8000, help="Port to serve the app on")
|
254
|
+
|
255
|
+
parser.add_argument("quizfile", type=pathlib.Path, help="Quiz file")
|
256
|
+
return parser
|
257
|
+
|
258
|
+
|
259
|
+
def main() -> NoReturn:
|
260
|
+
parser = get_arg_parser()
|
261
|
+
namespace = parser.parse_args()
|
262
|
+
|
263
|
+
if namespace.serve:
|
264
|
+
# The --serve flag is set, drop it from the args and serve the app instead through textual-serve
|
265
|
+
args = list(sys.argv)
|
266
|
+
args.remove("--serve")
|
267
|
+
|
268
|
+
server.Server(shlex.join(args), host=namespace.host, port=namespace.port).serve()
|
269
|
+
else:
|
270
|
+
config = models.load_config(namespace.quizfile)
|
271
|
+
app = QuizzyApp(config)
|
272
|
+
app.run()
|
273
|
+
sys.exit(0)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: quizzy
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: A Python TUI quiz app
|
5
5
|
Author-email: Jonas Ehrlich <jonas.ehrlich@gmail.com>
|
6
6
|
License-Expression: MIT
|
@@ -8,6 +8,7 @@ License-File: LICENSE
|
|
8
8
|
Requires-Python: >=3.10
|
9
9
|
Requires-Dist: pydantic>=2.10.3
|
10
10
|
Requires-Dist: pyyaml>=6.0.2
|
11
|
+
Requires-Dist: textual-serve>=1.1.1
|
11
12
|
Requires-Dist: textual>=1.0.0
|
12
13
|
Description-Content-Type: text/markdown
|
13
14
|
|
@@ -63,7 +64,7 @@ uv run quizzy examples/quizzy.yaml
|
|
63
64
|
Serve on a webserver using textual:
|
64
65
|
|
65
66
|
``` sh
|
66
|
-
|
67
|
+
uvx quizzy --serve examples/quizzy.yaml
|
67
68
|
```
|
68
69
|
|
69
70
|
Run in development mode:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
quizzy/__init__.py,sha256=IILIKzO2OO60Rhsh3SqhdKHDf7XI_RLRwzztBGZZmHY,78
|
2
|
+
quizzy/__main__.py,sha256=GiZpRpqbaOVG0pDtJswF_VsLByVFP2VMhHgm0Lm0LWw,36
|
3
|
+
quizzy/app.py,sha256=K1f0_wzcoAsTHbu4VPxKqIdb-j5rrLawWkR1Ez9PD-s,10173
|
4
|
+
quizzy/models.py,sha256=JrAc2IvtXByIKNg_lX7uQMK19zwi2WsYcNbttXccbOs,1265
|
5
|
+
quizzy/quizzy.tcss,sha256=VcPEGQ1J7oGatPf3kB-Hzo9AHQdrI7cOV8hDT_l9-3A,1810
|
6
|
+
quizzy-0.4.0.dist-info/METADATA,sha256=lk2-Z9mhWOUrVla4dbrC5VmFshu4Z8KXIMmbjhYww44,1608
|
7
|
+
quizzy-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
+
quizzy-0.4.0.dist-info/entry_points.txt,sha256=2RiVMgcS4h7TM59u9dyBQFm53cG6Eyekmb8fqZ5rXHM,48
|
9
|
+
quizzy-0.4.0.dist-info/licenses/LICENSE,sha256=JWN3MACgsucm6y_rlL_2MUzst0-wNh-Wab3XkxtfVzM,1070
|
10
|
+
quizzy-0.4.0.dist-info/RECORD,,
|
quizzy-0.3.0.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
quizzy/__init__.py,sha256=IILIKzO2OO60Rhsh3SqhdKHDf7XI_RLRwzztBGZZmHY,78
|
2
|
-
quizzy/__main__.py,sha256=TxTz5dT__4--aF49xzShPppphmYLCNYKMraPhp6scIc,117
|
3
|
-
quizzy/app.py,sha256=4Eh_c-kmM9T0MlfOmf4huYxdgFMWwQ_eCDzamLE81zQ,9312
|
4
|
-
quizzy/models.py,sha256=JrAc2IvtXByIKNg_lX7uQMK19zwi2WsYcNbttXccbOs,1265
|
5
|
-
quizzy/quizzy.tcss,sha256=VcPEGQ1J7oGatPf3kB-Hzo9AHQdrI7cOV8hDT_l9-3A,1810
|
6
|
-
quizzy-0.3.0.dist-info/METADATA,sha256=ELm8B0ukRe73MxsyG3Htmyt_-WPGr7xG8l9QWMpoapg,1590
|
7
|
-
quizzy-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
8
|
-
quizzy-0.3.0.dist-info/entry_points.txt,sha256=2RiVMgcS4h7TM59u9dyBQFm53cG6Eyekmb8fqZ5rXHM,48
|
9
|
-
quizzy-0.3.0.dist-info/licenses/LICENSE,sha256=JWN3MACgsucm6y_rlL_2MUzst0-wNh-Wab3XkxtfVzM,1070
|
10
|
-
quizzy-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|