Skip to content

Commit 9e79eea

Browse files
committed
chore: added deprecated decorator
1 parent f62c04e commit 9e79eea

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

cryptlex/lexfloatclient/lexfloatclient.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
import ctypes
22
import json
3+
import functools
4+
import warnings
35
from cryptlex.lexfloatclient import lexfloatclient_native as LexFloatClientNative
46
from cryptlex.lexfloatclient.lexfloatstatus_codes import LexFloatStatusCodes
57
from cryptlex.lexfloatclient.lexfloatclient_exception import LexFloatClientException
68

79
callback_list = []
810

11+
def deprecated(alternative):
12+
"""This is a decorator which can be used to mark functions as deprecated.
13+
It will result in a warning being emitted when the function is used.
14+
15+
Args:
16+
alternative (str): Name of the alternative function to use
17+
"""
18+
def decorator(func):
19+
@functools.wraps(func)
20+
def wrapper(*args, **kwargs):
21+
warnings.warn(
22+
f"The function {func.__name__}() is deprecated. Use {alternative}() instead.",
23+
category=DeprecationWarning,
24+
stacklevel=2
25+
)
26+
return func(*args, **kwargs)
27+
return wrapper
28+
return decorator
29+
930
class PermissionFlags:
1031
LF_USER = 10
1132
LF_ALL_USERS = 11
@@ -183,6 +204,7 @@ def GetHostConfig():
183204
raise LexFloatClientException(status)
184205

185206
@staticmethod
207+
@deprecated("GetHostLicenseEntitlementSetName")
186208
def GetHostProductVersionName():
187209
"""Gets the product version name.
188210
@@ -201,6 +223,7 @@ def GetHostProductVersionName():
201223
return LexFloatClientNative.byte_to_string(buffer.value)
202224

203225
@staticmethod
226+
@deprecated("GetHostLicenseEntitlementSetDisplayName")
204227
def GetHostProductVersionDisplayName():
205228
"""Gets the product version display name.
206229
@@ -219,6 +242,7 @@ def GetHostProductVersionDisplayName():
219242
return LexFloatClientNative.byte_to_string(buffer.value)
220243

221244
@staticmethod
245+
@deprecated("GetHostFeatureEntitlement")
222246
def GetHostProductVersionFeatureFlag(name):
223247
"""Gets the product version feature flag.
224248

0 commit comments

Comments
 (0)