Skip to content

Commit

Permalink
Expanded compatibility layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Oct 14, 2024
1 parent 972e108 commit a0d42ec
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pysmi/reader/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright (c) 2015-2020, Ilya Etingof <[email protected]>
# License: https://www.pysnmp.com/pysmi/license.html
#
import warnings
from urllib import parse as urlparse
from urllib.request import url2pathname

Expand Down Expand Up @@ -41,3 +42,19 @@ def get_readers_from_urls(*sourceUrls, **options):
raise error.PySmiError(f"Unsupported URL scheme {sourceUrl}")

return readers


# Compatibility API
deprecated_attributes = {
"getReadersFromUrls": "get_readers_from_urls",
}


def __getattr__(attr: str):
"""Handle deprecated attributes."""
if newAttr := deprecated_attributes.get(attr):
warnings.warn(
f"{attr} is deprecated. Please use {newAttr} instead.", DeprecationWarning
)
return globals()[newAttr]
raise AttributeError(f"module {__name__} has no attribute {attr}")

0 comments on commit a0d42ec

Please sign in to comment.