Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sign.value,
).split("\n")
)
item.maxwidth = curr_maxwidth
else:
rows.append(
pre_process(
item,
table.detect_numerics,
table.precision,
sign.value,
).split("\n")
)
for row in map(list, zip_longest(*rows, fillvalue="")):
for i in range(len(row)):
row[i] = pre_process(
row[i], table.detect_numerics, table.precision, sign.value,
)
for row_ in self._clamp_row(row):
for i in range(len(table.columns)):
# str.format method doesn't work for multibyte strings
# hence, we need to manually align the texts instead
# of using the align property of the str.format method
pad_len = width[i] - termwidth(row_[i])
if align[i].value == "<":
right_pad = " " * pad_len
row_[i] = to_unicode(row_[i]) + right_pad
elif align[i].value == ">":
left_pad = " " * pad_len
row_[i] = left_pad + to_unicode(row_[i])
else:
left_pad = " " * (pad_len // 2)
if align is None:
align = table.columns.alignment
if mask is None:
mask = [True] * len(table.columns)
lpw, rpw = self._get_padding()
string = []
for i, item in enumerate(self._value):
if isinstance(item, type(table)):
# temporarily change the max width of the table
curr_maxwidth = item.maxwidth
item.maxwidth = width[i] - lpw[i] - rpw[i]
rows.append(
pre_process(
item,
table.detect_numerics,
table.precision,
sign.value,
).split("\n")
)
item.maxwidth = curr_maxwidth
else:
rows.append(
pre_process(
item,
table.detect_numerics,
table.precision,
sign.value,
).split("\n")
)
def _compute_width(self):
"""Calculate width of column automatically based on data."""
table_width = self._width
lpw, rpw = self.columns.padding_left, self.columns.padding_right
pad_widths = [(lpw[i] + rpw[i]) for i in range(len(self.columns))]
maxwidths = [0 for index in range(len(self.columns))]
offset = table_width - sum(self.columns.width) + sum(pad_widths)
self._maxwidth = max(self._maxwidth, offset + len(self.columns))
for index, header in enumerate(self.columns.header):
max_length = 0
for i in pre_process(
header, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
i, self.detect_numerics, self.precision, self.sign.value,
)
max_length = max(max_length, termwidth(output_str))
maxwidths[index] += max_length
for index, column in enumerate(zip(*self._data)):
max_length = maxwidths[index]
for i in column:
for j in pre_process(
i, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
j,
self.detect_numerics,
self.precision,
self.sign.value,
for index, header in enumerate(self.columns.header):
max_length = 0
for i in pre_process(
header, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
i, self.detect_numerics, self.precision, self.sign.value,
)
max_length = max(max_length, termwidth(output_str))
maxwidths[index] += max_length
for index, column in enumerate(zip(*self._data)):
max_length = maxwidths[index]
for i in column:
for j in pre_process(
i, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
j,
self.detect_numerics,
self.precision,
self.sign.value,
)
max_length = max(max_length, termwidth(output_str))
maxwidths[index] = max_length
sum_ = sum(maxwidths)
desired_sum = self._maxwidth - offset
# Set flag for columns who are within their fair share
temp_sum = 0
def _compute_width(self):
"""Calculate width of column automatically based on data."""
table_width = self._width
lpw, rpw = self.columns.padding_left, self.columns.padding_right
pad_widths = [(lpw[i] + rpw[i]) for i in range(len(self.columns))]
maxwidths = [0 for index in range(len(self.columns))]
offset = table_width - sum(self.columns.width) + sum(pad_widths)
self._maxwidth = max(self._maxwidth, offset + len(self.columns))
for index, header in enumerate(self.columns.header):
max_length = 0
for i in pre_process(
header, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
i, self.detect_numerics, self.precision, self.sign.value,
)
max_length = max(max_length, termwidth(output_str))
maxwidths[index] += max_length
for index, column in enumerate(zip(*self._data)):
max_length = maxwidths[index]
for i in column:
for j in pre_process(
i, self.detect_numerics, self.precision, self.sign.value
).split("\n"):
output_str = pre_process(
j,