mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Add a Singleton metaclass, use it with Display (#48935)
* Add a Singleton class, use it with Display * update six import * Move remaining failes to display singleton * Fix rebase issues * Singleton improvements * Add code-smell for 'from __main__ import display'. ci_complete * s/self/cls/g * Add docs for no-main-display * Address linting issues * Add changelog fragment. ci_complete * Implement reentrant lock for class instantiation in Singleton * Add Display singleton porting guide
This commit is contained in:
parent
54a2f21f93
commit
9773a1f289
149 changed files with 407 additions and 766 deletions
|
@ -20,8 +20,8 @@ from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_va
|
|||
def _warning(msg):
|
||||
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
|
||||
try:
|
||||
from __main__ import display
|
||||
display.warning(msg)
|
||||
from ansible.utils.display import Display
|
||||
Display().warning(msg)
|
||||
except Exception:
|
||||
import sys
|
||||
sys.stderr.write(' [WARNING] %s\n' % (msg))
|
||||
|
@ -30,8 +30,8 @@ def _warning(msg):
|
|||
def _deprecated(msg, version='2.8'):
|
||||
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
|
||||
try:
|
||||
from __main__ import display
|
||||
display.deprecated(msg, version=version)
|
||||
from ansible.utils.display import Display
|
||||
Display().deprecated(msg, version=version)
|
||||
except Exception:
|
||||
import sys
|
||||
sys.stderr.write(' [DEPRECATED] %s, to be removed in %s\n' % (msg, version))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue