| 101 | } |
| 102 | |
| 103 | bool 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 | |
| 124 | PyThreadState* PythonAPI::initNewInterp() { |
| 125 | #ifdef SURELOG_WITH_PYTHON |
nothing calls this directly
no test coverage detected