def _create_split(pymux, window, split):
assert isinstance(split, (arrangement.HSplit, arrangement.VSplit))<EOL>is_vsplit = isinstance(split, arrangement.VSplit)<EOL>def get_average_weight():<EOL><INDENT>"""<STR_LIT>"""<EOL>weights = <NUM_LIT:0><EOL>count = <NUM_LIT:0><EOL>for i in split:<EOL><INDENT>if i in split.weights:<EOL><INDENT>weights += split.weights[i]<EOL>count += <NUM_LIT:1><EOL><DEDENT><DEDENT>if weights:<EOL><INDENT>return max(<NUM_LIT:1>, weights // count)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT><DEDENT>def report_write_position_callback(item, write_position):<EOL><INDENT>"""<STR_LIT>"""<EOL>if is_vsplit:<EOL><INDENT>split.weights[item] = write_position.width<EOL><DEDENT>else:<EOL><INDENT>split.weights[item] = write_position.height<EOL><DEDENT><DEDENT>def get_size(item):<EOL><INDENT>return D(weight=split.weights.get(item) or average_weight)<EOL><DEDENT>content = []<EOL>average_weight = get_average_weight()<EOL>for i, item in enumerate(split):<EOL><INDENT>width = height = None<EOL>if is_vsplit:<EOL><INDENT>width = partial(get_size, item)<EOL><DEDENT>else:<EOL><INDENT>height = partial(get_size, item)<EOL><DEDENT>if isinstance(item, (arrangement.VSplit, arrangement.HSplit)):<EOL><INDENT>child = _create_split(pymux, window, item)<EOL><DEDENT>elif isinstance(item, arrangement.Pane):<EOL><INDENT>child = _create_container_for_process(pymux, window, item)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>' % (item,))<EOL><DEDENT>content.append(SizedBox(<EOL>child, width=width, height=height,<EOL>report_write_position_callback=partial(report_write_position_callback, item)))<EOL><DEDENT>if is_vsplit:<EOL><INDENT>return_cls = VSplit<EOL>padding_char = _border_vertical<EOL><DEDENT>else:<EOL><INDENT>return_cls = HSplit<EOL>padding_char = _border_horizontal<EOL><DEDENT>return return_cls(content,<EOL>padding=<NUM_LIT:1>,<EOL>padding_char=padding_char)<EOL>
Create a prompt_toolkit `Container` instance for the given pymux split.