$34 GRAYBYTE WORDPRESS FILE MANAGER $92

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.180
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/opt/imunify360/venv/lib/python3.11/site-packages/babel/

HOME
Current File : /opt/imunify360/venv/lib/python3.11/site-packages/babel//lists.py
"""
    babel.lists
    ~~~~~~~~~~~

    Locale dependent formatting of lists.

    The default locale for the functions in this module is determined by the
    following environment variables, in that order:

     * ``LC_ALL``, and
     * ``LANG``

    :copyright: (c) 2015-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
"""
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING

from babel.core import Locale, default_locale

if TYPE_CHECKING:
    from typing_extensions import Literal

DEFAULT_LOCALE = default_locale()


def format_list(lst: Sequence[str],
                style: Literal['standard', 'standard-short', 'or', 'or-short', 'unit', 'unit-short', 'unit-narrow'] = 'standard',
                locale: Locale | str | None = DEFAULT_LOCALE) -> str:
    """
    Format the items in `lst` as a list.

    >>> format_list(['apples', 'oranges', 'pears'], locale='en')
    u'apples, oranges, and pears'
    >>> format_list(['apples', 'oranges', 'pears'], locale='zh')
    u'apples\u3001oranges\u548cpears'
    >>> format_list(['omena', 'peruna', 'aplari'], style='or', locale='fi')
    u'omena, peruna tai aplari'

    These styles are defined, but not all are necessarily available in all locales.
    The following text is verbatim from the Unicode TR35-49 spec [1].

    * standard:
      A typical 'and' list for arbitrary placeholders.
      eg. "January, February, and March"
    * standard-short:
      A short version of a 'and' list, suitable for use with short or abbreviated placeholder values.
      eg. "Jan., Feb., and Mar."
    * or:
      A typical 'or' list for arbitrary placeholders.
      eg. "January, February, or March"
    * or-short:
      A short version of an 'or' list.
      eg. "Jan., Feb., or Mar."
    * unit:
      A list suitable for wide units.
      eg. "3 feet, 7 inches"
    * unit-short:
      A list suitable for short units
      eg. "3 ft, 7 in"
    * unit-narrow:
      A list suitable for narrow units, where space on the screen is very limited.
      eg. "3′ 7″"

    [1]: https://www.unicode.org/reports/tr35/tr35-49/tr35-general.html#ListPatterns

    :param lst: a sequence of items to format in to a list
    :param style: the style to format the list with. See above for description.
    :param locale: the locale
    """
    locale = Locale.parse(locale)
    if not lst:
        return ''
    if len(lst) == 1:
        return lst[0]

    if style not in locale.list_patterns:
        raise ValueError(
            f'Locale {locale} does not support list formatting style {style!r} '
            f'(supported are {sorted(locale.list_patterns)})'
        )
    patterns = locale.list_patterns[style]

    if len(lst) == 2:
        return patterns['2'].format(*lst)

    result = patterns['start'].format(lst[0], lst[1])
    for elem in lst[2:-1]:
        result = patterns['middle'].format(result, elem)
    result = patterns['end'].format(result, lst[-1])

    return result


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
3 Mar 2026 8.59 AM
root / root
0755
__pycache__
--
3 Mar 2026 8.59 AM
root / root
0755
locale-data
--
3 Mar 2026 8.59 AM
root / root
0755
localtime
--
3 Mar 2026 8.59 AM
root / root
0755
messages
--
3 Mar 2026 8.59 AM
root / root
0755
__init__.py
0.843 KB
13 Feb 2026 12.40 PM
root / root
0644
core.py
41.62 KB
13 Feb 2026 12.40 PM
root / root
0644
dates.py
70.87 KB
13 Feb 2026 12.40 PM
root / root
0644
global.dat
254.071 KB
13 Feb 2026 12.40 PM
root / root
0644
languages.py
2.777 KB
13 Feb 2026 12.40 PM
root / root
0644
lists.py
2.943 KB
13 Feb 2026 12.40 PM
root / root
0644
localedata.py
8.046 KB
13 Feb 2026 12.40 PM
root / root
0644
numbers.py
48.35 KB
13 Feb 2026 12.40 PM
root / root
0644
plural.py
22.672 KB
13 Feb 2026 12.40 PM
root / root
0644
py.typed
0.058 KB
13 Feb 2026 12.40 PM
root / root
0644
support.py
25.624 KB
13 Feb 2026 12.40 PM
root / root
0644
units.py
11.602 KB
13 Feb 2026 12.40 PM
root / root
0644
util.py
7.77 KB
13 Feb 2026 12.40 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF