|
1 | 1 | #!/usr/bin/env python3 |
2 | | -"""SciTeX compat module — delegates to scitex-compat if available.""" |
| 2 | +"""SciTeX compat module — delegates to scitex-compat.""" |
3 | 3 |
|
4 | | -from __future__ import annotations |
5 | | - |
6 | | -import warnings |
7 | | -from functools import wraps |
8 | | -from typing import Callable |
9 | | - |
10 | | -try: |
11 | | - from scitex_compat import deprecated, notify, notify_async |
12 | | - |
13 | | - _BACKEND = "scitex-compat" |
14 | | -except ImportError: |
15 | | - |
16 | | - def deprecated(new_name: str, removal_version: str = "2.0"): |
17 | | - """Decorator to mark functions as deprecated.""" |
18 | | - |
19 | | - def decorator(func: Callable) -> Callable: |
20 | | - @wraps(func) |
21 | | - def wrapper(*args, **kwargs): |
22 | | - warnings.warn( |
23 | | - f"{func.__name__} is deprecated. " |
24 | | - f"Use {new_name} instead. " |
25 | | - f"Will be removed in v{removal_version}.", |
26 | | - DeprecationWarning, |
27 | | - stacklevel=2, |
28 | | - ) |
29 | | - return func(*args, **kwargs) |
30 | | - |
31 | | - return wrapper |
32 | | - |
33 | | - return decorator |
34 | | - |
35 | | - def notify(*args, **kwargs): |
36 | | - """Deprecated: Use scitex.notify.alert() instead.""" |
37 | | - warnings.warn( |
38 | | - "scitex.compat.notify is deprecated. Use scitex.notify.alert instead.", |
39 | | - DeprecationWarning, |
40 | | - stacklevel=2, |
41 | | - ) |
42 | | - from scitex.notify import alert |
43 | | - |
44 | | - return alert(*args, **kwargs) |
45 | | - |
46 | | - async def notify_async(*args, **kwargs): |
47 | | - """Deprecated: Use scitex.notify.alert_async() instead.""" |
48 | | - warnings.warn( |
49 | | - "scitex.compat.notify_async is deprecated. Use scitex.notify.alert_async instead.", |
50 | | - DeprecationWarning, |
51 | | - stacklevel=2, |
52 | | - ) |
53 | | - from scitex.notify import alert_async |
54 | | - |
55 | | - return await alert_async(*args, **kwargs) |
56 | | - |
57 | | - _BACKEND = "local" |
| 4 | +from scitex_compat import deprecated, notify, notify_async |
58 | 5 |
|
59 | 6 | __all__ = [ |
60 | 7 | "deprecated", |
|
0 commit comments