Module fpdf.deprecation
Utilities to manage deprecation errors & warnings.
The contents of this module are internal to fpdf2, and not part of the public API. They may change at any time without prior warning or any deprecation period, in non-backward-compatible ways.
Functions
def get_stack_level() ‑> int
-
Get the first place in the call stack that is not inside fpdf2
def support_deprecated_txt_arg(fn)
-
Decorator converting
txt=
arguments intotext=
arguments
Classes
class WarnOnDeprecatedModuleAttributes (*args, **kwargs)
-
Create a module object.
The name must be a string; the optional doc argument can have any type.
Expand source code Browse git
class WarnOnDeprecatedModuleAttributes(ModuleType): def __call__(self): raise TypeError( "You tried to instantied the fpdf module." " You probably want to import the FPDF class instead:" " from fpdf import FPDF" ) def __getattr__(self, name): if name in ("FPDF_CACHE_DIR", "FPDF_CACHE_MODE"): warnings.warn( ( "fpdf.FPDF_CACHE_DIR & fpdf.FPDF_CACHE_MODE" " have been deprecated in favour of" " FPDF(font_cache_dir=...)" ), DeprecationWarning, stacklevel=get_stack_level(), ) return None return super().__getattribute__(name) def __setattr__(self, name, value): if name in ("FPDF_CACHE_DIR", "FPDF_CACHE_MODE"): warnings.warn( ( "fpdf.FPDF_CACHE_DIR & fpdf.FPDF_CACHE_MODE" " have been deprecated in favour of" " FPDF(font_cache_dir=...)" ), DeprecationWarning, stacklevel=get_stack_level(), ) return super().__setattr__(name, value)
Ancestors
- builtins.module