| 22 | namespace language { |
| 23 | |
| 24 | Version completion(Category category, Kit kit, const Version &version) |
| 25 | { |
| 26 | qInfo() << __FUNCTION__ << version.major.value(); |
| 27 | Version ret = version; |
| 28 | if (category == User) { |
| 29 | if (kit == Python) { |
| 30 | QString program = "python"; |
| 31 | if (version.major) { |
| 32 | program += QString::number(version.major.value()); |
| 33 | } |
| 34 | ProcessUtil::execute(program, {"-V"}, [&](const QByteArray &data){ |
| 35 | QRegularExpression regExp {"Python\\s(?<" + RK_Major +">[0-9]+)" |
| 36 | + "\\.(?<"+ RK_Minor +">[0-9]+)" |
| 37 | + "\\.(?<"+ RK_Revision +">[0-9]+)" |
| 38 | + "(\\.(?<"+ RK_Build + ">[0-9]+))?"}; |
| 39 | auto matchs = regExp.match(data); |
| 40 | if (matchs.hasMatch()) { |
| 41 | auto major = matchs.captured(RK_Major); |
| 42 | auto minor = matchs.captured(RK_Minor); |
| 43 | auto revsion = matchs.captured(RK_Revision); |
| 44 | auto build = matchs.captured(RK_Build); |
| 45 | if (!major.isNull()) { |
| 46 | ret.major = major.toInt(); |
| 47 | } |
| 48 | if (!minor.isNull()) { |
| 49 | ret.minor = minor.toInt(); |
| 50 | } |
| 51 | if (!revsion.isNull()) { |
| 52 | ret.revision = revsion.toInt(); |
| 53 | } |
| 54 | if (!build.isNull()) { |
| 55 | ret.revision = build.toInt(); |
| 56 | } |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | return ret; |
| 62 | } |
| 63 | |
| 64 | Program search(Category category, Kit kit, const Version &version) |
| 65 | { |