bhs-calendars 2.8.1__tar.gz
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.
- bhs_calendars-2.8.1/LICENSE +21 -0
- bhs_calendars-2.8.1/PKG-INFO +72 -0
- bhs_calendars-2.8.1/README.md +44 -0
- bhs_calendars-2.8.1/bhs_calendars/__init__.py +50 -0
- bhs_calendars-2.8.1/bhs_calendars/data/bhs-2022-2023.json +619 -0
- bhs_calendars-2.8.1/bhs_calendars/data/bhs-2023-2024.json +794 -0
- bhs_calendars-2.8.1/bhs_calendars/data/bhs-2024-2025.json +798 -0
- bhs_calendars-2.8.1/bhs_calendars/data/bhs-2025-2026.json +895 -0
- bhs_calendars-2.8.1/bhs_calendars/data/bhs-2026-2027.json +326 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-6-2025-2026.json +156 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-6-2026-2027.json +156 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-7-2025-2026.json +230 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-7-2026-2027.json +230 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-8-2025-2026.json +230 -0
- bhs_calendars-2.8.1/bhs_calendars/data/king-8-2026-2027.json +230 -0
- bhs_calendars-2.8.1/bhs_calendars/data/longfellow-6-2025-2026.json +165 -0
- bhs_calendars-2.8.1/bhs_calendars/data/longfellow-6-2026-2027.json +165 -0
- bhs_calendars-2.8.1/bhs_calendars/data/longfellow-78-2025-2026.json +165 -0
- bhs_calendars-2.8.1/bhs_calendars/data/longfellow-78-2026-2027.json +165 -0
- bhs_calendars-2.8.1/bhs_calendars/data/willard-6-2025-2026.json +209 -0
- bhs_calendars-2.8.1/bhs_calendars/data/willard-6-2026-2027.json +209 -0
- bhs_calendars-2.8.1/bhs_calendars/data/willard-78-2025-2026.json +245 -0
- bhs_calendars-2.8.1/bhs_calendars/data/willard-78-2026-2027.json +245 -0
- bhs_calendars-2.8.1/bhs_calendars.egg-info/PKG-INFO +72 -0
- bhs_calendars-2.8.1/bhs_calendars.egg-info/SOURCES.txt +29 -0
- bhs_calendars-2.8.1/bhs_calendars.egg-info/dependency_links.txt +1 -0
- bhs_calendars-2.8.1/bhs_calendars.egg-info/requires.txt +3 -0
- bhs_calendars-2.8.1/bhs_calendars.egg-info/top_level.txt +1 -0
- bhs_calendars-2.8.1/pyproject.toml +45 -0
- bhs_calendars-2.8.1/setup.cfg +4 -0
- bhs_calendars-2.8.1/tests/test_load.py +37 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Peter Seibel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bhs-calendars
|
|
3
|
+
Version: 2.8.1
|
|
4
|
+
Summary: Bundled BHS-area school bell-schedule calendar data for the bells library
|
|
5
|
+
Author: Peter Seibel
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gigamonkey/bells
|
|
8
|
+
Project-URL: Repository, https://github.com/gigamonkey/bells
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/gigamonkey/bells/issues
|
|
10
|
+
Keywords: bell schedule,school,calendar,berkeley high,bhs,education,data
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Education
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# bhs-calendars (Python)
|
|
30
|
+
|
|
31
|
+
Bundled bell-schedule calendar data for Berkeley High School and nearby middle
|
|
32
|
+
schools, as a Python distribution. This is the Python counterpart of the npm
|
|
33
|
+
[`@peterseibel/bhs-calendars`](https://github.com/gigamonkey/bells/tree/main/bhs-calendars) package and ships the same
|
|
34
|
+
per-year JSON.
|
|
35
|
+
|
|
36
|
+
It is data, not logic — pair it with the [`bells`](https://github.com/gigamonkey/bells/tree/main/libs/python) library to build
|
|
37
|
+
schedules without supplying your own `{year}.json` files.
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install bhs-calendars
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from bhs_calendars import by_id, load_all
|
|
47
|
+
from bells import BellSchedule
|
|
48
|
+
|
|
49
|
+
# Grouped by school, each school's years sorted chronologically:
|
|
50
|
+
years = by_id()["bhs"]
|
|
51
|
+
schedule = BellSchedule(years, {})
|
|
52
|
+
|
|
53
|
+
# Or the flat list of every bundled school-year:
|
|
54
|
+
all_years = load_all() # list[dict]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`load_all()` mirrors the npm package's default export (a flat list of yearly
|
|
58
|
+
calendar objects). `by_id()` groups those by their `id` field — `"bhs"`,
|
|
59
|
+
`"king-6"`, `"king-7"`, `"king-8"`, `"longfellow-6"`, `"longfellow-78"`,
|
|
60
|
+
`"willard-6"`, `"willard-78"` — with each group's years sorted by `firstDay`.
|
|
61
|
+
|
|
62
|
+
Unlike the library's `Calendars` loader (which reads `{year}.json` from a
|
|
63
|
+
directory or URL), this data is bundled on disk with the package: no filesystem
|
|
64
|
+
layout or network access required. The trade-off is that it only covers the
|
|
65
|
+
BHS-area schools.
|
|
66
|
+
|
|
67
|
+
## Data source
|
|
68
|
+
|
|
69
|
+
The JSON under `bhs_calendars/data/` is copied verbatim from the canonical
|
|
70
|
+
`bhs-calendars/` directory at the repository root (the npm package source). Run
|
|
71
|
+
`make sync-calendars` from the repo root to refresh it after the source data
|
|
72
|
+
changes.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# bhs-calendars (Python)
|
|
2
|
+
|
|
3
|
+
Bundled bell-schedule calendar data for Berkeley High School and nearby middle
|
|
4
|
+
schools, as a Python distribution. This is the Python counterpart of the npm
|
|
5
|
+
[`@peterseibel/bhs-calendars`](https://github.com/gigamonkey/bells/tree/main/bhs-calendars) package and ships the same
|
|
6
|
+
per-year JSON.
|
|
7
|
+
|
|
8
|
+
It is data, not logic — pair it with the [`bells`](https://github.com/gigamonkey/bells/tree/main/libs/python) library to build
|
|
9
|
+
schedules without supplying your own `{year}.json` files.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install bhs-calendars
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from bhs_calendars import by_id, load_all
|
|
19
|
+
from bells import BellSchedule
|
|
20
|
+
|
|
21
|
+
# Grouped by school, each school's years sorted chronologically:
|
|
22
|
+
years = by_id()["bhs"]
|
|
23
|
+
schedule = BellSchedule(years, {})
|
|
24
|
+
|
|
25
|
+
# Or the flat list of every bundled school-year:
|
|
26
|
+
all_years = load_all() # list[dict]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`load_all()` mirrors the npm package's default export (a flat list of yearly
|
|
30
|
+
calendar objects). `by_id()` groups those by their `id` field — `"bhs"`,
|
|
31
|
+
`"king-6"`, `"king-7"`, `"king-8"`, `"longfellow-6"`, `"longfellow-78"`,
|
|
32
|
+
`"willard-6"`, `"willard-78"` — with each group's years sorted by `firstDay`.
|
|
33
|
+
|
|
34
|
+
Unlike the library's `Calendars` loader (which reads `{year}.json` from a
|
|
35
|
+
directory or URL), this data is bundled on disk with the package: no filesystem
|
|
36
|
+
layout or network access required. The trade-off is that it only covers the
|
|
37
|
+
BHS-area schools.
|
|
38
|
+
|
|
39
|
+
## Data source
|
|
40
|
+
|
|
41
|
+
The JSON under `bhs_calendars/data/` is copied verbatim from the canonical
|
|
42
|
+
`bhs-calendars/` directory at the repository root (the npm package source). Run
|
|
43
|
+
`make sync-calendars` from the repo root to refresh it after the source data
|
|
44
|
+
changes.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""bhs-calendars — bundled BHS-area school bell-schedule calendar data.
|
|
2
|
+
|
|
3
|
+
Python counterpart of the npm ``@peterseibel/bhs-calendars`` package. Ships the
|
|
4
|
+
per-year calendar JSON for Berkeley High and nearby middle schools as package
|
|
5
|
+
data and exposes it as plain dictionaries, ready to hand to
|
|
6
|
+
``bells.BellSchedule``.
|
|
7
|
+
|
|
8
|
+
Group the flat list by the ``id`` field to assemble the year sequence for a
|
|
9
|
+
single school; a ``BellSchedule`` consumes one such group.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
from collections import defaultdict
|
|
16
|
+
from importlib.resources import files
|
|
17
|
+
|
|
18
|
+
__all__ = ["load_all", "by_id"]
|
|
19
|
+
|
|
20
|
+
__version__ = "2.8.1"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_all() -> list[dict]:
|
|
24
|
+
"""Return every bundled yearly calendar object as a flat list.
|
|
25
|
+
|
|
26
|
+
Parallels the npm package's default export. Each entry is one school-year;
|
|
27
|
+
group by the ``id`` field (or use :func:`by_id`) to get a single school's
|
|
28
|
+
years.
|
|
29
|
+
"""
|
|
30
|
+
out: list[dict] = []
|
|
31
|
+
data_dir = files(__package__).joinpath("data")
|
|
32
|
+
for entry in sorted(data_dir.iterdir(), key=lambda p: p.name):
|
|
33
|
+
if entry.name.endswith(".json"):
|
|
34
|
+
data = json.loads(entry.read_text(encoding="utf-8"))
|
|
35
|
+
out.extend(data if isinstance(data, list) else [data])
|
|
36
|
+
return out
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def by_id() -> dict[str, list[dict]]:
|
|
40
|
+
"""Group :func:`load_all` by ``id``, each group's years sorted by ``firstDay``.
|
|
41
|
+
|
|
42
|
+
Returns a mapping of school id (e.g. ``"bhs"``, ``"king-6"``) to that
|
|
43
|
+
school's years in chronological order.
|
|
44
|
+
"""
|
|
45
|
+
groups: dict[str, list[dict]] = defaultdict(list)
|
|
46
|
+
for year in load_all():
|
|
47
|
+
groups[year["id"]].append(year)
|
|
48
|
+
for years in groups.values():
|
|
49
|
+
years.sort(key=lambda y: y["firstDay"])
|
|
50
|
+
return dict(groups)
|