Fix operation line numbers for the wrapped `init.*` operations.
'''
from pyinfra import logger
+from pyinfra.api.util import get_caller_frameinfo
from . import bsdinit, launchd, server, systemd, sysvinit, upstart
def _make_legacy_operation(legacy_op, op_func):
def wrapper(*args, **kwargs):
+ frameinfo = get_caller_frameinfo()
+ kwargs['_line_number'] = frameinfo.lineno
+
logger.warning((
'The `init.{0}` operation is deprecated, '
'please us the `{1}.{2}` operation.'
@@ -27,6 +31,7 @@ def _make_legacy_operation(legacy_op, op_func):
op_func.__name__,
))
return op_func(*args, **kwargs)
+
wrapper._pyinfra_op = op_func
return wrapper
