MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / pythonVersion

Method pythonVersion

src/plugins/python/utils/utils.cpp:46–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46QString Utils::pythonVersion(const QString &python)
47{
48 auto getVersion = [](const QString &output) -> QString {
49 static QRegularExpression regex(R"((\d{1,3}(?:\.\d{1,3}){0,2}))");
50 if (output.isEmpty())
51 return "";
52
53 QRegularExpressionMatch match = regex.match(output);
54 if (match.hasMatch())
55 return match.captured(1);
56
57 return "";
58 };
59
60 QProcess process;
61 process.start(python, { "--version" });
62 process.waitForFinished();
63
64 QString output = process.readAllStandardOutput();
65 QString version = getVersion(output);
66 if (version.isEmpty()) {
67 output = process.readAllStandardError();
68 version = getVersion(output);
69 if (version.isEmpty()) {
70 int index = python.lastIndexOf('/') + 1;
71 output = python.mid(index, python.length() - index);
72 version = getVersion(output);
73 }
74 }
75
76 return version;
77}
78
79QString Utils::packageInstallPath(const QString &python)
80{

Callers

nothing calls this directly

Calls 6

readAllStandardOutputMethod · 0.80
readAllStandardErrorMethod · 0.80
isEmptyMethod · 0.45
matchMethod · 0.45
startMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected