MCPcopy Create free account
hub / github.com/catboost/catboost / Find

Function Find

library/python/runtime_py3/__res.cpp:66–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66PyObject* Find(PyObject* self[[maybe_unused]], PyObject *const* args, Py_ssize_t nargs) noexcept {
67 if (nargs != 1) {
68 PyErr_Format(PyExc_TypeError, "__res.find takes 1 positional arguments but %z were given", nargs);
69 return nullptr;
70 }
71
72 TStringBuf key;
73 if (PyUnicode_Check(args[0])) {
74 Py_ssize_t sz;
75 const char* data = PyUnicode_AsUTF8AndSize(args[0], &sz);
76 if (sz < 0) {
77 return nullptr;
78 }
79 key = {data, static_cast<size_t>(sz)};
80 } else {
81 char* data = nullptr;
82 Py_ssize_t sz;
83 if (PyBytes_AsStringAndSize(args[0], &data, &sz) != 0) {
84 return nullptr;
85 }
86 key = {data, static_cast<size_t>(sz)};
87 }
88
89 return CallWithErrorTranslation([&]{
90 TString res;
91 if (!NResource::FindExact(key, &res)) {
92 Py_RETURN_NONE;
93 }
94 return PyBytes_FromStringAndSize(res.data(), res.size());
95 });
96}
97
98PyObject* Has(PyObject* self[[maybe_unused]], PyObject *const* args, Py_ssize_t nargs) noexcept {
99 if (nargs != 1) {

Callers 15

GetPyMainFunction · 0.50
UpdateImplMethod · 0.50
IsInSetFunction · 0.50
GetConnectionMethod · 0.50
CacheConnectionMethod · 0.50
AttachStatsMethod · 0.50
AttachStatsMethod · 0.50
cgiparam.cppFile · 0.50
FormFieldMethod · 0.50
FormFieldBufMethod · 0.50
FindMethod · 0.50
FindMethod · 0.50

Calls 4

CallWithErrorTranslationFunction · 0.85
PyUnicode_AsUTF8AndSizeFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected