Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/wcwidth/__init__.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Python 'wcwidth' module.
4https://github.com/jquast/wcwidth
5"""
7# re-export common and outermost functions & definitions, even a few private
8# ones, some for convenience, others for legacy, only the items in __all__ are
9# documented as public API
11__lazy_modules__ = [
12 "wcwidth._clip",
13 "wcwidth._wcswidth",
14 "wcwidth._wcwidth",
15 "wcwidth._width",
16 "wcwidth.align",
17 "wcwidth.bisearch",
18 "wcwidth.escape_sequences",
19 "wcwidth.grapheme",
20 "wcwidth.hyperlink",
21 "wcwidth.sgr_state",
22 "wcwidth.table_ambiguous",
23 "wcwidth.table_vs16",
24 "wcwidth.table_wide",
25 "wcwidth.table_zero",
26 "wcwidth.text_sizing",
27 "wcwidth.textwrap",
28 "wcwidth.unicode_versions",
29]
31# local
32from ._clip import clip
33from .align import ljust, rjust, center
34from ._width import width
35from .bisearch import bisearch as _bisearch
36from .grapheme import iter_graphemes, iter_graphemes_reverse, grapheme_boundary_before
37from .textwrap import SequenceTextWrapper, wrap
38from ._wcswidth import wcswidth, wcstwidth
39from .hyperlink import Hyperlink, HyperlinkParams
40from .sgr_state import propagate_sgr
41from ._constants import list_term_programs
42from .table_vs16 import VS16_NARROW_TO_WIDE
43from .table_wide import WIDE_EASTASIAN
44from .table_zero import ZERO_WIDTH
45from .text_sizing import TextSizing, TextSizingParams
46from .table_ambiguous import AMBIGUOUS_EASTASIAN
47from .escape_sequences import iter_sequences, strip_sequences
48from .unicode_versions import list_versions
50# NOTE: this sort order is important for legacy import API compatibility before release 0.7.0
51#
52# On Python < 3.15 the legacy submodule is eagerly pre-imported for backward compatibility
53# (populates sys.modules['wcwidth.wcwidth']). On 3.15+ __lazy_modules__ handles all submodules; the
54# legacy shim loads on-demand via file discovery when ``from wcwidth.wcwidth import ...`` is used.
55if __import__('sys').version_info < (3, 15):
56 # Pre-import the legacy submodule so that sys.modules['wcwidth.wcwidth'] is populated during
57 # package initialization. Without this, a later downstream dependent ``import wcwidth.wcwidth``
58 # triggers on-disk file discovery which rebinds wcwidth.wcwidth from the function to the module
59 # object.
60 #
61 # this is just a lot of carefulness for the original release that contained all functions in a
62 # single 'wcwidth.py' file. Even though we always exposed our API at the top-level the preferred
63 # 'from wcwidth import wcswidth', it was always possible to import them more directly,
64 # 'from wcwidth.wcwidth import wcswidth'
65 # -- and we make a lot of effort to allow any such import statements to continue to function.
66 from . import wcwidth as _wcwidth_module # isort:skip
67from ._wcwidth import wcwidth, _wcmatch_version, _wcversion_value # isort:skip # pylint: disable=wrong-import-position
70# The __all__ attribute defines the items exported from statement,
71# 'from wcwidth import *', but also to say, "This is the public API".
72__all__ = ('wcwidth', 'wcswidth', 'wcstwidth', 'width', 'iter_sequences', 'iter_graphemes',
73 'iter_graphemes_reverse', 'grapheme_boundary_before',
74 'ljust', 'rjust', 'center', 'wrap', 'clip', 'strip_sequences',
75 'list_versions', 'list_term_programs', 'propagate_sgr',
76 'Hyperlink', 'HyperlinkParams', 'TextSizing', 'TextSizingParams')
78# Using 'hatchling', it does not seem to provide the pyproject.toml nicety, "dynamic = ['version']"
79# like flit_core, maybe there is some better way but for now we have to duplicate it in both places
80# Prefer the installed distribution version when available (helps test environments)
81__version__ = '0.8.1' # don't forget to also update pyproject.toml:version