import typing
import json


def _read_brand(filename: str, comment: str) -> typing.Dict:
    """Read a brand from a file.

    :param filename: the filename of the file with the brand
    :param comment: the comment characters that prefix each line of the brand
    :return: the data that is encoded in the brand
    """
    # Read in the file, pulling in only the lines with branding on them.
    lines = []
    with open(filename, "r", encoding="utf8") as file:
        for line in file.readlines():
            if line.startswith(comment):
                lines.append(line)

    # Reassemble data and parse the JSON object from the brand.
    data_json = "".join(map(lambda x: x[len(comment):].rstrip(), lines))
    return json.loads(data_json) if data_json else {}