#!/usr/bin/python3

"""Remove all brand icons from the MDI charmaps.

These icons have been removed from the source package.

This overwrites the existing charmap, so should only be used on
the installed version.

"""

import json
import os.path
import sys


with open(
        os.path.join(os.path.dirname(__file__), "mdi-excluded.list"),
        encoding="utf-8",
) as excfile:
    excludeds = set(e.strip() for e in excfile.readlines())

metafile = sys.argv[1]

with open(metafile, encoding="utf-8") as meta:
    icons = json.load(meta)

icons_dfsg = dict(icon for icon in icons.items() if icon[0] not in excludeds)

with open(metafile, "w", encoding="utf-8") as meta_dfsg:
    json.dump(icons_dfsg, meta_dfsg, indent=4)
