@tricoteuses/assemblee 3.7.1 → 3.8.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/lib/parsers/recherche_amendements.d.ts +6 -0
- package/lib/parsers.js +148 -119
- package/package.json +1 -1
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { AmendementRaw as RawAmendement } from '../schemas/raw/amendements.js';
|
|
2
2
|
import { AmendementClean as Amendement } from '../schemas/clean/amendements.js';
|
|
3
|
+
/**
|
|
4
|
+
* Iterates the amendments of an amendment search URL. Supports both the
|
|
5
|
+
* unfiltered layout and pages filtered by a single examen (`?examen=…`, to be
|
|
6
|
+
* used in non-incremental mode, since incremental mode requires an `etat`
|
|
7
|
+
* parameter).
|
|
8
|
+
*/
|
|
3
9
|
export declare function iterRechercheAmendements(amendementsSearchCacheDir: string, url: string, incremental: boolean, minDateDepot?: string | null, minDateExamen?: string | null, options?: {
|
|
4
10
|
silent?: boolean;
|
|
5
11
|
verbose?: boolean;
|
package/lib/parsers.js
CHANGED
|
@@ -8291,13 +8291,32 @@ var Vu = [
|
|
|
8291
8291
|
function Hu(e) {
|
|
8292
8292
|
return Vu.some((t) => t.test(e));
|
|
8293
8293
|
}
|
|
8294
|
-
|
|
8295
|
-
|
|
8294
|
+
var Uu = "";
|
|
8295
|
+
function Wu(e, t) {
|
|
8296
|
+
if (!e.is("[class*=\"Num\"]") || e.find("br").length === 0) return t;
|
|
8297
|
+
let n = e.clone();
|
|
8298
|
+
return n.find("br").replaceWith(Uu), Lu(Q(Nu(n.html() ?? "", null, !1).root().text().split(Uu)[0])) || t;
|
|
8299
|
+
}
|
|
8300
|
+
function Gu(e, t) {
|
|
8301
|
+
let n = e(t), [r] = Iu(Ru(Wu(n, n.is("table") ? Fu(n) : Lu(Q(n.text())))));
|
|
8296
8302
|
return r !== null && r >= 0;
|
|
8297
8303
|
}
|
|
8298
|
-
function
|
|
8304
|
+
function Ku(e, t) {
|
|
8305
|
+
if (e.find("br").length === 0) return [t];
|
|
8306
|
+
let n = e.clone();
|
|
8307
|
+
n.find("br").replaceWith(Uu);
|
|
8308
|
+
let r = (n.html() ?? "").split(Uu).flatMap((t) => {
|
|
8309
|
+
let n = e.clone().html(Nu(t, null, !1).html()), r = Lu(Q(n.text()));
|
|
8310
|
+
return r ? [{
|
|
8311
|
+
texte: r,
|
|
8312
|
+
html: Lu(Q(n.prop("outerHTML") || ""))
|
|
8313
|
+
}] : [];
|
|
8314
|
+
});
|
|
8315
|
+
return r.length > 1 ? r : [t];
|
|
8316
|
+
}
|
|
8317
|
+
function qu(e, t) {
|
|
8299
8318
|
let n = Nu(Pu(t, { removeEmptyElements: !0 })), r = n("p:not(table p), h4, table").toArray().filter((e) => Lu(Q(n(e).text())).length > 0), i = [], a = [], o = null, s = null, c = !1, l = [], u = [], d = [], f = !1, p = !1, ee = !1, m = Array.from({ length: r.length + 1 }, () => !1), h = !1;
|
|
8300
|
-
for (let e = r.length - 1; e >= 0; e--) h = h ||
|
|
8319
|
+
for (let e = r.length - 1; e >= 0; e--) h = h || Gu(n, r[e]), m[e] = h;
|
|
8301
8320
|
for (let e = 0; e < r.length; e++) {
|
|
8302
8321
|
let t = r[e], h = n(t), g = h.find("a").first().attr("href") || "", _ = h.hasClass("assnatFootnoteText") || g.startsWith("#_ftnref"), v = Lu(Q(h.prop("outerHTML") || "")), y = h.is("table") ? Fu(h) : Lu(Q(h.text()));
|
|
8303
8322
|
if (_) {
|
|
@@ -8307,7 +8326,7 @@ function Wu(e, t) {
|
|
|
8307
8326
|
});
|
|
8308
8327
|
continue;
|
|
8309
8328
|
}
|
|
8310
|
-
let b = Ru(y), [x, S] = Iu(b);
|
|
8329
|
+
let b = Ru(Wu(h, y)), [x, S] = Iu(b);
|
|
8311
8330
|
if (!f) {
|
|
8312
8331
|
if (x !== null && x >= 0 && S !== "Annexe") f = !0;
|
|
8313
8332
|
else continue;
|
|
@@ -8347,10 +8366,10 @@ function Wu(e, t) {
|
|
|
8347
8366
|
titres: l,
|
|
8348
8367
|
alineas: u
|
|
8349
8368
|
}); a.length > 0 && o < a[a.length - 1];) a.pop();
|
|
8350
|
-
(a.length === 0 || o > a[a.length - 1]) && a.push(o), s = S, l =
|
|
8369
|
+
(a.length === 0 || o > a[a.length - 1]) && a.push(o), s = S, l = Ku(h, {
|
|
8351
8370
|
texte: y,
|
|
8352
8371
|
html: v
|
|
8353
|
-
}
|
|
8372
|
+
}), u = [], c = !b.match(/^ARTICLES?(_|$)/) && !b.match(/^EXPOSE_DES_MOTIFS$/);
|
|
8354
8373
|
}
|
|
8355
8374
|
}
|
|
8356
8375
|
l.length > 0 && i.push({
|
|
@@ -8388,7 +8407,7 @@ function Wu(e, t) {
|
|
|
8388
8407
|
}
|
|
8389
8408
|
//#endregion
|
|
8390
8409
|
//#region node_modules/date-fns/formatISO.js
|
|
8391
|
-
function
|
|
8410
|
+
function Ju(t, n) {
|
|
8392
8411
|
let r = i(t, n?.in);
|
|
8393
8412
|
if (isNaN(+r)) throw RangeError("Invalid time value");
|
|
8394
8413
|
let a = n?.format ?? "extended", o = n?.representation ?? "complete", s = "", c = "", l = a === "extended" ? "-" : "", u = a === "extended" ? ":" : "";
|
|
@@ -8413,14 +8432,36 @@ function Gu(t, n) {
|
|
|
8413
8432
|
}
|
|
8414
8433
|
//#endregion
|
|
8415
8434
|
//#region src/parsers/recherche_amendements.ts
|
|
8416
|
-
var
|
|
8417
|
-
function
|
|
8418
|
-
return e.replace(
|
|
8419
|
-
}
|
|
8420
|
-
|
|
8421
|
-
|
|
8435
|
+
var Yu = /* @__PURE__ */ RegExp("^(\\ufeff?(= yaml =|---)$[\\s\\S]*?^(?:\\2|\\.\\.\\.)\\s*$(?:\\r?\\n)?)", "m");
|
|
8436
|
+
function Xu(e) {
|
|
8437
|
+
return e.replace(Yu, "");
|
|
8438
|
+
}
|
|
8439
|
+
var Zu = [
|
|
8440
|
+
"",
|
|
8441
|
+
"n°",
|
|
8442
|
+
"Dossier législatif",
|
|
8443
|
+
"Emplacement",
|
|
8444
|
+
"Auteur",
|
|
8445
|
+
"État",
|
|
8446
|
+
"Sort",
|
|
8447
|
+
"Date d'examen",
|
|
8448
|
+
"Examiné par",
|
|
8449
|
+
"Texte visé",
|
|
8450
|
+
"Date de dépôt"
|
|
8451
|
+
], Qu = [
|
|
8452
|
+
"",
|
|
8453
|
+
"n°",
|
|
8454
|
+
"Emplacement",
|
|
8455
|
+
"Auteur",
|
|
8456
|
+
"État",
|
|
8457
|
+
"Sort",
|
|
8458
|
+
"Date d'examen",
|
|
8459
|
+
"Date de dépôt"
|
|
8460
|
+
];
|
|
8461
|
+
async function* $u(e, t, n, i, o, s = {}) {
|
|
8462
|
+
for await (let [c, l] of ed(e, t, n, i, o, s)) a(l), yield [c, r.toAmendement(JSON.stringify(l))];
|
|
8422
8463
|
}
|
|
8423
|
-
async function*
|
|
8464
|
+
async function* ed(e, r, i, a, f, p = {}) {
|
|
8424
8465
|
await s.ensureDir(e), o.strictEqual(/[?&]date_depot=/.exec(r), null, `URL ${r} already contains a deposit date`), o.strictEqual(/[?&]order=/.exec(r), null, `URL ${r} already contains a sort order`), o.strictEqual(/[?&]page=/.exec(r), null, `URL ${r} already contains a page number`), i && o.notStrictEqual(/[?&]etat=/.exec(r), null, `In incremental mode, URL ${r} must contain an "etat" query parameter`), r += (r.includes("?") ? "&" : "?") + "order=date_depot,desc&page=1", a != null && o.notStrictEqual(/\d{4}-\d{2}-\d{2}/.exec(a), null, `Invalid format for minimum date: ${a}`);
|
|
8425
8466
|
let ee = 0;
|
|
8426
8467
|
iterSearchPages: for (;;) {
|
|
@@ -8437,32 +8478,20 @@ async function* Yu(e, r, i, a, f, p = {}) {
|
|
|
8437
8478
|
o.notStrictEqual(b, null);
|
|
8438
8479
|
let x = b.querySelector("tfoot > tr");
|
|
8439
8480
|
o.notStrictEqual(x, null);
|
|
8440
|
-
let S = x.querySelectorAll("td, th").map((e) => e.text);
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
"Emplacement",
|
|
8446
|
-
"Auteur",
|
|
8447
|
-
"État",
|
|
8448
|
-
"Sort",
|
|
8449
|
-
"Date d'examen",
|
|
8450
|
-
"Examiné par",
|
|
8451
|
-
"Texte visé",
|
|
8452
|
-
"Date de dépôt"
|
|
8453
|
-
]), `Unexpected columns in ${JSON.stringify(S, null, 2)}`);
|
|
8454
|
-
let te = b.querySelectorAll("tbody > tr");
|
|
8455
|
-
o.notStrictEqual(te.length, 0);
|
|
8456
|
-
for (let l of te) {
|
|
8481
|
+
let S = x.querySelectorAll("td, th").map((e) => e.text), te, ne, re;
|
|
8482
|
+
l(S, Zu) ? (te = Zu.length, ne = 10, re = 7) : l(S, Qu) ? (te = Qu.length, ne = 7, re = 6) : o(!1, `Unexpected columns in ${JSON.stringify(S, null, 2)}`);
|
|
8483
|
+
let ie = b.querySelectorAll("tbody > tr");
|
|
8484
|
+
o.notStrictEqual(ie.length, 0);
|
|
8485
|
+
for (let l of ie) {
|
|
8457
8486
|
if (ee++, a != null || f != null) {
|
|
8458
8487
|
let e = l.querySelectorAll("td");
|
|
8459
|
-
if (o.strictEqual(e.length,
|
|
8460
|
-
let r = e[
|
|
8461
|
-
if (
|
|
8488
|
+
if (o.strictEqual(e.length, te, `Unexpected number of columns in amendment row: ${l.outerHTML}`), a != null) {
|
|
8489
|
+
let r = e[ne];
|
|
8490
|
+
if (Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < a) break iterSearchPages;
|
|
8462
8491
|
}
|
|
8463
8492
|
if (f != null) {
|
|
8464
|
-
let r = e[
|
|
8465
|
-
if (r.text &&
|
|
8493
|
+
let r = e[re];
|
|
8494
|
+
if (r.text && Ju(n(r.text, "d MMMM y", /* @__PURE__ */ new Date(), { locale: t }), { representation: "date" }) < f) continue;
|
|
8466
8495
|
}
|
|
8467
8496
|
}
|
|
8468
8497
|
let m = l.getAttribute("data-href");
|
|
@@ -8479,7 +8508,7 @@ async function* Yu(e, r, i, a, f, p = {}) {
|
|
|
8479
8508
|
if (i) break iterSearchPages;
|
|
8480
8509
|
continue;
|
|
8481
8510
|
}
|
|
8482
|
-
if (_ !== null &&
|
|
8511
|
+
if (_ !== null && Xu(_) === y) continue;
|
|
8483
8512
|
p.verbose && console.log(_ === null ? `Adding amendement search cache: ${g}…` : `Updating amendement search cache: ${g}…`);
|
|
8484
8513
|
let x = new URL(m, "https://www.assemblee-nationale.fr/").toString(), S = await fetch(x);
|
|
8485
8514
|
if (S.status === 404) {
|
|
@@ -8487,29 +8516,29 @@ async function* Yu(e, r, i, a, f, p = {}) {
|
|
|
8487
8516
|
continue;
|
|
8488
8517
|
}
|
|
8489
8518
|
o(S.ok, `Retrieval of amendement HTML page at ${x} failed with error: ${S.status} ${S.statusText}`);
|
|
8490
|
-
let
|
|
8491
|
-
o.notStrictEqual(
|
|
8492
|
-
let
|
|
8519
|
+
let ie = await S.text(), ae = d(ie).querySelectorAll("li.mirror-card-header--options--content--item");
|
|
8520
|
+
o.notStrictEqual(ae.length, 0);
|
|
8521
|
+
let oe = ae.find((e) => {
|
|
8493
8522
|
let t = e.querySelector("a > span");
|
|
8494
8523
|
return o.notStrictEqual(t, null, `No <span> in <a> found in ${e.toString()}`), t.text === "Version JSON";
|
|
8495
8524
|
});
|
|
8496
|
-
o.notStrictEqual(
|
|
8497
|
-
let
|
|
8498
|
-
o.notStrictEqual(
|
|
8499
|
-
let
|
|
8500
|
-
o.notStrictEqual(
|
|
8501
|
-
let
|
|
8502
|
-
o(
|
|
8525
|
+
o.notStrictEqual(oe, void 0, `No JSON version found for amendement at ${x}`);
|
|
8526
|
+
let se = oe.querySelector("a");
|
|
8527
|
+
o.notStrictEqual(se, null, `No <a> found in ${oe.toString()}`);
|
|
8528
|
+
let ce = se.getAttribute("href");
|
|
8529
|
+
o.notStrictEqual(ce, void 0, `No URL found for JSON version of amendement: ${oe.toString()}`);
|
|
8530
|
+
let le = new URL(ce, "https://www.assemblee-nationale.fr/").toString(), ue = await fetch(le);
|
|
8531
|
+
o(ue.ok, `Retrieval of amendement JSON page at ${le} failed with error: ${ue.status} ${ue.statusText}`), yield [m, await ue.json()], await s.writeFile(g, b, "utf8");
|
|
8503
8532
|
}
|
|
8504
|
-
let
|
|
8505
|
-
if (
|
|
8506
|
-
let
|
|
8507
|
-
o.notStrictEqual(
|
|
8533
|
+
let ae = g.querySelector("div.an-pagination--item > i.an-icons-chevron-right ~ a");
|
|
8534
|
+
if (ae === null) break;
|
|
8535
|
+
let oe = ae.getAttribute("href");
|
|
8536
|
+
o.notStrictEqual(oe, void 0), r = new URL(oe, "https://www.assemblee-nationale.fr/").toString();
|
|
8508
8537
|
}
|
|
8509
8538
|
}
|
|
8510
8539
|
//#endregion
|
|
8511
8540
|
//#region src/parsers/plf/parser_utils.ts
|
|
8512
|
-
function
|
|
8541
|
+
function td(e) {
|
|
8513
8542
|
return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toUpperCase();
|
|
8514
8543
|
}
|
|
8515
8544
|
function $(e) {
|
|
@@ -8518,7 +8547,7 @@ function $(e) {
|
|
|
8518
8547
|
html: Q(e.html())
|
|
8519
8548
|
};
|
|
8520
8549
|
}
|
|
8521
|
-
function
|
|
8550
|
+
function nd(e, t, n, r) {
|
|
8522
8551
|
return {
|
|
8523
8552
|
id: e,
|
|
8524
8553
|
type: t,
|
|
@@ -8528,10 +8557,10 @@ function Zu(e, t, n, r) {
|
|
|
8528
8557
|
alineas: []
|
|
8529
8558
|
};
|
|
8530
8559
|
}
|
|
8531
|
-
function
|
|
8560
|
+
function rd(e) {
|
|
8532
8561
|
return /états\s+l[ée]gislatifs\s+annex/i.test(e);
|
|
8533
8562
|
}
|
|
8534
|
-
function
|
|
8563
|
+
function id(e) {
|
|
8535
8564
|
return {
|
|
8536
8565
|
texte: Fu(e),
|
|
8537
8566
|
html: e.prop("outerHTML") || ""
|
|
@@ -8539,22 +8568,22 @@ function $u(e) {
|
|
|
8539
8568
|
}
|
|
8540
8569
|
//#endregion
|
|
8541
8570
|
//#region src/parsers/plf/depot.ts
|
|
8542
|
-
var
|
|
8571
|
+
var ad = [
|
|
8543
8572
|
"Partie",
|
|
8544
8573
|
"Titre",
|
|
8545
8574
|
"Chapitre",
|
|
8546
8575
|
"Section"
|
|
8547
8576
|
];
|
|
8548
|
-
function
|
|
8577
|
+
function od(e) {
|
|
8549
8578
|
let t = Nu(Pu(e)), n = [], r = [], i = "generalExpose", a = null, o = null, s = [], c = t("h1, h2, h3, h4, h5, h6, p.assnatPastille, p.assnatFPFexpogentitre1, p.assnatFPFexpogentexte, li.assnatFPFexpogentexte, li.assnatFPFprojetloiartexte, p.assnatFPFprojetloiartexte, p.assnatFPFfinartexte, table, img").toArray(), l = () => {
|
|
8550
|
-
o && s.length > 0 && (o.alineas =
|
|
8579
|
+
o && s.length > 0 && (o.alineas = sd(s)), s = [];
|
|
8551
8580
|
}, u = () => {
|
|
8552
8581
|
o && (l(), n.push(o), o = null);
|
|
8553
8582
|
};
|
|
8554
8583
|
for (let e of c) {
|
|
8555
8584
|
if (i === "done") break;
|
|
8556
|
-
let c = t(e), g = Q(c.text()), _ =
|
|
8557
|
-
if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re &&
|
|
8585
|
+
let c = t(e), g = Q(c.text()), _ = fd(c), v = _ !== null, y = _ !== null && _ >= 2 && _ <= 5, b = c.hasClass("assnatFPFexpogentitre1"), x = c.hasClass("assnatFPFexpogentexte"), S = c.hasClass("assnatPastille"), te = c.hasClass("assnatFPFprojetloiartexte"), ne = c.hasClass("assnatFPFfinartexte"), re = c.is("table"), ie = c.is("img"), ae = c.find("img").length > 0;
|
|
8586
|
+
if (!(v && g.length === 0) && !(re && c.find("p.assnatFARTT08Bleu").length > 0) && !(re && dd(c)) && !(x && g.length === 0)) {
|
|
8558
8587
|
if (i === "generalExpose") {
|
|
8559
8588
|
if (_ === 1) {
|
|
8560
8589
|
let e = g.toLowerCase();
|
|
@@ -8562,11 +8591,11 @@ function td(e) {
|
|
|
8562
8591
|
a && n.push(a), a = null, i = "hierarchy";
|
|
8563
8592
|
continue;
|
|
8564
8593
|
}
|
|
8565
|
-
e.includes("exposé général des motifs") && (a ?? (a =
|
|
8594
|
+
e.includes("exposé général des motifs") && (a ?? (a = nd("D_EXPOSE", "Exposé des motifs", 1, 1)));
|
|
8566
8595
|
}
|
|
8567
8596
|
if (y && (a && n.push(a), a = null, i = "hierarchy"), a) {
|
|
8568
8597
|
if (ie) {
|
|
8569
|
-
let e =
|
|
8598
|
+
let e = hd(c);
|
|
8570
8599
|
if (e) {
|
|
8571
8600
|
var d;
|
|
8572
8601
|
(d = a).alineas ?? (d.alineas = []), a.alineas.push(e);
|
|
@@ -8575,42 +8604,42 @@ function td(e) {
|
|
|
8575
8604
|
var f;
|
|
8576
8605
|
(f = a).titres ?? (f.titres = []), a.titres.push($(c));
|
|
8577
8606
|
} else if (b || x) {
|
|
8578
|
-
let e = ae ?
|
|
8607
|
+
let e = ae ? pd(c) : $(c);
|
|
8579
8608
|
if (e) {
|
|
8580
8609
|
var p;
|
|
8581
8610
|
(p = a).alineas ?? (p.alineas = []), a.alineas.push(e);
|
|
8582
8611
|
}
|
|
8583
8612
|
} else if (re) {
|
|
8584
8613
|
var ee;
|
|
8585
|
-
(ee = a).alineas ?? (ee.alineas = []), a.alineas.push(
|
|
8614
|
+
(ee = a).alineas ?? (ee.alineas = []), a.alineas.push(id(c));
|
|
8586
8615
|
}
|
|
8587
8616
|
continue;
|
|
8588
8617
|
}
|
|
8589
8618
|
}
|
|
8590
|
-
if (
|
|
8619
|
+
if (rd(g)) {
|
|
8591
8620
|
u(), a && (n.push(a), a = null), i = "done";
|
|
8592
8621
|
continue;
|
|
8593
8622
|
}
|
|
8594
8623
|
if (_ !== 1) {
|
|
8595
8624
|
if (y) {
|
|
8596
8625
|
u();
|
|
8597
|
-
let e = _ - 2, t =
|
|
8626
|
+
let e = _ - 2, t = ad[e];
|
|
8598
8627
|
for (; r.length > 0 && r[r.length - 1] >= e;) r.pop();
|
|
8599
8628
|
r.push(e);
|
|
8600
|
-
let a =
|
|
8629
|
+
let a = nd(`D_${td(g)}`, t, e + 1, r.length);
|
|
8601
8630
|
a.titres = [$(c)], n.push(a), i = "hierarchy";
|
|
8602
8631
|
continue;
|
|
8603
8632
|
}
|
|
8604
8633
|
if (_ === 6) {
|
|
8605
8634
|
u();
|
|
8606
8635
|
let e = r.length + 1;
|
|
8607
|
-
o =
|
|
8636
|
+
o = nd(`D_${td(g)}`, "Article", 5, e), o.titres = [$(c)], s = [], i = "articleBody";
|
|
8608
8637
|
continue;
|
|
8609
8638
|
}
|
|
8610
8639
|
if (S && i === "articleBody" && o) {
|
|
8611
8640
|
s.push({
|
|
8612
8641
|
type: "marker",
|
|
8613
|
-
number:
|
|
8642
|
+
number: ud(g)
|
|
8614
8643
|
});
|
|
8615
8644
|
continue;
|
|
8616
8645
|
}
|
|
@@ -8625,7 +8654,7 @@ function td(e) {
|
|
|
8625
8654
|
if (re && i === "articleBody" && o) {
|
|
8626
8655
|
s.push({
|
|
8627
8656
|
type: "content",
|
|
8628
|
-
content:
|
|
8657
|
+
content: id(c)
|
|
8629
8658
|
});
|
|
8630
8659
|
continue;
|
|
8631
8660
|
}
|
|
@@ -8646,7 +8675,7 @@ function td(e) {
|
|
|
8646
8675
|
}
|
|
8647
8676
|
if (re) {
|
|
8648
8677
|
var h;
|
|
8649
|
-
(h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(
|
|
8678
|
+
(h = o).exposeDesMotifs ?? (h.exposeDesMotifs = []), o.exposeDesMotifs.push(id(c));
|
|
8650
8679
|
}
|
|
8651
8680
|
}
|
|
8652
8681
|
}
|
|
@@ -8654,7 +8683,7 @@ function td(e) {
|
|
|
8654
8683
|
}
|
|
8655
8684
|
return u(), a && n.push(a), { subdivisions: n };
|
|
8656
8685
|
}
|
|
8657
|
-
function
|
|
8686
|
+
function sd(e) {
|
|
8658
8687
|
let t = e.flatMap((e) => e.type === "content" ? [e.content] : []);
|
|
8659
8688
|
if (e.length - t.length === 0) return t;
|
|
8660
8689
|
let n = [], r, i;
|
|
@@ -8670,43 +8699,43 @@ function nd(e) {
|
|
|
8670
8699
|
contents: []
|
|
8671
8700
|
}, n.push(r), i = a.number;
|
|
8672
8701
|
}
|
|
8673
|
-
|
|
8702
|
+
cd(n);
|
|
8674
8703
|
let a = [];
|
|
8675
8704
|
for (let e = 0; e < n.length; e++) {
|
|
8676
8705
|
let r = n[e], i = n[e + 1], o = i ? i.number - r.number : 1;
|
|
8677
8706
|
if (r.contents.length < o) return t;
|
|
8678
8707
|
for (let e = 0; e < o - 1; e++) a.push(r.contents[e]);
|
|
8679
|
-
a.push(
|
|
8708
|
+
a.push(ld(r.contents.slice(o - 1)));
|
|
8680
8709
|
}
|
|
8681
8710
|
return a;
|
|
8682
8711
|
}
|
|
8683
|
-
function
|
|
8712
|
+
function cd(e) {
|
|
8684
8713
|
for (let t = 0; t < e.length - 1; t++) {
|
|
8685
8714
|
let n = e[t].contents, r = e[t + 1].contents, i = n[n.length - 1];
|
|
8686
8715
|
i?.texte?.trim() === "«" && r.some(({ html: e }) => /<table\b/.test(e ?? "")) && (n.pop(), r.unshift(i));
|
|
8687
8716
|
}
|
|
8688
8717
|
}
|
|
8689
|
-
function
|
|
8718
|
+
function ld(e) {
|
|
8690
8719
|
return {
|
|
8691
8720
|
texte: e.flatMap(({ texte: e }) => e === void 0 ? [] : [e]).join("\n"),
|
|
8692
8721
|
html: e.flatMap(({ html: e }) => e === void 0 ? [] : [e]).join("\n")
|
|
8693
8722
|
};
|
|
8694
8723
|
}
|
|
8695
|
-
function
|
|
8724
|
+
function ud(e) {
|
|
8696
8725
|
let t = /^\((\d+)\)$/.exec(e);
|
|
8697
8726
|
if (!t) return;
|
|
8698
8727
|
let n = Number(t[1]);
|
|
8699
8728
|
return Number.isSafeInteger(n) && n > 0 ? n : void 0;
|
|
8700
8729
|
}
|
|
8701
|
-
function
|
|
8730
|
+
function dd(e) {
|
|
8702
8731
|
let t = e.children("tbody").children("tr").add(e.children("tr"));
|
|
8703
8732
|
return t.length === 1 && t.children("td").length === 1 && e.find("h6, .assnatFPFexpogentexte").length > 0;
|
|
8704
8733
|
}
|
|
8705
|
-
function
|
|
8734
|
+
function fd(e) {
|
|
8706
8735
|
for (let t = 1; t <= 6; t++) if (e.is(`h${t}`)) return t;
|
|
8707
8736
|
return null;
|
|
8708
8737
|
}
|
|
8709
|
-
function
|
|
8738
|
+
function pd(e) {
|
|
8710
8739
|
let t = e.clone();
|
|
8711
8740
|
t.find("img").remove();
|
|
8712
8741
|
let n = Q(t.text());
|
|
@@ -8715,14 +8744,14 @@ function cd(e) {
|
|
|
8715
8744
|
html: Q(t.html())
|
|
8716
8745
|
} : null;
|
|
8717
8746
|
}
|
|
8718
|
-
function
|
|
8747
|
+
function md(e) {
|
|
8719
8748
|
if (!e || !/^\d+$/.test(e)) return;
|
|
8720
8749
|
let t = Number(e);
|
|
8721
8750
|
return t > 0 ? t : void 0;
|
|
8722
8751
|
}
|
|
8723
|
-
function
|
|
8752
|
+
function hd(e) {
|
|
8724
8753
|
if (!e.attr("src")) return null;
|
|
8725
|
-
let t =
|
|
8754
|
+
let t = md(e.attr("width")), n = md(e.attr("height"));
|
|
8726
8755
|
return t === 15 && n === 15 || t === 2 && n === 138 ? null : {
|
|
8727
8756
|
texte: Q(e.attr("alt") ?? ""),
|
|
8728
8757
|
html: e.prop("outerHTML") || ""
|
|
@@ -8730,18 +8759,18 @@ function ud(e) {
|
|
|
8730
8759
|
}
|
|
8731
8760
|
//#endregion
|
|
8732
8761
|
//#region src/parsers/plf/later_stage.ts
|
|
8733
|
-
function
|
|
8762
|
+
function gd(e) {
|
|
8734
8763
|
let t = Nu(Pu(e)), n = [], r = [], i = null, a = null, o = null, s = !1, c = t("p.assnat2PartieNum, p.assnat2PartieIntit, p.assnat4TitreNum, p.assnat4TitreNum0, p.assnat4TitreIntit, p.assnat9ArticleNum, p.assnatLoiTexte, p.assnat1TomeNum, table, p.assnat5ChapitreIntit, p.assnat5ChapitreIntit0, p.assnat5ChapitreNum, p.assnat5ChapitreNum0, p.assnat6SectionIntit, p.assnat6SectionIntit0, p.assnat6SectionNum, p.assnat6SectionNum0").toArray();
|
|
8735
8764
|
for (let e of c) {
|
|
8736
8765
|
let c = t(e), l = Q(c.text());
|
|
8737
|
-
if (l.length === 0 || (!s &&
|
|
8766
|
+
if (l.length === 0 || (!s && rd(l) && (i && (n.push(i), i = null), s = !0), s)) continue;
|
|
8738
8767
|
let u = c.hasClass("assnat2PartieNum"), d = c.hasClass("assnat2PartieIntit"), f = c.hasClass("assnat4TitreNum") || c.hasClass("assnat4TitreNum0"), p = c.hasClass("assnat4TitreIntit"), ee = c.hasClass("assnat9ArticleNum"), m = c.hasClass("assnatLoiTexte"), h = c.is("table");
|
|
8739
8768
|
if (d) {
|
|
8740
8769
|
for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 0;) r.pop();
|
|
8741
8770
|
r.push(0);
|
|
8742
|
-
let e =
|
|
8771
|
+
let e = _d(a, $(c));
|
|
8743
8772
|
a = null, o = null;
|
|
8744
|
-
let t =
|
|
8773
|
+
let t = nd(`D_${td(e.texte ?? l)}`, "Partie", 1, r.length);
|
|
8745
8774
|
t.titres = [e], n.push(t);
|
|
8746
8775
|
continue;
|
|
8747
8776
|
}
|
|
@@ -8752,9 +8781,9 @@ function dd(e) {
|
|
|
8752
8781
|
if (p) {
|
|
8753
8782
|
for (i && (n.push(i), i = null); r.length > 0 && r[r.length - 1] >= 1;) r.pop();
|
|
8754
8783
|
r.push(1);
|
|
8755
|
-
let e =
|
|
8784
|
+
let e = _d(o, $(c));
|
|
8756
8785
|
o = null;
|
|
8757
|
-
let t =
|
|
8786
|
+
let t = nd(`D_${td(e.texte ?? l)}`, "Titre", 2, r.length);
|
|
8758
8787
|
t.titres = [e], n.push(t);
|
|
8759
8788
|
continue;
|
|
8760
8789
|
}
|
|
@@ -8765,7 +8794,7 @@ function dd(e) {
|
|
|
8765
8794
|
if (ee) {
|
|
8766
8795
|
i && n.push(i);
|
|
8767
8796
|
let e = r.length + 1;
|
|
8768
|
-
i =
|
|
8797
|
+
i = nd(`D_${td(l)}`, "Article", 5, e), i.titres = [$(c)];
|
|
8769
8798
|
continue;
|
|
8770
8799
|
}
|
|
8771
8800
|
if (m) {
|
|
@@ -8775,7 +8804,7 @@ function dd(e) {
|
|
|
8775
8804
|
let e = /^chapitre\b/i.test(l), t = /^section\b/i.test(l), a = /^[IVXLCDM]+[.\s]/.test(l), o = /^[A-Z][.\s]/.test(l), s = e || !t && a, u = s ? "Chapitre" : t || !e && o ? "Section" : "Chapitre", d = s ? 2 : 3;
|
|
8776
8805
|
for (; r.length > 0 && r[r.length - 1] >= d;) r.pop();
|
|
8777
8806
|
r.push(d);
|
|
8778
|
-
let f =
|
|
8807
|
+
let f = nd(`D_${td(l)}`, u, d + 1, r.length);
|
|
8779
8808
|
f.titres = [$(c)], n.push(f);
|
|
8780
8809
|
continue;
|
|
8781
8810
|
}
|
|
@@ -8783,14 +8812,14 @@ function dd(e) {
|
|
|
8783
8812
|
continue;
|
|
8784
8813
|
}
|
|
8785
8814
|
if (h && i) {
|
|
8786
|
-
i.alineas = i.alineas || [], i.alineas.push(
|
|
8815
|
+
i.alineas = i.alineas || [], i.alineas.push(id(c));
|
|
8787
8816
|
continue;
|
|
8788
8817
|
}
|
|
8789
8818
|
(/assnat5Chapitre(Intit|Num)/.test(c.attr("class") ?? "") || /assnat6Section(Intit|Num)/.test(c.attr("class") ?? "")) && i && (i.alineas = i.alineas || [], i.alineas.push($(c)));
|
|
8790
8819
|
}
|
|
8791
8820
|
return i && n.push(i), { subdivisions: n };
|
|
8792
8821
|
}
|
|
8793
|
-
function
|
|
8822
|
+
function _d(e, t) {
|
|
8794
8823
|
return e === null ? t : {
|
|
8795
8824
|
texte: `${e.texte} : ${t.texte}`,
|
|
8796
8825
|
html: `${e.html} : ${t.html}`
|
|
@@ -8798,20 +8827,20 @@ function fd(e, t) {
|
|
|
8798
8827
|
}
|
|
8799
8828
|
//#endregion
|
|
8800
8829
|
//#region src/parsers/plf/variant_detection.ts
|
|
8801
|
-
var
|
|
8830
|
+
var vd = [
|
|
8802
8831
|
"assnatFPFexpogentexte",
|
|
8803
8832
|
"assnatFPFexpogentitre1",
|
|
8804
8833
|
"assnatFPFexpogentitre2",
|
|
8805
8834
|
"assnatFPFexpogentitre3",
|
|
8806
8835
|
"assnatFPFexpogentitre4"
|
|
8807
8836
|
];
|
|
8808
|
-
function
|
|
8837
|
+
function yd(e) {
|
|
8809
8838
|
let t = Nu(Pu(e));
|
|
8810
|
-
return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(
|
|
8839
|
+
return t("h1, h2, h3, h4, h5, h6").toArray().some((e) => Q(t(e).text()).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().includes("expose general des motifs")) || t(vd.map((e) => `.${e}`).join(", ")).length > 0 ? "depot" : "laterStage";
|
|
8811
8840
|
}
|
|
8812
8841
|
//#endregion
|
|
8813
8842
|
//#region src/parsers/plf/credits.ts
|
|
8814
|
-
var
|
|
8843
|
+
var bd = {
|
|
8815
8844
|
bg: {
|
|
8816
8845
|
budgetType: "budgetGeneral",
|
|
8817
8846
|
libelle: "Budget général"
|
|
@@ -8829,15 +8858,15 @@ var hd = {
|
|
|
8829
8858
|
libelle: "Comptes de concours financiers"
|
|
8830
8859
|
}
|
|
8831
8860
|
};
|
|
8832
|
-
function
|
|
8861
|
+
function xd(e) {
|
|
8833
8862
|
if (!e) return [];
|
|
8834
|
-
let t = Nu(Pu(e)), n =
|
|
8863
|
+
let t = Nu(Pu(e)), n = Dd(t);
|
|
8835
8864
|
if (n.length === 0) return [];
|
|
8836
8865
|
let r = [];
|
|
8837
8866
|
for (let e of n) {
|
|
8838
8867
|
let n = [], i;
|
|
8839
8868
|
for (let r of e.tableEls) {
|
|
8840
|
-
let e =
|
|
8869
|
+
let e = Td(t, r);
|
|
8841
8870
|
n.push(...e.missions), e.total && (i = e.total);
|
|
8842
8871
|
}
|
|
8843
8872
|
n.length === 0 && !e.estConformeVersionPrecedente || r.push({
|
|
@@ -8853,7 +8882,7 @@ function gd(e) {
|
|
|
8853
8882
|
}
|
|
8854
8883
|
return r;
|
|
8855
8884
|
}
|
|
8856
|
-
function
|
|
8885
|
+
function Sd(e) {
|
|
8857
8886
|
let t = Q(e).replace(/[\u2212\u2011]/g, "-").replace(/\s/g, "").replace(/[^0-9,.-]/g, ""), n = (t.match(/,/g) ?? []).length;
|
|
8858
8887
|
if (n > 1) return;
|
|
8859
8888
|
let r = n === 1 ? t.replace(/\./g, "").replace(",", ".") : t;
|
|
@@ -8861,23 +8890,23 @@ function _d(e) {
|
|
|
8861
8890
|
let i = Number(r);
|
|
8862
8891
|
return Number.isNaN(i) ? void 0 : i;
|
|
8863
8892
|
}
|
|
8864
|
-
function
|
|
8893
|
+
function Cd(e) {
|
|
8865
8894
|
let t = Q(e);
|
|
8866
8895
|
if (!/\(\s*ligne\s+supprim(?:ée|ee)\s*\)\s*$/i.test(t)) return t.replace(/\s*\(\s*ligne\s+nouvelle\s*\)\s*$/i, "").trim();
|
|
8867
8896
|
}
|
|
8868
|
-
function
|
|
8869
|
-
let n =
|
|
8897
|
+
function wd(e, t) {
|
|
8898
|
+
let n = Sd(t(e[1]).text()), r = Sd(t(e[2]).text());
|
|
8870
8899
|
return e.length >= 5 ? {
|
|
8871
8900
|
autorisationEngagement: n,
|
|
8872
8901
|
creditPaiement: r,
|
|
8873
|
-
autorisationEngagementAnnule:
|
|
8874
|
-
creditPaiementAnnule:
|
|
8902
|
+
autorisationEngagementAnnule: Sd(t(e[3]).text()),
|
|
8903
|
+
creditPaiementAnnule: Sd(t(e[4]).text())
|
|
8875
8904
|
} : {
|
|
8876
8905
|
autorisationEngagement: n,
|
|
8877
8906
|
creditPaiement: r
|
|
8878
8907
|
};
|
|
8879
8908
|
}
|
|
8880
|
-
function
|
|
8909
|
+
function Td(e, t) {
|
|
8881
8910
|
let n = [], r = null, i = null, a, o = e(t).find("tbody tr").toArray(), s = o.some((t) => {
|
|
8882
8911
|
let n = (e(t).find("td").first().attr("style") || "").replace(/[\n\t]/g, " ");
|
|
8883
8912
|
return /border-top/.test(n);
|
|
@@ -8887,7 +8916,7 @@ function bd(e, t) {
|
|
|
8887
8916
|
if (o.length < 3) continue;
|
|
8888
8917
|
let c = e(o[0]), l = (c.attr("style") || "").replace(/[\n\t]/g, " "), u = Q(c.text());
|
|
8889
8918
|
if (!u) continue;
|
|
8890
|
-
let d = /^total/i.test(u), f =
|
|
8919
|
+
let d = /^total/i.test(u), f = wd(o, e);
|
|
8891
8920
|
if (d) {
|
|
8892
8921
|
a = f;
|
|
8893
8922
|
continue;
|
|
@@ -8901,7 +8930,7 @@ function bd(e, t) {
|
|
|
8901
8930
|
}
|
|
8902
8931
|
if (s ? /border-top/.test(l) : /border-bottom/.test(l)) {
|
|
8903
8932
|
r && n.push(r);
|
|
8904
|
-
let e =
|
|
8933
|
+
let e = Cd(c.text());
|
|
8905
8934
|
if (e === void 0) {
|
|
8906
8935
|
r = null, i = null;
|
|
8907
8936
|
continue;
|
|
@@ -8915,7 +8944,7 @@ function bd(e, t) {
|
|
|
8915
8944
|
continue;
|
|
8916
8945
|
}
|
|
8917
8946
|
if (r) {
|
|
8918
|
-
let e =
|
|
8947
|
+
let e = Cd(c.text());
|
|
8919
8948
|
if (e === void 0) {
|
|
8920
8949
|
i = null;
|
|
8921
8950
|
continue;
|
|
@@ -8931,11 +8960,11 @@ function bd(e, t) {
|
|
|
8931
8960
|
total: a
|
|
8932
8961
|
};
|
|
8933
8962
|
}
|
|
8934
|
-
function
|
|
8963
|
+
function Ed(e, t) {
|
|
8935
8964
|
let n = e(t).find("tr").slice(0, 3).find("th, td").toArray().map((t) => Q(e(t).text()).toLocaleLowerCase("fr"));
|
|
8936
8965
|
return n.some((e) => e.includes("mission / programme")) && n.some((e) => e.includes("autorisation") && e.includes("engagement")) && n.some((e) => e.includes("crédit") && e.includes("paiement"));
|
|
8937
8966
|
}
|
|
8938
|
-
function
|
|
8967
|
+
function Dd(e) {
|
|
8939
8968
|
let t, n, r = !1, i = /* @__PURE__ */ new Map(), a = e("p, h1, h2, h3, h4, h5, h6, a:not([href]), table").toArray().filter((t) => e(t).parents("table").length === 0);
|
|
8940
8969
|
for (let o of a) {
|
|
8941
8970
|
let a = e(o);
|
|
@@ -8952,7 +8981,7 @@ function Sd(e) {
|
|
|
8952
8981
|
for (let t of e) {
|
|
8953
8982
|
let e = i.get(t);
|
|
8954
8983
|
e ? e.estConformeVersionPrecedente = !0 : i.set(t, {
|
|
8955
|
-
...
|
|
8984
|
+
...bd[t],
|
|
8956
8985
|
tableEls: [],
|
|
8957
8986
|
estConformeVersionPrecedente: !0
|
|
8958
8987
|
});
|
|
@@ -8968,7 +8997,7 @@ function Sd(e) {
|
|
|
8968
8997
|
s !== /COMPTES\s+DE\s+CONCOURS\s+FINANCIERS/i.test(e) && (n = s ? "cas" : "ccf");
|
|
8969
8998
|
continue;
|
|
8970
8999
|
}
|
|
8971
|
-
if (!
|
|
9000
|
+
if (!Ed(e, o)) continue;
|
|
8972
9001
|
let s = t === "B" ? "bg" : t === "C" ? "ba" : t === "D" ? n : void 0;
|
|
8973
9002
|
if (!s) continue;
|
|
8974
9003
|
r = !0;
|
|
@@ -8978,7 +9007,7 @@ function Sd(e) {
|
|
|
8978
9007
|
continue;
|
|
8979
9008
|
}
|
|
8980
9009
|
i.set(s, {
|
|
8981
|
-
...
|
|
9010
|
+
...bd[s],
|
|
8982
9011
|
tableEls: [o],
|
|
8983
9012
|
estConformeVersionPrecedente: !1
|
|
8984
9013
|
});
|
|
@@ -8987,8 +9016,8 @@ function Sd(e) {
|
|
|
8987
9016
|
}
|
|
8988
9017
|
//#endregion
|
|
8989
9018
|
//#region src/parsers/plf/index.ts
|
|
8990
|
-
function
|
|
8991
|
-
return e ?
|
|
9019
|
+
function Od(e) {
|
|
9020
|
+
return e ? yd(e) === "depot" ? od(e) : gd(e) : { subdivisions: [] };
|
|
8992
9021
|
}
|
|
8993
9022
|
//#endregion
|
|
8994
|
-
export {
|
|
9023
|
+
export { $u as iterRechercheAmendements, ed as iterRechercheRawAmendements, Od as parsePlf, xd as parsePlfCredits, qu as parseTexte };
|