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

Function getEntryFilePath

src/plugins/python/python/pythongenerator.cpp:87–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87static 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
118RunCommandInfo PythonGenerator::getRunArguments(const ProjectInfo &projectInfo, const QString &currentFile)
119{

Callers 2

foreachFunction · 0.85
getRunArgumentsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected