remove log crate (in favor of tracing)
All checks were successful
CI/CD Pipeline / test (push) Successful in 2m9s

This commit is contained in:
2024-02-27 15:24:39 +01:00
parent b4d464506c
commit 2f077a447c
10 changed files with 41 additions and 69 deletions

View File

@ -16,7 +16,6 @@
//! Represents a parsed law text.
use log::{debug, info};
use serde::{Deserialize, Serialize};
use std::{
cell::RefCell,
@ -313,14 +312,10 @@ impl Builder {
#[cfg(test)]
self.history.push(format!("New_header: {name}"));
info!("new_header={name}");
let responsible_class = self
.responsible_classifier(name)
.unwrap_or_else(|| panic!("No classifier for '{name}'"));
debug!("Responsible_class = {responsible_class:#?}");
let mut heading: ClassifierInstance = name.into();
if let Some(last_instance) = &self.last_instance {
@ -407,7 +402,6 @@ impl Builder {
#[cfg(test)]
self.history.push(format!("New desc: {desc}"));
debug!("new_desc={desc}");
self.last_instance
.clone()
.expect("We can only set a description, if we already have received a classifier.")
@ -476,8 +470,6 @@ impl Builder {
serde_json::to_string(&content).unwrap()
));
debug!("new_par=par:{par};content:{content:#?}");
let par_header = self.next_para_header.clone();
self.next_para_header = None;
@ -505,7 +497,6 @@ impl Builder {
self.new_header(&next_para_header.clone()); // promote to bigger header :-)
}
debug!("new_next_para_header={header}");
self.next_para_header = Some(header.trim().into());
}

View File

@ -41,8 +41,6 @@ struct Args {
}
fn main() {
env_logger::init();
let args = Args::parse();
if args.clear_cache {

View File

@ -20,7 +20,6 @@ mod ris_structure;
use std::path::Path;
use log::info;
use serde::Deserialize;
use crate::misc::{current_date, get_cache_dir, Error};
@ -67,7 +66,7 @@ pub fn parse(law_id: usize) -> Result<Vec<String>, Error> {
let mut skip = true;
let mut ret = Vec::new();
loop {
info!("=== Fetching overview page #{page} ===");
//info!("=== Fetching overview page #{page} ===");
let json = fetch_page(law_id, page)?;
let (cont, nodes) = parse_from_str(&json, skip)?;
for n in nodes {
@ -116,7 +115,7 @@ fn fetch_page(overview_id: usize, page: usize) -> Result<String, Error> {
if let Ok(data) = fs::read_to_string(&expected_filename) {
Ok(data)
} else {
info!("Not finding law_id {overview_id} (page {page}) in the cache, downloading...");
//info!("Not finding law_id {overview_id} (page {page}) in the cache, downloading...");
let data = ureq::post("https://data.bka.gv.at/ris/api/v2.6/Bundesrecht")
.send_form(&[
("Applikation", "BrKons"),

View File

@ -25,8 +25,6 @@ use std::{
path::Path,
};
use log::info;
use crate::{
law,
misc::{fetch_with_retries, get_cache_dir, Error},
@ -126,7 +124,6 @@ impl Parser {
/// );
/// ```
pub fn parse(&self, url: &str, builder: &mut law::Builder) -> Result<bool, Error> {
info!("Parsing {url}");
let xml = fetch(url)?;
let xml = xml.replace('\u{a0}', " ");
@ -193,7 +190,6 @@ fn fetch(url: &str) -> Result<String, Error> {
if let Ok(data) = fs::read_to_string(&expected_filename) {
Ok(data)
} else {
info!("Not finding url {url} in the cache, downloading...");
let data = fetch_with_retries(url)?;
let path = Path::new(&expected_filename);
if let Some(parent) = path.parent() {

View File

@ -16,7 +16,6 @@
use std::iter::Peekable;
use log::trace;
use roxmltree::{Children, Node};
use crate::law::Content;
@ -40,7 +39,6 @@ impl Absatz {
// - String: (optional) paragraph id
// - Content: content of the paragraph
pub(crate) fn parse_full(c: &mut Peekable<Children>) -> (Option<String>, Content) {
trace!("Parsing absatz...");
let absatz = AbsatzAbs::parse(c.next().unwrap());
let par_id = absatz.gldsym;
@ -50,7 +48,6 @@ impl Absatz {
// If there's a "liste" after an "absatz", the "liste" should be part of the "absatz"
while let Some(child) = c.peek() {
if Liste::test(child) {
trace!("Found liste inside absatz, parsing...");
let liste = Liste::parse_full(c).content;
content.extend(liste);
} else if Table::test(child) {

View File

@ -17,7 +17,6 @@
use std::collections::HashMap;
use std::iter::Peekable;
use log::{debug, trace};
use roxmltree::{Children, Node};
use crate::law;
@ -72,7 +71,6 @@ impl Abschnitt {
builder.new_par(par_id, Content::List(contents));
}
debug!("Handling post metadata");
ret.handle_metadata(&mut c, builder);
// Skip all UeberschriftTitle and Absatz
@ -103,7 +101,6 @@ impl Abschnitt {
// We are done with meta-data parsing
if key == "Text" {
trace!("Done parsing metadata, got 'Text'");
break;
}
@ -128,7 +125,6 @@ impl Abschnitt {
builder.add_next_para_note(value.clone());
}
trace!("Parsed metadata: key='{key}', value='{value}'");
self.metadata.insert(key, value);
}
}

View File

@ -16,7 +16,6 @@
use std::iter::Peekable;
use log::trace;
use roxmltree::{Children, Node};
use crate::{
@ -34,7 +33,6 @@ impl Liste {
}
pub(crate) fn parse_full(n: &mut Peekable<Children>) -> Self {
trace!("Parsing liste...");
Expect::from(n.peek().unwrap()).tag("liste");
let mut content = Vec::new();
@ -44,17 +42,12 @@ impl Liste {
// Parse stuff inside <liste>
while let Some(child) = c.peek() {
if Ziffernliste::test(child) {
trace!("Found Ziffernliste in liste, parsing...");
let liste = Ziffernliste::parse(&mut c);
content.push(liste.get_content());
} else if Schlussteil::test(child) {
// 162 Schifffahrtsgesetz show use that a 'schlussteil' can be at the start of a list
content.push(Content::Text(Schlussteil::parse(c.next().unwrap()).content));
} else {
trace!(
"No more acceptable element in the list found: '{}'",
child.tag_name().name()
);
break;
}
}

View File

@ -22,7 +22,6 @@ mod table;
use std::{fmt::Display, iter::Peekable};
use abschnitt::Abschnitt;
use log::trace;
use roxmltree::{Children, Node};
use crate::{
@ -117,7 +116,6 @@ impl Risdok {
pub(crate) fn from_str(xml: &str, builder: &mut law::Builder) -> Result<bool, Error> {
let doc = roxmltree::Document::parse(xml)?;
trace!("{doc:?}");
let root = doc.root();
assert_eq!(root.children().count(), 1);
Ok(Self::parse(root.children().next().unwrap(), builder))
@ -183,7 +181,6 @@ impl Listelem {
let text = c.next().unwrap().text().unwrap().into();
trace!("Parsed Listelem with text='{text}'");
Expect::empty(c.next());
Self { symbol, text }
@ -211,7 +208,6 @@ impl Ziffernliste {
}
pub(crate) fn parse(c: &mut Peekable<Children>) -> Self {
trace!("Parsing Ziffernliste...");
let n = c.next().unwrap();
assert!(Self::test(&n));