From 24c60199cce8c8def9b67d17cf7569b57fcb3aed Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 17 Dec 2015 18:56:40 +0100 Subject: [PATCH] + improve getting proper group name from Python module path name --- src/Gui/ApplicationPy.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 31862d7043..a723dc77ad 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -914,18 +914,21 @@ PyObject* Application::sAddCommand(PyObject * /*self*/, PyObject *args,PyObject args = list.getItem(0); // usually this is the file name of the calling script - module = args.getItem(1).as_string(); - Base::FileInfo fi(module); + std::string file = args.getItem(1).as_string(); + Base::FileInfo fi(file); + // convert backslashes to slashes + file = fi.filePath(); module = fi.fileNamePure(); - group = module; - // check if the group name ends with 'Gui', 'Tools', 'Commands', ... - // and if yes remove the suffix - boost::regex rx("^(\\w+)(Gui|Tools|Commands|Feature)$"); + // for the group name get the directory name after 'Mod' + boost::regex rx("/Mod/(\\w+)/"); boost::smatch what; - if (boost::regex_search(group, what, rx)) { + if (boost::regex_search(file, what, rx)) { group = what[1]; } + else { + group = module; + } } catch (Py::Exception& e) { e.clear();