@@ -82,22 +82,37 @@ def _resolve_output_file(output_file_arg: str | None, save: bool, output_format:
8282 return output_file , False
8383
8484
85- def _resolve_ignore_file (ignore_file_arg : str | None ) -> Path | None :
85+ def _find_in_treemapper_dir (arg : str , root_dir : Path ) -> Path | None :
86+ if Path (arg ).parent == Path ("." ):
87+ candidate = root_dir / ".treemapper" / arg
88+ if candidate .is_file ():
89+ return candidate
90+ return None
91+
92+
93+ def _resolve_ignore_file (ignore_file_arg : str | None , root_dir : Path ) -> Path | None :
8694 if not ignore_file_arg :
8795 return None
88- ignore_file = Path (ignore_file_arg ).resolve ()
89- if not ignore_file .is_file ():
96+ found = _find_in_treemapper_dir (ignore_file_arg , root_dir )
97+ if found :
98+ return found
99+ resolved = Path (ignore_file_arg ).resolve ()
100+ if not resolved .is_file ():
90101 _exit_error (f"Ignore file '{ ignore_file_arg } ' does not exist" )
91- return ignore_file
102+ return resolved
92103
93104
94- def _resolve_whitelist_file (whitelist_file_arg : str | None ) -> Path | None :
105+ def _resolve_whitelist_file (whitelist_file_arg : str | None , root_dir : Path ) -> Path | None :
95106 if not whitelist_file_arg :
96107 return None
97- whitelist_file = Path (whitelist_file_arg ).resolve ()
98- if not whitelist_file .is_file ():
99- _exit_error (f"Whitelist file '{ whitelist_file_arg } ' does not exist" )
100- return whitelist_file
108+ found = _find_in_treemapper_dir (whitelist_file_arg , root_dir )
109+ if found :
110+ return found
111+ resolved = Path (whitelist_file_arg ).resolve ()
112+ if not resolved .is_file ():
113+ logger .warning ("Whitelist file '%s' does not exist, skipping" , whitelist_file_arg )
114+ return None
115+ return resolved
101116
102117
103118def _warn_diff_only_flags (args : argparse .Namespace ) -> None :
@@ -293,8 +308,8 @@ def parse_args() -> ParsedArgs:
293308 root_dir = _resolve_root_dir (args .directory )
294309 output_format = args .format
295310 output_file , force_stdout = _resolve_output_file (args .output_file , args .save , output_format )
296- ignore_file = _resolve_ignore_file (args .ignore )
297- whitelist_file = _resolve_whitelist_file (args .whitelist )
311+ ignore_file = _resolve_ignore_file (args .ignore , root_dir )
312+ whitelist_file = _resolve_whitelist_file (args .whitelist , root_dir )
298313
299314 log_level_map = {"error" : 0 , "warning" : 1 , "info" : 2 , "debug" : 3 }
300315 verbosity = log_level_map [args .log_level ]
0 commit comments