#NEWLINE# def warn_until( version , message , category = DeprecationWarning , stacklevel = None , _version_info_ = None , _dont_call_warnings = False ) : #NEWLINE# #INDENT# "\n    Helper function to raise a warning, by default, a ``DeprecationWarning``,\n    until the provided ``version``, after which, a ``RuntimeError`` will\n    be raised to remind the developers to remove the warning because the\n    target version has been reached.\n\n    :param version: The version info or name after which the warning becomes a\n                    ``RuntimeError``. For example ``(0, 17)`` or ``Hydrogen``\n                    or an instance of :class:`salt.version.SaltStackVersion`.\n    :param message: The warning message to be displayed.\n    :param category: The warning class to be thrown, by default\n                     ``DeprecationWarning``\n    :param stacklevel: There should be no need to set the value of\n                       ``stacklevel``. Salt should be able to do the right thing.\n    :param _version_info_: In order to reuse this function for other SaltStack\n                           projects, they need to be able to provide the\n                           version info to compare to.\n    :param _dont_call_warnings: This parameter is used just to get the\n                                functionality until the actual error is to be\n                                issued. When we're only after the salt version\n                                checks to raise a ``RuntimeError``.\n    " #NEWLINE# if ( not isinstance ( version , ( tuple , six . string_types , salt . version . SaltStackVersion ) ) ) : #NEWLINE# #INDENT# raise RuntimeError ( "The 'version' argument should be passed as a tuple, string or an instance of 'salt.version.SaltStackVersion'." ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( version , tuple ) : #NEWLINE# #INDENT# version = salt . version . SaltStackVersion ( * version ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( version , six . string_types ) : #NEWLINE# #INDENT# version = salt . version . SaltStackVersion . from_name ( version ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( stacklevel is None ) : #NEWLINE# #INDENT# stacklevel = 2 #NEWLINE# #UNINDENT# if ( _version_info_ is None ) : #NEWLINE# #INDENT# _version_info_ = salt . version . __version_info__ #NEWLINE# #UNINDENT# _version_ = salt . version . SaltStackVersion ( * _version_info_ ) #NEWLINE# if ( _version_ >= version ) : #NEWLINE# #INDENT# import inspect #NEWLINE# caller = inspect . getframeinfo ( sys . _getframe ( ( stacklevel - 1 ) ) ) #NEWLINE# raise RuntimeError ( "The warning triggered on filename '{filename}', line number {lineno}, is supposed to be shown until version {until_version} is released. Current version is now {salt_version}. Please remove the warning." . format ( filename = caller . filename , lineno = caller . lineno , until_version = version . formatted_version , salt_version = _version_ . formatted_version ) ) #NEWLINE# #UNINDENT# if ( _dont_call_warnings is False ) : #NEWLINE# #INDENT# def _formatwarning( message , category , filename , lineno , line = None ) : #NEWLINE# #INDENT# "\n            Replacement for warnings.formatwarning that disables the echoing of\n            the 'line' parameter.\n            " #NEWLINE# return '{0}:{1}: {2}: {3}\n' . format ( filename , lineno , category . __name__ , message ) #NEWLINE# #UNINDENT# saved = warnings . formatwarning #NEWLINE# warnings . formatwarning = _formatwarning #NEWLINE# warnings . warn ( message . format ( version = version . formatted_version ) , category , stacklevel = stacklevel ) #NEWLINE# warnings . formatwarning = saved