(start_path, file_name)
return locate_file(os.path.dirname(start_dir_path), file_name)
locate filename and return absolute file path.
        searching will be recursive upward until current working directory.

    Args:
        start_path (str): start locating path, maybe file path or directory path

    Returns:
        str: located file path. None if file not found.

    Raises:
        exceptions.FileNotFound: If failed to locate file.
locate filename and return absolute file path.
        searching will be recursive upward until current working directory.
locate filename and return absolute file path . searching will be recursive upward until current working directory .
def locate_file(start_path, file_name):
    """ locate filename and return absolute file path.
        searching will be recursive upward until current working directory.

    Args:
        start_path (str): start locating path, maybe file path or directory path

    Returns:
        str: located file path. None if file not found.

    Raises:
        exceptions.FileNotFound: If failed to locate file.

    """
    if os.path.isfile(start_path):
        start_dir_path = os.path.dirname(start_path)
    elif os.path.isdir(start_path):
        start_dir_path = start_path
    else:
        raise exceptions.FileNotFound("invalid path: {}".format(start_path))

    file_path = os.path.join(start_dir_path, file_name)
    if os.path.isfile(file_path):
        return os.path.abspath(file_path)

    # current working directory
    if os.path.abspath(start_dir_path) in [os.getcwd(), os.path.abspath(os.sep)]:
        raise exceptions.FileNotFound("{} not found in {}".format(file_name, start_path))

    # locate recursive upward
    return locate_file(os.path.dirname(start_dir_path), file_name)
def locate_file ( start_path , file_name ) : if os . path . isfile ( start_path ) : start_dir_path = os . path . dirname ( start_path ) elif os . path . isdir ( start_path ) : start_dir_path = start_path else : raise exceptions . FileNotFound ( "invalid path: {}" . format ( start_path ) ) file_path = os . path . join ( start_dir_path , file_name ) if os . path . isfile ( file_path ) : return os . path . abspath ( file_path ) # current working directory if os . path . abspath ( start_dir_path ) in [ os . getcwd ( ) , os . path . abspath ( os . sep ) ] : raise exceptions . FileNotFound ( "{} not found in {}" . format ( file_name , start_path ) ) # locate recursive upward return locate_file ( os . path . dirname ( start_dir_path ) , file_name )