def to_csscheme(data, out, skip_names):
    with StringIO() as stream:
        # Name
        name = data.get('name', "INSERT NAME HERE")
        stream.write('@name "%s";' % name)

        uuid = data.get('uuid')
        if uuid:
            stream.write('\n\n@uuid %s;' % uuid)

        # Search for settings item and extract the others
        items = data['settings']
        settings = None
        for i, item in enumerate(items):
            if 'scope' not in item:
                if 'settings' not in item:
                    out.write_line("Expected 'settings' key in item without scope")
                    return
                settings = item['settings']
                del items[i]  # remove from the regular items list
                break

        if not settings:
            settings = []
        else:
            settings = list(settings.items())

        # Global settings
        settings.sort(key=lambda x: x[0].lower())
        stream.write("\n\n* {")
        for key, value in settings:
            stream.write((key, value) % "\n\t%s: %s;")
        stream.write("\n}")

        # The other items
        for item in items:
            if 'scope' not in item:
                out.write_line("Missing 'scope' key in item")
                return
            stream.write("\n\n%s {" % item['scope'])

            if not skip_names and 'name' in item:
                stream.write('\n\t@name "%s";' % item['name'])

            if 'settings' not in item:
                out.write_line("Missing 'settings' key in item")
                return
            for key, value in item['settings'].items():
                stream.write("\n\t%s: %s;" % (key, value))

            stream.write("\n}")

        return stream.getvalue()
dataset/ETHPy150Open FichteFoll/CSScheme/converters/tmtheme.py/to_csscheme/swapped operands of `%`