Skip to content

Commit

Permalink
[Report][Fixed] Use relative path for single output
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyen-v committed Jan 3, 2025
1 parent 9748a34 commit 015014b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions kibot/out_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,20 @@ def do_replacements(self, line, defined):
output_name = base_var[:-8] # Strip `_outpath`
try:
targets, _, _ = get_output_targets(output_name, self._parent)
target = None
if isinstance(targets, list):
target = None
if index is not None:
if 0 <= index < len(targets):
target = targets[index]
else:
logger.warning(f"Index {index + 1} out of range for `{var_ori}`")
else:
target = targets[0]

if target is not None:
target_rel = os.path.relpath(target, os.path.join(GS.out_dir, self._parent.dir))
line = line.replace(f'${{{var_ori}}}', target_rel)
else:
target = targets
root_folder = defined.get('KIPRJMOD', '')
if target.startswith(root_folder):
target = target[len(root_folder):].lstrip('/')
line = line.replace(f'${{{var_ori}}}', target)
if target is not None:
target_rel = os.path.relpath(target, os.path.join(GS.out_dir, self._parent.dir))
line = line.replace(f'${{{var_ori}}}', target_rel)
except Exception as e:
logger.warning(f"Error processing _outpath for `{var_ori}`: {str(e)}")
continue
Expand Down

0 comments on commit 015014b

Please sign in to comment.