From ee8226d22425ef63f83e2deb79680c7c3b773200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Sat, 6 Apr 2019 15:32:20 +0200 Subject: [PATCH] small cleanup --- src/plugins.cc | 20 +++++++++----------- src/python_module.h | 3 +-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/plugins.cc b/src/plugins.cc index 96f27b3..fae6f2f 100644 --- a/src/plugins.cc +++ b/src/plugins.cc @@ -2,15 +2,16 @@ #include "config.h" #include "python_module.h" -Plugins::Plugins(): jucipp_module("Jucipp", Module::init_jucipp_module) { - auto &config = Config::get(); - config.load(); - const auto sys = py::module::import("sys"); - sys.attr("path").cast().append(config.plugins.path); - } +Plugins::Plugins() : jucipp_module("Jucipp", Module::init_jucipp_module) { + auto &config = Config::get(); + config.load(); + py::module::import("sys") + .attr("path") + .cast() + .append(config.plugins.path); +} void Plugins::load() { - std::cout << Config::get().plugins.path << std::endl; boost::filesystem::directory_iterator end_it; for(boost::filesystem::directory_iterator it(Config::get().plugins.path); it != end_it; it++) { auto module_name = it->path().stem().string(); @@ -27,15 +28,12 @@ void Plugins::load() { interpreter.reload_module(module); } else { Terminal::get().print("Loading plugin ´" + module_name + "´\n"); - py::module::import(module_name.c_str()); + py::module::import(module_name.c_str()); } - } catch(py::error_already_set &error) { Terminal::get().print("Error loading plugin `" + module_name + "`:\n" + error.what() + "\n"); } } - if(interpreter.error()) - std::cerr << py::error_already_set().what() << std::endl; } } diff --git a/src/python_module.h b/src/python_module.h index 8477d4a..b48e6ea 100644 --- a/src/python_module.h +++ b/src/python_module.h @@ -14,8 +14,7 @@ namespace pybind11 { public: PYBIND11_TYPE_CASTER(boost::filesystem::path, _("str")); bool load(handle src, bool) { - const std::string path = pybind11::str(src); - value = path; + value = pybind11::str(src); return !PyErr_Occurred(); }