def read_binary_metadata(metadata_file):
    """ Read the metadata of a binary file.
    Arguments:
        metadata_file: str
            Metadata filename.
    Returns:
        metadata: dict
            Metadata.
    """

    fid = open(metadata_file, 'r')
    trans_tab = str.maketrans(dict.fromkeys('\n{}'))
    metadata = dict()
    while 1:
        line = fid.readline()
        if '=' in line:
            key, value = line.split('=', 1)
            if ('{' in value) and ('}' not in value):
                while '}' not in line:
                    line = fid.readline()
                    if line.strip()[0] == ';':
                        continue
                    value += line
            key = key.strip()
            if ('{' in value) and ('}' in value):
                value = value.translate(trans_tab).strip()
                value = list(map(str.strip, value.split(',')))
            else:
                value = value.translate(trans_tab).strip()
            metadata[key] = value
        if line == '':
            break
    fid.close()

    return metadata