Make truncate and padding private staticmethods
This commit is contained in:
parent
ddda04e3b5
commit
5f1864807b
@ -900,7 +900,7 @@ class Escpos(object, metaclass=ABCMeta):
|
|||||||
self.text(textwrap.fill(txt, col_count))
|
self.text(textwrap.fill(txt, col_count))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def padding(
|
def _padding(
|
||||||
text: str,
|
text: str,
|
||||||
width: int,
|
width: int,
|
||||||
align: Alignment = "center",
|
align: Alignment = "center",
|
||||||
@ -920,7 +920,7 @@ class Escpos(object, metaclass=ABCMeta):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def truncate(text: str, width: int, placeholder: str = ".") -> str:
|
def _truncate(text: str, width: int, placeholder: str = ".") -> str:
|
||||||
"""Truncate an string at a max width or leave it untouched.
|
"""Truncate an string at a max width or leave it untouched.
|
||||||
|
|
||||||
Add a placeholder at the end of the output text if it has been truncated.
|
Add a placeholder at the end of the output text if it has been truncated.
|
||||||
@ -958,7 +958,7 @@ class Escpos(object, metaclass=ABCMeta):
|
|||||||
row = ["" for _ in range(n_cols)]
|
row = ["" for _ in range(n_cols)]
|
||||||
for j, item in enumerate(wrapped):
|
for j, item in enumerate(wrapped):
|
||||||
if i in range(len(item)):
|
if i in range(len(item)):
|
||||||
row[j] = self.truncate(item[i], widths[j])
|
row[j] = self._truncate(item[i], widths[j])
|
||||||
text_colums.append(row)
|
text_colums.append(row)
|
||||||
return text_colums
|
return text_colums
|
||||||
|
|
||||||
@ -970,7 +970,7 @@ class Escpos(object, metaclass=ABCMeta):
|
|||||||
) -> list:
|
) -> list:
|
||||||
"""Add padding, width and alignment into the items of a list of strings."""
|
"""Add padding, width and alignment into the items of a list of strings."""
|
||||||
return [
|
return [
|
||||||
self.padding(text, widths[i], align[i]) for i, text in enumerate(text_list)
|
self._padding(text, widths[i], align[i]) for i, text in enumerate(text_list)
|
||||||
]
|
]
|
||||||
|
|
||||||
def software_columns(
|
def software_columns(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user