feat: add warning class
This commit is contained in:
parent
fbba016007
commit
64e2d137c5
4 changed files with 21 additions and 5 deletions
|
|
@ -116,14 +116,20 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
continue
|
||||
if variable.type in RENAME_TYPE:
|
||||
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use "{RENAME_TYPE[variable.type]}" instead in {display_xmlfiles(variable.xmlfiles)}'
|
||||
warn(warning)
|
||||
warn(warning,
|
||||
DeprecationWarning,
|
||||
)
|
||||
variable.type = RENAME_TYPE[variable.type]
|
||||
if variable.type == 'cidr':
|
||||
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use type "ip" with attribute cidr=True instead in {display_xmlfiles(variable.xmlfiles)}'
|
||||
warn(warning)
|
||||
warn(warning,
|
||||
DeprecationWarning,
|
||||
)
|
||||
if variable.type == 'network_cidr':
|
||||
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use type "network" with attribute cidr=True instead in {display_xmlfiles(variable.xmlfiles)}'
|
||||
warn(warning)
|
||||
warn(warning,
|
||||
DeprecationWarning,
|
||||
)
|
||||
self.objectspace.informations.add(
|
||||
variable.path, "ymlfiles", variable.xmlfiles
|
||||
)
|
||||
|
|
|
|||
|
|
@ -585,7 +585,10 @@ class ParserVariable:
|
|||
del family["variable"]
|
||||
if self.version != "1.0":
|
||||
warning = f'"variable" attribute in dynamic family "{ path }" is depreciated in {filename}'
|
||||
warn(warning)
|
||||
warn(warning,
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
if "variable" in family:
|
||||
raise Exception(
|
||||
f'dynamic family must not have "variable" attribute for "{family["path"]}" in {family["xmlfiles"]}'
|
||||
|
|
|
|||
|
|
@ -307,7 +307,10 @@ class JinjaCalculation(Calculation):
|
|||
objectspace.jinja[jinja_path] = self.jinja
|
||||
if return_type in RENAME_TYPE:
|
||||
warning = f'the variable "{ self.path }" has a depreciated return_type "{return_type}", please use "{RENAME_TYPE[return_type]}" instead in {display_xmlfiles(variable.xmlfiles)}'
|
||||
warn(warning)
|
||||
warn(warning,
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return_type = RENAME_TYPE[return_type]
|
||||
default = {
|
||||
"function": function,
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ class ExtentionError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class RougailWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
## ---- specific exceptions ----
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue