diff options
| author | say <[email protected]> | 2023-03-31 10:07:15 +0300 | 
|---|---|---|
| committer | say <[email protected]> | 2023-03-31 10:07:15 +0300 | 
| commit | e163b69a87c70baac07bd99142916735e0c283fa (patch) | |
| tree | 73e22c0f9e975ff6dc70f38534ec84588587d25c /library/python/codecs/__codecs.pyx | |
| parent | 6be8bf780352147bcac5afec43505883b69229a0 (diff) | |
Swith flake8 to custom lint schema
Diffstat (limited to 'library/python/codecs/__codecs.pyx')
| -rw-r--r-- | library/python/codecs/__codecs.pyx | 61 | 
1 files changed, 0 insertions, 61 deletions
diff --git a/library/python/codecs/__codecs.pyx b/library/python/codecs/__codecs.pyx deleted file mode 100644 index 42ec37fe886..00000000000 --- a/library/python/codecs/__codecs.pyx +++ /dev/null @@ -1,61 +0,0 @@ -import six - -from libcpp cimport bool - -from util.generic.string cimport TString, TStringBuf - - -def to_bytes(s): -    try: -        return s.encode('utf-8') -    except AttributeError: -        pass - -    return s - - -def from_bytes(s): -    if six.PY3: -        return s.decode('utf-8') - -    return s - - -cdef extern from "library/cpp/blockcodecs/codecs.h" namespace "NBlockCodecs": -    cdef cppclass ICodec: -        void Encode(TStringBuf data, TString& res) nogil -        void Decode(TStringBuf data, TString& res) nogil - -    cdef const ICodec* Codec(const TStringBuf& name) except + -    cdef TString ListAllCodecsAsString() except + - - -def dumps(name, data): -    name = to_bytes(name) - -    cdef const ICodec* codec = Codec(TStringBuf(name, len(name))) -    cdef TString res -    cdef TStringBuf cdata = TStringBuf(data, len(data)) - -    with nogil: -        codec.Encode(cdata, res) - -    return res.c_str()[:res.length()] - - -def loads(name, data): -    name = to_bytes(name) - -    cdef const ICodec* codec = Codec(TStringBuf(name, len(name))) -    cdef TString res -    cdef TStringBuf cdata = TStringBuf(data, len(data)) - -    with nogil: -        codec.Decode(cdata, res) - -    return res.c_str()[:res.length()] - -def list_all_codecs(): -    cdef TString res = ListAllCodecsAsString() - -    return from_bytes(res.c_str()[:res.length()]).split(',')  | 
