refdatakit 0.1.0__py3-none-any.whl

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 (33) hide show
  1. refdatakit/__init__.py +8 -0
  2. refdatakit/canonical_json.py +34 -0
  3. refdatakit/cli.py +32 -0
  4. refdatakit/country_codes.py +11 -0
  5. refdatakit/data/__init__.py +0 -0
  6. refdatakit/data/datasets/cities/by-country/BD.json +1 -0
  7. refdatakit/data/datasets/cities/by-country/BT.json +1 -0
  8. refdatakit/data/datasets/cities/by-country/LK.json +1 -0
  9. refdatakit/data/datasets/cities/by-country/MV.json +1 -0
  10. refdatakit/data/datasets/cities/by-country/NP.json +1 -0
  11. refdatakit/data/datasets/cities/by-country/SG.json +1 -0
  12. refdatakit/data/datasets/countries/data.json +1 -0
  13. refdatakit/data/datasets/institutions/by-country/BD.json +1 -0
  14. refdatakit/data/datasets/institutions/by-country/BT.json +1 -0
  15. refdatakit/data/datasets/institutions/by-country/LK.json +1 -0
  16. refdatakit/data/datasets/institutions/by-country/MV.json +1 -0
  17. refdatakit/data/datasets/institutions/by-country/NP.json +1 -0
  18. refdatakit/data/datasets/institutions/by-country/SG.json +1 -0
  19. refdatakit/data/datasets/manifest.json +1 -0
  20. refdatakit/data/datasets/subdivisions/by-country/BD.json +1 -0
  21. refdatakit/data/schemas/city.schema.json +84 -0
  22. refdatakit/data/schemas/country.schema.json +98 -0
  23. refdatakit/data/schemas/entity.schema.json +174 -0
  24. refdatakit/data/schemas/manifest.schema.json +94 -0
  25. refdatakit/data/schemas/subdivision.schema.json +65 -0
  26. refdatakit/data.py +48 -0
  27. refdatakit/validator.py +512 -0
  28. refdatakit-0.1.0.dist-info/METADATA +39 -0
  29. refdatakit-0.1.0.dist-info/RECORD +33 -0
  30. refdatakit-0.1.0.dist-info/WHEEL +5 -0
  31. refdatakit-0.1.0.dist-info/entry_points.txt +2 -0
  32. refdatakit-0.1.0.dist-info/licenses/LICENSE +21 -0
  33. refdatakit-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1 @@
1
+ {"datasets":[{"additional_sources":[{"attribution":"Unicode CLDR 49; only language entries marked official are included. Full license notice: licenses/UNICODE-3.0.txt.","data_as_of":"2026-11-08","fields":["official_languages"],"license":"Unicode-3.0","source_url":"https://raw.githubusercontent.com/unicode-org/cldr-json/a198dbf17e1d2314a76b84b30904b87a5f8618bb/cldr-json/cldr-core/supplemental/territoryInfo.json"}],"attribution":"GeoNames countryInfo.txt; language list ordering follows the source speaker ordering.","data_as_of":"2026-11-08","license":"CC BY 4.0","path":"datasets/countries/data.json","sha256":"2f5cfd2eb9c604547e716975dd0a749020935f4960eee541f4c9c1df44cf914e","source_url":"https://download.geonames.org/export/dump/countryInfo.txt"},{"attribution":"Wikidata contributors, items Q459723, Q158087, Q330158, Q501696, Q19594930, Q379382, Q876023, and Q459732","license":"CC0-1.0","path":"datasets/subdivisions/by-country/BD.json","sha256":"9e6dd3676804e1941ccfb90e2462c1ea806fea1aee2ec8a4e0f10ed5a779cb38","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q459723%7CQ158087%7CQ330158%7CQ501696%7CQ19594930%7CQ379382%7CQ876023%7CQ459732&props=labels%7Cclaims&languages=en%7Cbn&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (English)","fields":["name","aliases"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/Chattogram"},{"attribution":"Bangladesh institutional master data supplied by a RefDataKit contributor in bangladesh_complete_institutions_master.json.","fields":["name","aliases"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"},{"attribution":"Bengali renderings prepared by RefDataKit contributors from the English names in the supplied dataset.","fields":["localized_names.bn"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q747840, Q376749, Q1354, Q243325, Q1006303, Q322155, Q994514, and Q466221","license":"CC0-1.0","path":"datasets/cities/by-country/BD.json","sha256":"8d1da8effe66c842ee7cc1bf438ff43fcffab15362bcdec54396a3228609966c","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q747840%7CQ376749%7CQ1354%7CQ243325%7CQ1006303%7CQ322155%7CQ994514%7CQ466221&props=labels%7Cclaims&languages=en%7Cbn&format=json"},{"attribution":"Wikidata contributors, items Q9270","license":"CC0-1.0","path":"datasets/cities/by-country/BT.json","sha256":"6897a82eb28a84bdb8a79177f0a145711515ebef338ffef174170ad323b169db","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q9270&props=labels%7Cclaims&languages=en&format=json"},{"attribution":"Wikidata contributors, items Q35381, Q489744, Q215277, Q3522428, Q867213, Q319366, Q810963, Q13360574","license":"CC0-1.0","path":"datasets/cities/by-country/LK.json","sha256":"484b855fb9a134787d9dde50a1b5da5a8f886adee9eac9151652d155294e80a3","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q13360574%7CQ215277%7CQ319366%7CQ3522428%7CQ35381%7CQ489744%7CQ810963%7CQ867213&props=labels%7Cclaims&languages=en&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (English)","fields":["population for wikidata:Q3038674 (4,815, 2022 census)"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/Gan_(Laamu_Atoll)"}],"attribution":"Wikidata contributors, items Q9347, Q3038674","license":"CC0-1.0","path":"datasets/cities/by-country/MV.json","sha256":"50f037085acfd0d564dea5c4bbda1fa744315735c98d5a70b01362a8010b3b72","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q3038674%7CQ9347&props=labels%7Cclaims&languages=en&format=json"},{"attribution":"Wikidata contributors, items Q3037, Q1517030, Q576437, Q6647, Q6640, Q8254","license":"CC0-1.0","path":"datasets/cities/by-country/NP.json","sha256":"f7bd0a71e6b4beb01ad0644708505d1a673cadfa6a625c1e7d15299588ddb590","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q1517030%7CQ3037%7CQ576437%7CQ6640%7CQ6647%7CQ8254&props=labels%7Cclaims&languages=en&format=json"},{"attribution":"Wikidata contributors, items Q334","license":"CC0-1.0","path":"datasets/cities/by-country/SG.json","sha256":"2e549c2c2671fb2d0773dab5d9a95d5c4c7c7a801f534d0a1d6043e4dddd2bb3","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q334&props=labels%7Cclaims&languages=en%7Cms%7Cta%7Czh&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (Bengali)","fields":["names.languages (bengali)"],"license":"CC BY-SA 4.0","source_url":"https://bn.wikipedia.org"},{"attribution":"Bangladesh institutional master data supplied by a RefDataKit contributor in bangladesh_complete_institutions_master.json.","fields":["names.en","entity_type","tags","ownership","city_id"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"},{"attribution":"Bengali renderings prepared by RefDataKit contributors from the English names in the supplied dataset.","fields":["names.languages.bn"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q1207503, Q1480421, Q29025023, Q3350920, Q4855005, Q4855319, Q506330, Q5233952, Q7494644, Q7895267","license":"CC0-1.0","path":"datasets/institutions/by-country/BD.json","sha256":"8b42214e6d91c72528234272f920c01a1992f6d07a7fe4ea8fe1e3d9c82c2585","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q1207503%7CQ1480421%7CQ29025023%7CQ3350920%7CQ4855005%7CQ4855319%7CQ506330%7CQ5233952%7CQ7494644%7CQ7895267&props=labels%7Cclaims&languages=bn%7Cen&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (English)","fields":["names.en for wikidata:Q4314988 (official full name)"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/Jigme_Dorji_Wangchuck_National_Referral_Hospital"},{"attribution":"WHO Regional Office for South-East Asia","fields":["names.en for wikidata:Q4314988 (official full name)"],"license":"Not stated by source; public web page used for factual verification","source_url":"https://apps.searo.who.int/PHI/Institute/Details/104"},{"attribution":"RefDataKit contributors; localized names translated from English names in this contribution.","fields":["names.languages.dz"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q2640138, Q4201619, Q4314988, Q86663201","license":"CC0-1.0","path":"datasets/institutions/by-country/BT.json","sha256":"23d18fd87d122a96b756e0033827ed31f9dcbd35eb07b71fa8ede4483ab64a64","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q2640138%7CQ4201619%7CQ4314988%7CQ86663201&props=labels%7Cclaims&languages=dz%7Cen&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (Sinhala)","fields":["names.languages (sinhala)"],"license":"CC BY-SA 4.0","source_url":"https://si.wikipedia.org"},{"attribution":"Wikipedia contributors (Tamil)","fields":["names.languages (tamil)"],"license":"CC BY-SA 4.0","source_url":"https://ta.wikipedia.org"},{"attribution":"University of Ruhuna","fields":["city_id for wikidata:Q12975239 (main campus Wellamadama, Matara)"],"license":"Not stated by source; public web page used for factual verification","source_url":"https://www.ruh.ac.lk/index.php/en/about/university-history"},{"attribution":"Wikipedia contributors (English)","fields":["city_id for wikidata:Q12975239","names.languages.si for wikidata:Q12975239 (infobox Sinhala name)"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/University_of_Ruhuna"},{"attribution":"RefDataKit contributors; localized names translated from English names in this contribution.","fields":["names.languages.si","names.languages.ta"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q12975239, Q16988751, Q24942979, Q3083280, Q3399947, Q3523254, Q3534731, Q4869912, Q5316328, Q6121967, Q6470509, Q720953, Q720958","license":"CC0-1.0","path":"datasets/institutions/by-country/LK.json","sha256":"21d2651ce9245d06c0946df12cccaf43f03afa2a1ac1e4f280bd4965166028da","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q12975239%7CQ16988751%7CQ24942979%7CQ3083280%7CQ3399947%7CQ3523254%7CQ3534731%7CQ4869912%7CQ5316328%7CQ6121967%7CQ6470509%7CQ720953%7CQ720958&props=labels%7Cclaims&languages=en%7Csi%7Cta&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (Divehi)","fields":["names.languages (divehi)"],"license":"CC BY-SA 4.0","source_url":"https://dv.wikipedia.org"},{"attribution":"Wikipedia contributors (English)","fields":["city_id for wikidata:Q5520449 (Gan, Laamu Atoll)"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/Gan_Regional_Hospital"},{"attribution":"RefDataKit contributors; localized names translated from English names in this contribution.","fields":["names.languages.dv"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q25110403, Q4120538, Q4651138, Q5520449, Q6024972","license":"CC0-1.0","path":"datasets/institutions/by-country/MV.json","sha256":"8ec7fa14ae48f74a606f62027d2cf0324dcba207303dbebee26a4a21bae72a70","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q25110403%7CQ4120538%7CQ4651138%7CQ5520449%7CQ6024972&props=labels%7Cclaims&languages=dv%7Cen&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (Nepali)","fields":["names.languages (nepali)"],"license":"CC BY-SA 4.0","source_url":"https://ne.wikipedia.org"},{"attribution":"Kathmandu University","fields":["city_id for wikidata:Q6376965 (Dhulikhel campus; Wikidata P131 lists Kathmandu District only)"],"license":"Not stated by source; public web page used for factual verification","source_url":"https://ku.edu.np/"},{"attribution":"Wikipedia contributors (English)","fields":["city_id for wikidata:Q588239 (Kirtipur campus)","city_id for wikidata:Q6376965"],"license":"CC BY-SA 4.0","source_url":"https://en.wikipedia.org/wiki/Kathmandu_University"}],"attribution":"Wikidata contributors, items Q13181748, Q13184064, Q13186297, Q15196996, Q3630498, Q4833866, Q5269864, Q588239, Q6365469, Q6376965","license":"CC0-1.0","path":"datasets/institutions/by-country/NP.json","sha256":"a8d4012d81a20321f6963cb24f527ec4761c77dffc922474afa723466b6bf03e","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q13181748%7CQ13184064%7CQ13186297%7CQ15196996%7CQ3630498%7CQ4833866%7CQ5269864%7CQ588239%7CQ6365469%7CQ6376965&props=labels%7Cclaims&languages=en%7Cne&format=json"},{"additional_sources":[{"attribution":"Wikipedia contributors (Malay)","fields":["names.languages (malay)"],"license":"CC BY-SA 4.0","source_url":"https://ms.wikipedia.org"},{"attribution":"Wikipedia contributors (Tamil)","fields":["names.languages (tamil)"],"license":"CC BY-SA 4.0","source_url":"https://ta.wikipedia.org"},{"attribution":"Wikipedia contributors (Chinese)","fields":["names.languages (chinese)"],"license":"CC BY-SA 4.0","source_url":"https://zh.wikipedia.org"},{"attribution":"RefDataKit contributors; localized names translated from English names in this contribution.","fields":["names.languages.ms","names.languages.ta"],"license":"MIT","source_url":"https://github.com/rezwan4029/refdatakit"}],"attribution":"Wikidata contributors, items Q11081251, Q1320916, Q16999402, Q494179, Q6332329, Q6979219, Q721064, Q738236, Q7522983, Q7523022, Q7682145, Q950609","license":"CC0-1.0","path":"datasets/institutions/by-country/SG.json","sha256":"c9023f29bba75258b51fc1b9d4a2979fb1b1fbf4638326cde73add1a126fa87c","source_url":"https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q11081251%7CQ1320916%7CQ16999402%7CQ494179%7CQ6332329%7CQ6979219%7CQ721064%7CQ738236%7CQ7522983%7CQ7523022%7CQ7682145%7CQ950609&props=labels%7Cclaims&languages=en%7Cms%7Cta%7Czh&format=json"}],"vocabularies":{"entity_tags":["hospital","k12_school","medical_college","nursing_home","polytechnic","technical_training_institute","university"]}}
@@ -0,0 +1 @@
1
+ [{"code":"BD-A","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"বরিশাল বিভাগ"}],"name":"Barisal Division"},{"code":"BD-B","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"চট্টগ্রাম বিভাগ"}],"name":"Chattogram Division"},{"code":"BD-C","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"ঢাকা বিভাগ"}],"name":"Dhaka Division"},{"code":"BD-D","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"খুলনা বিভাগ"}],"name":"Khulna Division"},{"code":"BD-H","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"ময়মনসিংহ বিভাগ"}],"name":"Mymensingh Division"},{"code":"BD-E","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"রাজশাহী বিভাগ"}],"name":"Rajshahi Division"},{"code":"BD-F","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"রংপুর বিভাগ"}],"name":"Rangpur Division"},{"code":"BD-G","country_code":"BD","level":"division","localized_names":[{"language":"bn","name":"সিলেট বিভাগ"}],"name":"Sylhet Division"}]
@@ -0,0 +1,84 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "City or Locality",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["id", "name", "country_code"],
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
11
+ "description": "Stable identifier that must not be derived from a mutable display name."
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "country_code": {
18
+ "type": "string",
19
+ "pattern": "^[A-Z]{2}$"
20
+ },
21
+ "subdivision_code": {
22
+ "type": "string",
23
+ "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$"
24
+ },
25
+ "coordinates": {
26
+ "$ref": "#/$defs/coordinates"
27
+ },
28
+ "population": {
29
+ "type": "integer",
30
+ "minimum": 0
31
+ },
32
+ "localized_names": {
33
+ "type": "array",
34
+ "items": {
35
+ "$ref": "#/$defs/localized_name"
36
+ }
37
+ },
38
+ "aliases": {
39
+ "type": "array",
40
+ "uniqueItems": true,
41
+ "items": {
42
+ "type": "string",
43
+ "minLength": 1
44
+ }
45
+ }
46
+ },
47
+ "$defs": {
48
+ "language": {
49
+ "type": "string",
50
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
51
+ },
52
+ "localized_name": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": ["language", "name"],
56
+ "properties": {
57
+ "language": {
58
+ "$ref": "#/$defs/language"
59
+ },
60
+ "name": {
61
+ "type": "string",
62
+ "minLength": 1
63
+ }
64
+ }
65
+ },
66
+ "coordinates": {
67
+ "type": "object",
68
+ "additionalProperties": false,
69
+ "required": ["latitude", "longitude"],
70
+ "properties": {
71
+ "latitude": {
72
+ "type": "number",
73
+ "minimum": -90,
74
+ "maximum": 90
75
+ },
76
+ "longitude": {
77
+ "type": "number",
78
+ "minimum": -180,
79
+ "maximum": 180
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Country",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["code", "name", "official_languages"],
7
+ "properties": {
8
+ "code": {
9
+ "type": "string",
10
+ "pattern": "^[A-Z]{2}$",
11
+ "description": "ISO 3166-1 alpha-2 code."
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ "alpha3_code": {
18
+ "type": "string",
19
+ "pattern": "^[A-Z]{3}$"
20
+ },
21
+ "numeric_code": {
22
+ "type": "string",
23
+ "pattern": "^[0-9]{3}$"
24
+ },
25
+ "official_languages": {
26
+ "type": "array",
27
+ "uniqueItems": true,
28
+ "items": {
29
+ "$ref": "#/$defs/language"
30
+ },
31
+ "description": "Known nationally official languages. An empty array means no value has been contributed or verified; it does not assert that the country has no official language."
32
+ },
33
+ "commonly_spoken_languages": {
34
+ "type": "array",
35
+ "uniqueItems": true,
36
+ "items": {
37
+ "$ref": "#/$defs/language"
38
+ },
39
+ "description": "Known commonly spoken languages from the sources listed in the manifest. An empty array means no value has been contributed or verified."
40
+ },
41
+ "centroid": {
42
+ "$ref": "#/$defs/coordinates",
43
+ "description": "Approximate country-level representative point; not a precise address."
44
+ },
45
+ "localized_names": {
46
+ "type": "array",
47
+ "items": {
48
+ "$ref": "#/$defs/localized_name"
49
+ }
50
+ },
51
+ "aliases": {
52
+ "type": "array",
53
+ "uniqueItems": true,
54
+ "items": {
55
+ "type": "string",
56
+ "minLength": 1
57
+ }
58
+ }
59
+ },
60
+ "$defs": {
61
+ "language": {
62
+ "type": "string",
63
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
64
+ "description": "BCP 47 language tag."
65
+ },
66
+ "localized_name": {
67
+ "type": "object",
68
+ "additionalProperties": false,
69
+ "required": ["language", "name"],
70
+ "properties": {
71
+ "language": {
72
+ "$ref": "#/$defs/language"
73
+ },
74
+ "name": {
75
+ "type": "string",
76
+ "minLength": 1
77
+ }
78
+ }
79
+ },
80
+ "coordinates": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": ["latitude", "longitude"],
84
+ "properties": {
85
+ "latitude": {
86
+ "type": "number",
87
+ "minimum": -90,
88
+ "maximum": 90
89
+ },
90
+ "longitude": {
91
+ "type": "number",
92
+ "minimum": -180,
93
+ "maximum": 180
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,174 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Universal Directory Entity",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "id",
8
+ "names",
9
+ "entity_type",
10
+ "country_code",
11
+ "city_id",
12
+ "tags"
13
+ ],
14
+ "properties": {
15
+ "id": {
16
+ "type": "string",
17
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$",
18
+ "description": "Stable identifier that must not be derived from a mutable display name."
19
+ },
20
+ "names": {
21
+ "type": "object",
22
+ "additionalProperties": false,
23
+ "required": [
24
+ "en",
25
+ "languages"
26
+ ],
27
+ "properties": {
28
+ "en": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "languages": {
33
+ "type": "object",
34
+ "propertyNames": {
35
+ "pattern": "^[a-z]{2}$"
36
+ },
37
+ "additionalProperties": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "description": "Partial names keyed by ISO 639-1 code for verified official non-English languages; unavailable translations may be omitted."
42
+ }
43
+ }
44
+ },
45
+ "entity_type": {
46
+ "enum": [
47
+ "school",
48
+ "college",
49
+ "university",
50
+ "corporation",
51
+ "civic_organization",
52
+ "religious_building",
53
+ "other"
54
+ ]
55
+ },
56
+ "country_code": {
57
+ "type": "string",
58
+ "pattern": "^[A-Z]{2}$"
59
+ },
60
+ "ownership": {
61
+ "type": "string",
62
+ "enum": [
63
+ "public",
64
+ "private"
65
+ ],
66
+ "description": "Optional public or private ownership classification when supported by the source."
67
+ },
68
+ "city_id": {
69
+ "type": "string",
70
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
71
+ },
72
+ "tags": {
73
+ "type": "array",
74
+ "minItems": 1,
75
+ "uniqueItems": true,
76
+ "items": {
77
+ "$ref": "#/$defs/tag"
78
+ },
79
+ "description": "Controlled classifications for an institution; multiple tags may apply."
80
+ },
81
+ "localized_aliases": {
82
+ "type": "array",
83
+ "items": {
84
+ "$ref": "#/$defs/localized_alias"
85
+ }
86
+ },
87
+ "languages": {
88
+ "type": "array",
89
+ "uniqueItems": true,
90
+ "items": {
91
+ "$ref": "#/$defs/language"
92
+ },
93
+ "description": "Languages used for instruction, services, or public-facing operations."
94
+ },
95
+ "website": {
96
+ "type": "string",
97
+ "format": "uri"
98
+ },
99
+ "domains": {
100
+ "type": "array",
101
+ "uniqueItems": true,
102
+ "items": {
103
+ "type": "string",
104
+ "format": "hostname"
105
+ }
106
+ },
107
+ "external_ids": {
108
+ "type": "array",
109
+ "uniqueItems": true,
110
+ "items": {
111
+ "$ref": "#/$defs/external_id"
112
+ }
113
+ }
114
+ },
115
+ "$defs": {
116
+ "tag": {
117
+ "type": "string",
118
+ "enum": [
119
+ "hospital",
120
+ "k12_school",
121
+ "medical_college",
122
+ "nursing_home",
123
+ "polytechnic",
124
+ "technical_training_institute",
125
+ "university"
126
+ ],
127
+ "description": "Generated from datasets/manifest.json vocabularies.entity_tags."
128
+ },
129
+ "language": {
130
+ "type": "string",
131
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
132
+ "description": "BCP 47 language tag."
133
+ },
134
+ "localized_alias": {
135
+ "type": "object",
136
+ "additionalProperties": false,
137
+ "required": [
138
+ "language",
139
+ "value"
140
+ ],
141
+ "properties": {
142
+ "language": {
143
+ "$ref": "#/$defs/language"
144
+ },
145
+ "value": {
146
+ "type": "string",
147
+ "minLength": 1
148
+ }
149
+ }
150
+ },
151
+ "external_id": {
152
+ "type": "object",
153
+ "additionalProperties": false,
154
+ "required": [
155
+ "system",
156
+ "value"
157
+ ],
158
+ "properties": {
159
+ "system": {
160
+ "type": "string",
161
+ "minLength": 1
162
+ },
163
+ "value": {
164
+ "type": "string",
165
+ "minLength": 1
166
+ },
167
+ "url": {
168
+ "type": "string",
169
+ "format": "uri"
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "RefDataKit Dataset Manifest",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["datasets", "vocabularies"],
7
+ "properties": {
8
+ "vocabularies": {
9
+ "type": "object",
10
+ "additionalProperties": false,
11
+ "required": ["entity_tags"],
12
+ "properties": {
13
+ "entity_tags": {
14
+ "type": "array",
15
+ "minItems": 1,
16
+ "uniqueItems": true,
17
+ "items": {
18
+ "type": "string",
19
+ "pattern": "^[a-z][a-z0-9_]*$"
20
+ }
21
+ }
22
+ }
23
+ },
24
+ "datasets": {
25
+ "type": "array",
26
+ "items": {
27
+ "type": "object",
28
+ "additionalProperties": false,
29
+ "required": ["path", "source_url", "license", "attribution", "sha256"],
30
+ "properties": {
31
+ "path": {
32
+ "type": "string",
33
+ "pattern": "^datasets/.+\\.json$"
34
+ },
35
+ "source_url": {
36
+ "type": "string",
37
+ "format": "uri"
38
+ },
39
+ "license": {
40
+ "type": "string",
41
+ "minLength": 1
42
+ },
43
+ "attribution": {
44
+ "type": "string",
45
+ "minLength": 1
46
+ },
47
+ "data_as_of": {
48
+ "type": "string",
49
+ "format": "date"
50
+ },
51
+ "additional_sources": {
52
+ "type": "array",
53
+ "items": {
54
+ "type": "object",
55
+ "additionalProperties": false,
56
+ "required": ["source_url", "license", "attribution", "fields"],
57
+ "properties": {
58
+ "source_url": {
59
+ "type": "string",
60
+ "format": "uri"
61
+ },
62
+ "license": {
63
+ "type": "string",
64
+ "minLength": 1
65
+ },
66
+ "attribution": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "data_as_of": {
71
+ "type": "string",
72
+ "format": "date"
73
+ },
74
+ "fields": {
75
+ "type": "array",
76
+ "minItems": 1,
77
+ "uniqueItems": true,
78
+ "items": {
79
+ "type": "string",
80
+ "minLength": 1
81
+ }
82
+ }
83
+ }
84
+ }
85
+ },
86
+ "sha256": {
87
+ "type": "string",
88
+ "pattern": "^[a-f0-9]{64}$"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Administrative Subdivision",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["code", "country_code", "name", "level"],
7
+ "properties": {
8
+ "code": {
9
+ "type": "string",
10
+ "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$",
11
+ "description": "ISO 3166-2 code when available; otherwise a stable country-scoped code."
12
+ },
13
+ "country_code": {
14
+ "type": "string",
15
+ "pattern": "^[A-Z]{2}$"
16
+ },
17
+ "name": {
18
+ "type": "string",
19
+ "minLength": 1
20
+ },
21
+ "level": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "description": "Country-specific administrative level."
25
+ },
26
+ "parent_code": {
27
+ "type": "string",
28
+ "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$"
29
+ },
30
+ "localized_names": {
31
+ "type": "array",
32
+ "items": {
33
+ "$ref": "#/$defs/localized_name"
34
+ }
35
+ },
36
+ "aliases": {
37
+ "type": "array",
38
+ "uniqueItems": true,
39
+ "items": {
40
+ "type": "string",
41
+ "minLength": 1
42
+ }
43
+ }
44
+ },
45
+ "$defs": {
46
+ "language": {
47
+ "type": "string",
48
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$"
49
+ },
50
+ "localized_name": {
51
+ "type": "object",
52
+ "additionalProperties": false,
53
+ "required": ["language", "name"],
54
+ "properties": {
55
+ "language": {
56
+ "$ref": "#/$defs/language"
57
+ },
58
+ "name": {
59
+ "type": "string",
60
+ "minLength": 1
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
refdatakit/data.py ADDED
@@ -0,0 +1,48 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from importlib.resources import files
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from .country_codes import CountryCode
9
+
10
+
11
+ def _records(relative_path: str) -> list[dict[str, Any]]:
12
+ resource = files("refdatakit").joinpath("data", "datasets", *relative_path.split("/"))
13
+ try:
14
+ return json.loads(resource.read_text(encoding="utf-8"))
15
+ except FileNotFoundError:
16
+ repository_file = Path(__file__).resolve().parents[4] / "datasets" / relative_path
17
+ try:
18
+ return json.loads(repository_file.read_text(encoding="utf-8"))
19
+ except FileNotFoundError:
20
+ return []
21
+
22
+
23
+ def _country_path(country_code: CountryCode, kind: str) -> str:
24
+ if not isinstance(country_code, CountryCode):
25
+ raise TypeError("country_code must be a CountryCode member")
26
+ return f"{kind}/by-country/{country_code}.json"
27
+
28
+
29
+ def get_countries() -> list[dict[str, Any]]:
30
+ return _records("countries/data.json")
31
+
32
+
33
+ def get_country(country_code: CountryCode) -> dict[str, Any] | None:
34
+ if not isinstance(country_code, CountryCode):
35
+ raise TypeError("country_code must be a CountryCode member")
36
+ return next((country for country in get_countries() if country["code"] == country_code), None)
37
+
38
+
39
+ def get_cities(country_code: CountryCode) -> list[dict[str, Any]]:
40
+ return _records(_country_path(country_code, "cities"))
41
+
42
+
43
+ def get_subdivisions(country_code: CountryCode) -> list[dict[str, Any]]:
44
+ return _records(_country_path(country_code, "subdivisions"))
45
+
46
+
47
+ def get_institutions(country_code: CountryCode) -> list[dict[str, Any]]:
48
+ return _records(_country_path(country_code, "institutions"))