Skip to content

Commit

Permalink
[tech] Use crate 'minidom_writer'
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed Apr 24, 2020
1 parent 2fa832d commit 4dbcebd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 165 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ log = "0.4"
md5 = "0.7"
minidom = "0.12"
minidom_ext = "1"
minidom_writer = "1"
num-traits = "0.2"
pretty_assertions = "0.6"
proj = { version = "0.14", optional = true }
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub mod objects;
pub mod gtfs;
pub mod hellogo_fares;
pub mod merge_stop_areas;
mod minidom_utils;
pub mod model;
#[cfg(feature = "proj")]
pub mod netex_france;
Expand Down
21 changes: 0 additions & 21 deletions src/minidom_utils/mod.rs

This file was deleted.

127 changes: 0 additions & 127 deletions src/minidom_utils/writer.rs

This file was deleted.

32 changes: 16 additions & 16 deletions src/netex_france/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

//! Exporter for Netex France profile
use crate::{
minidom_utils::ElementWriter,
model::Model,
netex_france::{
CalendarExporter, CompanyExporter, LineExporter, NetworkExporter, OfferExporter,
Expand All @@ -28,6 +27,7 @@ use chrono::prelude::*;
use failure::format_err;
use log::info;
use minidom::{Element, Node};
use minidom_writer::ElementWriter;
use proj::Proj;
use relational_types::IdxSet;
use std::{
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Exporter<'_> {
P: AsRef<Path>,
{
let filepath = path.as_ref().join(NETEX_FRANCE_LINES_FILENAME);
let mut file = File::create(&filepath)?;
let file = File::create(&filepath)?;
let network_frames = self.create_networks_frames()?;
let lines_frame = self.create_lines_frame()?;
let companies_frame = self.create_companies_frame();
Expand All @@ -257,9 +257,9 @@ impl Exporter<'_> {
);
let composite_frame = Self::create_composite_frame(composite_frame_id, frames);
let netex = self.wrap_frame(composite_frame, VersionType::Lines)?;
let writer = ElementWriter::new(netex, true);
let mut writer = ElementWriter::pretty(file);
info!("Writing {:?}", &filepath);
writer.write(&mut file)?;
writer.write(&netex)?;
Ok(())
}

Expand Down Expand Up @@ -316,12 +316,12 @@ impl Exporter<'_> {
P: AsRef<Path>,
{
let filepath = path.as_ref().join(NETEX_FRANCE_STOPS_FILENAME);
let mut file = File::create(&filepath)?;
let file = File::create(&filepath)?;
let stop_frame = self.create_stops_frame()?;
let netex = self.wrap_frame(stop_frame, VersionType::Stops)?;
let writer = ElementWriter::new(netex, true);
let mut writer = ElementWriter::pretty(file);
info!("Writing {:?}", &filepath);
writer.write(&mut file)?;
writer.write(&netex)?;
Ok(())
}

Expand All @@ -345,12 +345,12 @@ impl Exporter<'_> {
P: AsRef<Path>,
{
let filepath = path.as_ref().join(NETEX_FRANCE_CALENDARS_FILENAME);
let mut file = File::create(&filepath)?;
let file = File::create(&filepath)?;
let calendars_frame = self.create_calendars_frame()?;
let netex = self.wrap_frame(calendars_frame, VersionType::Calendars)?;
let writer = ElementWriter::new(netex, true);
let mut writer = ElementWriter::pretty(file);
info!("Writing {:?}", &filepath);
writer.write(&mut file)?;
writer.write(&netex)?;
Ok(())
}

Expand Down Expand Up @@ -396,12 +396,12 @@ impl Exporter<'_> {
P: AsRef<Path>,
{
let filepath = path.as_ref().join(NETEX_FRANCE_TRANSFERS_FILENAME);
let mut file = File::create(&filepath)?;
let file = File::create(&filepath)?;
let transfers_frame = self.create_transfers_frame()?;
let netex = self.wrap_frame(transfers_frame, VersionType::Transfers)?;
let writer = ElementWriter::new(netex, true);
let mut writer = ElementWriter::pretty(file);
info!("Writing {:?}", &filepath);
writer.write(&mut file)?;
writer.write(&netex)?;
Ok(())
}

Expand Down Expand Up @@ -459,12 +459,12 @@ impl Exporter<'_> {
};
let file_name = format!("offre_{}{:x}.xml", line_code, line_id_md5);
let filepath = network_path.as_ref().join(file_name);
let mut file = File::create(&filepath)?;
let file = File::create(&filepath)?;
let offer_frame = self.create_offer_frame(&offer_exporter, line_idx)?;
let netex = self.wrap_frame(offer_frame, VersionType::Schedule)?;
let writer = ElementWriter::new(netex, true);
let mut writer = ElementWriter::pretty(file);
info!("Writing {:?}", &filepath);
writer.write(&mut file)?;
writer.write(&netex)?;
}
Ok(())
}
Expand Down

0 comments on commit 4dbcebd

Please sign in to comment.