MCPcopy Create free account
hub / github.com/bab2min/tomotopy / getattro

Method getattro

src/python/handler/py_utils.cpp:915–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915py::UniqueObj DocumentObject::getattro(PyObject* attr) const
916{
917 if (!corpus->isIndependent()) return py::UniqueObj{ PyObject_GenericGetAttr((PyObject*)this, attr) };
918 std::string a;
919 if (!py::toCpp<std::string>(attr, a)) throw py::AttributeError{ "invalid attribute name" };
920 string name = a;
921 auto it = getRawDoc()->misc.find(name);
922 if (it == getRawDoc()->misc.end()) return py::UniqueObj{ PyObject_GenericGetAttr((PyObject*)this, attr) };
923 auto ret = py::UniqueObj{ (PyObject*)std::get<std::shared_ptr<void>>(it->second).get() };
924 Py_INCREF(ret.get());
925 return ret;
926}
927
928std::string DocumentObject::repr() const
929{

Callers

nothing calls this directly

Calls 3

isIndependentMethod · 0.80
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected