aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/runtime/__res.pyx
blob: 5e2e72abf39d1c6c1d4051560de205866926f2a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 FindExact(TStringBuf(s, len(s)), &res):
        return res.c_str()[:res.length()]

    return None


include "importer.pxi"