Skip to content

Commit

Permalink
python parser
Browse files Browse the repository at this point in the history
  • Loading branch information
wbqpk3 committed Jul 8, 2024
1 parent b04d926 commit a34f3ad
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions plugins/python/parser/src/pythonparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ PythonParser::PythonParser(ParserContext& ctx_): AbstractParser(ctx_)
// Init PyService module
try {
m_py_module = python::import("parser");

// DEBUG
m_py_module.attr("hello")();
}catch (const python::error_already_set&)
{
PyErr_Print();
Expand All @@ -48,10 +45,21 @@ bool PythonParser::parse()
{
LOG(info) << "PythonParser parse path: " << currPath_;

model::FilePtr pyfile = _ctx.srcMgr.getFile(currPath_);
pyfile->parseStatus = model::File::ParseStatus::PSFullyParsed;
pyfile->type = "PY";
_ctx.srcMgr.updateFile(*pyfile);
try {
bool parsed = python::extract<bool>(m_py_module.attr("parse")(currPath_));

if(parsed)
{
model::FilePtr pyfile = _ctx.srcMgr.getFile(currPath_);
pyfile->parseStatus = model::File::ParseStatus::PSFullyParsed;
pyfile->type = "PY";
_ctx.srcMgr.updateFile(*pyfile);
}

}catch (const python::error_already_set&)
{
PyErr_Print();
}
}

return true;
Expand Down

0 comments on commit a34f3ad

Please sign in to comment.