21
21
import functools
22
22
import re
23
23
import sys
24
- from typing import Any , Callable , Dict , Tuple
24
+ from typing import Any , Callable , Dict , Optional , Tuple
25
25
26
26
import gitlab .config
27
27
36
36
37
37
38
38
def register_custom_action (
39
- cls_names , mandatory : Tuple [Any , ...] = tuple (), optional : Tuple [Any , ...] = tuple ()
39
+ cls_names ,
40
+ mandatory : Tuple [Any , ...] = tuple (),
41
+ optional : Tuple [Any , ...] = tuple (),
42
+ custom_action : Optional [str ] = None ,
40
43
) -> Callable :
41
- def wrap (f ) -> Callable :
44
+ def wrap (f , custom_action : Optional [ str ] = custom_action ) -> Callable :
42
45
@functools .wraps (f )
43
46
def wrapped_f (* args , ** kwargs ):
44
47
return f (* args , ** kwargs )
@@ -57,7 +60,7 @@ def wrapped_f(*args, **kwargs):
57
60
if final_name not in custom_actions :
58
61
custom_actions [final_name ] = {}
59
62
60
- action = f .__name__ .replace ("_" , "-" )
63
+ action = custom_action or f .__name__ .replace ("_" , "-" )
61
64
custom_actions [final_name ][action ] = (mandatory , optional , in_obj )
62
65
63
66
return wrapped_f
0 commit comments