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;
|
return;
|
||||||
}
|
}
|
||||||
let plugin_path = plugin_path.unwrap();
|
let plugin_path = plugin_path.unwrap();
|
||||||
for entry in std::fs::read_dir(plugin_path).unwrap() {
|
for entry in std::fs::read_dir(plugin_path).unwrap().flatten() {
|
||||||
if let Ok(entry) = entry {
|
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if let Some(ext) = path.extension() {
|
if let Some(ext) = path.extension() {
|
||||||
if ext == "py" && !PyStatus::verify_file(&path) {
|
if ext == "py" && !PyStatus::verify_file(&path) {
|
||||||
|
@ -60,7 +59,6 @@ pub fn verify_plugins() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if need_reload_files.is_empty() {
|
if need_reload_files.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod call;
|
pub mod call;
|
||||||
pub mod class;
|
pub mod class;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ pub fn get_change_time(path: &PathBuf) -> Option<SystemTime> {
|
||||||
path.metadata().ok()?.modified().ok()
|
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>> {
|
Python::with_gil(|py| -> PyResult<Py<PyAny>> {
|
||||||
let module: PyResult<Py<PyAny>> = PyModule::from_code(
|
let module: PyResult<Py<PyAny>> = PyModule::from_code(
|
||||||
py,
|
py,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user