33
44import traceback
55import types
6+ import warnings
67
78from colcon_core .logging import colcon_logger
89from colcon_core .plugin_system import instantiate_extensions
@@ -108,11 +109,23 @@ def __init__(self, parser, **kwargs):
108109 """
109110 assert '_parser' not in kwargs
110111 kwargs ['_parser' ] = parser
111- assert '_nested_decorators' not in kwargs
112- kwargs ['_nested_decorators' ] = []
112+ assert '_nested_decorators_' not in kwargs
113+ kwargs ['_nested_decorators_' ] = []
114+ assert '_group_decorators' not in kwargs
115+ kwargs ['_group_decorators' ] = []
116+ assert '_recursive_decorators' not in kwargs
117+ kwargs ['_recursive_decorators' ] = []
113118 for k , v in kwargs .items ():
114119 self .__dict__ [k ] = v
115120
121+ @property
122+ def _nested_decorators (self ):
123+ warnings .warn (
124+ 'colcon_core.argument_parser.ArgumentParserDecorator.'
125+ '_nested_decorators is a private variable and has been '
126+ 'deprecated' , stacklevel = 2 )
127+ return self ._nested_decorators_
128+
116129 def __getattr__ (self , name ):
117130 """
118131 Get an attribute from this decorator if it exists or the decoree.
@@ -157,7 +170,8 @@ def add_argument_group(self, *args, **kwargs):
157170 """
158171 group = self .__class__ (
159172 self ._parser .add_argument_group (* args , ** kwargs ))
160- self ._nested_decorators .append (group )
173+ self ._nested_decorators_ .append (group )
174+ self ._group_decorators .append (group )
161175 return group
162176
163177 def add_mutually_exclusive_group (self , * args , ** kwargs ):
@@ -169,7 +183,8 @@ def add_mutually_exclusive_group(self, *args, **kwargs):
169183 """
170184 group = self .__class__ (
171185 self ._parser .add_mutually_exclusive_group (* args , ** kwargs ))
172- self ._nested_decorators .append (group )
186+ self ._nested_decorators_ .append (group )
187+ self ._group_decorators .append (group )
173188 return group
174189
175190 def add_parser (self , * args , ** kwargs ):
@@ -181,7 +196,8 @@ def add_parser(self, *args, **kwargs):
181196 """
182197 parser = self .__class__ (
183198 self ._parser .add_parser (* args , ** kwargs ))
184- self ._nested_decorators .append (parser )
199+ self ._nested_decorators_ .append (parser )
200+ self ._recursive_decorators .append (parser )
185201 return parser
186202
187203 def add_subparsers (self , * args , ** kwargs ):
@@ -193,7 +209,8 @@ def add_subparsers(self, *args, **kwargs):
193209 """
194210 subparser = self .__class__ (
195211 self ._parser .add_subparsers (* args , ** kwargs ))
196- self ._nested_decorators .append (subparser )
212+ self ._nested_decorators_ .append (subparser )
213+ self ._recursive_decorators .append (subparser )
197214 return subparser
198215
199216
0 commit comments