pub mod plot_obj_parser;
pub mod until;
use crate::preprocessor::config::PlotlyInputType;
use anyhow::Result;
use log::{debug, warn};
use plotly::Plot;
use serde_json::Value;
pub fn handle(raw_code: String, input_type: &PlotlyInputType) -> Result<Plot> {
let result = match input_type {
PlotlyInputType::SandBoxScript => {
warn!("The entry has been discarded. This config shouldn't be used.");
debug!("This function returns an empty string.");
Plot::new()
}
PlotlyInputType::JSONInput => handle_json_input(raw_code)?,
};
Ok(result)
}
pub fn handle_json_input(raw_code: String) -> Result<Plot> {
let mut value: Value = json5::from_str(&raw_code)?;
plot_obj_parser::parse(&mut value)
}