def _fixed_table(table_element): """ Returns a new TableElement. """ assert isinstance(table_element, TableElement) lines = tuple(common.lines(table_element.sub_elements)) fixed_lines = tuple(_fixed_line(l) if _line_length(l) > MAXIMUM_LINE_LENGTH else l for l in lines) return TableElement(sub_elements=tuple(reduce(operator.concat, fixed_lines)))
def _fixed_table(table_element): """ Returns a new TableElement. """ assert isinstance(table_element, TableElement) lines = tuple(common.lines(table_element.sub_elements)) fixed_lines = tuple( _fixed_line(l) if _line_length(l) > MAXIMUM_LINE_LENGTH else l for l in lines) return TableElement( sub_elements=tuple(reduce(operator.concat, fixed_lines)))
def _sorted_table(table): """ Returns another TableElement where the table entries are sorted lexicographically by key. """ assert isinstance(table, TableElement) # Discarding TokenElements with no tokens in them table_elements = common.non_empty_elements(table.sub_elements) lines = tuple(common.lines(table_elements)) sorted_lines = sorted(lines, key=_line_key) sorted_elements = reduce(operator.concat, sorted_lines) return TableElement(sorted_elements)
def _unindent_table(table_element): table_lines = tuple(common.lines(table_element.sub_elements)) unindented_lines = tuple( tuple(dropwhile(lambda e: isinstance(e, WhitespaceElement), line)) for line in table_lines) return TableElement(reduce(operator.concat, unindented_lines))
def _unindent_table(table_element): table_lines = tuple(common.lines(table_element.sub_elements)) unindented_lines = tuple(tuple(dropwhile(lambda e: isinstance(e, WhitespaceElement), line)) for line in table_lines) return TableElement(reduce(operator.concat, unindented_lines))