def get_project(directory):
    """
    Get the project in the given directory.

    Figure out the project name, and return a dictionary with the project name,
    the readable project path, the absolute project path, and a unique ID.
    """
    namefile = directory.expanduser() / '.idea' / '.name'
    try:
        name = namefile.read_text(encoding='utf-8').strip()
    except FileNotFoundError:
        name = directory.name
    # When changing this object change the `Project` interface in extension.ts
    return {
        # Conveniently use the absolute path as ID, because it's definitely unique,
        # and prefix it with the name of this launch to avoid conflicts with IDs
        # from other providers.
        'id': 'intellij-idea-search-provider-{0}'.format(directory.expanduser()),
        'name': name,
        'path': str(directory),
        'abspath': str(directory.expanduser())
    }