in src/advisor/helpers/find_port.py [0:0]
def find_port_dir(dirname, other_dirs):
"""Given a directory path dir searches other_dirs for a directory that
may be an aarch64 port of dir.
Args:
dirname (str): The directory to find the port for.
other_dirs (list): The list of directories to search through for the
port.
Returns:
str: A directory that may be an aarch64 port of dir, or None.
Examples:
>>> find_port_dir('/work/app/source/otherarch',
['/work/app/source/common',
'/work/app/source/aarch64'])
'/work/app/source/aarch64'
"""
parts = dirname.split(os.sep)
for i, last_part in enumerate(parts):
filenames = port_filenames(last_part)
for port_filename in filenames:
port_path = os.sep.join(parts[:i] + [port_filename])
if port_path in other_dirs:
return port_path
return None