forked from etingof/pysmi
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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}") |