Skip to content

Commit

Permalink
Variable optimization for absolute path checking methods
Browse files Browse the repository at this point in the history
The optimized method avoids creating unnecessary intermediate variable abs_path
and directly processes on the original variable file_path, making the code more concise.

Signed-off-by: wulei01 <[email protected]>
  • Loading branch information
wulei01 committed Jul 20, 2023
1 parent ed927e8 commit 3dba4e7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions avocado/core/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ def system_wide_or_base_path(file_path):
:type file_path: str
:rtype: str
"""
if os.path.isabs(file_path):
abs_path = file_path
else:
abs_path = os.path.join(os.path.sep, file_path)
if os.path.exists(abs_path):
return abs_path
return prepend_base_path(file_path)
if not os.path.isabs(file_path):
file_path = os.path.join(os.path.sep, file_path)
if not os.path.exists(file_path):
return prepend_base_path(file_path)
return file_path

0 comments on commit 3dba4e7

Please sign in to comment.