def format_object_summary(obj, formatter, is_justify=True, name=None,<EOL>indent_for_name=True):
from pandas.io.formats.console import get_console_size<EOL>from pandas.io.formats.format import _get_adjustment<EOL>display_width, _ = get_console_size()<EOL>if display_width is None:<EOL><INDENT>display_width = get_option('<STR_LIT>') or <NUM_LIT><EOL><DEDENT>if name is None:<EOL><INDENT>name = obj.__class__.__name__<EOL><DEDENT>if indent_for_name:<EOL><INDENT>name_len = len(name)<EOL>space1 = "<STR_LIT>" % ('<STR_LIT:U+0020>' * (name_len + <NUM_LIT:1>))<EOL>space2 = "<STR_LIT>" % ('<STR_LIT:U+0020>' * (name_len + <NUM_LIT:2>))<EOL><DEDENT>else:<EOL><INDENT>space1 = "<STR_LIT:\n>"<EOL>space2 = "<STR_LIT>"  <EOL><DEDENT>n = len(obj)<EOL>sep = '<STR_LIT:U+002C>'<EOL>max_seq_items = get_option('<STR_LIT>') or n<EOL>is_truncated = n > max_seq_items<EOL>adj = _get_adjustment()<EOL>def _extend_line(s, line, value, display_width, next_line_prefix):<EOL><INDENT>if (adj.len(line.rstrip()) + adj.len(value.rstrip()) >=<EOL>display_width):<EOL><INDENT>s += line.rstrip()<EOL>line = next_line_prefix<EOL><DEDENT>line += value<EOL>return s, line<EOL><DEDENT>def best_len(values):<EOL><INDENT>if values:<EOL><INDENT>return max(adj.len(x) for x in values)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT><DEDENT>close = '<STR_LIT:U+002CU+0020>'<EOL>if n == <NUM_LIT:0>:<EOL><INDENT>summary = '<STR_LIT>'.format(close)<EOL><DEDENT>elif n == <NUM_LIT:1>:<EOL><INDENT>first = formatter(obj[<NUM_LIT:0>])<EOL>summary = '<STR_LIT>'.format(first, close)<EOL><DEDENT>elif n == <NUM_LIT:2>:<EOL><INDENT>first = formatter(obj[<NUM_LIT:0>])<EOL>last = formatter(obj[-<NUM_LIT:1>])<EOL>summary = '<STR_LIT>'.format(first, last, close)<EOL><DEDENT>else:<EOL><INDENT>if n > max_seq_items:<EOL><INDENT>n = min(max_seq_items // <NUM_LIT:2>, <NUM_LIT:10>)<EOL>head = [formatter(x) for x in obj[:n]]<EOL>tail = [formatter(x) for x in obj[-n:]]<EOL><DEDENT>else:<EOL><INDENT>head = []<EOL>tail = [formatter(x) for x in obj]<EOL><DEDENT>if is_justify:<EOL><INDENT>if (is_truncated or<EOL>not (len('<STR_LIT:U+002CU+0020>'.join(head)) < display_width and<EOL>len('<STR_LIT:U+002CU+0020>'.join(tail)) < display_width)):<EOL><INDENT>max_len = max(best_len(head), best_len(tail))<EOL>head = [x.rjust(max_len) for x in head]<EOL>tail = [x.rjust(max_len) for x in tail]<EOL><DEDENT><DEDENT>summary = "<STR_LIT>"<EOL>line = space2<EOL>for i in range(len(head)):<EOL><INDENT>word = head[i] + sep + '<STR_LIT:U+0020>'<EOL>summary, line = _extend_line(summary, line, word,<EOL>display_width, space2)<EOL><DEDENT>if is_truncated:<EOL><INDENT>summary += line.rstrip() + space2 + '<STR_LIT>'<EOL>line = space2<EOL><DEDENT>for i in range(len(tail) - <NUM_LIT:1>):<EOL><INDENT>word = tail[i] + sep + '<STR_LIT:U+0020>'<EOL>summary, line = _extend_line(summary, line, word,<EOL>display_width, space2)<EOL><DEDENT>summary, line = _extend_line(summary, line, tail[-<NUM_LIT:1>],<EOL>display_width - <NUM_LIT:2>, space2)<EOL>summary += line<EOL>close = '<STR_LIT:]>' + close.rstrip('<STR_LIT:U+0020>')<EOL>summary += close<EOL>if len(summary) > (display_width):<EOL><INDENT>summary += space1<EOL><DEDENT>else:  <EOL><INDENT>summary += '<STR_LIT:U+0020>'<EOL><DEDENT>summary = '<STR_LIT:[>' + summary[len(space2):]<EOL><DEDENT>return summary<EOL>
Return the formatted obj as a unicode string

Parameters
----------
obj : object
    must be iterable and support __getitem__
formatter : callable
    string formatter for an element
is_justify : boolean
    should justify the display
name : name, optional
    defaults to the class name of the obj
indent_for_name : bool, default True
    Whether subsequent lines should be be indented to
    align with the name.

Returns
-------
summary string