Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to specify line break character used in pagination #193

Merged
merged 2 commits into from Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/prettytable/prettytable.py
Expand Up @@ -2004,7 +2004,7 @@ def _stringify_row(self, row, options, hrule):

return "\n".join(bits)

def paginate(self, page_length=58, **kwargs):
def paginate(self, page_length=58, line_break="\f", **kwargs):

pages = []
kwargs["start"] = kwargs.get("start", 0)
Expand All @@ -2015,7 +2015,7 @@ def paginate(self, page_length=58, **kwargs):
if kwargs["end"] == true_end:
break
kwargs["start"] += page_length
return "\f".join(pages)
return line_break.join(pages)

##############################
# CSV STRING METHODS #
Expand Down
3 changes: 3 additions & 0 deletions tests/test_prettytable.py
Expand Up @@ -1735,6 +1735,9 @@ def test_paginate():
assert paginated.startswith(expected_page_1)
assert "\f" in paginated
assert paginated.endswith(expected_page_2)
paginated = t.paginate(page_length=4, line_break="\n")
assert "\f" not in paginated
assert "\n" in paginated
hugovk marked this conversation as resolved.
Show resolved Hide resolved


def test_add_rows():
Expand Down