@tricoteuses/assemblee 2.0.2 → 2.1.0
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.
- package/README.md +26 -8
- package/lib/amendements-40Z7OJLT.js +682 -0
- package/lib/amendements-DcffXOt8.js +154 -0
- package/lib/api.d.ts +0 -1
- package/lib/cleaners/actes_legislatifs.d.ts +0 -1
- package/lib/cleaners/acteurs.d.ts +0 -1
- package/lib/cleaners/amendements.d.ts +0 -1
- package/lib/cleaners/debats.d.ts +0 -1
- package/lib/cleaners/documents.d.ts +0 -1
- package/lib/cleaners/dossiers_legislatifs.d.ts +0 -1
- package/lib/cleaners/index.d.ts +0 -1
- package/lib/cleaners/organes.d.ts +0 -1
- package/lib/cleaners/questions.d.ts +0 -1
- package/lib/cleaners/reunions.d.ts +0 -1
- package/lib/cleaners/scrutins.d.ts +0 -1
- package/lib/cleaners/xml.d.ts +0 -1
- package/lib/cleaners.js +508 -1082
- package/lib/datasets.d.ts +0 -1
- package/lib/dates.d.ts +0 -1
- package/lib/dossiers_legislatifs.d.ts +1 -3
- package/lib/file_systems.d.ts +0 -1
- package/lib/git.d.ts +0 -1
- package/lib/index.d.ts +8 -9
- package/lib/index.js +857 -1211
- package/lib/inserters.d.ts +0 -1
- package/lib/loaders-DX6btNsl.js +4201 -0
- package/lib/loaders.d.ts +0 -1
- package/lib/loaders.js +27 -983
- package/lib/logger.d.ts +0 -1
- package/lib/organes.d.ts +0 -1
- package/lib/parse-Ccs6wcUg.js +2512 -0
- package/lib/parsers/index.d.ts +0 -1
- package/lib/parsers/plf.d.ts +0 -1
- package/lib/parsers/recherche_amendements.d.ts +3 -1
- package/lib/parsers/textes_lois.d.ts +0 -1
- package/lib/parsers.js +292 -287
- package/lib/raw_types/acteurs_et_organes.d.ts +0 -1
- package/lib/raw_types/agendas.d.ts +0 -1
- package/lib/raw_types/amendements.d.ts +0 -1
- package/lib/raw_types/debats.d.ts +0 -1
- package/lib/raw_types/dossiers_legislatifs.d.ts +8 -9
- package/lib/raw_types/questions.d.ts +0 -1
- package/lib/raw_types/scrutins.d.ts +0 -1
- package/lib/schemas/acteurs_et_organes.json +26 -26
- package/lib/schemas/agendas.json +47 -47
- package/lib/schemas/amendements.json +69 -68
- package/lib/schemas/dossiers_legislatifs.json +112 -112
- package/lib/schemas/questions.json +25 -25
- package/lib/schemas/scrutins.json +15 -15
- package/lib/scripts/add_links_to_documents.d.ts +0 -1
- package/lib/scripts/clean_reorganized_data.d.ts +0 -1
- package/lib/scripts/copy-schemas.d.ts +0 -1
- package/lib/scripts/diff_amendements.d.ts +0 -1
- package/lib/scripts/document_dossiers_legislatifs.d.ts +0 -1
- package/lib/scripts/generate-json-schemas.d.ts +0 -1
- package/lib/scripts/get_today_reunions.d.ts +0 -1
- package/lib/scripts/merge_scrutins.d.ts +0 -1
- package/lib/scripts/process_open_dataset.d.ts +0 -1
- package/lib/scripts/raw_types_from_amendements.d.ts +0 -1
- package/lib/scripts/reorganize_data.d.ts +0 -1
- package/lib/scripts/retrieve_deputes_photos.d.ts +0 -1
- package/lib/scripts/retrieve_documents.d.ts +0 -1
- package/lib/scripts/retrieve_open_data.d.ts +0 -1
- package/lib/scripts/retrieve_pending_amendments.d.ts +0 -1
- package/lib/scripts/retrieve_senateurs_photos.d.ts +0 -1
- package/lib/scripts/shared/cli_helpers.d.ts +0 -1
- package/lib/scripts/test_iter_load.d.ts +0 -1
- package/lib/scripts/test_load.d.ts +0 -1
- package/lib/scripts/test_load_big_files.d.ts +0 -1
- package/lib/scripts/validate_json.d.ts +0 -1
- package/lib/shared_types/codes_actes.d.ts +0 -1
- package/lib/strings.d.ts +0 -1
- package/lib/types/acteurs_et_organes.d.ts +26 -27
- package/lib/types/agendas.d.ts +21 -22
- package/lib/types/amendements.d.ts +76 -51
- package/lib/types/debats.d.ts +0 -1
- package/lib/types/dossiers_legislatifs.d.ts +51 -52
- package/lib/types/legislatures.d.ts +0 -1
- package/lib/types/questions.d.ts +22 -25
- package/lib/types/scrutins.d.ts +15 -16
- package/lib/urls.d.ts +0 -1
- package/package.json +12 -4
- package/lib/amendements-CN7bRFdP.js +0 -259
- package/lib/amendements-CN7bRFdP.js.map +0 -1
- package/lib/amendements-Cg1lyCBp.js +0 -735
- package/lib/amendements-Cg1lyCBp.js.map +0 -1
- package/lib/api.d.ts.map +0 -1
- package/lib/cleaners/actes_legislatifs.d.ts.map +0 -1
- package/lib/cleaners/acteurs.d.ts.map +0 -1
- package/lib/cleaners/amendements.d.ts.map +0 -1
- package/lib/cleaners/debats.d.ts.map +0 -1
- package/lib/cleaners/documents.d.ts.map +0 -1
- package/lib/cleaners/dossiers_legislatifs.d.ts.map +0 -1
- package/lib/cleaners/index.d.ts.map +0 -1
- package/lib/cleaners/organes.d.ts.map +0 -1
- package/lib/cleaners/questions.d.ts.map +0 -1
- package/lib/cleaners/reunions.d.ts.map +0 -1
- package/lib/cleaners/scrutins.d.ts.map +0 -1
- package/lib/cleaners/xml.d.ts.map +0 -1
- package/lib/cleaners.js.map +0 -1
- package/lib/datasets.d.ts.map +0 -1
- package/lib/dates.d.ts.map +0 -1
- package/lib/debats-BwZYgzXe.js +0 -3978
- package/lib/debats-BwZYgzXe.js.map +0 -1
- package/lib/dossiers_legislatifs.d.ts.map +0 -1
- package/lib/file_systems.d.ts.map +0 -1
- package/lib/git.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/inserters.d.ts.map +0 -1
- package/lib/loaders.d.ts.map +0 -1
- package/lib/loaders.js.map +0 -1
- package/lib/logger.d.ts.map +0 -1
- package/lib/organes.d.ts.map +0 -1
- package/lib/parse-CzW8NHW5.js +0 -2850
- package/lib/parse-CzW8NHW5.js.map +0 -1
- package/lib/parsers/index.d.ts.map +0 -1
- package/lib/parsers/plf.d.ts.map +0 -1
- package/lib/parsers/recherche_amendements.d.ts.map +0 -1
- package/lib/parsers/textes_lois.d.ts.map +0 -1
- package/lib/parsers.js.map +0 -1
- package/lib/raw_types/acteurs_et_organes.d.ts.map +0 -1
- package/lib/raw_types/agendas.d.ts.map +0 -1
- package/lib/raw_types/amendements.d.ts.map +0 -1
- package/lib/raw_types/debats.d.ts.map +0 -1
- package/lib/raw_types/dossiers_legislatifs.d.ts.map +0 -1
- package/lib/raw_types/questions.d.ts.map +0 -1
- package/lib/raw_types/scrutins.d.ts.map +0 -1
- package/lib/schemas/acteurs_et_organes.d.json +0 -982
- package/lib/schemas/agendas.d.json +0 -1561
- package/lib/schemas/amendements.d.json +0 -1901
- package/lib/schemas/debats.d.json +0 -623
- package/lib/schemas/dossiers_legislatifs.d.json +0 -3690
- package/lib/schemas/legislatures.d.json +0 -17
- package/lib/schemas/questions.d.json +0 -520
- package/lib/schemas/scrutins.d.json +0 -517
- package/lib/scripts/add_links_to_documents.d.ts.map +0 -1
- package/lib/scripts/clean_reorganized_data.d.ts.map +0 -1
- package/lib/scripts/copy-schemas.d.ts.map +0 -1
- package/lib/scripts/diff_amendements.d.ts.map +0 -1
- package/lib/scripts/document_dossiers_legislatifs.d.ts.map +0 -1
- package/lib/scripts/generate-json-schemas.d.ts.map +0 -1
- package/lib/scripts/get_today_reunions.d.ts.map +0 -1
- package/lib/scripts/merge_scrutins.d.ts.map +0 -1
- package/lib/scripts/process_open_dataset.d.ts.map +0 -1
- package/lib/scripts/raw_types_from_amendements.d.ts.map +0 -1
- package/lib/scripts/reorganize_data.d.ts.map +0 -1
- package/lib/scripts/retrieve_deputes_photos.d.ts.map +0 -1
- package/lib/scripts/retrieve_documents.d.ts.map +0 -1
- package/lib/scripts/retrieve_open_data.d.ts.map +0 -1
- package/lib/scripts/retrieve_pending_amendments.d.ts.map +0 -1
- package/lib/scripts/retrieve_senateurs_photos.d.ts.map +0 -1
- package/lib/scripts/shared/cli_helpers.d.ts.map +0 -1
- package/lib/scripts/test_iter_load.d.ts.map +0 -1
- package/lib/scripts/test_load.d.ts.map +0 -1
- package/lib/scripts/test_load_big_files.d.ts.map +0 -1
- package/lib/scripts/validate_json.d.ts.map +0 -1
- package/lib/shared_types/codes_actes.d.ts.map +0 -1
- package/lib/strings.d.ts.map +0 -1
- package/lib/types/acteurs_et_organes.d.ts.map +0 -1
- package/lib/types/agendas.d.ts.map +0 -1
- package/lib/types/amendements.d.ts.map +0 -1
- package/lib/types/debats.d.ts.map +0 -1
- package/lib/types/dossiers_legislatifs.d.ts.map +0 -1
- package/lib/types/legislatures.d.ts.map +0 -1
- package/lib/types/questions.d.ts.map +0 -1
- package/lib/types/scrutins.d.ts.map +0 -1
- package/lib/urls.d.ts.map +0 -1
package/lib/parsers.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { JSDOM } from "jsdom";
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { parse } from "node-html-parser";
|
|
10
|
-
import { d as
|
|
11
|
-
import { C as
|
|
12
|
-
function
|
|
13
|
-
const
|
|
1
|
+
import e from "node:assert";
|
|
2
|
+
import { JSDOM as z } from "jsdom";
|
|
3
|
+
import { t as Q, a as v, p as k, q as J } from "./parse-Ccs6wcUg.js";
|
|
4
|
+
import Z from "deep-equal";
|
|
5
|
+
import q from "fs-extra";
|
|
6
|
+
import K from "front-matter";
|
|
7
|
+
import W from "js-yaml";
|
|
8
|
+
import F from "node:path";
|
|
9
|
+
import { parse as X } from "node-html-parser";
|
|
10
|
+
import { d as G } from "./amendements-DcffXOt8.js";
|
|
11
|
+
import { C as ee } from "./amendements-40Z7OJLT.js";
|
|
12
|
+
function te(i) {
|
|
13
|
+
const t = [
|
|
14
14
|
{ regex: /^(RAPPORT_)?ANNEXE(_|$)|^ETAT_/, level: 0, name: "Annexe" },
|
|
15
15
|
{ regex: /^TOME_/, level: 1, name: "Tome" },
|
|
16
16
|
{
|
|
@@ -39,80 +39,61 @@ function parseHeader(header) {
|
|
|
39
39
|
name: "CMP"
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
|
-
for (const { regex, level, name } of
|
|
43
|
-
if (
|
|
44
|
-
return [
|
|
45
|
-
}
|
|
46
|
-
}
|
|
42
|
+
for (const { regex: a, level: r, name: m } of t)
|
|
43
|
+
if (a.test(i))
|
|
44
|
+
return [r, m];
|
|
47
45
|
return [null, ""];
|
|
48
46
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
47
|
+
function P(i) {
|
|
48
|
+
return i?.replace(/[\n\t]+/g, "").trim() || "";
|
|
51
49
|
}
|
|
52
|
-
const
|
|
50
|
+
const ne = [
|
|
53
51
|
/^Délibéré en séance publique/,
|
|
54
52
|
/^Fait le/,
|
|
55
53
|
/^La Présidente,$/,
|
|
56
54
|
/^Le Président,$/,
|
|
57
55
|
/^Signé/
|
|
58
56
|
];
|
|
59
|
-
function
|
|
60
|
-
return
|
|
57
|
+
function ae(i) {
|
|
58
|
+
return ne.some((t) => t.test(i));
|
|
61
59
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let currentSection = bodyElement.children?.[1];
|
|
71
|
-
if (bodyElement.children.length < 3 || currentSection.tagName !== "BR") {
|
|
60
|
+
function he(i, t) {
|
|
61
|
+
const a = t.replace(/(<style[\w\W]+style>)/g, ""), { window: r } = new z(a), m = r.document;
|
|
62
|
+
e.strictEqual(m.children.length, 1);
|
|
63
|
+
const d = m.children[0];
|
|
64
|
+
e.strictEqual(d.children.length, 2);
|
|
65
|
+
const u = d.children[1];
|
|
66
|
+
let n = u.children?.[1];
|
|
67
|
+
if (u.children.length < 3 || n.tagName !== "BR")
|
|
72
68
|
return {
|
|
73
69
|
error: null,
|
|
74
70
|
subdivisions: [],
|
|
75
|
-
url:
|
|
71
|
+
url: i
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let
|
|
81
|
-
let level = null;
|
|
82
|
-
let state = "section";
|
|
83
|
-
const levels = [];
|
|
84
|
-
const subdivisions = [];
|
|
85
|
-
let subdivisionAlineas = [];
|
|
86
|
-
let subdivisionHeaders = [];
|
|
73
|
+
e.strictEqual(u.children[0].tagName, "DIV");
|
|
74
|
+
let o = null, s = !1, f = null, l = "section";
|
|
75
|
+
const c = [], S = [];
|
|
76
|
+
let p = [], g = [];
|
|
87
77
|
try {
|
|
88
|
-
|
|
89
|
-
switch (
|
|
78
|
+
for (; l !== null; )
|
|
79
|
+
switch (l) {
|
|
90
80
|
case "section":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (currentSection.tagName === "DIV") {
|
|
96
|
-
alineaElement = currentSection.firstElementChild;
|
|
97
|
-
if (alineaElement && !currentSection.id.includes("ftn")) {
|
|
98
|
-
state = "alineaElement";
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
assert(["BR", "HR", "P"].includes(currentSection.tagName), `Unexpected tag name "${currentSection.tagName}" for body child section`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
81
|
+
n.nextElementSibling ? (n = n.nextElementSibling, n.tagName === "DIV" ? (o = n.firstElementChild, o && !n.id.includes("ftn") && (l = "alineaElement")) : e(
|
|
82
|
+
["BR", "HR", "P"].includes(n.tagName),
|
|
83
|
+
`Unexpected tag name "${n.tagName}" for body child section`
|
|
84
|
+
)) : l = null;
|
|
104
85
|
break;
|
|
105
86
|
case "alineaElement":
|
|
106
|
-
if (!
|
|
107
|
-
|
|
87
|
+
if (!o) {
|
|
88
|
+
l = "nextAlineaElement";
|
|
108
89
|
break;
|
|
109
90
|
}
|
|
110
|
-
switch (
|
|
91
|
+
switch (o.tagName) {
|
|
111
92
|
case "DIV":
|
|
112
93
|
case "OL":
|
|
113
94
|
case "BR":
|
|
114
95
|
case "SPAN":
|
|
115
|
-
|
|
96
|
+
l = "nextAlineaElement";
|
|
116
97
|
break;
|
|
117
98
|
case "H4":
|
|
118
99
|
case "P":
|
|
@@ -122,272 +103,296 @@ function parseTexte(assembleeUrl, page) {
|
|
|
122
103
|
return {
|
|
123
104
|
error: {
|
|
124
105
|
code: -2,
|
|
125
|
-
message: `Unexpected tag name for alinea element: ${
|
|
106
|
+
message: `Unexpected tag name for alinea element: ${o.tagName}`
|
|
126
107
|
}
|
|
127
108
|
};
|
|
128
109
|
}
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
state = "nextAlineaElement";
|
|
110
|
+
const E = P(o.textContent).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\(nouveau\)/, "").replace(/\(Pour coordination\)/, "").replace(/\(Supprimés?\)/, "").replace(/ /g, " ").replace(/[\-,.…]/g, "").trim().replace(/ {1,}/g, "_").toUpperCase(), [x, T] = te(E);
|
|
111
|
+
if (!E || x !== null && x < 0) {
|
|
112
|
+
l = "nextAlineaElement";
|
|
133
113
|
break;
|
|
134
114
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
state = "nextAlineaElement";
|
|
115
|
+
const h = P(o.outerHTML), $ = P(o.textContent);
|
|
116
|
+
if (x === null) {
|
|
117
|
+
if (ae($)) {
|
|
118
|
+
l = "nextAlineaElement";
|
|
140
119
|
break;
|
|
141
120
|
}
|
|
142
|
-
|
|
143
|
-
subdivisionHeaders.push({ texte: lineText, html: lineHtml });
|
|
144
|
-
} else {
|
|
145
|
-
subdivisionAlineas.push({ texte: lineText, html: lineHtml });
|
|
146
|
-
}
|
|
147
|
-
if (isMultiLinesHeader && subdivisionHeaders.length >= 2) {
|
|
148
|
-
isMultiLinesHeader = false;
|
|
149
|
-
}
|
|
121
|
+
g.length === 0 || s && p.length === 0 ? g.push({ texte: $, html: h }) : p.push({ texte: $, html: h }), s && g.length >= 2 && (s = !1);
|
|
150
122
|
} else {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
isMultiLinesHeader = !nameComputed.match(/^ARTICLES?_/) && !nameComputed.match(/^EXPOSE_DES_MOTIFS$/);
|
|
161
|
-
subdivisions.push({
|
|
162
|
-
id: `D_${nameComputed}`,
|
|
163
|
-
type: paragraphType,
|
|
164
|
-
niveau: level + 1,
|
|
165
|
-
niveauRelatif: levels.length,
|
|
166
|
-
titres: subdivisionHeaders,
|
|
167
|
-
alineas: subdivisionAlineas
|
|
123
|
+
for (f = x; c.length > 0 && f < c[c.length - 1]; )
|
|
124
|
+
c.pop();
|
|
125
|
+
(c.length === 0 || f > c[c.length - 1]) && c.push(f), p = [], g = [{ texte: $, html: h }], s = !E.match(/^ARTICLES?_/) && !E.match(/^EXPOSE_DES_MOTIFS$/), S.push({
|
|
126
|
+
id: `D_${E}`,
|
|
127
|
+
type: T,
|
|
128
|
+
niveau: f + 1,
|
|
129
|
+
niveauRelatif: c.length,
|
|
130
|
+
titres: g,
|
|
131
|
+
alineas: p
|
|
168
132
|
});
|
|
169
133
|
}
|
|
170
|
-
|
|
134
|
+
l = "nextAlineaElement";
|
|
171
135
|
break;
|
|
172
136
|
case "nextAlineaElement":
|
|
173
|
-
if (!
|
|
174
|
-
|
|
137
|
+
if (!o) {
|
|
138
|
+
l = "section";
|
|
175
139
|
break;
|
|
176
140
|
}
|
|
177
|
-
|
|
178
|
-
state = alineaElement ? "alineaElement" : "section";
|
|
141
|
+
o = o.nextElementSibling, l = o ? "alineaElement" : "section";
|
|
179
142
|
break;
|
|
180
143
|
default:
|
|
181
|
-
throw new Error(`Unexpected state: ${
|
|
144
|
+
throw new Error(`Unexpected state: ${l}`);
|
|
182
145
|
}
|
|
183
|
-
|
|
184
|
-
const result = {
|
|
146
|
+
const w = {
|
|
185
147
|
error: null,
|
|
186
|
-
subdivisions,
|
|
187
|
-
url:
|
|
148
|
+
subdivisions: S,
|
|
149
|
+
url: i
|
|
188
150
|
};
|
|
189
|
-
|
|
190
|
-
subdivisionHeaders = [];
|
|
191
|
-
return result;
|
|
151
|
+
return p = [], g = [], w;
|
|
192
152
|
} finally {
|
|
193
|
-
|
|
153
|
+
r.close();
|
|
194
154
|
}
|
|
195
155
|
}
|
|
196
|
-
function
|
|
197
|
-
const
|
|
198
|
-
if (isNaN(+
|
|
156
|
+
function j(i, t) {
|
|
157
|
+
const a = Q(i, t?.in);
|
|
158
|
+
if (isNaN(+a))
|
|
199
159
|
throw new RangeError("Invalid time value");
|
|
160
|
+
const r = t?.format ?? "extended", m = t?.representation ?? "complete";
|
|
161
|
+
let d = "", u = "";
|
|
162
|
+
const n = r === "extended" ? "-" : "", o = r === "extended" ? ":" : "";
|
|
163
|
+
if (m !== "time") {
|
|
164
|
+
const s = v(a.getDate(), 2), f = v(a.getMonth() + 1, 2);
|
|
165
|
+
d = `${v(a.getFullYear(), 4)}${n}${f}${n}${s}`;
|
|
200
166
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
const year = addLeadingZeros(date_.getFullYear(), 4);
|
|
211
|
-
result = `${year}${dateDelimiter}${month}${dateDelimiter}${day}`;
|
|
167
|
+
if (m !== "date") {
|
|
168
|
+
const s = a.getTimezoneOffset();
|
|
169
|
+
if (s !== 0) {
|
|
170
|
+
const g = Math.abs(s), w = v(Math.trunc(g / 60), 2), E = v(g % 60, 2);
|
|
171
|
+
u = `${s < 0 ? "+" : "-"}${w}:${E}`;
|
|
172
|
+
} else
|
|
173
|
+
u = "Z";
|
|
174
|
+
const f = v(a.getHours(), 2), l = v(a.getMinutes(), 2), c = v(a.getSeconds(), 2), S = d === "" ? "" : "T", p = [f, l, c].join(o);
|
|
175
|
+
d = `${d}${S}${p}${u}`;
|
|
212
176
|
}
|
|
213
|
-
|
|
214
|
-
const offset = date_.getTimezoneOffset();
|
|
215
|
-
if (offset !== 0) {
|
|
216
|
-
const absoluteOffset = Math.abs(offset);
|
|
217
|
-
const hourOffset = addLeadingZeros(Math.trunc(absoluteOffset / 60), 2);
|
|
218
|
-
const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);
|
|
219
|
-
const sign = offset < 0 ? "+" : "-";
|
|
220
|
-
tzOffset = `${sign}${hourOffset}:${minuteOffset}`;
|
|
221
|
-
} else {
|
|
222
|
-
tzOffset = "Z";
|
|
223
|
-
}
|
|
224
|
-
const hour = addLeadingZeros(date_.getHours(), 2);
|
|
225
|
-
const minute = addLeadingZeros(date_.getMinutes(), 2);
|
|
226
|
-
const second = addLeadingZeros(date_.getSeconds(), 2);
|
|
227
|
-
const separator = result === "" ? "" : "T";
|
|
228
|
-
const time = [hour, minute, second].join(timeDelimiter);
|
|
229
|
-
result = `${result}${separator}${time}${tzOffset}`;
|
|
230
|
-
}
|
|
231
|
-
return result;
|
|
177
|
+
return d;
|
|
232
178
|
}
|
|
233
|
-
async function*
|
|
234
|
-
for await (const [
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
179
|
+
async function* Se(i, t, a, r, m, d = {}) {
|
|
180
|
+
for await (const [
|
|
181
|
+
u,
|
|
182
|
+
n
|
|
183
|
+
] of le(
|
|
184
|
+
i,
|
|
185
|
+
t,
|
|
186
|
+
a,
|
|
187
|
+
r,
|
|
188
|
+
m,
|
|
189
|
+
d
|
|
190
|
+
))
|
|
191
|
+
G(n), yield [
|
|
192
|
+
u,
|
|
193
|
+
ee.toAmendement(JSON.stringify(n))
|
|
239
194
|
];
|
|
240
|
-
}
|
|
241
195
|
}
|
|
242
|
-
async function*
|
|
243
|
-
await
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
196
|
+
async function* le(i, t, a, r, m, d = {}) {
|
|
197
|
+
await q.ensureDir(i), e.strictEqual(
|
|
198
|
+
/[?&]date_depot=/.exec(t),
|
|
199
|
+
null,
|
|
200
|
+
`URL ${t} already contains a deposit date`
|
|
201
|
+
), e.strictEqual(
|
|
202
|
+
/[?&]order=/.exec(t),
|
|
203
|
+
null,
|
|
204
|
+
`URL ${t} already contains a sort order`
|
|
205
|
+
), e.strictEqual(
|
|
206
|
+
/[?&]page=/.exec(t),
|
|
207
|
+
null,
|
|
208
|
+
`URL ${t} already contains a page number`
|
|
209
|
+
), a && e.notStrictEqual(
|
|
210
|
+
/[?&]etat=/.exec(t),
|
|
211
|
+
null,
|
|
212
|
+
`In incremental mode, URL ${t} must contain an "etat" query parameter`
|
|
213
|
+
), t += (t.includes("?") ? "&" : "?") + "order=date_depot,desc&page=1", r != null && e.notStrictEqual(
|
|
214
|
+
/\d{4}-\d{2}-\d{2}/.exec(r),
|
|
215
|
+
null,
|
|
216
|
+
`Invalid format for minimum date: ${r}`
|
|
217
|
+
);
|
|
218
|
+
let u = 0;
|
|
219
|
+
e: for (; ; ) {
|
|
220
|
+
d.verbose && console.log(`Fetching amendements search page at ${t}…`);
|
|
221
|
+
const n = await fetch(t);
|
|
222
|
+
e(
|
|
223
|
+
n.ok,
|
|
224
|
+
`Retrieval of search page at ${t} failed with error: ${n.status} ${n.statusText}`
|
|
225
|
+
);
|
|
226
|
+
const o = await n.text(), s = X(o);
|
|
227
|
+
if (s.querySelector("div.no-result") !== null)
|
|
264
228
|
break;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
229
|
+
const f = s.querySelector("div.mirror-card-subtitle");
|
|
230
|
+
e.notStrictEqual(f, null);
|
|
231
|
+
const l = parseInt(/\d+/.exec(f.text)[0]), c = s.querySelector(
|
|
232
|
+
"div.amendement-list--results-table"
|
|
233
|
+
);
|
|
234
|
+
e.notStrictEqual(c, null);
|
|
235
|
+
const S = c.querySelector("table");
|
|
236
|
+
e.notStrictEqual(S, null);
|
|
237
|
+
const p = S.querySelector("tfoot > tr");
|
|
238
|
+
e.notStrictEqual(p, null);
|
|
239
|
+
const g = p.querySelectorAll("td, th").map((T) => T.text);
|
|
240
|
+
e(
|
|
241
|
+
Z(g, [
|
|
242
|
+
"",
|
|
243
|
+
"n°",
|
|
244
|
+
"Dossier législatif",
|
|
245
|
+
"Emplacement",
|
|
246
|
+
"Auteur",
|
|
247
|
+
"État",
|
|
248
|
+
"Sort",
|
|
249
|
+
"Date d'examen",
|
|
250
|
+
"Examiné par",
|
|
251
|
+
"Texte visé",
|
|
252
|
+
"Date de dépôt"
|
|
253
|
+
]),
|
|
254
|
+
`Unexpected columns in ${JSON.stringify(g, null, 2)}`
|
|
255
|
+
);
|
|
256
|
+
const w = S.querySelectorAll("tbody > tr");
|
|
257
|
+
e.notStrictEqual(w.length, 0);
|
|
258
|
+
for (const T of w) {
|
|
259
|
+
if (u++, r != null || m != null) {
|
|
260
|
+
const b = T.querySelectorAll("td");
|
|
261
|
+
if (e.strictEqual(
|
|
262
|
+
b.length,
|
|
263
|
+
11,
|
|
264
|
+
`Unexpected number of columns in amendment row: ${T.outerHTML}`
|
|
265
|
+
), r != null) {
|
|
266
|
+
const R = b[10];
|
|
267
|
+
if (j(
|
|
268
|
+
k(R.text, "d MMMM y", /* @__PURE__ */ new Date(), {
|
|
269
|
+
locale: J
|
|
270
|
+
}),
|
|
271
|
+
{ representation: "date" }
|
|
272
|
+
) < r)
|
|
273
|
+
break e;
|
|
304
274
|
}
|
|
305
|
-
if (
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
|
|
309
|
-
locale:
|
|
310
|
-
}),
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
275
|
+
if (m != null) {
|
|
276
|
+
const R = b[7];
|
|
277
|
+
if (R.text && j(
|
|
278
|
+
k(R.text, "d MMMM y", /* @__PURE__ */ new Date(), {
|
|
279
|
+
locale: J
|
|
280
|
+
}),
|
|
281
|
+
{ representation: "date" }
|
|
282
|
+
) < m)
|
|
283
|
+
continue;
|
|
315
284
|
}
|
|
316
285
|
}
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
${
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
286
|
+
const h = T.getAttribute("data-href");
|
|
287
|
+
e.notStrictEqual(h, void 0);
|
|
288
|
+
const $ = h.split("/");
|
|
289
|
+
e.strictEqual(
|
|
290
|
+
$[0],
|
|
291
|
+
"",
|
|
292
|
+
`Unexpected URL path for amendement: ${h}`
|
|
293
|
+
), e.strictEqual(
|
|
294
|
+
$[1],
|
|
295
|
+
"dyn",
|
|
296
|
+
`Unexpected URL path for amendement: ${h}`
|
|
297
|
+
);
|
|
298
|
+
const A = F.join(
|
|
299
|
+
i,
|
|
300
|
+
...$.slice(2)
|
|
301
|
+
) + ".html";
|
|
302
|
+
await q.ensureDir(F.dirname(A));
|
|
303
|
+
const y = await q.pathExists(
|
|
304
|
+
A
|
|
305
|
+
) ? await q.readFile(A, "utf8") : null, L = T.outerHTML, U = `---
|
|
306
|
+
${W.dump(
|
|
307
|
+
{
|
|
308
|
+
position: l - u,
|
|
309
|
+
search: t.replace(/&page=[\d]+/, "")
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
sortKeys: !0
|
|
338
313
|
}
|
|
314
|
+
)}---
|
|
315
|
+
|
|
316
|
+
${L}`;
|
|
317
|
+
if (U === y) {
|
|
318
|
+
if (a)
|
|
319
|
+
break e;
|
|
339
320
|
continue;
|
|
340
321
|
}
|
|
341
|
-
if (
|
|
322
|
+
if (y !== null && K(y).body === L)
|
|
342
323
|
continue;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
console.log(`Amendement HTML page not found at ${amendementHtmlUrl}. Skipping.`);
|
|
324
|
+
d.verbose && console.log(
|
|
325
|
+
y === null ? `Adding amendement search cache: ${A}…` : `Updating amendement search cache: ${A}…`
|
|
326
|
+
);
|
|
327
|
+
const _ = new URL(
|
|
328
|
+
h,
|
|
329
|
+
"https://www.assemblee-nationale.fr/"
|
|
330
|
+
).toString(), O = await fetch(_);
|
|
331
|
+
if (O.status === 404) {
|
|
332
|
+
console.log(
|
|
333
|
+
`Amendement HTML page not found at ${_}. Skipping.`
|
|
334
|
+
);
|
|
355
335
|
continue;
|
|
356
336
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
337
|
+
e(
|
|
338
|
+
O.ok,
|
|
339
|
+
`Retrieval of amendement HTML page at ${_} failed with error: ${O.status} ${O.statusText}`
|
|
340
|
+
);
|
|
341
|
+
const V = await O.text(), N = X(V).querySelectorAll(
|
|
342
|
+
"li.mirror-card-header--options--content--item"
|
|
343
|
+
);
|
|
344
|
+
e.notStrictEqual(N.length, 0);
|
|
345
|
+
const I = N.find((b) => {
|
|
346
|
+
const R = b.querySelector("a > span");
|
|
347
|
+
return e.notStrictEqual(
|
|
348
|
+
R,
|
|
349
|
+
null,
|
|
350
|
+
`No <span> in <a> found in ${b.toString()}`
|
|
351
|
+
), R.text === "Version JSON";
|
|
366
352
|
});
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
353
|
+
e.notStrictEqual(
|
|
354
|
+
I,
|
|
355
|
+
void 0,
|
|
356
|
+
`No JSON version found for amendement at ${_}`
|
|
357
|
+
);
|
|
358
|
+
const C = I.querySelector("a");
|
|
359
|
+
e.notStrictEqual(
|
|
360
|
+
C,
|
|
361
|
+
null,
|
|
362
|
+
`No <a> found in ${I.toString()}`
|
|
363
|
+
);
|
|
364
|
+
const H = C.getAttribute("href");
|
|
365
|
+
e.notStrictEqual(
|
|
366
|
+
H,
|
|
367
|
+
void 0,
|
|
368
|
+
`No URL found for JSON version of amendement: ${I.toString()}`
|
|
369
|
+
);
|
|
370
|
+
const D = new URL(
|
|
371
|
+
H,
|
|
372
|
+
"https://www.assemblee-nationale.fr/"
|
|
373
|
+
).toString(), M = await fetch(D);
|
|
374
|
+
e(
|
|
375
|
+
M.ok,
|
|
376
|
+
`Retrieval of amendement JSON page at ${D} failed with error: ${M.status} ${M.statusText}`
|
|
377
|
+
);
|
|
378
|
+
const B = await M.json();
|
|
379
|
+
yield [h, B], await q.writeFile(
|
|
380
|
+
A,
|
|
381
|
+
U,
|
|
382
|
+
"utf8"
|
|
383
|
+
);
|
|
378
384
|
}
|
|
379
|
-
const
|
|
380
|
-
|
|
385
|
+
const E = s.querySelector(
|
|
386
|
+
"div.an-pagination--item > i.an-icons-chevron-right ~ a"
|
|
387
|
+
);
|
|
388
|
+
if (E === null)
|
|
381
389
|
break;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
assert.notStrictEqual(urlPath, void 0);
|
|
385
|
-
url = new URL(urlPath, "https://www.assemblee-nationale.fr/").toString();
|
|
390
|
+
const x = E.getAttribute("href");
|
|
391
|
+
e.notStrictEqual(x, void 0), t = new URL(x, "https://www.assemblee-nationale.fr/").toString();
|
|
386
392
|
}
|
|
387
393
|
}
|
|
388
394
|
export {
|
|
389
|
-
iterRechercheAmendements,
|
|
390
|
-
iterRechercheRawAmendements,
|
|
391
|
-
parseTexte
|
|
395
|
+
Se as iterRechercheAmendements,
|
|
396
|
+
le as iterRechercheRawAmendements,
|
|
397
|
+
he as parseTexte
|
|
392
398
|
};
|
|
393
|
-
//# sourceMappingURL=parsers.js.map
|