scjn 0.5.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.
scjn-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: scjn
3
+ Version: 0.5.0
4
+ Summary: Client for the SCJN's SCOW JSON API and reader for the scjn-leyes release: a Mexican federal law's reform-dated snapshots.
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/INGEOTEC/LegalIA/tree/main/packages/scjn
7
+ Classifier: License :: OSI Approved :: Apache Software License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: requests>=2.31
13
+ Requires-Dist: platformdirs>=4.0
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=7.0; extra == "test"
16
+
17
+ # scjn
18
+
19
+ Client for the SCJN's SCOW JSON API (`https://legislacion.scjn.gob.mx`) and
20
+ reader for the `scjn-leyes` GitHub release: a Mexican federal law's
21
+ reform-dated snapshots, each tagged with a `fuente: scjn` provenance header.
22
+ The SCJN is **not** an official source of legal text — the *Diario Oficial de
23
+ la Federación* (DOF), read through [`dofjson`](../dofjson), remains that;
24
+ this package's crawl is a convenience corpus SCJN's own consolidated view
25
+ makes possible, never a replacement for it.
26
+
27
+ This package was extracted out of a downstream package's own modules (issue
28
+ #206). Fase 1 (issue #207) moved the transport (`scjn.api`), the catalogue's
29
+ own algebra (`scjn.catalog`), per-instrument crawl state (`scjn.state`), and
30
+ the provenance header's reader (`scjn.header`) — no behaviour change, no
31
+ release-format change. Fase 3 (issue #209) moved the `scjn-leyes` release's
32
+ own readers here too (`scjn.release`: `download_scjn_leyes_corpus`,
33
+ `download_scjn_leyes_index`, `download_scjn_leyes_catalog`,
34
+ `iter_current_federal_laws`, `markdown_de_snapshot`,
35
+ `download_scjn_leyes_assets`, `local_slugs`), now in the package's own public
36
+ `scjn.__all__`, disk-first and with their own cache directory
37
+ (`scjn.cache`, `$SCJN_CACHE_DIR` — a separate lifecycle from the downstream
38
+ package's cache, migrated once automatically from wherever it used to live).
39
+ `codNota` linking — matching a snapshot to the DOF `codNota` that produced it
40
+ — stays one layer up: a `codNota` is a DOF concept, and this package's
41
+ dependency direction is one way (see `tests/test_boundary.py`).
42
+
43
+ Since issue #215 every law also carries the SCJN's own `materia` (subject
44
+ classification), `vigencia` (whether it is still in force — seven values, not
45
+ a boolean) and `resumen` (a one-paragraph abstract). They are per law, not
46
+ per reform, so they live in each law's own `estado.json` and in the release
47
+ index, and `download_scjn_leyes_catalog`/`iter_current_federal_laws` return
48
+ them with no extra request — which makes `scjn-leyes` a *classified* corpus.
49
+ `scripts/fetch_federal_law_metadata.py` is what fills them in, one SCJN
50
+ search per law, matched by `idOrdenamiento` so a wrong document can never be
51
+ described as the right one (issue #115, Hallazgo C).
52
+
53
+ scjn download [--slug SLUG] [--cache-dir DIR] [--refrescar]
54
+
55
+ puts the release on disk; every reader in `scjn.release` then reads off it
56
+ with no network request at all, raising `scjn.release.AssetNotCached` for
57
+ whatever is not there yet.
58
+
59
+ ## Changelog
60
+
61
+ - **0.5.0** — the fourth id-keyed collection, `scjn-tratados` (issue #277):
62
+ every international treaty the SCJN serves (~1,456 instruments, members
63
+ by the SCJN's *ámbito* `TRATADOS INTERNACIONALES`, any category).
64
+ `download_scjn_tratados_index` / `_corpus` / `_assets`,
65
+ `local_tratados_ids` and `iter_current_tratados` are the same thin
66
+ wrappers over the generic core the reglamentos/lineamientos ones are
67
+ (same `AssetNotCached`/`SinTextoEnSCJN` raise order), `scjn.cache.TRATADOS`
68
+ joins `COLECCIONES_POR_ID`, `scjn download --coleccion tratados` fetches
69
+ it, and `scjn.release.construye_indice_global_tratados` is its index
70
+ builder. The release is a numbered series of tags (`scjn-tratados`,
71
+ `scjn-tratados-2`, ...). `scjn.discovery` gains an `ambito` keyword
72
+ (`discover`/`discover_by_category`, default `"FEDERAL"`, existing calls
73
+ unchanged), a by-ámbito mode (`categoria=""`: no reform-category rescue
74
+ and no coverage audit) and `report_outside_ambito`.
75
+
76
+ - **0.4.0** — `articulos_a_markdown` recovers table rows from a
77
+ blank-line-separated block of an article's `contenido` that carries a tab
78
+ (issue #253): the SCJN's plain text uses a run of tabs as its only column
79
+ separator, and a wrapped multi-line cell used to come back as one
80
+ Markdown paragraph per source line instead of one per row. A block with
81
+ no tab is unaffected, byte for byte. Measured on the cached `scjn-leyes`
82
+ release: 35 of 315 laws, 567 of 3,707 snapshots — a snapshot already on
83
+ disk only picks up the fix via `scripts/fetch_scjn_legislacion.py
84
+ --reintenta <slug>`, never automatically.
85
+
86
+ - **0.3.0** — `iter_current_reglamentos` / `iter_current_lineamientos`
87
+ (issue #227, Fase 2): `iter_current_federal_laws`' id-keyed siblings, the
88
+ *current* text of every instrument of either collection, one tarball open
89
+ at a time. No `codNota` and no `abrev` (neither collection is DOF-linked),
90
+ the newest snapshot chosen from the file names since an id-keyed tarball
91
+ ships no `indice.json`, and an instrument the index lists with no
92
+ consolidated text at all is skipped rather than raising `SinTextoEnSCJN`.
93
+
94
+ - **0.2.0** — the package's first release: the SCOW transport (`scjn.api`),
95
+ the catalogue algebra, the crawl state, the provenance header and the
96
+ disk-first readers of the `scjn-leyes`/`scjn-reglamentos`/
97
+ `scjn-lineamientos` releases (issues #206-#212, #220, #222).
98
+
99
+ ## Development
100
+
101
+ ```bash
102
+ pip install -e "packages/scjn[test]"
103
+ pytest packages/scjn
104
+ ```
105
+
106
+ ## License
107
+
108
+ Apache License 2.0. See [LICENSE](../../LICENSE).
scjn-0.5.0/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # scjn
2
+
3
+ Client for the SCJN's SCOW JSON API (`https://legislacion.scjn.gob.mx`) and
4
+ reader for the `scjn-leyes` GitHub release: a Mexican federal law's
5
+ reform-dated snapshots, each tagged with a `fuente: scjn` provenance header.
6
+ The SCJN is **not** an official source of legal text — the *Diario Oficial de
7
+ la Federación* (DOF), read through [`dofjson`](../dofjson), remains that;
8
+ this package's crawl is a convenience corpus SCJN's own consolidated view
9
+ makes possible, never a replacement for it.
10
+
11
+ This package was extracted out of a downstream package's own modules (issue
12
+ #206). Fase 1 (issue #207) moved the transport (`scjn.api`), the catalogue's
13
+ own algebra (`scjn.catalog`), per-instrument crawl state (`scjn.state`), and
14
+ the provenance header's reader (`scjn.header`) — no behaviour change, no
15
+ release-format change. Fase 3 (issue #209) moved the `scjn-leyes` release's
16
+ own readers here too (`scjn.release`: `download_scjn_leyes_corpus`,
17
+ `download_scjn_leyes_index`, `download_scjn_leyes_catalog`,
18
+ `iter_current_federal_laws`, `markdown_de_snapshot`,
19
+ `download_scjn_leyes_assets`, `local_slugs`), now in the package's own public
20
+ `scjn.__all__`, disk-first and with their own cache directory
21
+ (`scjn.cache`, `$SCJN_CACHE_DIR` — a separate lifecycle from the downstream
22
+ package's cache, migrated once automatically from wherever it used to live).
23
+ `codNota` linking — matching a snapshot to the DOF `codNota` that produced it
24
+ — stays one layer up: a `codNota` is a DOF concept, and this package's
25
+ dependency direction is one way (see `tests/test_boundary.py`).
26
+
27
+ Since issue #215 every law also carries the SCJN's own `materia` (subject
28
+ classification), `vigencia` (whether it is still in force — seven values, not
29
+ a boolean) and `resumen` (a one-paragraph abstract). They are per law, not
30
+ per reform, so they live in each law's own `estado.json` and in the release
31
+ index, and `download_scjn_leyes_catalog`/`iter_current_federal_laws` return
32
+ them with no extra request — which makes `scjn-leyes` a *classified* corpus.
33
+ `scripts/fetch_federal_law_metadata.py` is what fills them in, one SCJN
34
+ search per law, matched by `idOrdenamiento` so a wrong document can never be
35
+ described as the right one (issue #115, Hallazgo C).
36
+
37
+ scjn download [--slug SLUG] [--cache-dir DIR] [--refrescar]
38
+
39
+ puts the release on disk; every reader in `scjn.release` then reads off it
40
+ with no network request at all, raising `scjn.release.AssetNotCached` for
41
+ whatever is not there yet.
42
+
43
+ ## Changelog
44
+
45
+ - **0.5.0** — the fourth id-keyed collection, `scjn-tratados` (issue #277):
46
+ every international treaty the SCJN serves (~1,456 instruments, members
47
+ by the SCJN's *ámbito* `TRATADOS INTERNACIONALES`, any category).
48
+ `download_scjn_tratados_index` / `_corpus` / `_assets`,
49
+ `local_tratados_ids` and `iter_current_tratados` are the same thin
50
+ wrappers over the generic core the reglamentos/lineamientos ones are
51
+ (same `AssetNotCached`/`SinTextoEnSCJN` raise order), `scjn.cache.TRATADOS`
52
+ joins `COLECCIONES_POR_ID`, `scjn download --coleccion tratados` fetches
53
+ it, and `scjn.release.construye_indice_global_tratados` is its index
54
+ builder. The release is a numbered series of tags (`scjn-tratados`,
55
+ `scjn-tratados-2`, ...). `scjn.discovery` gains an `ambito` keyword
56
+ (`discover`/`discover_by_category`, default `"FEDERAL"`, existing calls
57
+ unchanged), a by-ámbito mode (`categoria=""`: no reform-category rescue
58
+ and no coverage audit) and `report_outside_ambito`.
59
+
60
+ - **0.4.0** — `articulos_a_markdown` recovers table rows from a
61
+ blank-line-separated block of an article's `contenido` that carries a tab
62
+ (issue #253): the SCJN's plain text uses a run of tabs as its only column
63
+ separator, and a wrapped multi-line cell used to come back as one
64
+ Markdown paragraph per source line instead of one per row. A block with
65
+ no tab is unaffected, byte for byte. Measured on the cached `scjn-leyes`
66
+ release: 35 of 315 laws, 567 of 3,707 snapshots — a snapshot already on
67
+ disk only picks up the fix via `scripts/fetch_scjn_legislacion.py
68
+ --reintenta <slug>`, never automatically.
69
+
70
+ - **0.3.0** — `iter_current_reglamentos` / `iter_current_lineamientos`
71
+ (issue #227, Fase 2): `iter_current_federal_laws`' id-keyed siblings, the
72
+ *current* text of every instrument of either collection, one tarball open
73
+ at a time. No `codNota` and no `abrev` (neither collection is DOF-linked),
74
+ the newest snapshot chosen from the file names since an id-keyed tarball
75
+ ships no `indice.json`, and an instrument the index lists with no
76
+ consolidated text at all is skipped rather than raising `SinTextoEnSCJN`.
77
+
78
+ - **0.2.0** — the package's first release: the SCOW transport (`scjn.api`),
79
+ the catalogue algebra, the crawl state, the provenance header and the
80
+ disk-first readers of the `scjn-leyes`/`scjn-reglamentos`/
81
+ `scjn-lineamientos` releases (issues #206-#212, #220, #222).
82
+
83
+ ## Development
84
+
85
+ ```bash
86
+ pip install -e "packages/scjn[test]"
87
+ pytest packages/scjn
88
+ ```
89
+
90
+ ## License
91
+
92
+ Apache License 2.0. See [LICENSE](../../LICENSE).
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scjn"
7
+ description = "Client for the SCJN's SCOW JSON API and reader for the scjn-leyes release: a Mexican federal law's reform-dated snapshots."
8
+ readme = "README.md"
9
+ license = { text = "Apache-2.0" }
10
+ # 3.10 for the PEP 604 unions (`X | None`) the package evaluates at import:
11
+ # they sit in function signatures, so they run when the module is defined.
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "License :: OSI Approved :: Apache Software License",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ ]
18
+ # Dependency direction is one way (issue #206/#207): this package imports
19
+ # neither nota2md nor dofjson, so it needs nothing from either of them —
20
+ # nota2md depends on scjn, never the reverse.
21
+ dependencies = [
22
+ "requests>=2.31",
23
+ # scjn.cache's own on-disk cache for the scjn-leyes release (issue #209).
24
+ "platformdirs>=4.0",
25
+ ]
26
+ dynamic = ['version']
27
+
28
+ [project.optional-dependencies]
29
+ test = ["pytest>=7.0"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/INGEOTEC/LegalIA/tree/main/packages/scjn"
33
+
34
+ [project.scripts]
35
+ scjn = "scjn.cli:main"
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["scjn", "scjn.*"]
39
+
40
+ [tool.setuptools.dynamic]
41
+ version = {attr = 'scjn.__version__'}
@@ -0,0 +1,78 @@
1
+ """Client for the SCJN's SCOW JSON API (`scjn.api`), the federal-law
2
+ catalogue's own algebra (`scjn.catalog`), per-instrument crawl state
3
+ (`scjn.state`), the provenance header a crawl writes to every snapshot
4
+ (`scjn.header`), and the disk-first readers (`scjn.release`) for the four
5
+ GitHub releases this package feeds -- `scjn-leyes` and, since issues #220,
6
+ #222 and #277, the id-keyed `scjn-reglamentos`/`scjn-lineamientos`/
7
+ `scjn-tratados` -- re-exported
8
+ here as the package's own entry points.
9
+
10
+ The SCJN is not an official source of legal text — the Diario Oficial de la
11
+ Federación remains that; this package's own crawl is a convenience corpus
12
+ its consolidated view makes possible, not a replacement for it.
13
+
14
+ This is Fase 3 of a larger split (issue #206/#209). `codNota` linking —
15
+ matching a snapshot to the DOF `codNota` that produced it — stays one layer
16
+ up, in the downstream package that depends on this one: a `codNota` is a DOF
17
+ concept, so that seam sits there, calling the readers below (this package
18
+ never imports back — see `tests/test_boundary.py`). No id-keyed
19
+ collection has such linking at all yet (issue #220's own Scope, unchanged by
20
+ #222 and #277) — a future issue adds it for reglamentos, lineamientos,
21
+ tratados and laws alike.
22
+ """
23
+
24
+ from scjn.release import (
25
+ AssetNotCached,
26
+ SinTextoEnSCJN,
27
+ download_scjn_leyes_assets,
28
+ download_scjn_leyes_catalog,
29
+ download_scjn_leyes_corpus,
30
+ download_scjn_leyes_index,
31
+ download_scjn_lineamientos_assets,
32
+ download_scjn_lineamientos_corpus,
33
+ download_scjn_lineamientos_index,
34
+ download_scjn_reglamentos_assets,
35
+ download_scjn_reglamentos_corpus,
36
+ download_scjn_reglamentos_index,
37
+ download_scjn_tratados_assets,
38
+ download_scjn_tratados_corpus,
39
+ download_scjn_tratados_index,
40
+ iter_current_federal_laws,
41
+ iter_current_lineamientos,
42
+ iter_current_reglamentos,
43
+ iter_current_tratados,
44
+ local_lineamientos_ids,
45
+ local_reglamentos_ids,
46
+ local_slugs,
47
+ local_tratados_ids,
48
+ markdown_de_snapshot,
49
+ )
50
+
51
+ __version__ = "0.5.0"
52
+
53
+ __all__ = [
54
+ "download_scjn_leyes_corpus",
55
+ "download_scjn_leyes_index",
56
+ "download_scjn_leyes_catalog",
57
+ "iter_current_federal_laws",
58
+ "iter_current_reglamentos",
59
+ "iter_current_lineamientos",
60
+ "iter_current_tratados",
61
+ "markdown_de_snapshot",
62
+ "download_scjn_leyes_assets",
63
+ "local_slugs",
64
+ "download_scjn_reglamentos_index",
65
+ "download_scjn_reglamentos_corpus",
66
+ "download_scjn_reglamentos_assets",
67
+ "local_reglamentos_ids",
68
+ "download_scjn_lineamientos_index",
69
+ "download_scjn_lineamientos_corpus",
70
+ "download_scjn_lineamientos_assets",
71
+ "local_lineamientos_ids",
72
+ "download_scjn_tratados_index",
73
+ "download_scjn_tratados_corpus",
74
+ "download_scjn_tratados_assets",
75
+ "local_tratados_ids",
76
+ "AssetNotCached",
77
+ "SinTextoEnSCJN",
78
+ ]