moveq-catalogue 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.
- moveq_catalogue-0.1.0/LICENSE +29 -0
- moveq_catalogue-0.1.0/PKG-INFO +91 -0
- moveq_catalogue-0.1.0/README.md +60 -0
- moveq_catalogue-0.1.0/pyproject.toml +50 -0
- moveq_catalogue-0.1.0/setup.cfg +4 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue/__init__.py +7 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue/catalogue.py +114 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue.egg-info/PKG-INFO +91 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue.egg-info/SOURCES.txt +11 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue.egg-info/dependency_links.txt +1 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue.egg-info/requires.txt +3 -0
- moveq_catalogue-0.1.0/src/moveq_catalogue.egg-info/top_level.txt +1 -0
- moveq_catalogue-0.1.0/tests/test_catalogue.py +61 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, moveq contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moveq-catalogue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Same/replace/omit harmonization registry for cross-country transport-equity section catalogues.
|
|
5
|
+
Author-email: Soura <martisoura@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/SVamseekar/moveq
|
|
8
|
+
Project-URL: Documentation, https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md
|
|
9
|
+
Project-URL: Repository, https://github.com/SVamseekar/moveq
|
|
10
|
+
Project-URL: Issues, https://github.com/SVamseekar/moveq/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: transport,equity,harmonization,catalogue,cross-country
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# moveq-catalogue
|
|
33
|
+
|
|
34
|
+
Registry for the **same / replace / omit** pattern used to extend one country's
|
|
35
|
+
section questionnaire to another country without silent omissions.
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
38
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
39
|
+
[](https://github.com/SVamseekar/moveq/blob/main/LICENSE)
|
|
40
|
+
|
|
41
|
+
- **same** — the question carries over; only the local data source changes
|
|
42
|
+
- **replace** — the question does not transfer; a locally meaningful replacement is required
|
|
43
|
+
- **omit** — no small-area variable exists; the section is dropped with a note
|
|
44
|
+
|
|
45
|
+
Most applications should install the umbrella package instead:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install moveq
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Requires Python 3.10+.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install moveq-catalogue
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from moveq_catalogue import Catalogue, SectionAction
|
|
63
|
+
|
|
64
|
+
base_sections = ["coverage_pct", "service_deserts", "policy_scenarios"]
|
|
65
|
+
|
|
66
|
+
ie = Catalogue(base_sections, country="ireland")
|
|
67
|
+
ie.register("coverage_pct", SectionAction.SAME, note="TFI x CSO Small Area")
|
|
68
|
+
ie.register("service_deserts", SectionAction.SAME)
|
|
69
|
+
ie.register(
|
|
70
|
+
"policy_scenarios",
|
|
71
|
+
SectionAction.REPLACE,
|
|
72
|
+
replacement_title="Connecting Ireland / Local Link / BusConnects",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
assert ie.validate() == [] # every base section has been decided
|
|
76
|
+
print(ie.summary()) # {'same': 2, 'replace': 1, 'omit': 0}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`validate()` is the whole point of this package: it fails if a new country
|
|
80
|
+
silently forgets to decide what happens to a base section.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [Catalogue harmonization guide](https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md)
|
|
85
|
+
- [API reference](https://github.com/SVamseekar/moveq/blob/main/docs/api_reference.md)
|
|
86
|
+
- [Source repository](https://github.com/SVamseekar/moveq)
|
|
87
|
+
- [Changelog](https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md)
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[BSD 3-Clause](https://github.com/SVamseekar/moveq/blob/main/LICENSE).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# moveq-catalogue
|
|
2
|
+
|
|
3
|
+
Registry for the **same / replace / omit** pattern used to extend one country's
|
|
4
|
+
section questionnaire to another country without silent omissions.
|
|
5
|
+
|
|
6
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
7
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
8
|
+
[](https://github.com/SVamseekar/moveq/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
- **same** — the question carries over; only the local data source changes
|
|
11
|
+
- **replace** — the question does not transfer; a locally meaningful replacement is required
|
|
12
|
+
- **omit** — no small-area variable exists; the section is dropped with a note
|
|
13
|
+
|
|
14
|
+
Most applications should install the umbrella package instead:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install moveq
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Requires Python 3.10+.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install moveq-catalogue
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from moveq_catalogue import Catalogue, SectionAction
|
|
32
|
+
|
|
33
|
+
base_sections = ["coverage_pct", "service_deserts", "policy_scenarios"]
|
|
34
|
+
|
|
35
|
+
ie = Catalogue(base_sections, country="ireland")
|
|
36
|
+
ie.register("coverage_pct", SectionAction.SAME, note="TFI x CSO Small Area")
|
|
37
|
+
ie.register("service_deserts", SectionAction.SAME)
|
|
38
|
+
ie.register(
|
|
39
|
+
"policy_scenarios",
|
|
40
|
+
SectionAction.REPLACE,
|
|
41
|
+
replacement_title="Connecting Ireland / Local Link / BusConnects",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
assert ie.validate() == [] # every base section has been decided
|
|
45
|
+
print(ie.summary()) # {'same': 2, 'replace': 1, 'omit': 0}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`validate()` is the whole point of this package: it fails if a new country
|
|
49
|
+
silently forgets to decide what happens to a base section.
|
|
50
|
+
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
- [Catalogue harmonization guide](https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md)
|
|
54
|
+
- [API reference](https://github.com/SVamseekar/moveq/blob/main/docs/api_reference.md)
|
|
55
|
+
- [Source repository](https://github.com/SVamseekar/moveq)
|
|
56
|
+
- [Changelog](https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md)
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
[BSD 3-Clause](https://github.com/SVamseekar/moveq/blob/main/LICENSE).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "moveq-catalogue"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Same/replace/omit harmonization registry for cross-country transport-equity section catalogues."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "BSD-3-Clause"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Soura", email = "martisoura@gmail.com" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"transport",
|
|
18
|
+
"equity",
|
|
19
|
+
"harmonization",
|
|
20
|
+
"catalogue",
|
|
21
|
+
"cross-country",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Science/Research",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Scientific/Engineering",
|
|
36
|
+
]
|
|
37
|
+
dependencies = []
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
test = ["pytest>=7"]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://github.com/SVamseekar/moveq"
|
|
44
|
+
Documentation = "https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md"
|
|
45
|
+
Repository = "https://github.com/SVamseekar/moveq"
|
|
46
|
+
Issues = "https://github.com/SVamseekar/moveq/issues"
|
|
47
|
+
Changelog = "https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
where = ["src"]
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"""Same / replace / omit registry for cross-country section catalogues.
|
|
2
|
+
|
|
3
|
+
A base country defines a questionnaire (a list of section ids). Every other
|
|
4
|
+
country must explicitly decide, per section, whether to keep the same
|
|
5
|
+
question against local data (``same``), swap in a locally-meaningful
|
|
6
|
+
question (``replace``), or drop the section because no free small-area
|
|
7
|
+
variable exists yet (``omit``). ``Catalogue.validate()`` fails loudly on any
|
|
8
|
+
section left undecided, so a new country can never silently inherit an
|
|
9
|
+
unconsidered section from the base.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from enum import Enum
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SectionAction(str, Enum):
|
|
20
|
+
SAME = "same"
|
|
21
|
+
REPLACE = "replace"
|
|
22
|
+
OMIT = "omit"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class SectionMapping:
|
|
27
|
+
section_id: str
|
|
28
|
+
action: SectionAction
|
|
29
|
+
country: str
|
|
30
|
+
note: str | None = None
|
|
31
|
+
replacement_title: str | None = None
|
|
32
|
+
|
|
33
|
+
def __post_init__(self) -> None:
|
|
34
|
+
if self.action is SectionAction.REPLACE and not self.replacement_title:
|
|
35
|
+
raise ValueError(
|
|
36
|
+
f"section '{self.section_id}': action=replace requires a replacement_title"
|
|
37
|
+
)
|
|
38
|
+
if self.action is SectionAction.OMIT and not self.note:
|
|
39
|
+
raise ValueError(
|
|
40
|
+
f"section '{self.section_id}': action=omit requires a note explaining why"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict[str, Any]:
|
|
44
|
+
return {
|
|
45
|
+
"section_id": self.section_id,
|
|
46
|
+
"action": self.action.value,
|
|
47
|
+
"country": self.country,
|
|
48
|
+
"note": self.note,
|
|
49
|
+
"replacement_title": self.replacement_title,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Catalogue:
|
|
54
|
+
"""A country's section-by-section decisions against a base questionnaire."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, base_sections: list[str], country: str):
|
|
57
|
+
if len(base_sections) != len(set(base_sections)):
|
|
58
|
+
raise ValueError("base_sections must not contain duplicates")
|
|
59
|
+
self.base_sections = list(base_sections)
|
|
60
|
+
self.country = country
|
|
61
|
+
self._mappings: dict[str, SectionMapping] = {}
|
|
62
|
+
|
|
63
|
+
def register(
|
|
64
|
+
self,
|
|
65
|
+
section_id: str,
|
|
66
|
+
action: SectionAction,
|
|
67
|
+
*,
|
|
68
|
+
note: str | None = None,
|
|
69
|
+
replacement_title: str | None = None,
|
|
70
|
+
) -> "Catalogue":
|
|
71
|
+
if section_id not in self.base_sections:
|
|
72
|
+
raise ValueError(
|
|
73
|
+
f"'{section_id}' is not in the base questionnaire for {self.country}"
|
|
74
|
+
)
|
|
75
|
+
self._mappings[section_id] = SectionMapping(
|
|
76
|
+
section_id=section_id,
|
|
77
|
+
action=action,
|
|
78
|
+
country=self.country,
|
|
79
|
+
note=note,
|
|
80
|
+
replacement_title=replacement_title,
|
|
81
|
+
)
|
|
82
|
+
return self
|
|
83
|
+
|
|
84
|
+
def unregistered(self) -> list[str]:
|
|
85
|
+
"""Base sections this country has not yet decided on."""
|
|
86
|
+
return [s for s in self.base_sections if s not in self._mappings]
|
|
87
|
+
|
|
88
|
+
def validate(self) -> list[str]:
|
|
89
|
+
"""Return validation issues; an empty list means fully specified."""
|
|
90
|
+
issues = []
|
|
91
|
+
missing = self.unregistered()
|
|
92
|
+
if missing:
|
|
93
|
+
issues.append(
|
|
94
|
+
f"{self.country}: {len(missing)} section(s) not mapped: {', '.join(missing)}"
|
|
95
|
+
)
|
|
96
|
+
return issues
|
|
97
|
+
|
|
98
|
+
def summary(self) -> dict[str, int]:
|
|
99
|
+
counts = {action.value: 0 for action in SectionAction}
|
|
100
|
+
for mapping in self._mappings.values():
|
|
101
|
+
counts[mapping.action.value] += 1
|
|
102
|
+
return counts
|
|
103
|
+
|
|
104
|
+
def mapping_for(self, section_id: str) -> SectionMapping | None:
|
|
105
|
+
return self._mappings.get(section_id)
|
|
106
|
+
|
|
107
|
+
def to_dict(self) -> dict[str, Any]:
|
|
108
|
+
return {
|
|
109
|
+
"country": self.country,
|
|
110
|
+
"base_sections": list(self.base_sections),
|
|
111
|
+
"mappings": [m.to_dict() for m in self._mappings.values()],
|
|
112
|
+
"unregistered": self.unregistered(),
|
|
113
|
+
"summary": self.summary(),
|
|
114
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: moveq-catalogue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Same/replace/omit harmonization registry for cross-country transport-equity section catalogues.
|
|
5
|
+
Author-email: Soura <martisoura@gmail.com>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/SVamseekar/moveq
|
|
8
|
+
Project-URL: Documentation, https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md
|
|
9
|
+
Project-URL: Repository, https://github.com/SVamseekar/moveq
|
|
10
|
+
Project-URL: Issues, https://github.com/SVamseekar/moveq/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: transport,equity,harmonization,catalogue,cross-country
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# moveq-catalogue
|
|
33
|
+
|
|
34
|
+
Registry for the **same / replace / omit** pattern used to extend one country's
|
|
35
|
+
section questionnaire to another country without silent omissions.
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
38
|
+
[](https://pypi.org/project/moveq-catalogue/)
|
|
39
|
+
[](https://github.com/SVamseekar/moveq/blob/main/LICENSE)
|
|
40
|
+
|
|
41
|
+
- **same** — the question carries over; only the local data source changes
|
|
42
|
+
- **replace** — the question does not transfer; a locally meaningful replacement is required
|
|
43
|
+
- **omit** — no small-area variable exists; the section is dropped with a note
|
|
44
|
+
|
|
45
|
+
Most applications should install the umbrella package instead:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install moveq
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
Requires Python 3.10+.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install moveq-catalogue
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from moveq_catalogue import Catalogue, SectionAction
|
|
63
|
+
|
|
64
|
+
base_sections = ["coverage_pct", "service_deserts", "policy_scenarios"]
|
|
65
|
+
|
|
66
|
+
ie = Catalogue(base_sections, country="ireland")
|
|
67
|
+
ie.register("coverage_pct", SectionAction.SAME, note="TFI x CSO Small Area")
|
|
68
|
+
ie.register("service_deserts", SectionAction.SAME)
|
|
69
|
+
ie.register(
|
|
70
|
+
"policy_scenarios",
|
|
71
|
+
SectionAction.REPLACE,
|
|
72
|
+
replacement_title="Connecting Ireland / Local Link / BusConnects",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
assert ie.validate() == [] # every base section has been decided
|
|
76
|
+
print(ie.summary()) # {'same': 2, 'replace': 1, 'omit': 0}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`validate()` is the whole point of this package: it fails if a new country
|
|
80
|
+
silently forgets to decide what happens to a base section.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [Catalogue harmonization guide](https://github.com/SVamseekar/moveq/blob/main/docs/catalogue_guide.md)
|
|
85
|
+
- [API reference](https://github.com/SVamseekar/moveq/blob/main/docs/api_reference.md)
|
|
86
|
+
- [Source repository](https://github.com/SVamseekar/moveq)
|
|
87
|
+
- [Changelog](https://github.com/SVamseekar/moveq/blob/main/CHANGELOG.md)
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[BSD 3-Clause](https://github.com/SVamseekar/moveq/blob/main/LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/moveq_catalogue/__init__.py
|
|
5
|
+
src/moveq_catalogue/catalogue.py
|
|
6
|
+
src/moveq_catalogue.egg-info/PKG-INFO
|
|
7
|
+
src/moveq_catalogue.egg-info/SOURCES.txt
|
|
8
|
+
src/moveq_catalogue.egg-info/dependency_links.txt
|
|
9
|
+
src/moveq_catalogue.egg-info/requires.txt
|
|
10
|
+
src/moveq_catalogue.egg-info/top_level.txt
|
|
11
|
+
tests/test_catalogue.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
moveq_catalogue
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from moveq_catalogue import Catalogue, SectionAction
|
|
4
|
+
|
|
5
|
+
BASE = ["coverage_pct", "service_deserts", "policy_scenarios"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_same_action_registers_cleanly():
|
|
9
|
+
cat = Catalogue(BASE, country="ireland")
|
|
10
|
+
cat.register("coverage_pct", SectionAction.SAME, note="TFI x CSO Small Area")
|
|
11
|
+
mapping = cat.mapping_for("coverage_pct")
|
|
12
|
+
assert mapping.action is SectionAction.SAME
|
|
13
|
+
assert mapping.country == "ireland"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_replace_without_title_raises():
|
|
17
|
+
cat = Catalogue(BASE, country="ireland")
|
|
18
|
+
with pytest.raises(ValueError, match="replacement_title"):
|
|
19
|
+
cat.register("policy_scenarios", SectionAction.REPLACE)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_omit_without_note_raises():
|
|
23
|
+
cat = Catalogue(BASE, country="ireland")
|
|
24
|
+
with pytest.raises(ValueError, match="note"):
|
|
25
|
+
cat.register("service_deserts", SectionAction.OMIT)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_register_unknown_section_raises():
|
|
29
|
+
cat = Catalogue(BASE, country="ireland")
|
|
30
|
+
with pytest.raises(ValueError, match="not in the base questionnaire"):
|
|
31
|
+
cat.register("nonexistent", SectionAction.SAME)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_validate_flags_unregistered_sections():
|
|
35
|
+
cat = Catalogue(BASE, country="ireland")
|
|
36
|
+
cat.register("coverage_pct", SectionAction.SAME)
|
|
37
|
+
issues = cat.validate()
|
|
38
|
+
assert len(issues) == 1
|
|
39
|
+
assert "service_deserts" in issues[0]
|
|
40
|
+
assert "policy_scenarios" in issues[0]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_validate_passes_when_fully_mapped():
|
|
44
|
+
cat = Catalogue(BASE, country="ireland")
|
|
45
|
+
cat.register("coverage_pct", SectionAction.SAME)
|
|
46
|
+
cat.register("service_deserts", SectionAction.OMIT, note="no free small-area variable")
|
|
47
|
+
cat.register("policy_scenarios", SectionAction.REPLACE, replacement_title="Connecting Ireland")
|
|
48
|
+
assert cat.validate() == []
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_summary_counts_actions():
|
|
52
|
+
cat = Catalogue(BASE, country="ireland")
|
|
53
|
+
cat.register("coverage_pct", SectionAction.SAME)
|
|
54
|
+
cat.register("service_deserts", SectionAction.SAME)
|
|
55
|
+
cat.register("policy_scenarios", SectionAction.REPLACE, replacement_title="Connecting Ireland")
|
|
56
|
+
assert cat.summary() == {"same": 2, "replace": 1, "omit": 0}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_duplicate_base_sections_raise():
|
|
60
|
+
with pytest.raises(ValueError, match="duplicates"):
|
|
61
|
+
Catalogue(["a", "a", "b"], country="ireland")
|