Skip to content

Commit c1c2c79

Browse files
committed
Avoid including extended version number info; causes problems with venv
1 parent a03fd75 commit c1c2c79

File tree

3 files changed

+24
-57
lines changed

3 files changed

+24
-57
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export TOX_OPTS ?= -e py39-extra,py310-extra,py311-extra,py312-extra,py313-extr
1414
export PYTEST ?= $(PYTHON) -m pytest
1515
export PYTEST_OPTS ?= # -vv --capture=no
1616

17-
VERSION = $(shell $(PYTHON) -c "exec(open('tabulate/version.py').read()); print('.'.join(map(str, __version_tuple__[:-2])))" )
17+
VERSION = $(shell $(PYTHON) -c "exec(open('tabulate/version.py').read()); print('.'.join(map(str, __version_tuple__[:3])))" )
1818
VERSION_FULL = $(shell $(PYTHON) -c "exec(open('tabulate/version.py').read()); print(__version__)" )
1919
WHEEL = dist/tabulate_slip39-$(VERSION_FULL)-py3-none-any.whl
2020
VENV = $(CURDIR)-$(VERSION)-$(PYTHON_V)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ packages = ["tabulate"]
3737

3838
[tool.setuptools_scm]
3939
write_to = "tabulate/version.py"
40+
local_scheme = "no-local-version"

tabulate/__init__.py

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,13 +1638,7 @@ def _normalize_tabular_data(tabular_data, headers, showindex="default"):
16381638
return rows, headers, headers_pad
16391639

16401640

1641-
def _wrap_text_to_colwidths(
1642-
list_of_lists,
1643-
colwidths,
1644-
numparses=True,
1645-
break_long_words=_BREAK_LONG_WORDS,
1646-
break_on_hyphens=_BREAK_ON_HYPHENS,
1647-
):
1641+
def _wrap_text_to_colwidths(list_of_lists, colwidths, numparses=True, break_long_words=_BREAK_LONG_WORDS, break_on_hyphens=_BREAK_ON_HYPHENS):
16481642
if len(list_of_lists):
16491643
num_cols = len(list_of_lists[0])
16501644
else:
@@ -1661,11 +1655,7 @@ def _wrap_text_to_colwidths(
16611655
continue
16621656

16631657
if width is not None:
1664-
wrapper = _CustomTextWrap(
1665-
width=width,
1666-
break_long_words=break_long_words,
1667-
break_on_hyphens=break_on_hyphens,
1668-
)
1658+
wrapper = _CustomTextWrap(width=width, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens)
16691659
casted_cell = str(cell)
16701660
wrapped = [
16711661
"\n".join(wrapper.wrap(line))
@@ -2268,11 +2258,7 @@ def tabulate(
22682258

22692259
numparses = _expand_numparse(disable_numparse, num_cols)
22702260
list_of_lists = _wrap_text_to_colwidths(
2271-
list_of_lists,
2272-
maxcolwidths,
2273-
numparses=numparses,
2274-
break_long_words=break_long_words,
2275-
break_on_hyphens=break_on_hyphens,
2261+
list_of_lists, maxcolwidths, numparses=numparses, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens
22762262
)
22772263

22782264
if maxheadercolwidths is not None:
@@ -2286,11 +2272,7 @@ def tabulate(
22862272

22872273
numparses = _expand_numparse(disable_numparse, num_cols)
22882274
headers = _wrap_text_to_colwidths(
2289-
[headers],
2290-
maxheadercolwidths,
2291-
numparses=numparses,
2292-
break_long_words=break_long_words,
2293-
break_on_hyphens=break_on_hyphens,
2275+
[headers], maxheadercolwidths, numparses=numparses, break_long_words=break_long_words, break_on_hyphens=break_on_hyphens
22942276
)[0]
22952277

22962278
# empty values in the first column of RST tables should be escaped (issue #82)
@@ -2756,45 +2738,29 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
27562738

27572739
# If we're allowed to break long words, then do so: put as much
27582740
# of the next chunk onto the current line as will fit.
2759-
2760-
# Reverted the broken ANSI code handling stuff to fix wcwidth handling
2761-
# - Doesn't use self._lend, infinite loops
2762-
# - doesn't locate chunks correctly b/c could be split by ANSI codes
2763-
#
2764-
# if self.break_long_words and space_left > 0:
2765-
# # Tabulate Custom: Build the string up piece-by-piece in order to
2766-
# # take each charcter's width into account
2767-
# chunk = reversed_chunks[-1]
2768-
# # Only count printable characters, so strip_ansi first, index later.
2769-
# for i in range( 1, space_left + 1 ):
2770-
# if self._len(_strip_ansi(chunk)[:i]) > space_left:
2771-
# break
2772-
#
2773-
# # Consider escape codes when breaking words up
2774-
# total_escape_len = 0
2775-
# last_group = 0
2776-
# if _ansi_codes.search(chunk) is not None:
2777-
# for group, _, _, _ in _ansi_codes.findall(chunk):
2778-
# escape_len = len(group)
2779-
# if (
2780-
# group
2781-
# in chunk[last_group : i + total_escape_len + escape_len - 1]
2782-
# ):
2783-
# total_escape_len += escape_len
2784-
# found = _ansi_codes.search(chunk[last_group:])
2785-
# last_group += found.end()
2786-
# cur_line.append(chunk[: i + total_escape_len - 1])
2787-
# reversed_chunks[-1] = chunk[i + total_escape_len - 1 :]
2788-
2789-
if self.break_long_words: # and space_left > 0:
2741+
if self.break_long_words:
27902742
# Tabulate Custom: Build the string up piece-by-piece in order to
27912743
# take each charcter's width into account
27922744
chunk = reversed_chunks[-1]
27932745
i = 1
2794-
while self._len(chunk[:i]) <= space_left:
2746+
# Only count printable characters, so strip_ansi first, index later.
2747+
while len(_strip_ansi(chunk)[:i]) <= space_left:
27952748
i = i + 1
2796-
cur_line.append(chunk[: i - 1])
2797-
reversed_chunks[-1] = chunk[i - 1 :]
2749+
# Consider escape codes when breaking words up
2750+
total_escape_len = 0
2751+
last_group = 0
2752+
if _ansi_codes.search(chunk) is not None:
2753+
for group, _, _, _ in _ansi_codes.findall(chunk):
2754+
escape_len = len(group)
2755+
if (
2756+
group
2757+
in chunk[last_group : i + total_escape_len + escape_len - 1]
2758+
):
2759+
total_escape_len += escape_len
2760+
found = _ansi_codes.search(chunk[last_group:])
2761+
last_group += found.end()
2762+
cur_line.append(chunk[: i + total_escape_len - 1])
2763+
reversed_chunks[-1] = chunk[i + total_escape_len - 1 :]
27982764

27992765
# Otherwise, we have to preserve the long word intact. Only add
28002766
# it to the current line if there's nothing already there --

0 commit comments

Comments
 (0)