#!/usr/bin/env python3"""Utility to show pywikibot colors."""## (C) Pywikibot team, 2016-2024## Distributed under the terms of the MIT license.#from__future__importannotationsimportpywikibotfrompywikibot.backportsimportbatchedfrompywikibot.userinterfaces.terminal_interface_baseimportcolors
[docs]defmain():"""Main function."""fg_colors=[colforcolincolorsifcol!='default']bg_colors=fg_colors[:]n_fg_colors=len(fg_colors)foriinrange(4):fg_colors.insert((3-i)*(n_fg_colors//4),'default')# Max len of color names for padding.max_len_fg_colors=len(max(fg_colors,key=len))max_len_bc_color=len(max(bg_colors,key=len))forbg_colinbg_colors:# Three lines per each backgoung color.forfg_col_groupinbatched(fg_colors,n_fg_colors//4+1):line=''forfg_colinfg_col_group:line+=' 'line+='<<{color}>>{}<<default>>'.format(fg_col.ljust(max_len_fg_colors),color=f'{fg_col};{bg_col}')line=f'{bg_col.ljust(max_len_bc_color)}{line}'pywikibot.info(line)pywikibot.info()