tods-validate 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.
Files changed (112) hide show
  1. tods_validate-0.1.0/.claude/settings.local.json +8 -0
  2. tods_validate-0.1.0/.github/dependabot.yml +10 -0
  3. tods_validate-0.1.0/.github/workflows/ci.yml +54 -0
  4. tods_validate-0.1.0/.gitignore +16 -0
  5. tods_validate-0.1.0/.pre-commit-config.yaml +20 -0
  6. tods_validate-0.1.0/LICENSE +202 -0
  7. tods_validate-0.1.0/PKG-INFO +151 -0
  8. tods_validate-0.1.0/README.md +123 -0
  9. tods_validate-0.1.0/action.yml +38 -0
  10. tods_validate-0.1.0/docs/rules.md +300 -0
  11. tods_validate-0.1.0/docs/spec-questions.md +93 -0
  12. tods_validate-0.1.0/pyproject.toml +60 -0
  13. tods_validate-0.1.0/scripts/generate_rules_doc.py +84 -0
  14. tods_validate-0.1.0/src/tods_validate/__init__.py +3 -0
  15. tods_validate-0.1.0/src/tods_validate/cli.py +71 -0
  16. tods_validate-0.1.0/src/tods_validate/findings.py +56 -0
  17. tods_validate-0.1.0/src/tods_validate/gtfs_companion.py +170 -0
  18. tods_validate-0.1.0/src/tods_validate/loader.py +183 -0
  19. tods_validate-0.1.0/src/tods_validate/report.py +107 -0
  20. tods_validate-0.1.0/src/tods_validate/rules/__init__.py +110 -0
  21. tods_validate-0.1.0/src/tods_validate/rules/fields.py +278 -0
  22. tods_validate-0.1.0/src/tods_validate/rules/references.py +593 -0
  23. tods_validate-0.1.0/src/tods_validate/rules/semantics.py +408 -0
  24. tods_validate-0.1.0/src/tods_validate/rules/structure.py +252 -0
  25. tods_validate-0.1.0/src/tods_validate/runner.py +35 -0
  26. tods_validate-0.1.0/src/tods_validate/schema.py +368 -0
  27. tods_validate-0.1.0/tests/conftest.py +32 -0
  28. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E103/vehicles.txt +0 -0
  29. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E104/vehicles.txt +2 -0
  30. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E105/vehicles.txt +2 -0
  31. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E106/run_events.txt +2 -0
  32. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E201/run_events.txt +2 -0
  33. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E202/stops_supplement.txt +2 -0
  34. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E203/run_events.txt +2 -0
  35. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E204/vehicles.txt +3 -0
  36. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E205/trips.txt +3 -0
  37. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E205/vehicle_assignments.txt +2 -0
  38. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E205/vehicles.txt +2 -0
  39. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E301/employee_run_dates.txt +2 -0
  40. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E301/run_events.txt +2 -0
  41. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E303/vehicle_assignments.txt +2 -0
  42. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E303/vehicles.txt +2 -0
  43. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E304/stops_supplement.txt +3 -0
  44. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E307/run_events.txt +2 -0
  45. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E307/trips.txt +2 -0
  46. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E308/calendar.txt +2 -0
  47. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E308/run_events.txt +2 -0
  48. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E309/run_events.txt +2 -0
  49. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E309/stops.txt +2 -0
  50. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E310/run_events.txt +2 -0
  51. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E310/trips.txt +2 -0
  52. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E311/trips.txt +2 -0
  53. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E311/vehicle_assignments.txt +2 -0
  54. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E311/vehicles.txt +2 -0
  55. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E312/calendar.txt +2 -0
  56. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E312/trips.txt +2 -0
  57. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E312/vehicle_assignments.txt +2 -0
  58. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E312/vehicles.txt +2 -0
  59. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E401/run_events.txt +2 -0
  60. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E402/run_events.txt +3 -0
  61. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E405/calendar.txt +3 -0
  62. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E405/run_events.txt +2 -0
  63. tods_validate-0.1.0/tests/fixtures/invalid/TODS-E405/trips.txt +2 -0
  64. tods_validate-0.1.0/tests/fixtures/invalid/TODS-I102/notes.txt +2 -0
  65. tods_validate-0.1.0/tests/fixtures/invalid/TODS-I102/run_events.txt +2 -0
  66. tods_validate-0.1.0/tests/fixtures/invalid/TODS-I108/stops_supplement.txt +2 -0
  67. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W101/agency.txt +2 -0
  68. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W107/vehicles.txt +2 -0
  69. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W206/vehicles.txt +2 -0
  70. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W302/employee_run_dates.txt +2 -0
  71. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W305/stops_supplement.txt +3 -0
  72. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W306/stops_supplement.txt +2 -0
  73. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W313/stops.txt +2 -0
  74. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W313/stops_supplement.txt +2 -0
  75. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W403/run_events.txt +3 -0
  76. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W404/employee_run_dates.txt +3 -0
  77. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W404/run_events.txt +3 -0
  78. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W406/calendar.txt +2 -0
  79. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W406/employee_run_dates.txt +2 -0
  80. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W406/run_events.txt +2 -0
  81. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W407/calendar.txt +2 -0
  82. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W407/trips.txt +2 -0
  83. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W407/vehicle_assignments.txt +2 -0
  84. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W407/vehicles.txt +2 -0
  85. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W408/employee_run_dates.txt +3 -0
  86. tods_validate-0.1.0/tests/fixtures/invalid/TODS-W408/run_events.txt +2 -0
  87. tods_validate-0.1.0/tests/fixtures/valid/gtfs/agency.txt +2 -0
  88. tods_validate-0.1.0/tests/fixtures/valid/gtfs/calendar.txt +2 -0
  89. tods_validate-0.1.0/tests/fixtures/valid/gtfs/routes.txt +2 -0
  90. tods_validate-0.1.0/tests/fixtures/valid/gtfs/stop_times.txt +13 -0
  91. tods_validate-0.1.0/tests/fixtures/valid/gtfs/stops.txt +4 -0
  92. tods_validate-0.1.0/tests/fixtures/valid/gtfs/trips.txt +5 -0
  93. tods_validate-0.1.0/tests/fixtures/valid/tods/calendar_dates_supplement.txt +2 -0
  94. tods_validate-0.1.0/tests/fixtures/valid/tods/calendar_supplement.txt +2 -0
  95. tods_validate-0.1.0/tests/fixtures/valid/tods/employee_run_dates.txt +4 -0
  96. tods_validate-0.1.0/tests/fixtures/valid/tods/routes_supplement.txt +2 -0
  97. tods_validate-0.1.0/tests/fixtures/valid/tods/run_events.txt +12 -0
  98. tods_validate-0.1.0/tests/fixtures/valid/tods/stop_times_supplement.txt +7 -0
  99. tods_validate-0.1.0/tests/fixtures/valid/tods/stops_supplement.txt +3 -0
  100. tods_validate-0.1.0/tests/fixtures/valid/tods/trips_supplement.txt +3 -0
  101. tods_validate-0.1.0/tests/fixtures/valid/tods/vehicle_assignments.txt +3 -0
  102. tods_validate-0.1.0/tests/fixtures/valid/tods/vehicles.txt +3 -0
  103. tods_validate-0.1.0/tests/test_cli.py +80 -0
  104. tods_validate-0.1.0/tests/test_fields.py +68 -0
  105. tods_validate-0.1.0/tests/test_gtfs_companion.py +98 -0
  106. tods_validate-0.1.0/tests/test_loader.py +77 -0
  107. tods_validate-0.1.0/tests/test_references.py +71 -0
  108. tods_validate-0.1.0/tests/test_registry.py +40 -0
  109. tods_validate-0.1.0/tests/test_report.py +37 -0
  110. tods_validate-0.1.0/tests/test_semantics.py +55 -0
  111. tods_validate-0.1.0/tests/test_structure.py +58 -0
  112. tods_validate-0.1.0/tests/test_valid_feed.py +29 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebSearch",
5
+ "WebFetch(domain:ods.calitp.org)"
6
+ ]
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule:
6
+ interval: monthly
7
+ - package-ecosystem: pip
8
+ directory: /
9
+ schedule:
10
+ interval: monthly
@@ -0,0 +1,54 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - run: python -m pip install ".[dev]"
17
+ - run: ruff check src tests scripts
18
+ - run: ruff format --check src tests scripts
19
+ - run: mypy
20
+
21
+ docs-drift:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.12"
28
+ - run: python -m pip install .
29
+ - name: Check that docs/rules.md matches the rule registry
30
+ run: |
31
+ python scripts/generate_rules_doc.py --check
32
+
33
+ test:
34
+ runs-on: ubuntu-latest
35
+ strategy:
36
+ matrix:
37
+ python-version: ["3.11", "3.12", "3.13"]
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: actions/setup-python@v5
41
+ with:
42
+ python-version: ${{ matrix.python-version }}
43
+ - run: python -m pip install ".[dev]"
44
+ - run: pytest --cov --cov-report=term-missing
45
+
46
+ action-self-test:
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ - name: Run the action against the valid fixture feed
51
+ uses: ./
52
+ with:
53
+ path: tests/fixtures/valid/tods
54
+ gtfs: tests/fixtures/valid/gtfs
@@ -0,0 +1,16 @@
1
+ # local working notes, not part of the published repo
2
+ CLAUDE.md
3
+ CLAUDE-*.md
4
+
5
+ __pycache__/
6
+ *.py[cod]
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .venv/
11
+ .coverage
12
+ htmlcov/
13
+ .mypy_cache/
14
+ .ruff_cache/
15
+ .pytest_cache/
16
+ .DS_Store
@@ -0,0 +1,20 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.0
4
+ hooks:
5
+ - id: end-of-file-fixer
6
+ - id: trailing-whitespace
7
+ exclude: ^tests/fixtures/
8
+ - id: check-yaml
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: v0.5.5
11
+ hooks:
12
+ - id: ruff
13
+ args: [--fix]
14
+ - id: ruff-format
15
+ - repo: https://github.com/pre-commit/mirrors-mypy
16
+ rev: v1.11.0
17
+ hooks:
18
+ - id: mypy
19
+ files: ^src/
20
+ additional_dependencies: [click]
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: tods-validate
3
+ Version: 0.1.0
4
+ Summary: Validator for Transit Operational Data Standard (TODS) feeds, formerly the Operational Data Standard (ODS)
5
+ Project-URL: Repository, https://github.com/ChelseaKR/tods-validate
6
+ Project-URL: TODS specification, https://tods-transit.org/spec/
7
+ Author: Chelsea Kelly-Reif
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: cal-itp,gtfs,ods,tods,transit,validation
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Other Audience
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: GIS
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: click>=8.1
21
+ Provides-Extra: dev
22
+ Requires-Dist: mypy>=1.10; extra == 'dev'
23
+ Requires-Dist: pre-commit>=3.7; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
25
+ Requires-Dist: pytest>=8; extra == 'dev'
26
+ Requires-Dist: ruff>=0.5; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # tods-validate
30
+
31
+ A validator for [Transit Operational Data Standard (TODS)](https://tods-transit.org/)
32
+ feeds, with a CLI and a GitHub Action.
33
+
34
+ TODS is an open standard for describing scheduled transit operations: crew
35
+ runs, deadheads, vehicle assignments, and other non-public service that GTFS
36
+ does not cover. It works as an overlay on an agency's GTFS feed. The standard
37
+ was originally published by Cal-ITP as the Operational Data Standard (ODS)
38
+ and is now maintained with MobilityData under its current name. This
39
+ validator checks feeds against the current spec, TODS v2.1.0.
40
+
41
+ `tods-validate` reads a TODS package, checks it against the spec, and reports
42
+ findings in language a scheduler can act on. Each finding says what is wrong,
43
+ where, and what good looks like, and cites the spec section it comes from.
44
+
45
+ ## Install
46
+
47
+ Requires Python 3.11 or newer.
48
+
49
+ ```sh
50
+ pipx install tods-validate
51
+ ```
52
+
53
+ or `pip install tods-validate` into an environment of your choice.
54
+
55
+ ## Usage
56
+
57
+ Point it at the directory or .zip file containing your TODS files. If your
58
+ GTFS feed lives in a separate file, pass it with `--gtfs` so trip, stop,
59
+ service, and block references can be checked:
60
+
61
+ ```sh
62
+ tods-validate exports/tods/ --gtfs exports/gtfs.zip
63
+ ```
64
+
65
+ When the TODS files sit next to the GTFS files in one package, the GTFS files
66
+ are picked up automatically:
67
+
68
+ ```console
69
+ $ tods-validate /tmp/demo-feed
70
+ tods-validate: /tmp/demo-feed (TODS v2.1.0)
71
+
72
+ 2 errors:
73
+ ERROR TODS-E203 [run_events.txt, row 4, field 'end_time']
74
+ run_events.txt row 4: end_time is '9:45', which is not a valid time. Use HH:MM:SS, e.g. '09:45:00' or '25:10:00' for 1:10 AM the next service day.
75
+ ERROR TODS-E307 [run_events.txt, row 4, field 'trip_id']
76
+ run_events.txt row 4: trip_id 'WKDY-1002' does not exist in the companion GTFS trips.txt (after applying trips_supplement.txt). Run events that represent work on a trip must reference a scheduled trip.
77
+ Fix: Correct the trip_id, or add the trip via trips_supplement.txt if it is non-revenue service.
78
+
79
+ Summary: 2 error(s), 0 warning(s), 0 info.
80
+ $ echo $?
81
+ 1
82
+ ```
83
+
84
+ The exit code is 0 when no errors are found, 1 when there are errors, and 2
85
+ when the package cannot be read at all. Warnings do not fail the run unless
86
+ you pass `--fail-on warning`.
87
+
88
+ Other output formats:
89
+
90
+ - `--format json` prints a stable JSON document for tooling.
91
+ - `--format github` prints GitHub Actions workflow annotations.
92
+
93
+ References into GTFS are resolved after applying the supplement files, so a
94
+ trip added by `trips_supplement.txt` is a valid target for
95
+ `run_events.trip_id`, and a stop deleted by `stops_supplement.txt` is not.
96
+
97
+ ## GitHub Action
98
+
99
+ If your TODS export lives in a repository, this workflow validates it on
100
+ every pull request and annotates findings inline:
101
+
102
+ ```yaml
103
+ name: Validate TODS feed
104
+ on: [pull_request]
105
+ jobs:
106
+ validate:
107
+ runs-on: ubuntu-latest
108
+ steps:
109
+ - uses: actions/checkout@v4
110
+ - uses: ChelseaKR/tods-validate@v0
111
+ with:
112
+ path: feed/tods
113
+ gtfs: feed/gtfs # omit if GTFS files sit next to the TODS files
114
+ ```
115
+
116
+ ## Rules
117
+
118
+ The full catalog of checks, with IDs, severities, and spec citations, is in
119
+ [docs/rules.md](docs/rules.md). Rule IDs are stable: a CI pipeline can safely
120
+ filter or suppress specific IDs.
121
+
122
+ Ambiguities in the spec discovered while building the validator are tracked
123
+ in [docs/spec-questions.md](docs/spec-questions.md).
124
+
125
+ ## What this does not check
126
+
127
+ `tods-validate` validates the TODS files and their references into the
128
+ companion GTFS feed. It does not re-validate the GTFS feed itself, and it
129
+ does not check that the merged ("TODS-Supplemented") GTFS dataset is valid
130
+ GTFS. For those, run MobilityData's
131
+ [gtfs-validator](https://github.com/MobilityData/gtfs-validator), optionally
132
+ on the merged feed.
133
+
134
+ ## Development
135
+
136
+ ```sh
137
+ git clone https://github.com/ChelseaKR/tods-validate
138
+ cd tods-validate
139
+ python -m venv .venv && . .venv/bin/activate
140
+ pip install -e ".[dev]"
141
+ pytest
142
+ ```
143
+
144
+ Lint and type-check with `ruff check src tests scripts` and `mypy`. The rule
145
+ catalog is generated: after adding or changing a rule, run
146
+ `python scripts/generate_rules_doc.py` and commit the result; CI fails if it
147
+ drifts.
148
+
149
+ ## License
150
+
151
+ Apache-2.0, matching the TODS specification repository.
@@ -0,0 +1,123 @@
1
+ # tods-validate
2
+
3
+ A validator for [Transit Operational Data Standard (TODS)](https://tods-transit.org/)
4
+ feeds, with a CLI and a GitHub Action.
5
+
6
+ TODS is an open standard for describing scheduled transit operations: crew
7
+ runs, deadheads, vehicle assignments, and other non-public service that GTFS
8
+ does not cover. It works as an overlay on an agency's GTFS feed. The standard
9
+ was originally published by Cal-ITP as the Operational Data Standard (ODS)
10
+ and is now maintained with MobilityData under its current name. This
11
+ validator checks feeds against the current spec, TODS v2.1.0.
12
+
13
+ `tods-validate` reads a TODS package, checks it against the spec, and reports
14
+ findings in language a scheduler can act on. Each finding says what is wrong,
15
+ where, and what good looks like, and cites the spec section it comes from.
16
+
17
+ ## Install
18
+
19
+ Requires Python 3.11 or newer.
20
+
21
+ ```sh
22
+ pipx install tods-validate
23
+ ```
24
+
25
+ or `pip install tods-validate` into an environment of your choice.
26
+
27
+ ## Usage
28
+
29
+ Point it at the directory or .zip file containing your TODS files. If your
30
+ GTFS feed lives in a separate file, pass it with `--gtfs` so trip, stop,
31
+ service, and block references can be checked:
32
+
33
+ ```sh
34
+ tods-validate exports/tods/ --gtfs exports/gtfs.zip
35
+ ```
36
+
37
+ When the TODS files sit next to the GTFS files in one package, the GTFS files
38
+ are picked up automatically:
39
+
40
+ ```console
41
+ $ tods-validate /tmp/demo-feed
42
+ tods-validate: /tmp/demo-feed (TODS v2.1.0)
43
+
44
+ 2 errors:
45
+ ERROR TODS-E203 [run_events.txt, row 4, field 'end_time']
46
+ run_events.txt row 4: end_time is '9:45', which is not a valid time. Use HH:MM:SS, e.g. '09:45:00' or '25:10:00' for 1:10 AM the next service day.
47
+ ERROR TODS-E307 [run_events.txt, row 4, field 'trip_id']
48
+ run_events.txt row 4: trip_id 'WKDY-1002' does not exist in the companion GTFS trips.txt (after applying trips_supplement.txt). Run events that represent work on a trip must reference a scheduled trip.
49
+ Fix: Correct the trip_id, or add the trip via trips_supplement.txt if it is non-revenue service.
50
+
51
+ Summary: 2 error(s), 0 warning(s), 0 info.
52
+ $ echo $?
53
+ 1
54
+ ```
55
+
56
+ The exit code is 0 when no errors are found, 1 when there are errors, and 2
57
+ when the package cannot be read at all. Warnings do not fail the run unless
58
+ you pass `--fail-on warning`.
59
+
60
+ Other output formats:
61
+
62
+ - `--format json` prints a stable JSON document for tooling.
63
+ - `--format github` prints GitHub Actions workflow annotations.
64
+
65
+ References into GTFS are resolved after applying the supplement files, so a
66
+ trip added by `trips_supplement.txt` is a valid target for
67
+ `run_events.trip_id`, and a stop deleted by `stops_supplement.txt` is not.
68
+
69
+ ## GitHub Action
70
+
71
+ If your TODS export lives in a repository, this workflow validates it on
72
+ every pull request and annotates findings inline:
73
+
74
+ ```yaml
75
+ name: Validate TODS feed
76
+ on: [pull_request]
77
+ jobs:
78
+ validate:
79
+ runs-on: ubuntu-latest
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+ - uses: ChelseaKR/tods-validate@v0
83
+ with:
84
+ path: feed/tods
85
+ gtfs: feed/gtfs # omit if GTFS files sit next to the TODS files
86
+ ```
87
+
88
+ ## Rules
89
+
90
+ The full catalog of checks, with IDs, severities, and spec citations, is in
91
+ [docs/rules.md](docs/rules.md). Rule IDs are stable: a CI pipeline can safely
92
+ filter or suppress specific IDs.
93
+
94
+ Ambiguities in the spec discovered while building the validator are tracked
95
+ in [docs/spec-questions.md](docs/spec-questions.md).
96
+
97
+ ## What this does not check
98
+
99
+ `tods-validate` validates the TODS files and their references into the
100
+ companion GTFS feed. It does not re-validate the GTFS feed itself, and it
101
+ does not check that the merged ("TODS-Supplemented") GTFS dataset is valid
102
+ GTFS. For those, run MobilityData's
103
+ [gtfs-validator](https://github.com/MobilityData/gtfs-validator), optionally
104
+ on the merged feed.
105
+
106
+ ## Development
107
+
108
+ ```sh
109
+ git clone https://github.com/ChelseaKR/tods-validate
110
+ cd tods-validate
111
+ python -m venv .venv && . .venv/bin/activate
112
+ pip install -e ".[dev]"
113
+ pytest
114
+ ```
115
+
116
+ Lint and type-check with `ruff check src tests scripts` and `mypy`. The rule
117
+ catalog is generated: after adding or changing a rule, run
118
+ `python scripts/generate_rules_doc.py` and commit the result; CI fails if it
119
+ drifts.
120
+
121
+ ## License
122
+
123
+ Apache-2.0, matching the TODS specification repository.
@@ -0,0 +1,38 @@
1
+ name: tods-validate
2
+ description: >-
3
+ Validate a Transit Operational Data Standard (TODS) feed and annotate
4
+ findings on the pull request.
5
+ branding:
6
+ icon: check-circle
7
+ color: green
8
+
9
+ inputs:
10
+ path:
11
+ description: Directory or .zip file containing the TODS files.
12
+ required: true
13
+ gtfs:
14
+ description: >-
15
+ Companion GTFS feed (directory or .zip). Leave empty if the GTFS files
16
+ sit next to the TODS files.
17
+ required: false
18
+ default: ""
19
+ fail-on:
20
+ description: Fail the job on findings at or above this severity (error or warning).
21
+ required: false
22
+ default: error
23
+
24
+ runs:
25
+ using: composite
26
+ steps:
27
+ - name: Install tods-validate
28
+ shell: bash
29
+ run: python3 -m pip install --quiet "${{ github.action_path }}"
30
+
31
+ - name: Validate feed
32
+ shell: bash
33
+ run: |
34
+ args=("${{ inputs.path }}" --format github --fail-on "${{ inputs['fail-on'] }}")
35
+ if [ -n "${{ inputs.gtfs }}" ]; then
36
+ args+=(--gtfs "${{ inputs.gtfs }}")
37
+ fi
38
+ tods-validate "${args[@]}"