From bd1c8d5bc2cfda3751e5cfb415ff7e77797037f3 Mon Sep 17 00:00:00 2001 From: Zicklag Date: Thu, 5 Nov 2020 20:09:23 -0600 Subject: [PATCH] Cargo Format --- arsenal_blender_core/src/exporter.rs | 9 ++++++--- arsenal_blender_core/src/lib.rs | 2 +- arsenal_blender_core/src/operators.rs | 22 ++++++++++++---------- arsenal_blender_core/src/utils.rs | 23 ++++++++++++----------- xtask/src/commands.rs | 2 +- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/arsenal_blender_core/src/exporter.rs b/arsenal_blender_core/src/exporter.rs index 736233c..e211bc0 100644 --- a/arsenal_blender_core/src/exporter.rs +++ b/arsenal_blender_core/src/exporter.rs @@ -112,7 +112,10 @@ impl BlendExporter { // Dump the static assets. These will eventually be dynamically // generated based on the Blend configuration. self.write_resource("scene.ron", include_bytes!("exporter/scene.ron"))?; - self.write_resource("display_config.ron", include_bytes!("exporter/display_config.ron"))?; + self.write_resource( + "display_config.ron", + include_bytes!("exporter/display_config.ron"), + )?; Ok(()) } @@ -230,8 +233,8 @@ impl BlendExporter { if object.getattr(py, "rotation_mode")?.extract::(py)? == "QUATERNION" { blender_quat = object.getattr(py, "rotation_quaternion")?; } else { - blender_quat = object. - getattr(py, "rotation_euler")? + blender_quat = object + .getattr(py, "rotation_euler")? .call_method0(py, "to_quaternion")?; } // Collect coordinates from blender quat diff --git a/arsenal_blender_core/src/lib.rs b/arsenal_blender_core/src/lib.rs index 3b9c933..f6dbce9 100644 --- a/arsenal_blender_core/src/lib.rs +++ b/arsenal_blender_core/src/lib.rs @@ -15,7 +15,7 @@ pub mod operators; pub mod utils; /// Arsenal Blender Core -/// +/// /// This is the core library used to perform most work in the arsenal-blender /// plugin. #[pymodule] diff --git a/arsenal_blender_core/src/operators.rs b/arsenal_blender_core/src/operators.rs index cf2490b..3771960 100644 --- a/arsenal_blender_core/src/operators.rs +++ b/arsenal_blender_core/src/operators.rs @@ -1,11 +1,11 @@ pub mod py { - use std::path::PathBuf; - use std::process::Command; - use crate::utils::python::get_arsenal_runtime_path; - use crate::utils::blender::get_build_dir; use crate::exporter; - use pyo3::prelude::*; + use crate::utils::blender::get_build_dir; + use crate::utils::python::get_arsenal_runtime_path; use pyo3::exceptions::IOError; + use pyo3::prelude::*; + use std::path::PathBuf; + use std::process::Command; /// Blender operators #[pymodule] @@ -23,12 +23,14 @@ pub mod py { exporter::export(py, &build_dir)?; // Run the exported scene with the arsenal runtime - Command::new(&get_arsenal_runtime_path(py)?) + Command::new(&get_arsenal_runtime_path(py)?) .current_dir(&build_dir) - .arg(PathBuf::from(&build_dir) - .join("scene.ron") - .to_str() - .ok_or_else(|| IOError::py_err("Build dir path not valid UTF-8"))?) + .arg( + PathBuf::from(&build_dir) + .join("scene.ron") + .to_str() + .ok_or_else(|| IOError::py_err("Build dir path not valid UTF-8"))?, + ) .spawn()?; // Dump flamegraph diff --git a/arsenal_blender_core/src/utils.rs b/arsenal_blender_core/src/utils.rs index b760bee..f6c31c9 100644 --- a/arsenal_blender_core/src/utils.rs +++ b/arsenal_blender_core/src/utils.rs @@ -1,9 +1,9 @@ /// Python utilities pub mod python { - use std::path::PathBuf; + use pyo3::exceptions::{Exception, FileNotFoundError, IOError}; use pyo3::prelude::*; - use pyo3::exceptions::{FileNotFoundError, IOError, Exception}; - use pyo3::types::{PyDict, IntoPyDict}; + use pyo3::types::{IntoPyDict, PyDict}; + use std::path::PathBuf; /// Print a Python object as it would be printed by the Python interpreter. pub fn print_py_value(py: Python, value: PyObject) -> PyResult<()> { @@ -26,14 +26,17 @@ pub mod python { .getattr(py, "modules")? .cast_as::(py)? .get_item("arsenal_blender") - .ok_or_else( - || Exception::py_err("Could not load arsenal_blender module, used to determine Blender plugin path."))? + .ok_or_else(|| { + Exception::py_err( + "Could not load arsenal_blender module, used to determine Blender plugin path.", + ) + })? .to_object(py) .getattr(py, "__spec__")? .getattr(py, "origin")? .extract(py)?; let module_path = PathBuf::from(module_path); - + // Path to the arsenal-blend addon directory let arsenal_plugin_path = module_path .parent() @@ -59,10 +62,10 @@ pub mod python { /// Blender utilities pub mod blender { - use std::path::PathBuf; - use std::fs::DirBuilder; use pyo3::exceptions::{FileNotFoundError, IOError}; use pyo3::prelude::*; + use std::fs::DirBuilder; + use std::path::PathBuf; /// Get the blend filepath. This will be None if the blend has not been saved /// yet. @@ -115,9 +118,7 @@ pub mod blender { let build_dir_path = parent_dir.to_path_buf().join(build_dir_name); // Create path if it doesn't exist - DirBuilder::new() - .recursive(true) - .create(&build_dir_path)?; + DirBuilder::new().recursive(true).create(&build_dir_path)?; // Return path string Ok(build_dir_path diff --git a/xtask/src/commands.rs b/xtask/src/commands.rs index 229ec9b..152adf1 100644 --- a/xtask/src/commands.rs +++ b/xtask/src/commands.rs @@ -1 +1 @@ -pub mod hello; \ No newline at end of file +pub mod hello;