@@ -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,15 +231,17 @@ 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
237243
238- def append_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' ):
244+ def append_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' , warn_exists = True ):
239245 """
240246 Generate append-path statements for the given list of paths.
241247
@@ -244,14 +250,15 @@ def append_paths(self, key, paths, allow_abs=False, expand_relpaths=True, delim=
244250 :param allow_abs: allow providing of absolute paths
245251 :param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
246252 :param delim: delimiter used between paths
253+ :param warn_exists: Show a warning if any path was already added to the variable
247254 """
248- paths = self ._filter_paths (key , paths )
255+ paths = self ._filter_paths (key , paths , warn_exists = warn_exists )
249256 if paths is None :
250257 return ''
251258 return self .update_paths (key , paths , prepend = False , allow_abs = allow_abs , expand_relpaths = expand_relpaths ,
252259 delim = delim )
253260
254- def prepend_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' ):
261+ def prepend_paths (self , key , paths , allow_abs = False , expand_relpaths = True , delim = ':' , warn_exists = True ):
255262 """
256263 Generate prepend-path statements for the given list of paths.
257264
@@ -260,8 +267,9 @@ def prepend_paths(self, key, paths, allow_abs=False, expand_relpaths=True, delim
260267 :param allow_abs: allow providing of absolute paths
261268 :param expand_relpaths: expand relative paths into absolute paths (by prefixing install dir)
262269 :param delim: delimiter used between paths
270+ :param warn_exists: Show a warning if any path was already added to the variable
263271 """
264- paths = self ._filter_paths (key , paths )
272+ paths = self ._filter_paths (key , paths , warn_exists = warn_exists )
265273 if paths is None :
266274 return ''
267275 return self .update_paths (key , paths , prepend = True , allow_abs = allow_abs , expand_relpaths = expand_relpaths ,
0 commit comments