def pp_options_list(keys, width=<NUM_LIT>, _print=False):
from textwrap import wrap<EOL>from itertools import groupby<EOL>def pp(name, ks):<EOL><INDENT>pfx = ('<STR_LIT>' + name + '<STR_LIT>' if name else '<STR_LIT>')<EOL>ls = wrap('<STR_LIT:U+002CU+0020>'.join(ks), width, initial_indent=pfx,<EOL>subsequent_indent='<STR_LIT:U+0020>', break_long_words=False)<EOL>if ls and ls[-<NUM_LIT:1>] and name:<EOL><INDENT>ls[-<NUM_LIT:1>] = ls[-<NUM_LIT:1>] + '<STR_LIT:]>'<EOL><DEDENT>return ls<EOL><DEDENT>ls = []<EOL>singles = [x for x in sorted(keys) if x.find('<STR_LIT:.>') < <NUM_LIT:0>]<EOL>if singles:<EOL><INDENT>ls += pp('<STR_LIT>', singles)<EOL><DEDENT>keys = [x for x in keys if x.find('<STR_LIT:.>') >= <NUM_LIT:0>]<EOL>for k, g in groupby(sorted(keys), lambda x: x[:x.rfind('<STR_LIT:.>')]):<EOL><INDENT>ks = [x[len(k) + <NUM_LIT:1>:] for x in list(g)]<EOL>ls += pp(k, ks)<EOL><DEDENT>s = '<STR_LIT:\n>'.join(ls)<EOL>if _print:<EOL><INDENT>print(s)<EOL><DEDENT>else:<EOL><INDENT>return s<EOL><DEDENT>
Builds a concise listing of available options, grouped by prefix