LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Classes | Functions | Variables
lsst.daf.persistence.deprecation Namespace Reference

Classes

class  Deprecator
 

Functions

def deprecateGen2 (component=None)
 
def deprecate_class (cls)
 

Variables

bool always_warn = False
 

Function Documentation

◆ deprecate_class()

def lsst.daf.persistence.deprecation.deprecate_class (   cls)

Definition at line 151 of file deprecation.py.

151def deprecate_class(cls):
152 return Deprecator()(cls)

◆ deprecateGen2()

def lsst.daf.persistence.deprecation.deprecateGen2 (   component = None)
Issue deprecation warning for Butler.

Parameters
----------
component : `str`, optional
    Name of component to warn about. If `None` will only issue a warning
    if no other warnings have been issued.

Notes
-----
The package variable `lsst.daf.persistence.deprecation.always_warn` can be
set to `True` to always issue a warning rather than only issuing
on first encounter. If set to `None` only a single message will ever
be issued.

Definition at line 52 of file deprecation.py.

52def deprecateGen2(component=None):
53 """Issue deprecation warning for Butler.
54
55 Parameters
56 ----------
57 component : `str`, optional
58 Name of component to warn about. If `None` will only issue a warning
59 if no other warnings have been issued.
60
61 Notes
62 -----
63 The package variable `lsst.daf.persistence.deprecation.always_warn` can be
64 set to `True` to always issue a warning rather than only issuing
65 on first encounter. If set to `None` only a single message will ever
66 be issued.
67 """
68 global _issued
69
70 if always_warn:
71 # Sidestep all the logic and always issue the warning
72 pass
73 elif always_warn is None and _issued:
74 # We have already issued so return immediately
75 return
76 else:
77 # Either we've already issued a warning for this component
78 # or it's a null component and we've issued something already.
79 # In this situation we do not want to warn again.
80 if _issued.get(component, False) or (component is None and _issued):
81 return
82
83 # Calculate a stacklevel that pops the warning out of daf_persistence
84 # and into user code.
85 stacklevel = 3 # Default to the caller's caller
86 stack = traceback.extract_stack()
87 for i, s in enumerate(reversed(stack)):
88 if not ("python/lsst/daf/persistence" in s.filename or "python/lsst/obs/base" in s.filename):
89 stacklevel = i + 1
90 break
91
92 label = ""
93 if component is not None and always_warn is not None:
94 label = f" ({component})"
95
96 warnings.warn(_warning_msg.format(label=label), category=FutureWarning, stacklevel=stacklevel)
97 _issued[component] = True
98
99
def deprecateGen2(component=None)
Definition: deprecation.py:52

Variable Documentation

◆ always_warn

bool lsst.daf.persistence.deprecation.always_warn = False

Definition at line 29 of file deprecation.py.