Dans la série suppression des liens symboliques : /usr/scripts/lib devient /usr/scripts/cranslib
* Comme ça c'est plus clair que c'est un truc custom crans * Le lien symbolique /usr/scripts/gestion/crans/ est retiré. D'autres suivront.
This commit is contained in:
parent
c57795f23b
commit
10275229a1
35 changed files with 20 additions and 29 deletions
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import warnings
|
||||
import functools
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
def deprecated(replace=None):
|
||||
'''This is a decorator which can be used to mark functions
|
||||
as deprecated. It will result in a warning being emitted
|
||||
when the function is used.'''
|
||||
|
||||
warnings.resetwarnings()
|
||||
|
||||
if replace == None:
|
||||
instead = ""
|
||||
elif isinstance(replace, str) or isinstance(replace, unicode):
|
||||
instead = " " + replace
|
||||
else:
|
||||
instead = " Use %s instead." % (replace.__name__,)
|
||||
|
||||
def real_decorator(func):
|
||||
"""Nested because a decorator with a parameter has to be coded this way"""
|
||||
@functools.wraps(func)
|
||||
def new_func(*args, **kwargs):
|
||||
warnings.warn_explicit(
|
||||
"Call to deprecated function %s.%s" % (func.__name__, instead),
|
||||
category=DeprecationWarning,
|
||||
filename=func.func_code.co_filename,
|
||||
lineno=func.func_code.co_firstlineno + 1
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
return new_func
|
||||
return real_decorator
|
||||
|
||||
|
||||
def module(replace=None):
|
||||
"""À appeler dans un module déprécié"""
|
||||
|
||||
warnings.resetwarnings()
|
||||
|
||||
# On récupère le nom du module appelant la fonction
|
||||
frm = inspect.stack()[1]
|
||||
mod = inspect.getmodule(frm[0])
|
||||
if mod and mod.__name__ != '__main__':
|
||||
module_name = mod.__name__
|
||||
else:
|
||||
module_name = sys.argv[0]
|
||||
|
||||
if replace == None:
|
||||
instead = ""
|
||||
elif isinstance(replace, str) or isinstance(replace, unicode):
|
||||
instead = " " + replace
|
||||
else:
|
||||
instead = " Use %s instead." % (replace.__name__,)
|
||||
|
||||
warnings.warn(
|
||||
"Call to deprecated module %s.%s" % (module_name, instead),
|
||||
category=DeprecationWarning,
|
||||
stacklevel=3
|
||||
)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue