MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getModuleInfoString

Function getModuleInfoString

src/App/ProgramInformation.cpp:113–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static std::string getModuleInfoString(const std::string& path)
114{
115 QString modPath = QString::fromStdString(path);
116 QFileInfo mod(modPath);
117 if (mod.isHidden()) { // Ignore hidden directories
118 return {};
119 }
120
121 std::string addonName = mod.isDir() ? QDir(modPath).dirName().toStdString()
122 : mod.fileName().toStdString();
123 std::string versionString;
124 std::stringstream str;
125 try {
126 auto metadataFile = std::filesystem::path(mod.absoluteFilePath().toStdString())
127 / "package.xml";
128 if (std::filesystem::exists(metadataFile)) {
129 App::Metadata metadata(metadataFile);
130 if (!metadata.name().empty()) {
131 addonName = metadata.name();
132 }
133 if (metadata.version() != App::Meta::Version()) {
134 versionString = " " + metadata.version().str();
135 }
136 }
137 }
138 catch (const Base::Exception& e) {
139 auto what = QString::fromUtf8(e.what()).trimmed().replace(
140 QChar::fromLatin1('\n'),
141 QChar::fromLatin1(' ')
142 );
143 str << " (Malformed metadata: " << what << ")";
144 }
145 str << " * " << addonName << versionString;
146 QFileInfo disablingFile(mod.absoluteFilePath(), QStringLiteral("ADDON_DISABLED"));
147 if (disablingFile.exists()) {
148 str << " (Disabled)";
149 }
150
151 str << "\n";
152 return str.str();
153}
154
155std::string ProgramInformation::getValueOrEmpty(
156 const std::map<std::string, std::string>& map,

Callers 1

getVerboseAddOnsInfoMethod · 0.85

Calls 13

isDirMethod · 0.80
toStdStringMethod · 0.80
VersionFunction · 0.70
QDirClass · 0.50
isHiddenMethod · 0.45
fileNameMethod · 0.45
emptyMethod · 0.45
nameMethod · 0.45
versionMethod · 0.45
strMethod · 0.45
replaceMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected