/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/python/runtime_py3/__res.pyx
36 строк
730 B
wilytiger
support building opensource nbs with ya make
09 окт 2023, 17:33
09 окт 2023, 17:33
759d542
Код
Авторство
О чём код?
from _codecs import utf_8_decode, utf_8_encode from libcpp cimport bool from util.generic.string cimport TString, TStringBuf cdef extern from "library/cpp/resource/resource.h" namespace "NResource": cdef size_t Count() except + cdef TStringBuf KeyByIndex(size_t idx) except + cdef bool FindExact(const TStringBuf key, TString* result) nogil except + def count(): return Count() def key_by_index(idx): cdef TStringBuf ret = KeyByIndex(idx) return ret.Data()[:ret.Size()] def find(s): cdef TString res if isinstance(s, str): s = utf_8_encode(s)[0] if FindExact(TStringBuf(s, len(s)), &res): return res.c_str()[:res.length()] return None include "importer.pxi"