use std::path::PathBuf;
#[derive(Debug)]
pub struct Entrypoint {
pub entrypoint: String,
pub file_path: String,
pub function_name: String,
}
impl Entrypoint {
pub fn new(entrypoint_path: &str) -> Self {
let pth_cmpts: Vec<&str> = entrypoint_path.split('.').collect();
let function = pth_cmpts.last().unwrap();
let path = &pth_cmpts[..pth_cmpts.len() - 1].join(".");
let python_path = PathBuf::from(format!("{}.py", path)).canonicalize().unwrap();
if !python_path.as_path().exists() {
panic!("Entrypoint `{}` not found", entrypoint_path);
};
let canonical_path = python_path.to_str().unwrap();
Entrypoint {
entrypoint: entrypoint_path.to_owned(),
file_path: canonical_path.to_owned(),
function_name: function.to_string(),
}
}
}