provost 0.1.0__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.
Potentially problematic release.
This version of provost might be problematic. Click here for more details.
- provost-0.1.0/LICENSE +21 -0
- provost-0.1.0/PKG-INFO +173 -0
- provost-0.1.0/README.md +137 -0
- provost-0.1.0/pyproject.toml +68 -0
- provost-0.1.0/setup.cfg +4 -0
- provost-0.1.0/src/provost/__init__.py +84 -0
- provost-0.1.0/src/provost/__main__.py +6 -0
- provost-0.1.0/src/provost/attendance.py +75 -0
- provost-0.1.0/src/provost/cli.py +118 -0
- provost-0.1.0/src/provost/giving.py +73 -0
- provost-0.1.0/src/provost/io.py +43 -0
- provost-0.1.0/src/provost/membership.py +70 -0
- provost-0.1.0/src/provost/metrics.py +91 -0
- provost-0.1.0/src/provost/models.py +75 -0
- provost-0.1.0/src/provost/py.typed +0 -0
- provost-0.1.0/src/provost.egg-info/PKG-INFO +173 -0
- provost-0.1.0/src/provost.egg-info/SOURCES.txt +25 -0
- provost-0.1.0/src/provost.egg-info/dependency_links.txt +1 -0
- provost-0.1.0/src/provost.egg-info/entry_points.txt +2 -0
- provost-0.1.0/src/provost.egg-info/requires.txt +8 -0
- provost-0.1.0/src/provost.egg-info/top_level.txt +1 -0
- provost-0.1.0/tests/test_attendance.py +54 -0
- provost-0.1.0/tests/test_cli.py +37 -0
- provost-0.1.0/tests/test_giving.py +57 -0
- provost-0.1.0/tests/test_io.py +40 -0
- provost-0.1.0/tests/test_membership.py +56 -0
- provost-0.1.0/tests/test_metrics.py +56 -0
provost-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Martin Gallagher
|
|
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.
|
provost-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: provost
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Simple, dependency-free data automation for church administration (attendance, giving and membership analytics).
|
|
5
|
+
Author-email: Martin Gallagher <martinjgallagher@icloud.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/MartinGallagher-code/provost
|
|
8
|
+
Project-URL: Repository, https://github.com/MartinGallagher-code/provost
|
|
9
|
+
Project-URL: Documentation, https://github.com/MartinGallagher-code/provost/tree/main/docs
|
|
10
|
+
Project-URL: Issues, https://github.com/MartinGallagher-code/provost/issues
|
|
11
|
+
Keywords: church,congregation,administration,attendance,giving,membership,analytics,csv
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Religion
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Office/Business
|
|
24
|
+
Classifier: Topic :: Religion
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Provides-Extra: docs
|
|
32
|
+
Requires-Dist: mkdocs>=1.5; extra == "docs"
|
|
33
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
34
|
+
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# provost
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/provost/)
|
|
40
|
+
[](https://pypi.org/project/provost/)
|
|
41
|
+
[](https://github.com/MartinGallagher-code/provost/blob/main/LICENSE)
|
|
42
|
+
[](https://github.com/MartinGallagher-code/provost/actions/workflows/ci.yml)
|
|
43
|
+
[](https://pypi.org/project/provost/)
|
|
44
|
+
[](https://pypi.org/project/provost/)
|
|
45
|
+
|
|
46
|
+
**Simple, dependency-free data automation for church administration.**
|
|
47
|
+
|
|
48
|
+
`provost` helps church and congregation administrators turn the CSV exports
|
|
49
|
+
their management software already produces into plain-English summaries:
|
|
50
|
+
attendance trends, giving analytics and membership lifecycle metrics — without
|
|
51
|
+
a spreadsheet wrestling match.
|
|
52
|
+
|
|
53
|
+
The name is a nod to the traditional role of a *provost*: the person who keeps
|
|
54
|
+
the day-to-day administration of a church running.
|
|
55
|
+
|
|
56
|
+
📚 **Full documentation** lives in [`docs/`](docs/index.md) and builds into a
|
|
57
|
+
searchable site with MkDocs (`pip install ".[docs]" && mkdocs serve`).
|
|
58
|
+
|
|
59
|
+
## Why provost?
|
|
60
|
+
|
|
61
|
+
- **No third-party runtime dependencies.** It is built entirely on the Python
|
|
62
|
+
standard library, so it installs instantly and audits easily.
|
|
63
|
+
- **No surprises.** It reads only the CSV files you point it at and writes only
|
|
64
|
+
to stdout. It never touches the network, phones home, collects telemetry, or
|
|
65
|
+
runs anything at install time. What you see in the source is all it does.
|
|
66
|
+
- **Explainable maths.** Every metric is a short, readable function you can
|
|
67
|
+
check yourself. No black boxes.
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install provost
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Python 3.9 or newer.
|
|
76
|
+
|
|
77
|
+
## Quick start
|
|
78
|
+
|
|
79
|
+
### As a command-line tool
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
provost attendance attendance.csv
|
|
83
|
+
provost giving giving.csv
|
|
84
|
+
provost members members.csv
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Example output:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
Attendance summary for attendance.csv
|
|
91
|
+
weeks recorded : 12
|
|
92
|
+
mean / week : 182.5
|
|
93
|
+
median / week : 180.0
|
|
94
|
+
best week : 240
|
|
95
|
+
quietest week : 150
|
|
96
|
+
next-week est. : 188.0
|
|
97
|
+
by year:
|
|
98
|
+
2024: 2190
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### As a library
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from provost import read_attendance, attendance_summary, forecast_next
|
|
105
|
+
|
|
106
|
+
records = read_attendance("attendance.csv")
|
|
107
|
+
print(attendance_summary(records)) # mean, median, min, max, stdev...
|
|
108
|
+
print(forecast_next(records)) # naive next-week estimate
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from provost import read_giving, giving_by_fund, recurring_donors
|
|
113
|
+
|
|
114
|
+
gifts = read_giving("giving.csv")
|
|
115
|
+
print(giving_by_fund(gifts)) # {"general": 12450.0, "building": 3200.0}
|
|
116
|
+
print(recurring_donors(gifts)) # members who gave in 3+ distinct months
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from provost import read_members, active_members, retention_rate
|
|
121
|
+
from datetime import date
|
|
122
|
+
|
|
123
|
+
members = read_members("members.csv")
|
|
124
|
+
print(len(active_members(members)))
|
|
125
|
+
print(retention_rate(members, date(2023, 1, 1), date(2024, 1, 1)))
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Expected CSV formats
|
|
129
|
+
|
|
130
|
+
**Attendance** — `date,service,count` (`service` optional, defaults to `main`):
|
|
131
|
+
|
|
132
|
+
```csv
|
|
133
|
+
date,service,count
|
|
134
|
+
2024-01-07,morning,182
|
|
135
|
+
2024-01-07,evening,64
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Giving** — `date,member_id,amount` (plus optional `fund`, `method`):
|
|
139
|
+
|
|
140
|
+
```csv
|
|
141
|
+
date,member_id,amount,fund,method
|
|
142
|
+
2024-01-07,M001,100.00,general,card
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Members** — `member_id,join_date` (plus optional `status`, `left_date`):
|
|
146
|
+
|
|
147
|
+
```csv
|
|
148
|
+
member_id,join_date,status,left_date
|
|
149
|
+
M001,2019-03-01,active,
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Sample files live in [`examples/`](examples/).
|
|
153
|
+
|
|
154
|
+
## What's included
|
|
155
|
+
|
|
156
|
+
| Module | Highlights |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `provost.attendance` | weekly totals, rolling average, year-over-year, naive forecast |
|
|
159
|
+
| `provost.giving` | totals, split by fund/member, average gift, recurring donors |
|
|
160
|
+
| `provost.membership` | active members, joiners, leavers, net growth, retention |
|
|
161
|
+
| `provost.metrics` | moving average, growth rate, CAGR, percentile, summary stats |
|
|
162
|
+
| `provost.io` | tolerant CSV loaders with clear per-row error messages |
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
pip install -e ".[dev]"
|
|
168
|
+
pytest
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
[MIT](LICENSE)
|
provost-0.1.0/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# provost
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/provost/)
|
|
4
|
+
[](https://pypi.org/project/provost/)
|
|
5
|
+
[](https://github.com/MartinGallagher-code/provost/blob/main/LICENSE)
|
|
6
|
+
[](https://github.com/MartinGallagher-code/provost/actions/workflows/ci.yml)
|
|
7
|
+
[](https://pypi.org/project/provost/)
|
|
8
|
+
[](https://pypi.org/project/provost/)
|
|
9
|
+
|
|
10
|
+
**Simple, dependency-free data automation for church administration.**
|
|
11
|
+
|
|
12
|
+
`provost` helps church and congregation administrators turn the CSV exports
|
|
13
|
+
their management software already produces into plain-English summaries:
|
|
14
|
+
attendance trends, giving analytics and membership lifecycle metrics — without
|
|
15
|
+
a spreadsheet wrestling match.
|
|
16
|
+
|
|
17
|
+
The name is a nod to the traditional role of a *provost*: the person who keeps
|
|
18
|
+
the day-to-day administration of a church running.
|
|
19
|
+
|
|
20
|
+
📚 **Full documentation** lives in [`docs/`](docs/index.md) and builds into a
|
|
21
|
+
searchable site with MkDocs (`pip install ".[docs]" && mkdocs serve`).
|
|
22
|
+
|
|
23
|
+
## Why provost?
|
|
24
|
+
|
|
25
|
+
- **No third-party runtime dependencies.** It is built entirely on the Python
|
|
26
|
+
standard library, so it installs instantly and audits easily.
|
|
27
|
+
- **No surprises.** It reads only the CSV files you point it at and writes only
|
|
28
|
+
to stdout. It never touches the network, phones home, collects telemetry, or
|
|
29
|
+
runs anything at install time. What you see in the source is all it does.
|
|
30
|
+
- **Explainable maths.** Every metric is a short, readable function you can
|
|
31
|
+
check yourself. No black boxes.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install provost
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Python 3.9 or newer.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
### As a command-line tool
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
provost attendance attendance.csv
|
|
47
|
+
provost giving giving.csv
|
|
48
|
+
provost members members.csv
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Example output:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Attendance summary for attendance.csv
|
|
55
|
+
weeks recorded : 12
|
|
56
|
+
mean / week : 182.5
|
|
57
|
+
median / week : 180.0
|
|
58
|
+
best week : 240
|
|
59
|
+
quietest week : 150
|
|
60
|
+
next-week est. : 188.0
|
|
61
|
+
by year:
|
|
62
|
+
2024: 2190
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### As a library
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from provost import read_attendance, attendance_summary, forecast_next
|
|
69
|
+
|
|
70
|
+
records = read_attendance("attendance.csv")
|
|
71
|
+
print(attendance_summary(records)) # mean, median, min, max, stdev...
|
|
72
|
+
print(forecast_next(records)) # naive next-week estimate
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from provost import read_giving, giving_by_fund, recurring_donors
|
|
77
|
+
|
|
78
|
+
gifts = read_giving("giving.csv")
|
|
79
|
+
print(giving_by_fund(gifts)) # {"general": 12450.0, "building": 3200.0}
|
|
80
|
+
print(recurring_donors(gifts)) # members who gave in 3+ distinct months
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from provost import read_members, active_members, retention_rate
|
|
85
|
+
from datetime import date
|
|
86
|
+
|
|
87
|
+
members = read_members("members.csv")
|
|
88
|
+
print(len(active_members(members)))
|
|
89
|
+
print(retention_rate(members, date(2023, 1, 1), date(2024, 1, 1)))
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Expected CSV formats
|
|
93
|
+
|
|
94
|
+
**Attendance** — `date,service,count` (`service` optional, defaults to `main`):
|
|
95
|
+
|
|
96
|
+
```csv
|
|
97
|
+
date,service,count
|
|
98
|
+
2024-01-07,morning,182
|
|
99
|
+
2024-01-07,evening,64
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Giving** — `date,member_id,amount` (plus optional `fund`, `method`):
|
|
103
|
+
|
|
104
|
+
```csv
|
|
105
|
+
date,member_id,amount,fund,method
|
|
106
|
+
2024-01-07,M001,100.00,general,card
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Members** — `member_id,join_date` (plus optional `status`, `left_date`):
|
|
110
|
+
|
|
111
|
+
```csv
|
|
112
|
+
member_id,join_date,status,left_date
|
|
113
|
+
M001,2019-03-01,active,
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Sample files live in [`examples/`](examples/).
|
|
117
|
+
|
|
118
|
+
## What's included
|
|
119
|
+
|
|
120
|
+
| Module | Highlights |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `provost.attendance` | weekly totals, rolling average, year-over-year, naive forecast |
|
|
123
|
+
| `provost.giving` | totals, split by fund/member, average gift, recurring donors |
|
|
124
|
+
| `provost.membership` | active members, joiners, leavers, net growth, retention |
|
|
125
|
+
| `provost.metrics` | moving average, growth rate, CAGR, percentile, summary stats |
|
|
126
|
+
| `provost.io` | tolerant CSV loaders with clear per-row error messages |
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install -e ".[dev]"
|
|
132
|
+
pytest
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "provost"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Simple, dependency-free data automation for church administration (attendance, giving and membership analytics)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Martin Gallagher", email = "martinjgallagher@icloud.com" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"church",
|
|
15
|
+
"congregation",
|
|
16
|
+
"administration",
|
|
17
|
+
"attendance",
|
|
18
|
+
"giving",
|
|
19
|
+
"membership",
|
|
20
|
+
"analytics",
|
|
21
|
+
"csv",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"Intended Audience :: Religion",
|
|
26
|
+
"Intended Audience :: End Users/Desktop",
|
|
27
|
+
"License :: OSI Approved :: MIT License",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.9",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Topic :: Office/Business",
|
|
36
|
+
"Topic :: Religion",
|
|
37
|
+
"Typing :: Typed",
|
|
38
|
+
]
|
|
39
|
+
dependencies = []
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/MartinGallagher-code/provost"
|
|
43
|
+
Repository = "https://github.com/MartinGallagher-code/provost"
|
|
44
|
+
Documentation = "https://github.com/MartinGallagher-code/provost/tree/main/docs"
|
|
45
|
+
Issues = "https://github.com/MartinGallagher-code/provost/issues"
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
dev = ["pytest>=7.0"]
|
|
49
|
+
docs = [
|
|
50
|
+
"mkdocs>=1.5",
|
|
51
|
+
"mkdocs-material>=9.5",
|
|
52
|
+
"mkdocstrings[python]>=0.24",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[project.scripts]
|
|
56
|
+
provost = "provost.cli:main"
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.dynamic]
|
|
59
|
+
version = { attr = "provost.__version__" }
|
|
60
|
+
|
|
61
|
+
[tool.setuptools.packages.find]
|
|
62
|
+
where = ["src"]
|
|
63
|
+
|
|
64
|
+
[tool.setuptools.package-data]
|
|
65
|
+
provost = ["py.typed"]
|
|
66
|
+
|
|
67
|
+
[tool.pytest.ini_options]
|
|
68
|
+
testpaths = ["tests"]
|
provost-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""provost — simple, transparent data automation for church administration.
|
|
2
|
+
|
|
3
|
+
``provost`` helps church and congregation administrators turn the CSV exports
|
|
4
|
+
their management software already produces into plain-English summaries:
|
|
5
|
+
attendance trends, giving analytics and membership lifecycle metrics.
|
|
6
|
+
|
|
7
|
+
Design principles:
|
|
8
|
+
|
|
9
|
+
* **Standard library only.** No third-party runtime dependencies.
|
|
10
|
+
* **No side effects.** Nothing here touches the network, reads the system
|
|
11
|
+
clock implicitly, or executes anything from the data it reads.
|
|
12
|
+
* **Explainable maths.** Every metric is a short, auditable function.
|
|
13
|
+
|
|
14
|
+
Example
|
|
15
|
+
-------
|
|
16
|
+
>>> from provost import read_attendance, attendance_summary
|
|
17
|
+
>>> records = read_attendance("attendance.csv")
|
|
18
|
+
>>> attendance_summary(records)["mean"] # doctest: +SKIP
|
|
19
|
+
182.5
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from .io import read_attendance, read_giving, read_members
|
|
25
|
+
from .models import AttendanceRecord, GivingRecord, Member
|
|
26
|
+
from . import attendance, giving, membership, metrics
|
|
27
|
+
from .attendance import (
|
|
28
|
+
attendance_summary,
|
|
29
|
+
forecast_next,
|
|
30
|
+
rolling_average,
|
|
31
|
+
weekly_totals,
|
|
32
|
+
year_over_year,
|
|
33
|
+
)
|
|
34
|
+
from .giving import (
|
|
35
|
+
average_gift,
|
|
36
|
+
giving_by_fund,
|
|
37
|
+
giving_by_member,
|
|
38
|
+
giving_summary,
|
|
39
|
+
recurring_donors,
|
|
40
|
+
total_giving,
|
|
41
|
+
)
|
|
42
|
+
from .membership import (
|
|
43
|
+
active_members,
|
|
44
|
+
net_growth,
|
|
45
|
+
new_members,
|
|
46
|
+
retention_rate,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
__version__ = "0.1.0"
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"__version__",
|
|
53
|
+
# io
|
|
54
|
+
"read_attendance",
|
|
55
|
+
"read_giving",
|
|
56
|
+
"read_members",
|
|
57
|
+
# models
|
|
58
|
+
"AttendanceRecord",
|
|
59
|
+
"GivingRecord",
|
|
60
|
+
"Member",
|
|
61
|
+
# submodules
|
|
62
|
+
"attendance",
|
|
63
|
+
"giving",
|
|
64
|
+
"membership",
|
|
65
|
+
"metrics",
|
|
66
|
+
# attendance
|
|
67
|
+
"attendance_summary",
|
|
68
|
+
"forecast_next",
|
|
69
|
+
"rolling_average",
|
|
70
|
+
"weekly_totals",
|
|
71
|
+
"year_over_year",
|
|
72
|
+
# giving
|
|
73
|
+
"average_gift",
|
|
74
|
+
"giving_by_fund",
|
|
75
|
+
"giving_by_member",
|
|
76
|
+
"giving_summary",
|
|
77
|
+
"recurring_donors",
|
|
78
|
+
"total_giving",
|
|
79
|
+
# membership
|
|
80
|
+
"active_members",
|
|
81
|
+
"net_growth",
|
|
82
|
+
"new_members",
|
|
83
|
+
"retention_rate",
|
|
84
|
+
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Attendance analytics.
|
|
2
|
+
|
|
3
|
+
Turns a list of :class:`~provost.models.AttendanceRecord` into weekly totals,
|
|
4
|
+
rolling averages, year-over-year comparisons and a naive next-period forecast.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from collections import defaultdict
|
|
10
|
+
from datetime import date
|
|
11
|
+
from typing import Sequence
|
|
12
|
+
|
|
13
|
+
from .metrics import moving_average, summarize
|
|
14
|
+
from .models import AttendanceRecord
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def weekly_totals(records: Sequence[AttendanceRecord]) -> dict[date, int]:
|
|
18
|
+
"""Sum attendance per ISO-week, keyed by that week's Monday.
|
|
19
|
+
|
|
20
|
+
Every service on the same date is combined, then dates are grouped into
|
|
21
|
+
their week. The result is ordered oldest-first.
|
|
22
|
+
"""
|
|
23
|
+
by_week: dict[date, int] = defaultdict(int)
|
|
24
|
+
for record in records:
|
|
25
|
+
monday = record.date.fromordinal(
|
|
26
|
+
record.date.toordinal() - record.date.weekday()
|
|
27
|
+
)
|
|
28
|
+
by_week[monday] += record.count
|
|
29
|
+
return dict(sorted(by_week.items()))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def rolling_average(
|
|
33
|
+
records: Sequence[AttendanceRecord], window: int = 4
|
|
34
|
+
) -> list[tuple[date, float]]:
|
|
35
|
+
"""Rolling average of weekly totals over ``window`` weeks.
|
|
36
|
+
|
|
37
|
+
Returns ``(week_start, average)`` pairs. An empty list is returned when
|
|
38
|
+
there are fewer weeks of data than ``window``.
|
|
39
|
+
"""
|
|
40
|
+
weeks = weekly_totals(records)
|
|
41
|
+
if len(weeks) < window:
|
|
42
|
+
return []
|
|
43
|
+
starts = list(weeks.keys())
|
|
44
|
+
counts = list(weeks.values())
|
|
45
|
+
averages = moving_average(counts, window)
|
|
46
|
+
return list(zip(starts[window - 1 :], averages))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def year_over_year(records: Sequence[AttendanceRecord]) -> dict[int, int]:
|
|
50
|
+
"""Total attendance grouped by calendar year, ordered oldest-first."""
|
|
51
|
+
by_year: dict[int, int] = defaultdict(int)
|
|
52
|
+
for record in records:
|
|
53
|
+
by_year[record.date.year] += record.count
|
|
54
|
+
return dict(sorted(by_year.items()))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def forecast_next(records: Sequence[AttendanceRecord], window: int = 4) -> float:
|
|
58
|
+
"""Naive forecast for the next week: the mean of the last ``window`` weeks.
|
|
59
|
+
|
|
60
|
+
This is deliberately simple and explainable — it is a baseline, not a
|
|
61
|
+
statistical model. Raises ``ValueError`` when there is no data.
|
|
62
|
+
"""
|
|
63
|
+
weeks = weekly_totals(records)
|
|
64
|
+
if not weeks:
|
|
65
|
+
raise ValueError("no attendance data to forecast from")
|
|
66
|
+
recent = list(weeks.values())[-window:]
|
|
67
|
+
return sum(recent) / len(recent)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def attendance_summary(records: Sequence[AttendanceRecord]) -> dict[str, float]:
|
|
71
|
+
"""Descriptive statistics of weekly attendance totals."""
|
|
72
|
+
weeks = weekly_totals(records)
|
|
73
|
+
if not weeks:
|
|
74
|
+
raise ValueError("no attendance data to summarize")
|
|
75
|
+
return summarize(weeks.values())
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Command-line interface for provost.
|
|
2
|
+
|
|
3
|
+
Usage::
|
|
4
|
+
|
|
5
|
+
provost attendance path/to/attendance.csv
|
|
6
|
+
provost giving path/to/giving.csv
|
|
7
|
+
provost members path/to/members.csv
|
|
8
|
+
|
|
9
|
+
Each command prints a human-readable summary to stdout. The CLI reads only the
|
|
10
|
+
file you point it at and writes only to stdout.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import sys
|
|
17
|
+
from typing import Sequence
|
|
18
|
+
|
|
19
|
+
from . import __version__
|
|
20
|
+
from .attendance import attendance_summary, forecast_next, year_over_year
|
|
21
|
+
from .giving import (
|
|
22
|
+
average_gift,
|
|
23
|
+
giving_by_fund,
|
|
24
|
+
recurring_donors,
|
|
25
|
+
total_giving,
|
|
26
|
+
)
|
|
27
|
+
from .io import read_attendance, read_giving, read_members
|
|
28
|
+
from .membership import active_members
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _money(value: float) -> str:
|
|
32
|
+
return f"{value:,.2f}"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _cmd_attendance(path: str) -> int:
|
|
36
|
+
records = read_attendance(path)
|
|
37
|
+
if not records:
|
|
38
|
+
print("No attendance records found.")
|
|
39
|
+
return 0
|
|
40
|
+
stats = attendance_summary(records)
|
|
41
|
+
print(f"Attendance summary for {path}")
|
|
42
|
+
print(f" weeks recorded : {int(stats['count'])}")
|
|
43
|
+
print(f" mean / week : {stats['mean']:.1f}")
|
|
44
|
+
print(f" median / week : {stats['median']:.1f}")
|
|
45
|
+
print(f" best week : {int(stats['max'])}")
|
|
46
|
+
print(f" quietest week : {int(stats['min'])}")
|
|
47
|
+
print(f" next-week est. : {forecast_next(records):.1f}")
|
|
48
|
+
print(" by year:")
|
|
49
|
+
for year, total in year_over_year(records).items():
|
|
50
|
+
print(f" {year}: {total}")
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _cmd_giving(path: str) -> int:
|
|
55
|
+
records = read_giving(path)
|
|
56
|
+
if not records:
|
|
57
|
+
print("No giving records found.")
|
|
58
|
+
return 0
|
|
59
|
+
print(f"Giving summary for {path}")
|
|
60
|
+
print(f" gifts recorded : {len(records)}")
|
|
61
|
+
print(f" total given : {_money(total_giving(records))}")
|
|
62
|
+
print(f" average gift : {_money(average_gift(records))}")
|
|
63
|
+
print(" by fund:")
|
|
64
|
+
for fund, amount in giving_by_fund(records).items():
|
|
65
|
+
print(f" {fund}: {_money(amount)}")
|
|
66
|
+
recurring = recurring_donors(records)
|
|
67
|
+
print(f" recurring donors (3+ months): {len(recurring)}")
|
|
68
|
+
return 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _cmd_members(path: str) -> int:
|
|
72
|
+
members = read_members(path)
|
|
73
|
+
if not members:
|
|
74
|
+
print("No member records found.")
|
|
75
|
+
return 0
|
|
76
|
+
active = active_members(members)
|
|
77
|
+
print(f"Membership summary for {path}")
|
|
78
|
+
print(f" members on file : {len(members)}")
|
|
79
|
+
print(f" currently active: {len(active)}")
|
|
80
|
+
return 0
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
84
|
+
parser = argparse.ArgumentParser(
|
|
85
|
+
prog="provost",
|
|
86
|
+
description="Simple data automation for church administration.",
|
|
87
|
+
)
|
|
88
|
+
parser.add_argument("--version", action="version", version=f"provost {__version__}")
|
|
89
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
90
|
+
|
|
91
|
+
for name, help_text in (
|
|
92
|
+
("attendance", "Summarise an attendance CSV."),
|
|
93
|
+
("giving", "Summarise a giving CSV."),
|
|
94
|
+
("members", "Summarise a members CSV."),
|
|
95
|
+
):
|
|
96
|
+
p = sub.add_parser(name, help=help_text)
|
|
97
|
+
p.add_argument("path", help="Path to the CSV file.")
|
|
98
|
+
|
|
99
|
+
return parser
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
103
|
+
parser = build_parser()
|
|
104
|
+
args = parser.parse_args(argv)
|
|
105
|
+
handlers = {
|
|
106
|
+
"attendance": _cmd_attendance,
|
|
107
|
+
"giving": _cmd_giving,
|
|
108
|
+
"members": _cmd_members,
|
|
109
|
+
}
|
|
110
|
+
try:
|
|
111
|
+
return handlers[args.command](args.path)
|
|
112
|
+
except (OSError, ValueError) as exc:
|
|
113
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
114
|
+
return 1
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__": # pragma: no cover
|
|
118
|
+
raise SystemExit(main())
|