@@ -264,18 +264,18 @@ def read_gitmodules_file(root_dir, file_name):
264
264
return externals_description
265
265
266
266
def create_externals_description (
267
- model_data , model_format = 'cfg' , components = None , parent_repo = None ):
267
+ model_data , model_format = 'cfg' , components = None , exclude = None , parent_repo = None ):
268
268
"""Create the a externals description object from the provided data
269
269
"""
270
270
externals_description = None
271
271
if model_format == 'dict' :
272
272
externals_description = ExternalsDescriptionDict (
273
- model_data , components = components )
273
+ model_data , components = components , exclude = exclude )
274
274
elif model_format == 'cfg' :
275
275
major , _ , _ = get_cfg_schema_version (model_data )
276
276
if major == 1 :
277
277
externals_description = ExternalsDescriptionConfigV1 (
278
- model_data , components = components , parent_repo = parent_repo )
278
+ model_data , components = components , exclude = exclude , parent_repo = parent_repo )
279
279
else :
280
280
msg = ('Externals description file has unsupported schema '
281
281
'version "{0}".' .format (major ))
@@ -710,7 +710,7 @@ class ExternalsDescriptionDict(ExternalsDescription):
710
710
711
711
"""
712
712
713
- def __init__ (self , model_data , components = None ):
713
+ def __init__ (self , model_data , components = None , exclude = None ):
714
714
"""Parse a native dictionary into a externals description.
715
715
"""
716
716
ExternalsDescription .__init__ (self )
@@ -725,6 +725,10 @@ def __init__(self, model_data, components=None):
725
725
for key in model_data .items ():
726
726
if key not in components :
727
727
del model_data [key ]
728
+ if exclude :
729
+ for key in model_data .items ():
730
+ if key in exclude :
731
+ del model_data [key ]
728
732
729
733
self .update (model_data )
730
734
self ._check_user_input ()
@@ -736,7 +740,7 @@ class ExternalsDescriptionConfigV1(ExternalsDescription):
736
740
737
741
"""
738
742
739
- def __init__ (self , model_data , components = None , parent_repo = None ):
743
+ def __init__ (self , model_data , components = None , exclude = None , parent_repo = None ):
740
744
"""Convert the config data into a standardized dict that can be used to
741
745
construct the source objects
742
746
@@ -749,7 +753,7 @@ def __init__(self, model_data, components=None, parent_repo=None):
749
753
get_cfg_schema_version (model_data )
750
754
self ._verify_schema_version ()
751
755
self ._remove_metadata (model_data )
752
- self ._parse_cfg (model_data , components = components )
756
+ self ._parse_cfg (model_data , components = components , exclude = exclude )
753
757
self ._check_user_input ()
754
758
755
759
@staticmethod
@@ -761,7 +765,7 @@ def _remove_metadata(model_data):
761
765
"""
762
766
model_data .remove_section (DESCRIPTION_SECTION )
763
767
764
- def _parse_cfg (self , cfg_data , components = None ):
768
+ def _parse_cfg (self , cfg_data , components = None , exclude = None ):
765
769
"""Parse a config_parser object into a externals description.
766
770
"""
767
771
def list_to_dict (input_list , convert_to_lower_case = True ):
@@ -778,7 +782,7 @@ def list_to_dict(input_list, convert_to_lower_case=True):
778
782
779
783
for section in cfg_data .sections ():
780
784
name = config_string_cleaner (section .lower ().strip ())
781
- if components and name not in components :
785
+ if ( components and name not in components ) or ( exclude and name in exclude ) :
782
786
continue
783
787
self [name ] = {}
784
788
self [name ].update (list_to_dict (cfg_data .items (section )))
0 commit comments