Skip to content

Commit

Permalink
Cargo Format
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Nov 6, 2020
1 parent 16c2e05 commit bd1c8d5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
9 changes: 6 additions & 3 deletions arsenal_blender_core/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -230,8 +233,8 @@ impl BlendExporter {
if object.getattr(py, "rotation_mode")?.extract::<String>(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
Expand Down
2 changes: 1 addition & 1 deletion arsenal_blender_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 12 additions & 10 deletions arsenal_blender_core/src/operators.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions arsenal_blender_core/src/utils.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand All @@ -26,14 +26,17 @@ pub mod python {
.getattr(py, "modules")?
.cast_as::<PyDict>(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()
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod hello;
pub mod hello;

0 comments on commit bd1c8d5

Please sign in to comment.