def _make_category()

in scripts/awsicons/icon.py [0:0]


    def _make_category(self, regex: str, filename: str, mappings: dict):
        """Create PUML friendly category with any remappings

        :param regex: regular expression to obtain category
        :type regex: str
        :param filename: full filename path
        :type filename: str
        :param mappings: category mapping (incorrect->correct)
        :type mappings: dict
        :return: PUML friendly category name
        :rtype: str
        """
        try:
            category = re.search(regex, filename).group(1)
            friendly_category = re.sub(r"[^a-zA-Z0-9]", "", category)
        except Exception as e:
            print(
                f"Error in extracting category from filename. Regex: {regex}, source filename string: {filename}"
            )
            raise SystemExit(1)
        if mappings:
            try:
                friendly_category = mappings[friendly_category]
            except KeyError:
                # no match found, existing category is okay
                pass
        return friendly_category