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

Method loadScript_

src/API/PythonAPI.cpp:103–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103bool PythonAPI::loadScript_(const std::filesystem::path& name, bool check) {
104#ifdef SURELOG_WITH_PYTHON
105 FileSystem* const fileSystem = FileSystem::getInstance();
106 std::unique_ptr<SymbolTable> symbolTable(new SymbolTable);
107 PathId nameId = fileSystem->toPathId(name.string(), symbolTable.get());
108 if (fileSystem->isRegularFile(nameId)) {
109 std::string fname = name.string();
110 FILE* fp = fopen(fname.c_str(), "r");
111 PyRun_SimpleFile(fp, fname.c_str());
112 PyErr_Print();
113 fclose(fp);
114 return true;
115 } else {
116 if (check)
117 std::cerr << "PYTHON API ERROR: Script \"" << name
118 << "\" does not exist.\n";
119 }
120#endif
121 return false;
122}
123
124PyThreadState* PythonAPI::initNewInterp() {
125#ifdef SURELOG_WITH_PYTHON

Callers

nothing calls this directly

Calls 2

toPathIdMethod · 0.80
isRegularFileMethod · 0.45

Tested by

no test coverage detected