From adc0961ea2a0ee0f48a26562080454bc8f14c961 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Sun, 19 Jan 2025 20:27:40 +0100 Subject: [PATCH] rename index methods --- python/src/addons/Index.pyx | 25 +++++++++++++++++++++++-- python/src/addons/ReadOnlyIndex.pyx | 11 ++++++++++- python/src/pxds/index.pxd | 16 ++++++++-------- python/src/pxds/read_only_index.pxd | 6 +++--- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/python/src/addons/Index.pyx b/python/src/addons/Index.pyx index 89a508cb2..8e3e0dd14 100644 --- a/python/src/addons/Index.pyx +++ b/python/src/addons/Index.pyx @@ -36,7 +36,7 @@ self.inst.get().Delete(key) - def Get (self, key, default = None): + def get (self, key, default = None): """Return the value for key if key is in the dictionary, else default.""" if isinstance(key, unicode): key = key.encode('utf-8') @@ -50,6 +50,9 @@ py_result.inst = _r return py_result + def Get(self, *args): + return call_deprecated_method("Get", "get", self.get, *args) + def __contains__(self, key): if isinstance(key, unicode): key = key.encode('utf-8') @@ -72,7 +75,7 @@ py_result.inst = _r return py_result - def MSet(self, list key_values ): + def mset(self, list key_values ): assert isinstance(key_values, list), 'arg in_0 wrong type' cdef shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]] cpp_key_values = shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]](new libcpp_vector[libcpp_pair[libcpp_utf8_string,libcpp_utf8_string]]()) cdef libcpp_pair[libcpp_utf8_string, libcpp_utf8_string] cpp_kv @@ -92,3 +95,21 @@ cpp_key_values.get().push_back(cpp_kv) self.inst.get().MSet(cpp_key_values) + + def MSet(self, *args): + return call_deprecated_method("MSet", "mset", self.mset, *args) + + def Set(self, *args): + return call_deprecated_method("Set", "set", self.set, *args) + + def GetNear(self, *args): + return call_deprecated_method("GetNear", "get_near", self.get_near, *args) + + def GetFuzzy(self, *args): + return call_deprecated_method("GetFuzzy", "get_fuzzy", self.get_fuzzy, *args) + + def Delete(self, *args): + return call_deprecated_method("Delete", "delete", self.delete, *args) + + def Flush(self, *args): + return call_deprecated_method("Flush", "flush", self.flush, *args) diff --git a/python/src/addons/ReadOnlyIndex.pyx b/python/src/addons/ReadOnlyIndex.pyx index 2861463fe..de1b3a0c6 100644 --- a/python/src/addons/ReadOnlyIndex.pyx +++ b/python/src/addons/ReadOnlyIndex.pyx @@ -1,6 +1,6 @@ - def Get (self, key, default = None): + def get (self, key, default = None): """Return the value for key if key is in the dictionary, else default.""" if isinstance(key, unicode): key = key.encode('utf-8') @@ -14,6 +14,9 @@ py_result.inst = _r return py_result + def Get(self, *args): + return call_deprecated_method("Get", "get", self.get, *args) + def __contains__(self, key): if isinstance(key, unicode): key = key.encode('utf-8') @@ -35,3 +38,9 @@ cdef Match py_result = Match.__new__(Match) py_result.inst = _r return py_result + + def GetNear(self, *args): + return call_deprecated_method("GetNear", "get_near", self.get_near, *args) + + def GetFuzzy(self, *args): + return call_deprecated_method("GetFuzzy", "get_fuzzy", self.get_fuzzy, *args) diff --git a/python/src/pxds/index.pxd b/python/src/pxds/index.pxd index 8bfeb82b9..9f078e5ce 100644 --- a/python/src/pxds/index.pxd +++ b/python/src/pxds/index.pxd @@ -12,13 +12,13 @@ cdef extern from "keyvi/index/index.h" namespace "keyvi::index": cdef cppclass Index: Index(libcpp_utf8_string) except+ # wrap-ignore Index(libcpp_utf8_string, libcpp_map[libcpp_utf8_string, libcpp_utf8_string] params) except+ # wrap-ignore - void Set(libcpp_utf8_string, libcpp_utf8_string) except+ - void MSet(shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string, libcpp_utf8_string]]]) # wrap-ignore - _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + - _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + - _MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except + - void Delete(libcpp_utf8_string) except+ - void Flush() except+ - void Flush(bool) except+ + void Set(libcpp_utf8_string, libcpp_utf8_string) except+ # wrap-as:set + void MSet(shared_ptr[libcpp_vector[libcpp_pair[libcpp_utf8_string, libcpp_utf8_string]]]) except+ # wrap-ignore + _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + # wrap-as:get_near + _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + # wrap-as:get_near + _MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except + # wrap-as:get_fuzzy + void Delete(libcpp_utf8_string) except+ # wrap-as:delete + void Flush() except+ # wrap-as:flush + void Flush(bool) except+ # wrap-as:flush bool Contains(libcpp_utf8_string) # wrap-ignore shared_ptr[Match] operator[](libcpp_utf8_string) # wrap-ignore diff --git a/python/src/pxds/read_only_index.pxd b/python/src/pxds/read_only_index.pxd index 7ccee40fc..2708a1be4 100644 --- a/python/src/pxds/read_only_index.pxd +++ b/python/src/pxds/read_only_index.pxd @@ -12,6 +12,6 @@ cdef extern from "keyvi/index/read_only_index.h" namespace "keyvi::index": ReadOnlyIndex(libcpp_utf8_string, libcpp_map[libcpp_utf8_string, libcpp_utf8_string] params) except+ bool Contains(libcpp_utf8_string) # wrap-ignore shared_ptr[Match] operator[](libcpp_utf8_string) # wrap-ignore - _MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except+ - _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + - _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + + _MatchIteratorPair GetFuzzy(libcpp_utf8_string, int32_t max_edit_distance, size_t minimum_exact_prefix) except+ # wrap-as:get_fuzzy + _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length) except + # wrap-as:get_near + _MatchIteratorPair GetNear (libcpp_utf8_string, size_t minimum_prefix_length, bool greedy) except + # wrap-as:get_near