aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pytest/py3/_pytest/_io/wcwidth.py
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
committermonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /contrib/python/pytest/py3/_pytest/_io/wcwidth.py
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
downloadydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz
fix ya.make
Diffstat (limited to 'contrib/python/pytest/py3/_pytest/_io/wcwidth.py')
-rw-r--r--contrib/python/pytest/py3/_pytest/_io/wcwidth.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/contrib/python/pytest/py3/_pytest/_io/wcwidth.py b/contrib/python/pytest/py3/_pytest/_io/wcwidth.py
deleted file mode 100644
index e5c7bf4d86..0000000000
--- a/contrib/python/pytest/py3/_pytest/_io/wcwidth.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import unicodedata
-from functools import lru_cache
-
-
-@lru_cache(100)
-def wcwidth(c: str) -> int:
- """Determine how many columns are needed to display a character in a terminal.
-
- Returns -1 if the character is not printable.
- Returns 0, 1 or 2 for other characters.
- """
- o = ord(c)
-
- # ASCII fast path.
- if 0x20 <= o < 0x07F:
- return 1
-
- # Some Cf/Zp/Zl characters which should be zero-width.
- if (
- o == 0x0000
- or 0x200B <= o <= 0x200F
- or 0x2028 <= o <= 0x202E
- or 0x2060 <= o <= 0x2063
- ):
- return 0
-
- category = unicodedata.category(c)
-
- # Control characters.
- if category == "Cc":
- return -1
-
- # Combining characters with zero width.
- if category in ("Me", "Mn"):
- return 0
-
- # Full/Wide east asian characters.
- if unicodedata.east_asian_width(c) in ("F", "W"):
- return 2
-
- return 1
-
-
-def wcswidth(s: str) -> int:
- """Determine how many columns are needed to display a string in a terminal.
-
- Returns -1 if the string contains non-printable characters.
- """
- width = 0
- for c in unicodedata.normalize("NFC", s):
- wc = wcwidth(c)
- if wc < 0:
- return -1
- width += wc
- return width