Skip to content

Commit

Permalink
[FIX] pylint_odoo: Fix walk-up normalizing windows OS separator // vs \\
Browse files Browse the repository at this point in the history
  • Loading branch information
moylop260 committed Dec 18, 2024
1 parent 4c79fec commit 37d03fc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pylint_odoo/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,20 @@ def top_path(path):
return path.root or path.drive


def full_norm_path(path):
"""Expand paths in all possible ways"""
return os.path.normpath(os.path.realpath(os.path.abspath(os.path.expanduser(os.path.expandvars(path.strip())))))


@lru_cache(maxsize=256)
def walk_up(path, filenames, top):
"""Look for "filenames" walking up in parent paths of "path"
but limited only to "top" path
"""
if path == top:
if full_norm_path(path) == full_norm_path(top):
return None
for filename in filenames:
path_filename = os.path.join(path, filename)
if os.path.isfile(path_filename):
if os.path.isfile(full_norm_path(path_filename)):
return path_filename
return walk_up(os.path.dirname(path), filenames, top)

0 comments on commit 37d03fc

Please sign in to comment.