Skip to content

Commit

Permalink
@deprecated warning display can be toggled off (#795)
Browse files Browse the repository at this point in the history
* `@deprecated` warning display can be toggled off

* `show_deprecated_warnings` -> `show_deprecation_warnings`
  • Loading branch information
hugsy committed Jan 18, 2022
1 parent d162004 commit 9560041
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,11 @@ def deprecated(solution: str = "") -> Callable:
def decorator(f: Callable) -> Callable:
@functools.wraps(f)
def wrapper(*args: Tuple, **kwargs: Dict) -> Any:
msg = f"'{f.__name__}' is deprecated and will be removed in a feature release. "
if solution:
msg += solution
warn(msg)
if gef.config["gef.show_deprecation_warnings"] is True:
msg = f"'{f.__name__}' is deprecated and will be removed in a feature release. "
if solution:
msg += solution
warn(msg)
return f(*args, **kwargs)

if not wrapper.__doc__:
Expand Down Expand Up @@ -10480,6 +10481,7 @@ def __init__(self) -> None:
gef.config["gef.extra_plugins_dir"] = GefSetting("", str, "Autoload additional GEF commands from external directory")
gef.config["gef.disable_color"] = GefSetting(False, bool, "Disable all colors in GEF")
gef.config["gef.tempdir"] = GefSetting(GEF_TEMP_DIR, str, "Directory to use for temporary/cache content")
gef.config["gef.show_deprecation_warnings"] = GefSetting(True, bool, "Toggle the display of the `deprecated` warnings")
self.loaded_commands = []
self.loaded_functions = []
self.missing_commands = {}
Expand Down

0 comments on commit 9560041

Please sign in to comment.