Commit 430c7320 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Reformat source code.

parent fc43060a
Pipeline #104891 passed with stage
in 2 minutes and 42 seconds
......@@ -66,21 +66,25 @@ fn main() {
let acteurs_dir = dataset_dir.join("acteurs");
if acteurs_dir.exists() {
fs::remove_dir_all(&acteurs_dir).expect("Recursive deletion of acteurs directory failed");
fs::remove_dir_all(&acteurs_dir)
.expect("Recursive deletion of acteurs directory failed");
}
fs::create_dir(&acteurs_dir).expect("Creation of acteurs directory failed");
for acteur in data["export"]["acteurs"]["acteur"].members() {
let json_file_path = acteurs_dir.join(acteur["uid"]["#text"].as_str().unwrap().to_owned() + ".json");
let json_file_path =
acteurs_dir.join(acteur["uid"]["#text"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, acteur.pretty(2)).expect("Error while writing JSON file");
}
let organes_dir = dataset_dir.join("organes");
if organes_dir.exists() {
fs::remove_dir_all(&organes_dir).expect("Recursive deletion of organes directory failed");
fs::remove_dir_all(&organes_dir)
.expect("Recursive deletion of organes directory failed");
}
fs::create_dir(&organes_dir).expect("Creation of organes directory failed");
for organe in data["export"]["organes"]["organe"].members() {
let json_file_path = organes_dir.join(organe["uid"].as_str().unwrap().to_owned() + ".json");
let json_file_path =
organes_dir.join(organe["uid"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, organe.pretty(2)).expect("Error while writing JSON file");
}
}
......@@ -110,12 +114,15 @@ fn main() {
let reunions_dir = dataset_dir.join("reunions");
if reunions_dir.exists() {
fs::remove_dir_all(&reunions_dir).expect("Recursive deletion of reunions directory failed");
fs::remove_dir_all(&reunions_dir)
.expect("Recursive deletion of reunions directory failed");
}
fs::create_dir(&reunions_dir).expect("Creation of reunions directory failed");
for reunion in data["reunions"]["reunion"].members() {
let uid = reunion["uid"].as_str().unwrap();
let captures = reunion_uid_regex.captures(&uid).expect(&format!("Unexpected uid for reunion: {}", uid));
let captures = reunion_uid_regex
.captures(&uid)
.expect(&format!("Unexpected uid for reunion: {}", uid));
let organe_dir = reunions_dir.join(captures[1].to_string());
if !organe_dir.exists() {
fs::create_dir(&organe_dir).expect("Creation of organe directory failed");
......@@ -158,12 +165,21 @@ fn main() {
let textes_legislatifs_dir = dataset_dir.join("textes_legislatifs");
if textes_legislatifs_dir.exists() {
fs::remove_dir_all(&textes_legislatifs_dir).expect("Recursive deletion of textes_legislatifs directory failed");
fs::remove_dir_all(&textes_legislatifs_dir)
.expect("Recursive deletion of textes_legislatifs directory failed");
}
fs::create_dir(&textes_legislatifs_dir).expect("Creation of textes_legislatifs directory failed");
fs::create_dir(&textes_legislatifs_dir)
.expect("Creation of textes_legislatifs directory failed");
for texte_legislatif in data["textesEtAmendements"]["texteleg"].members() {
let json_file_path = textes_legislatifs_dir.join(texte_legislatif["refTexteLegislatif"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, texte_legislatif.pretty(2)).expect("Error while writing JSON file");
let json_file_path = textes_legislatifs_dir.join(
texte_legislatif["refTexteLegislatif"]
.as_str()
.unwrap()
.to_owned()
+ ".json",
);
fs::write(&json_file_path, texte_legislatif.pretty(2))
.expect("Error while writing JSON file");
}
}
......@@ -188,22 +204,38 @@ fn main() {
let dossiers_legislatifs_dir = dataset_dir.join("dossiers_legislatifs");
if dossiers_legislatifs_dir.exists() {
fs::remove_dir_all(&dossiers_legislatifs_dir).expect("Recursive deletion of dossiers_legislatifs directory failed");
fs::remove_dir_all(&dossiers_legislatifs_dir)
.expect("Recursive deletion of dossiers_legislatifs directory failed");
}
fs::create_dir(&dossiers_legislatifs_dir).expect("Creation of dossiers_legislatifs directory failed");
fs::create_dir(&dossiers_legislatifs_dir)
.expect("Creation of dossiers_legislatifs directory failed");
for dossier_legislatif in data["export"]["dossiersLegislatifs"]["dossier"].members() {
let json_file_path = dossiers_legislatifs_dir.join(dossier_legislatif["dossierParlementaire"]["uid"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, dossier_legislatif["dossierParlementaire"].pretty(2)).expect("Error while writing JSON file");
let json_file_path = dossiers_legislatifs_dir.join(
dossier_legislatif["dossierParlementaire"]["uid"]
.as_str()
.unwrap()
.to_owned()
+ ".json",
);
fs::write(
&json_file_path,
dossier_legislatif["dossierParlementaire"].pretty(2),
)
.expect("Error while writing JSON file");
}
let textes_legislatifs_dir = dataset_dir.join("textes_legislatifs");
if textes_legislatifs_dir.exists() {
fs::remove_dir_all(&textes_legislatifs_dir).expect("Recursive deletion of textes_legislatifs directory failed");
fs::remove_dir_all(&textes_legislatifs_dir)
.expect("Recursive deletion of textes_legislatifs directory failed");
}
fs::create_dir(&textes_legislatifs_dir).expect("Creation of textes_legislatifs directory failed");
fs::create_dir(&textes_legislatifs_dir)
.expect("Creation of textes_legislatifs directory failed");
for texte_legislatif in data["export"]["textesLegislatifs"]["document"].members() {
let json_file_path = textes_legislatifs_dir.join(texte_legislatif["uid"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, texte_legislatif.pretty(2)).expect("Error while writing JSON file");
let json_file_path = textes_legislatifs_dir
.join(texte_legislatif["uid"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, texte_legislatif.pretty(2))
.expect("Error while writing JSON file");
}
}
......@@ -228,11 +260,13 @@ fn main() {
let scrutins_dir = dataset_dir.join("scrutins");
if scrutins_dir.exists() {
fs::remove_dir_all(&scrutins_dir).expect("Recursive deletion of scrutins directory failed");
fs::remove_dir_all(&scrutins_dir)
.expect("Recursive deletion of scrutins directory failed");
}
fs::create_dir(&scrutins_dir).expect("Creation of scrutins directory failed");
for scrutin in data["scrutins"]["scrutin"].members() {
let json_file_path = scrutins_dir.join(scrutin["uid"].as_str().unwrap().to_owned() + ".json");
let json_file_path =
scrutins_dir.join(scrutin["uid"].as_str().unwrap().to_owned() + ".json");
fs::write(&json_file_path, scrutin.pretty(2)).expect("Error while writing JSON file");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment