import re


def parse(path):
    """Return the Zotero preferences in a dictionary

    Args:
        path: The path to the prefs.js preferences file.

    Returns:
        A dictionary of preferences.
    """
    prog = re.compile('^user_pref\("([a-zA-Z.]*)"\s*,\s*(.*)\);$')
    with open(path, 'r') as f:
        lines = (bytes(line, 'utf-8').decode('unicode_escape') for line in f)
        matches = (prog.match(line) for line in lines)
        prefs = {match.group(1): match.group(2).strip('"\'')
                 for match in matches if match}
        return prefs