|
1 | 1 | # mysoc-validator
|
2 | 2 |
|
3 |
| -A set of pydantic based validators for common mySociety democracy formats. |
| 3 | +A set of pydantic-based validators and classes for common mySociety democracy formats. |
4 | 4 |
|
5 |
| -The long term goal is to consolidate different scripts behind a common validation system. |
| 5 | +Currently supports: |
6 | 6 |
|
7 |
| -## Transcripts |
8 |
| - |
9 |
| -Python validator and handler for 'publicwhip' style transcript format. |
| 7 | +- Popolo database |
| 8 | +- Transcript format |
| 9 | +- Interests format |
10 | 10 |
|
11 |
| -Haven't ensured it can do round trips yet - but can read and write. Needs tests. |
| 11 | +XML based formats are tested to round-trip with themselves, but not to be string identical with the original source. |
12 | 12 |
|
13 |
| -```python |
14 |
| -from mysoc_validator import Transcript |
15 |
| - |
16 |
| -transcript = Transcript.from_path(<path to xml file>) |
17 |
| -``` |
| 13 | +To use as a cli validator : |
18 | 14 |
|
19 | 15 | ```bash
|
| 16 | +python -m mysoc_validator validate --path <path-to-people.json> --type popolo |
20 | 17 | python -m mysoc_validator validate --path <path-to-transcript.xml> --type transcript
|
| 18 | +python -m mysoc_validator validate --path <path-to-interests.xml> --type interests |
| 19 | + |
21 | 20 | ```
|
22 | 21 |
|
23 | 22 | ## Popolo
|
24 | 23 |
|
25 |
| -A pydantic based validator for main mysociety people.json file (which mostly follows the popolo standard with a few extra bits). |
| 24 | +A pydantic based validator for main mySociety people.json file (which mostly follows the popolo standard with a few extra bits). |
26 | 25 |
|
27 | 26 | Validates:
|
28 | 27 |
|
29 | 28 | - Basic structure
|
30 | 29 | - Unique IDs and ID Patterns
|
31 | 30 | - Foreign key relationships between objects.
|
32 | 31 |
|
33 |
| -It also has support for looking up from name or indentifer to person (see tests), and new ID generation for membership. |
| 32 | +It also has support for looking up from name or identifying to person, and new ID generation for membership. |
| 33 | + |
| 34 | +### Using name or ID lookup |
| 35 | + |
| 36 | +After first use, there is some caching behind the scenes to speed this up. |
34 | 37 |
|
35 | 38 | ```python
|
36 | 39 | from mysoc_validator import Popolo
|
37 |
| - |
| 40 | +from mysoc_validator.models.popolo import Chamber, IdentifierScheme |
| 41 | +from datetime import date |
38 | 42 | popolo = Popolo.from_path(<path to people.json>)
|
| 43 | + |
| 44 | +keir_starmer_parl_id = popolo.persons.from_identifier(4514, scheme=IdentifierScheme.MNIS) |
| 45 | +keir_starmer_name = popolo.persons.from_name( |
| 46 | + "keir starmer", chamber_id=Chamber.COMMONS, date=date.fromisoformat("2022-07-31") |
| 47 | + ) |
| 48 | + |
| 49 | +keir_starmer_parl_id.id == keir_starmer_name.id |
| 50 | +``` |
| 51 | + |
| 52 | + |
| 53 | +## Transcripts |
| 54 | + |
| 55 | +Python validator and handler for 'publicwhip' style transcript format. |
| 56 | + |
| 57 | +```python |
| 58 | +from mysoc_validator import Transcript |
| 59 | + |
| 60 | +transcript = Transcript.from_path(<path to xml file>) |
| 61 | +``` |
| 62 | + |
| 63 | +## Register of Interests |
| 64 | + |
| 65 | +Python validator and handler for 'publicwhip' style interests format. |
| 66 | + |
| 67 | +```python |
| 68 | +from mysoc_validator import Registry |
| 69 | + |
| 70 | +interests = Registry.from_path(<path to xml file>) |
39 | 71 | ```
|
40 | 72 |
|
41 |
| -```bash |
42 |
| -python -m mysoc_validator validate --path <path-to-people.json> --type popolo |
43 |
| -``` |
|
0 commit comments