mirror of
https://github.com/flibusta-apps/library_updater.git
synced 2026-03-04 15:40:54 +01:00
Add simple rust implementation
This commit is contained in:
26
src/utils.rs
Normal file
26
src/utils.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufRead};
|
||||
use std::path::Path;
|
||||
|
||||
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let file = File::open(filename)?;
|
||||
Ok(io::BufReader::new(file).lines())
|
||||
}
|
||||
|
||||
pub fn remove_wrong_chars(s: &str) -> String {
|
||||
s.replace(';', "").replace('\n', " ").replace('ё', "е")
|
||||
}
|
||||
|
||||
pub fn parse_lang(s: &str) -> String {
|
||||
s.replace('-', "").replace('~', "").to_lowercase()
|
||||
}
|
||||
|
||||
pub fn fix_annotation_text(text: &str) -> String {
|
||||
text.replace(" ", "")
|
||||
.replace("[b]", "")
|
||||
.replace("[/b]", "")
|
||||
.replace("[hr]", "")
|
||||
}
|
||||
Reference in New Issue
Block a user