codehood-cli 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codehood/__init__.py +0 -0
- codehood/__main__.py +4 -0
- codehood/actions/__init__.py +0 -0
- codehood/actions/base.py +119 -0
- codehood/actions/resources.py +30 -0
- codehood/api/__init__.py +0 -0
- codehood/api/base.py +256 -0
- codehood/api/generate.py +1370 -0
- codehood/api/generated.py +3818 -0
- codehood/api/openapi.py +134 -0
- codehood/api/pages.py +53 -0
- codehood/cli/__init__.py +64 -0
- codehood/cli/api.py +422 -0
- codehood/cli/attendance.py +136 -0
- codehood/cli/auth.py +106 -0
- codehood/cli/base.py +42 -0
- codehood/cli/chill.py +52 -0
- codehood/cli/exam.py +107 -0
- codehood/cli/grades.py +185 -0
- codehood/cli/init.py +161 -0
- codehood/cli/push.py +609 -0
- codehood/cli/show.py +77 -0
- codehood/cli/uitils.py +26 -0
- codehood/functional.py +40 -0
- codehood/globs.py +71 -0
- codehood/grades.py +74 -0
- codehood/hypothesis.py +274 -0
- codehood/models/__init__.py +0 -0
- codehood/models/base.py +15 -0
- codehood/models/repo.py +187 -0
- codehood/models/validators.py +177 -0
- codehood/push/__init__.py +225 -0
- codehood/push/base.py +216 -0
- codehood/push/calendar.py +664 -0
- codehood/push/errors.py +136 -0
- codehood/push/exam.py +636 -0
- codehood/push/exclude.py +60 -0
- codehood/push/grades.py +455 -0
- codehood/push/hook.py +48 -0
- codehood/push/links.py +614 -0
- codehood/push/ours.py +78 -0
- codehood/push/plan.py +1981 -0
- codehood/push/project.py +272 -0
- codehood/push/question.py +338 -0
- codehood/push/report.py +244 -0
- codehood/push/repository.py +326 -0
- codehood/push/resource.py +576 -0
- codehood/push/run.py +1275 -0
- codehood/push/unconsumed.py +208 -0
- codehood/push/wire.py +222 -0
- codehood/py.typed +0 -0
- codehood/repo/__init__.py +62 -0
- codehood/repo/_config.py +28 -0
- codehood/repo/_layout.py +132 -0
- codehood/repo/_scaffold.py +244 -0
- codehood/repo/diff.py +71 -0
- codehood/repo/file_tracker.py +124 -0
- codehood/theme.py +101 -0
- codehood/widgets/__init__.py +0 -0
- codehood/widgets/mascot.py +76 -0
- codehood/widgets/questions/__init__.py +65 -0
- codehood/widgets/questions/base.py +119 -0
- codehood/widgets/questions/controls.py +194 -0
- codehood/widgets/questions/fill_in.py +81 -0
- codehood/widgets/questions/responses.py +137 -0
- codehood/widgets/questions/simple.py +117 -0
- codehood_cli-0.5.0.dist-info/METADATA +294 -0
- codehood_cli-0.5.0.dist-info/RECORD +71 -0
- codehood_cli-0.5.0.dist-info/WHEEL +4 -0
- codehood_cli-0.5.0.dist-info/entry_points.txt +4 -0
- codehood_cli-0.5.0.dist-info/licenses/LICENSE +21 -0
codehood/push/errors.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Exceptions `codehood/push/` raises before it touches the network.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"CalendarError",
|
|
12
|
+
"QuestionParseError",
|
|
13
|
+
"QuestionSourceError",
|
|
14
|
+
"RepositoryError",
|
|
15
|
+
"ResourceFileError",
|
|
16
|
+
"ResourceLinkError",
|
|
17
|
+
"SlugCollisionError",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SlugCollisionError(Exception):
|
|
22
|
+
"""
|
|
23
|
+
Two or more files under `resources/` or `questions/` flatten to the
|
|
24
|
+
same slug.
|
|
25
|
+
|
|
26
|
+
Raised by `scan_resources`/`scan_questions` before any network call,
|
|
27
|
+
refusing the whole push: it does not guess which file was meant, and
|
|
28
|
+
does not push a partial repository on the way to an error.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, collisions: Mapping[str, list[Path]]) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Args:
|
|
34
|
+
collisions: Every contested slug mapped to every file that
|
|
35
|
+
wants it.
|
|
36
|
+
"""
|
|
37
|
+
self.collisions = dict(collisions)
|
|
38
|
+
detail = "; ".join(
|
|
39
|
+
f"{slug!r} wanted by {', '.join(str(path) for path in paths)}"
|
|
40
|
+
for slug, paths in self.collisions.items()
|
|
41
|
+
)
|
|
42
|
+
super().__init__(f"colliding slugs: {detail}")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class QuestionParseError(Exception):
|
|
46
|
+
"""
|
|
47
|
+
`mdq` refused to parse a file under `questions/`.
|
|
48
|
+
|
|
49
|
+
Raised by `question.read_question`; `scan_questions` turns it into an
|
|
50
|
+
`InvalidQuestion`, so one bad file fails alone.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(self, path: Path, cause: Exception) -> None:
|
|
54
|
+
"""
|
|
55
|
+
Args:
|
|
56
|
+
path: The question file `mdq` refused.
|
|
57
|
+
cause: The `mdq.InvalidDocument` it raised.
|
|
58
|
+
"""
|
|
59
|
+
self.path = path
|
|
60
|
+
self.cause = cause
|
|
61
|
+
super().__init__(f"{path}: {cause}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class QuestionSourceError(Exception):
|
|
65
|
+
"""
|
|
66
|
+
A file linked by a question or an exam (a test source or an attachment)
|
|
67
|
+
cannot be read, or is over the upload limit.
|
|
68
|
+
|
|
69
|
+
Raised by `question.resolve_test_sources` and `question.read_attachments`
|
|
70
|
+
before any network call, refusing the whole push: the document cannot be
|
|
71
|
+
sent without the files it links, and the server must not keep a version
|
|
72
|
+
that lacks them.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
def __init__(self, path: Path, origin: str, cause: Exception) -> None:
|
|
76
|
+
"""
|
|
77
|
+
Args:
|
|
78
|
+
path: The test file the link resolves to.
|
|
79
|
+
origin: The link target, as written in the question.
|
|
80
|
+
cause: The `OSError` or `UnicodeDecodeError` reading it raised,
|
|
81
|
+
or the `ValueError` saying it is too large.
|
|
82
|
+
"""
|
|
83
|
+
self.path = path
|
|
84
|
+
self.origin = origin
|
|
85
|
+
self.cause = cause
|
|
86
|
+
reason = "file not found" if isinstance(cause, FileNotFoundError) else cause
|
|
87
|
+
super().__init__(f"cannot read linked file {origin!r} ({path}): {reason}")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class CalendarError(Exception):
|
|
91
|
+
"""
|
|
92
|
+
`calendar.md` does not parse, or asks for something impossible.
|
|
93
|
+
|
|
94
|
+
Raised by `calendar.parse_calendar` and `calendar.allocate` before any
|
|
95
|
+
network call, refusing the whole push: the calendar sets the course's
|
|
96
|
+
own dates, so there is no partial push that still makes sense.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class ResourceLinkError(Exception):
|
|
101
|
+
"""
|
|
102
|
+
A `calendar.md` lesson links to `resources/` in a way that cannot be
|
|
103
|
+
pushed.
|
|
104
|
+
|
|
105
|
+
Raised by `links.attach_resources` before any network call, in two
|
|
106
|
+
cases: a link targets a path under `resources/` that no scanned
|
|
107
|
+
resource has, or one resource is linked from two different lessons.
|
|
108
|
+
The message names the offending path and, for the second case, both
|
|
109
|
+
lessons.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class RepositoryError(Exception):
|
|
114
|
+
"""
|
|
115
|
+
A folder under `repositories/` cannot be pushed as it is.
|
|
116
|
+
|
|
117
|
+
Raised by `repository.scan_repositories` before any network call: a loose
|
|
118
|
+
file in `repositories/`, a folder whose name is not a slug, a symlink,
|
|
119
|
+
a file over the upload limit, or a folder with nothing to publish. The
|
|
120
|
+
message names the offending path.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class ResourceFileError(Exception):
|
|
125
|
+
"""
|
|
126
|
+
A file under `resources/` cannot be read as its kind says it should.
|
|
127
|
+
|
|
128
|
+
Raised by `resource.scan_resources` before any network call: an
|
|
129
|
+
`info.yaml` that is not a mapping of existing file names to known keys,
|
|
130
|
+
or a `.url` file with no `http(s)` URI. The message names the file.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
def __init__(self, path: Path, reason: str) -> None:
|
|
134
|
+
self.path = path
|
|
135
|
+
self.reason = reason
|
|
136
|
+
super().__init__(f"{path}: {reason}")
|