MCPcopy Create free account
hub / github.com/Sigil-Ebook/Sigil / GetSingleReplacementByFunction

Method GetSingleReplacementByFunction

src/EmbedPython/PythonRoutines.cpp:511–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509
510
511QString PythonRoutines::GetSingleReplacementByFunction(PyObjectPtr FSO,
512 const QString& bookpath,
513 const QString& text,
514 const QList<std::pair<int,int> > capture_groups)
515{
516 if (FSO.isNull()) {
517 fprintf(stderr, "get_single_replacement_by_function error - null Search Environment\n");
518 return text;
519 }
520 int rv = 0;
521 QString traceback;
522 QList<QVariant> args;
523 EmbeddedPython* epp = EmbeddedPython::instance();
524 args.append(QVariant(bookpath));
525 args.append(QVariant(text));
526 QList<QVariant> groups;
527 for (int i=0; i < capture_groups.size(); i++) {
528 std::pair<int, int> pi = capture_groups.at(i);
529 QVariant v = QVariant::fromValue(pi);
530 groups.append(v);
531 }
532 args.append(QVariant(groups));
533
534 QVariant res = epp->callPyObjMethod(FSO, QString("get_single_replacement_by_function"), args, &rv, traceback);
535 if (rv) {
536 fprintf(stderr, "get_single_replacement_by_function error %d traceback %s\n",rv, traceback.toStdString().c_str());
537 }
538 return res.toString();
539}
540
541
542bool PythonRoutines::CreateUserJsonFileInPython()

Callers 2

replaceTextMethod · 0.80
functionReplaceTextMethod · 0.80

Calls 5

isNullMethod · 0.80
appendMethod · 0.80
callPyObjMethodMethod · 0.80
QStringClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected