__res.pyx 623 B

12345678910111213141516171819202122232425262728293031
  1. from libcpp cimport bool
  2. from util.generic.string cimport TString, TStringBuf
  3. cdef extern from "library/cpp/resource/resource.h" namespace "NResource":
  4. cdef size_t Count() except +
  5. cdef TStringBuf KeyByIndex(size_t idx) except +
  6. cdef bool FindExact(const TStringBuf key, TString* result) nogil except +
  7. def count():
  8. return Count()
  9. def key_by_index(idx):
  10. cdef TStringBuf ret = KeyByIndex(idx)
  11. return ret.Data()[:ret.Size()]
  12. def find(s):
  13. cdef TString res
  14. if FindExact(TStringBuf(s, len(s)), &res):
  15. return res.c_str()[:res.length()]
  16. return None
  17. include "importer.pxi"