@@ -206,8 +206,12 @@ def get_modules_path(self, fake=False, mod_path_suffix=None):
206206
207207 return os .path .join (mod_path , mod_path_suffix )
208208
209- def _filter_paths (self , key , paths ):
210- """Filter out paths already added to key and return the remaining ones"""
209+ def _filter_paths (self , key , paths , warn_exists = True ):
210+ """
211+ Filter out paths already added to key and return the remaining ones
212+
213+ :param warn_exists: Show a warning for paths already added to the key
214+ """
211215 if self .added_paths_per_key is None :
212216 # For compatibility this is only a warning for now and we don't filter any paths
213217 print_warning ('Module creation has not been started. Call start_module_creation first!' )
@@ -227,10 +231,12 @@ def _filter_paths(self, key, paths):
227231 paths = list (paths )
228232 filtered_paths = [x for x in paths if x not in added_paths and not added_paths .add (x )]
229233 if filtered_paths != paths :
230- removed_paths = paths if filtered_paths is None else [x for x in paths if x not in filtered_paths ]
231- print_warning ("Suppressed adding the following path(s) to $%s of the module as they were already added: %s" ,
232- key , removed_paths ,
233- log = self .log )
234+ if warn_exists :
235+ removed_paths = paths if filtered_paths is None else [x for x in paths if x not in filtered_paths ]
236+ print_warning ("Suppressed adding the following path(s) to $%s of the module "
237+ "as they were already added: %s" ,
238+ key , removed_paths ,
239+ log = self .log )
234240 if not filtered_paths :
235241 filtered_paths = None
236242 return filtered_paths
@@ -251,7 +257,7 @@ def append_paths(self, key, paths, allow_abs=False, expand_relpaths=True, delim=
251257 return self .update_paths (key , paths , prepend = False , allow_abs = allow_abs , expand_relpaths = expand_relpaths ,
252258 delim = delim )
253259
254- def prepend_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' ):
260+ def prepend_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' , warn_exists = True ):
255261 """
256262 Generate prepend-path statements for the given list of paths.
257263
@@ -260,8 +266,9 @@ def prepend_paths(self, key, paths, allow_abs=False, expand_relpaths=True, delim
260266 :param allow_abs: allow providing of absolute paths
261267 :param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
262268 :param delim: delimiter used between paths
269+ :param warn_exists: Show a warning if any path was already added to the variable
263270 """
264- paths = self ._filter_paths (key , paths )
271+ paths = self ._filter_paths (key , paths , warn_exists = warn_exists )
265272 if paths is None :
266273 return ''
267274 return self .update_paths (key , paths , prepend = True , allow_abs = allow_abs , expand_relpaths = expand_relpaths ,
0 commit comments