wcwidth 0.2.12__py2.py3-none-any.whl → 0.2.14__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wcwidth might be problematic. Click here for more details.

@@ -1,7 +1,7 @@
1
1
  """
2
2
  Exports function list_versions() for unicode version level support.
3
3
 
4
- This code generated by wcwidth/bin/update-tables.py on 2023-09-14 15:45:33 UTC.
4
+ This code generated by wcwidth/bin/update-tables.py on 2025-09-15 16:57:50 UTC.
5
5
  """
6
6
 
7
7
 
@@ -35,4 +35,6 @@ def list_versions():
35
35
  "14.0.0",
36
36
  "15.0.0",
37
37
  "15.1.0",
38
+ "16.0.0",
39
+ "17.0.0",
38
40
  )
wcwidth/wcwidth.py CHANGED
@@ -60,12 +60,11 @@ http://www.unicode.org/unicode/reports/tr11/
60
60
 
61
61
  Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
62
62
  """
63
- from __future__ import division
64
63
 
65
64
  # std imports
66
65
  import os
67
- import sys
68
66
  import warnings
67
+ from functools import lru_cache
69
68
 
70
69
  # local
71
70
  from .table_vs16 import VS16_NARROW_TO_WIDE
@@ -73,17 +72,6 @@ from .table_wide import WIDE_EASTASIAN
73
72
  from .table_zero import ZERO_WIDTH
74
73
  from .unicode_versions import list_versions
75
74
 
76
- try:
77
- # std imports
78
- from functools import lru_cache
79
- except ImportError:
80
- # lru_cache was added in Python 3.2
81
- # 3rd party
82
- from backports.functools_lru_cache import lru_cache
83
-
84
- # global cache
85
- _PY3 = sys.version_info[0] >= 3
86
-
87
75
 
88
76
  def _bisearch(ucs, table):
89
77
  """
@@ -162,8 +150,11 @@ def wcswidth(pwcs, n=None, unicode_version='auto'):
162
150
  Given a unicode string, return its printable length on a terminal.
163
151
 
164
152
  :param str pwcs: Measure width of given unicode string.
165
- :param int n: When ``n`` is None (default), return the length of the
166
- entire string, otherwise width the first ``n`` characters specified.
153
+ :param int n: When ``n`` is None (default), return the length of the entire
154
+ string, otherwise only the first ``n`` characters are measured. This
155
+ argument exists only for compatibility with the C POSIX function
156
+ signature. It is suggested instead to use python's string slicing
157
+ capability, ``wcswidth(pwcs[:n])``
167
158
  :param str unicode_version: An explicit definition of the unicode version
168
159
  level to use for determination, may be ``auto`` (default), which uses
169
160
  the Environment Variable, ``UNICODE_VERSION`` if defined, or the latest
@@ -183,11 +174,11 @@ def wcswidth(pwcs, n=None, unicode_version='auto'):
183
174
  last_measured_char = None
184
175
  while idx < end:
185
176
  char = pwcs[idx]
186
- if char == u'\u200D':
177
+ if char == '\u200D':
187
178
  # Zero Width Joiner, do not measure this or next character
188
179
  idx += 2
189
180
  continue
190
- if char == u'\uFE0F' and last_measured_char:
181
+ if char == '\uFE0F' and last_measured_char:
191
182
  # on variation selector 16 (VS16) following another character,
192
183
  # conditionally add '1' to the measured width if that character is
193
184
  # known to be converted from narrow to wide by the VS16 character.
@@ -247,8 +238,7 @@ def _wcmatch_version(given_version):
247
238
  ``UNICODE_VERSION``. If the environment variable is not set, then the
248
239
  latest is used.
249
240
  :rtype: str
250
- :returns: unicode string, or non-unicode ``str`` type for python 2
251
- when given ``version`` is also type ``str``.
241
+ :returns: unicode string.
252
242
  """
253
243
  # Design note: the choice to return the same type that is given certainly
254
244
  # complicates it for python 2 str-type, but allows us to define an api that
@@ -258,30 +248,24 @@ def _wcmatch_version(given_version):
258
248
  # That, along with the string-to-numeric and comparisons of earliest,
259
249
  # latest, matching, or nearest, greatly complicates this function.
260
250
  # Performance is somewhat curbed by memoization.
261
- _return_str = not _PY3 and isinstance(given_version, str)
262
-
263
- if _return_str:
264
- # avoid list-comprehension to work around a coverage issue:
265
- # https://github.com/nedbat/coveragepy/issues/753
266
- unicode_versions = list(map(lambda ucs: ucs.encode(), list_versions()))
267
- else:
268
- unicode_versions = list_versions()
251
+
252
+ unicode_versions = list_versions()
269
253
  latest_version = unicode_versions[-1]
270
254
 
271
- if given_version in (u'auto', 'auto'):
255
+ if given_version == 'auto':
272
256
  given_version = os.environ.get(
273
257
  'UNICODE_VERSION',
274
- 'latest' if not _return_str else latest_version.encode())
258
+ 'latest')
275
259
 
276
- if given_version in (u'latest', 'latest'):
260
+ if given_version == 'latest':
277
261
  # default match, when given as 'latest', use the most latest unicode
278
262
  # version specification level supported.
279
- return latest_version if not _return_str else latest_version.encode()
263
+ return latest_version
280
264
 
281
265
  if given_version in unicode_versions:
282
266
  # exact match, downstream has specified an explicit matching version
283
267
  # matching any value of list_versions().
284
- return given_version if not _return_str else given_version.encode()
268
+ return given_version
285
269
 
286
270
  # The user's version is not supported by ours. We return the newest unicode
287
271
  # version level that we support below their given value.
@@ -295,7 +279,7 @@ def _wcmatch_version(given_version):
295
279
  "supported unicode version {latest_version!r} has been "
296
280
  "inferred.".format(given_version=given_version,
297
281
  latest_version=latest_version))
298
- return latest_version if not _return_str else latest_version.encode()
282
+ return latest_version
299
283
 
300
284
  # given version is less than any available version, return earliest
301
285
  # version.
@@ -311,7 +295,7 @@ def _wcmatch_version(given_version):
311
295
  "version level, {earliest_version!r}".format(
312
296
  given_version=given_version,
313
297
  earliest_version=earliest_version))
314
- return earliest_version if not _return_str else earliest_version.encode()
298
+ return earliest_version
315
299
 
316
300
  # create list of versions which are less than our equal to given version,
317
301
  # and return the tail value, which is the highest level we may support,
@@ -325,7 +309,7 @@ def _wcmatch_version(given_version):
325
309
  cmp_next_version = _wcversion_value(unicode_versions[idx + 1])
326
310
  except IndexError:
327
311
  # at end of list, return latest version
328
- return latest_version if not _return_str else latest_version.encode()
312
+ return latest_version
329
313
 
330
314
  # Maybe our given version has less parts, as in tuple(8, 0), than the
331
315
  # next compare version tuple(8, 0, 0). Test for an exact match by
@@ -335,7 +319,7 @@ def _wcmatch_version(given_version):
335
319
 
336
320
  # Or, if any next value is greater than our given support level
337
321
  # version, return the current value in index. Even though it must
338
- # be less than the given value, its our closest possible match. That
322
+ # be less than the given value, it's our closest possible match. That
339
323
  # is, 4.1 is returned for given 4.9.9, where 4.1 and 5.0 are available.
340
324
  if cmp_next_version > cmp_given:
341
325
  return unicode_version
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: wcwidth
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: Measures the displayed width of unicode strings in a terminal
5
5
  Home-page: https://github.com/jquast/wcwidth
6
6
  Author: Jeff Quast
@@ -13,8 +13,6 @@ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Environment :: Console
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: POSIX
16
- Classifier: Programming Language :: Python :: 2.7
17
- Classifier: Programming Language :: Python :: 3.5
18
16
  Classifier: Programming Language :: Python :: 3.6
19
17
  Classifier: Programming Language :: Python :: 3.7
20
18
  Classifier: Programming Language :: Python :: 3.8
@@ -22,12 +20,24 @@ Classifier: Programming Language :: Python :: 3.9
22
20
  Classifier: Programming Language :: Python :: 3.10
23
21
  Classifier: Programming Language :: Python :: 3.11
24
22
  Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
25
  Classifier: Topic :: Software Development :: Libraries
26
26
  Classifier: Topic :: Software Development :: Localization
27
27
  Classifier: Topic :: Software Development :: Internationalization
28
28
  Classifier: Topic :: Terminals
29
+ Requires-Python: >=3.6
29
30
  License-File: LICENSE
30
- Requires-Dist: backports.functools-lru-cache >=1.2.1 ; python_version < "3.2"
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: home-page
36
+ Dynamic: keywords
37
+ Dynamic: license
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+ Dynamic: summary
31
41
 
32
42
  |pypi_downloads| |codecov| |license|
33
43
 
@@ -63,7 +73,7 @@ Example
63
73
  >>> text = u'コンニチハ'
64
74
 
65
75
  Python **incorrectly** uses the *string length* of 5 codepoints rather than the
66
- *printible length* of 10 cells, so that when using the `rjust` function, the
76
+ *printable length* of 10 cells, so that when using the `rjust` function, the
67
77
  output length is wrong::
68
78
 
69
79
  >>> print(len('コンニチハ'))
@@ -126,7 +136,7 @@ Briefly, return values of function ``wcwidth()`` are:
126
136
  Function ``wcswidth()`` simply returns the sum of all values for each character
127
137
  along a string, or ``-1`` when it occurs anywhere along a string.
128
138
 
129
- Full API Documentation at https://wcwidth.readthedocs.org
139
+ Full API Documentation at https://wcwidth.readthedocs.io
130
140
 
131
141
  ==========
132
142
  Developing
@@ -136,9 +146,9 @@ Install wcwidth in editable mode::
136
146
 
137
147
  pip install -e .
138
148
 
139
- Execute unit tests using tox_::
149
+ Execute unit tests using tox_ for all supported Python versions::
140
150
 
141
- tox -e py27,py35,py36,py37,py38,py39,py310,py311,py312
151
+ tox -e py36,py37,py38,py39,py310,py311,py312,py313,py314
142
152
 
143
153
  Updating Unicode Version
144
154
  ------------------------
@@ -247,8 +257,19 @@ Other Languages
247
257
  =======
248
258
  History
249
259
  =======
260
+
261
+ 0.2.14 *2025-09-22*
262
+ * **Drop Support** for Python 2.7 and 3.5. `PR #117`_.
263
+ * **Update** tables to include Unicode Specifications 16.0.0 and 17.0.0.
264
+ `PR #146`_.
265
+ * **Bugfix** U+00AD SOFT HYPHEN should measure as 1, versions 0.2.9 through
266
+ 0.2.13 measured as 0. `PR #149`_.
267
+
268
+ 0.2.13 *2024-01-06*
269
+ * **Bugfix** zero-width support for Hangul Jamo (Korean)
270
+
250
271
  0.2.12 *2023-11-21*
251
- * re-release to remove .pyi file misplaced in wheel files `Issue #101`.
272
+ * re-release to remove .pyi file misplaced in wheel files `Issue #101`_.
252
273
 
253
274
  0.2.11 *2023-11-20*
254
275
  * Include tests files in the source distribution (`PR #98`_, `PR #100`_).
@@ -286,7 +307,7 @@ History
286
307
  Environment variable ``UNICODE_VERSION``, such as ``13.0``, or ``6.3.0``.
287
308
  See the `jquast/ucs-detect`_ CLI utility for automatic detection.
288
309
  * **Enhancement**:
289
- API Documentation is published to readthedocs.org.
310
+ API Documentation is published to readthedocs.io.
290
311
  * **Updated** tables for *all* Unicode Specifications with files
291
312
  published in a programmatically consumable format, versions 4.1.0
292
313
  through 13.0
@@ -364,6 +385,9 @@ https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c::
364
385
  .. _`PR #97`: https://github.com/jquast/wcwidth/pull/97
365
386
  .. _`PR #98`: https://github.com/jquast/wcwidth/pull/98
366
387
  .. _`PR #100`: https://github.com/jquast/wcwidth/pull/100
388
+ .. _`PR #117`: https://github.com/jquast/wcwidth/pull/117
389
+ .. _`PR #146`: https://github.com/jquast/wcwidth/pull/146
390
+ .. _`PR #149`: https://github.com/jquast/wcwidth/pull/149
367
391
  .. _`Issue #101`: https://github.com/jquast/wcwidth/issues/101
368
392
  .. _`jquast/blessed`: https://github.com/jquast/blessed
369
393
  .. _`selectel/pyte`: https://github.com/selectel/pyte
@@ -0,0 +1,13 @@
1
+ wcwidth/__init__.py,sha256=5RiBcbmILHnDStKPOr1jA_31LMgbwTZmv7UoSf1c1-A,1076
2
+ wcwidth/table_vs15.py,sha256=Xl7hsr04XJ4vvxe37LvaL0ex93rWUvzYIpX1vJiHyYQ,5170
3
+ wcwidth/table_vs16.py,sha256=STRpUr9FNE3B2aOKtIy-a3wix4eMUSyOg65ZCIHY4qM,6857
4
+ wcwidth/table_wide.py,sha256=DL-zI2JGLcJkEMPcaMvqBYLQDbhheOL3pGYpzvHTQPU,117873
5
+ wcwidth/table_zero.py,sha256=YcdDVx4WuXVdlJGSOvOZ99Msn8KeRVLIDDz4Om9DXOI,409071
6
+ wcwidth/unicode_versions.py,sha256=XprVckZk9FOFrmQaSxEnDqa8G-q8h36j7zRnFUj6V4I,887
7
+ wcwidth/wcwidth.py,sha256=Sx85FzyPmJzXPSOSZvq3IDqS6cZrp_f6n1jHdS4Ox7s,13551
8
+ wcwidth-0.2.14.dist-info/licenses/LICENSE,sha256=cLmKlaIUTrcK-AF_qMbZXOJH5AhnQ26LxknhN_4T0ho,1322
9
+ wcwidth-0.2.14.dist-info/METADATA,sha256=zOIuk0LOo4aPc1wHTJfSNJASCiSzRkq_EMHRsLsWK1M,15629
10
+ wcwidth-0.2.14.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
11
+ wcwidth-0.2.14.dist-info/top_level.txt,sha256=LLjS8SFiXXuLEcD2BNdFdGhpKWe5opHtvn7KNj9AIRI,8
12
+ wcwidth-0.2.14.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
+ wcwidth-0.2.14.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -1,12 +0,0 @@
1
- wcwidth/__init__.py,sha256=MgWOMcKDsFxzbsPWadphSxeMnbb4yZl9sZfZBG96IBo,1076
2
- wcwidth/table_vs16.py,sha256=hPbuoFxmxrGfuBaeoheMTAGmgB2a4EudhxYsYokLf6o,6857
3
- wcwidth/table_wide.py,sha256=fB3tpAqA_c4288vIqxXOZiyitHnbItZYJZpHw92ilNU,100104
4
- wcwidth/table_zero.py,sha256=4xe0VnipYwM4KzFfFHofhyOSFhxJo3NVrXJgfG3z4MU,356657
5
- wcwidth/unicode_versions.py,sha256=7nShgeRYrvZFkGpREdr-PkUeXnuM-WxeOmGYj6QNaaE,851
6
- wcwidth/wcwidth.py,sha256=P9-Tgvv-UhIAR6HHcqn6-OOvVLPuH4xzZAFJiuOEyyo,14315
7
- wcwidth-0.2.12.dist-info/LICENSE,sha256=cLmKlaIUTrcK-AF_qMbZXOJH5AhnQ26LxknhN_4T0ho,1322
8
- wcwidth-0.2.12.dist-info/METADATA,sha256=FAnbB4Khqefu4iDdlHOiVwnRNSbiOMQGcTimM6DIn4k,14910
9
- wcwidth-0.2.12.dist-info/WHEEL,sha256=P2T-6epvtXQ2cBOE_U1K4_noqlJFN3tj15djMgEu4NM,110
10
- wcwidth-0.2.12.dist-info/top_level.txt,sha256=LLjS8SFiXXuLEcD2BNdFdGhpKWe5opHtvn7KNj9AIRI,8
11
- wcwidth-0.2.12.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
12
- wcwidth-0.2.12.dist-info/RECORD,,