pyridis_file_ext/
plugin.rs1use crate::prelude::{
2 thirdparty::ird::{thirdparty::*, *},
3 *,
4};
5
6#[derive(FileExtPlugin)]
7pub struct PythonFileExtPlugin {}
8
9#[file_ext_plugin(runtime = "default_runtime")]
10impl FileExtPlugin for PythonFileExtPlugin {
11 async fn new() -> Result<Self>
12 where
13 Self: Sized,
14 {
15 Ok(PythonFileExtPlugin {})
16 }
17
18 fn target(&self) -> Vec<String> {
19 vec!["py".to_string()]
20 }
21
22 async fn load(
23 &self,
24 path: std::path::PathBuf,
25
26 inputs: ird::Inputs,
27 outputs: ird::Outputs,
28 queries: ird::Queries,
29 queryables: ird::Queryables,
30 configuration: serde_yml::Value,
31 ) -> Result<iridis_runtime_core::prelude::RuntimeNode> {
32 match path.extension() {
33 Some(ext) => {
34 if ext == "py" {
35 let mut configuration = configuration.clone();
36 configuration["python_file_path"] =
37 serde_yml::Value::String(path.to_string_lossy().to_string());
38
39 Ok(RuntimeNode::StaticallyLinked(
40 PythonNode::new(inputs, outputs, queries, queryables, configuration)
41 .await??,
42 ))
43 } else {
44 Err(eyre::eyre!("Unsupported file extension '{:?}'.", ext))
45 }
46 }
47 None => Err(eyre::eyre!("No file extension found for path {:?}", path)),
48 }
49 }
50}