Skip to content

Commit 0a5d441

Browse files
committed
add deprecator
1 parent 2316eaa commit 0a5d441

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/diffpy/structure/__init__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
* SymmetryError
3434
"""
3535

36-
# Interface definitions ------------------------------------------------------
3736

37+
import sys
38+
39+
import diffpy.structure as _structure
3840
from diffpy.structure.atom import Atom
3941
from diffpy.structure.lattice import Lattice
4042
from diffpy.structure.parsers import getParser
@@ -45,6 +47,28 @@
4547
# package version
4648
from diffpy.structure.version import __version__
4749

50+
# Deprecations -------------------------------------------------------
51+
# Only use the backport for module shims
52+
53+
54+
# @deprecated
55+
# custom deprecator for diffpy.Structure module
56+
class DeprecatedStructureModule:
57+
"""Proxy for backward compatibility of diffpy.Structure."""
58+
59+
def __getattr__(self, name):
60+
import warnings
61+
62+
warnings.warn(
63+
"Module 'diffpy.Structure' is deprecated. Use 'diffpy.structure' instead.",
64+
DeprecationWarning,
65+
stacklevel=2,
66+
)
67+
return getattr(_structure, name)
68+
69+
70+
sys.modules["diffpy.Structure"] = DeprecatedStructureModule()
71+
4872
# top level routines
4973

5074

0 commit comments

Comments
 (0)