Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup xrdutil #663

Merged
merged 16 commits into from
Jul 3, 2024
35 changes: 35 additions & 0 deletions hexrd/deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
import functools


class DeprecatedFunctionError(Exception):
"""Custom exception for deprecated functions."""
pass


def deprecated(new_func: str = None, removal_date: str = None):
"""
Decorator to mark functions as deprecated. Raises an error if
the 'ACK_DEPRECATED' environment variable is not set. Alerts the
user to the replacement function if provided.
"""

def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if new_func is not None:
print(

Check warning on line 21 in hexrd/deprecation.py

View check run for this annotation

Codecov / codecov/patch

hexrd/deprecation.py#L20-L21

Added lines #L20 - L21 were not covered by tests
f"Warning: {func.__name__} is deprecated and is marked for"
f" removal. Please use {new_func} instead."
f" Removal date: {removal_date}"
)
if os.getenv('ACK_DEPRECATED') != 'true':
raise DeprecatedFunctionError(

Check warning on line 27 in hexrd/deprecation.py

View check run for this annotation

Codecov / codecov/patch

hexrd/deprecation.py#L26-L27

Added lines #L26 - L27 were not covered by tests
f"Function {func.__name__} is deprecated. Set environment "
"variable 'ACK_DEPRECATED' to 'true' to acknowledge."
)
return func(*args, **kwargs)

Check warning on line 31 in hexrd/deprecation.py

View check run for this annotation

Codecov / codecov/patch

hexrd/deprecation.py#L31

Added line #L31 was not covered by tests

return wrapper

return decorator
2 changes: 1 addition & 1 deletion hexrd/findorientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@
map_fname
)

eta_ome.save(fn)
eta_ome.save_eta_ome_maps(fn)

Check warning on line 595 in hexrd/findorientations.py

View check run for this annotation

Codecov / codecov/patch

hexrd/findorientations.py#L595

Added line #L595 was not covered by tests

logger.info('saved eta/ome orientation maps to "%s"', fn)

Expand Down
Loading
Loading