| 85 | } |
| 86 | |
| 87 | static QString getEntryFilePath(const QDir &dir) |
| 88 | { |
| 89 | QFileInfoList entries = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); |
| 90 | //Create a QRegExp object with the given regular expression |
| 91 | QRegExp regExp("if\\s*__name__\\s*==\\s*['|\"]__main__['|\"]"); |
| 92 | |
| 93 | //Loop through files |
| 94 | foreach (QFileInfo entry, entries) { |
| 95 | if (entry.isDir()) { |
| 96 | //If the entry is a folder, call the browseRecursively function again |
| 97 | QDir dir(entry.filePath()); |
| 98 | QString mainClass = getEntryFilePath(dir); |
| 99 | if (!mainClass.isEmpty()) |
| 100 | return mainClass; |
| 101 | } else { |
| 102 | if (entry.suffix().toLower() == "py") { |
| 103 | QFile file(entry.filePath()); |
| 104 | if (file.open(QIODevice::ReadOnly)) { |
| 105 | QString fileContent = file.readAll(); |
| 106 | file.close(); |
| 107 | //Check if the given regular expression matches the file content |
| 108 | if (regExp.indexIn(fileContent) >= 0) { |
| 109 | return entry.filePath(); |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | return {}; |
| 116 | } |
| 117 | |
| 118 | RunCommandInfo PythonGenerator::getRunArguments(const ProjectInfo &projectInfo, const QString ¤tFile) |
| 119 | { |
no outgoing calls
no test coverage detected