From cd65cc102a30c63b0081424695f0c91852206c35 Mon Sep 17 00:00:00 2001 From: Richard Neumann Date: Mon, 14 Feb 2022 13:10:03 +0100 Subject: [PATCH] Add legacy interface with deprecation warnings --- rcon/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rcon/__init__.py b/rcon/__init__.py index 89b54e0..dff29c7 100644 --- a/rcon/__init__.py +++ b/rcon/__init__.py @@ -1 +1,27 @@ """RCON client library.""" + +from warnings import warn + +from rcon.source import rcon as _rcon +from rcon.source import Client as _Client + + +class Client(_Client): + """Backwards compatibility.""" + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + warn( + 'rcon.Client() is deprecated. Use rcon.source.Client() instead.', + DeprecationWarning + ) + + +async def rcon(*args, **kwargs) -> str: + """Backwards compatibility.""" + + warn( + 'rcon.rcon() is deprecated. Use rcon.source.rcon() instead.', + DeprecationWarning + ) + return await _rcon(*args, **kwargs)