mirror of
http://shenjack.top:5100/shenjack/icalingua-python-bot.git
synced 2024-11-23 12:41:05 +08:00
优化插件验证逻辑和代码结构
This commit is contained in:
parent
0843826435
commit
8cd8d93a28
|
@ -51,8 +51,7 @@ pub fn verify_plugins() {
|
|||
return;
|
||||
}
|
||||
let plugin_path = plugin_path.unwrap();
|
||||
for entry in std::fs::read_dir(plugin_path).unwrap() {
|
||||
if let Ok(entry) = entry {
|
||||
for entry in std::fs::read_dir(plugin_path).unwrap().flatten() {
|
||||
let path = entry.path();
|
||||
if let Some(ext) = path.extension() {
|
||||
if ext == "py" && !PyStatus::verify_file(&path) {
|
||||
|
@ -60,7 +59,6 @@ pub fn verify_plugins() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if need_reload_files.is_empty() {
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
pub mod call;
|
||||
pub mod class;
|
||||
|
||||
use std::path::Path;
|
||||
use std::time::SystemTime;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
|
@ -222,7 +223,7 @@ pub fn get_change_time(path: &PathBuf) -> Option<SystemTime> {
|
|||
path.metadata().ok()?.modified().ok()
|
||||
}
|
||||
|
||||
pub fn py_module_from_code(content: &str, path: &PathBuf) -> PyResult<Py<PyAny>> {
|
||||
pub fn py_module_from_code(content: &str, path: &Path) -> PyResult<Py<PyAny>> {
|
||||
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
|
||||
let module: PyResult<Py<PyAny>> = PyModule::from_code(
|
||||
py,
|
||||
|
|
Loading…
Reference in New Issue
Block a user