MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / loadScriptsInInterp_

Method loadScriptsInInterp_

src/API/PythonAPI.cpp:154–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void PythonAPI::loadScriptsInInterp_() {
155#ifdef SURELOG_WITH_PYTHON
156 FileSystem* const fileSystem = FileSystem::getInstance();
157 std::unique_ptr<SymbolTable> symbolTable(new SymbolTable);
158
159 const std::filesystem::path workingDir = fileSystem->getWorkingDir();
160
161 bool waiverLoaded = false;
162 std::filesystem::path waivers = workingDir / "slwaivers.py";
163 PathId waiversId = fileSystem->toPathId(waivers.string(), symbolTable.get());
164 if (fileSystem->isRegularFile(waiversId)) {
165 waiverLoaded = loadScript_(waivers);
166 }
167
168 if (!waiverLoaded) {
169 waivers = m_programPath / "python" / "slwaivers.py";
170 waiversId = fileSystem->toPathId(waivers.string(), symbolTable.get());
171 if (fileSystem->isRegularFile(waiversId)) {
172 waiverLoaded = loadScript_(waivers);
173 }
174 }
175
176 bool messageFormatLoaded = false;
177 std::filesystem::path format = workingDir / "slformatmsg.py";
178 PathId formatId = fileSystem->toPathId(format.string(), symbolTable.get());
179 if (fileSystem->isRegularFile(formatId)) {
180 messageFormatLoaded = loadScript_(format);
181 }
182
183 if (!messageFormatLoaded) {
184 format = m_programPath / "python" / "slformatmsg.py";
185 formatId = fileSystem->toPathId(format.string(), symbolTable.get());
186 if (fileSystem->isRegularFile(formatId)) {
187 messageFormatLoaded = loadScript_(format);
188 }
189 }
190
191 if (!m_listenerScript.empty()) {
192 PathId listenerId =
193 fileSystem->toPathId(m_listenerScript.string(), symbolTable.get());
194 if (fileSystem->isRegularFile(listenerId)) {
195 m_listenerLoaded = loadScript_(m_listenerScript);
196 }
197 }
198
199 if (!m_listenerLoaded) {
200 std::filesystem::path listener = workingDir / "slSV3_1aPythonListener.py";
201 PathId listenerId =
202 fileSystem->toPathId(listener.string(), symbolTable.get());
203 if (fileSystem->isRegularFile(listenerId)) {
204 m_listenerScript = listener;
205 m_listenerLoaded = loadScript_(listener);
206 }
207 }
208
209 if (!m_listenerLoaded) {
210 std::filesystem::path listener =
211 m_programPath / "python" / "slSV3_1aPythonListener.py";

Callers

nothing calls this directly

Calls 3

toPathIdMethod · 0.80
getWorkingDirMethod · 0.45
isRegularFileMethod · 0.45

Tested by

no test coverage detected