def format_objects(objects, children=False, columns=None, header=True):
columns = columns or ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>objects = sorted(objects, key=_type_and_name)<EOL>data = []<EOL>for obj in objects:<EOL><INDENT>if isinstance(obj, cpenv.VirtualEnvironment):<EOL><INDENT>data.append(get_info(obj))<EOL>modules = obj.get_modules()<EOL>if children and modules:<EOL><INDENT>for mod in modules:<EOL><INDENT>data.append(get_info(mod, indent=<NUM_LIT:2>, root=obj.path))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>data.append(get_info(obj))<EOL><DEDENT><DEDENT>maxes = [len(max(col, key=len)) for col in zip(*data)]<EOL>tmpl = '<STR_LIT>' % tuple(maxes)<EOL>lines = []<EOL>if header:<EOL><INDENT>lines.append('<STR_LIT:\n>' + bold_blue(tmpl.format(*columns)))<EOL><DEDENT>for obj_data in data:<EOL><INDENT>lines.append(tmpl.format(*obj_data))<EOL><DEDENT>return '<STR_LIT:\n>'.join(lines)<EOL>
Format a list of environments and modules for terminal output