babel.util ~~~~~~~~~~ Various utility classes and functions. :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details.
Class |
|
Fixed offset in minutes east from UTC. |
Class |
|
Undocumented |
Function | distinct |
Yield all items in an iterable collection that are distinct. |
Function | parse |
Deduce the encoding of a source file from magic comment. |
Function | parse |
Parse the compiler flags by :mod:`__future__` from the given Python code. |
Function | pathmatch |
Extended pathname pattern matching. |
Function | wraptext |
Simple wrapper around the ``textwrap.wrap`` function in the standard library. This version does not wrap lines on hyphens in words. |
Variable | missing |
Undocumented |
Variable |
|
Undocumented |
Variable |
|
Undocumented |
Function | _cmp |
Undocumented |
Type Variable | _T |
Undocumented |
Yield all items in an iterable collection that are distinct. Unlike when using sets for a similar effect, the original ordering of the items in the collection is preserved by this function. >>> print(list(distinct([1, 2, 1, 3, 4, 4]))) [1, 2, 3, 4] >>> print(list(distinct('foobar'))) ['f', 'o', 'b', 'a', 'r'] :param iterable: the iterable collection providing the data
Deduce the encoding of a source file from magic comment. It does this in the same way as the `Python interpreter`__ .. __: https://docs.python.org/3.4/reference/lexical_analysis.html#encoding-declarations The ``fp`` argument should be a seekable file object. (From Jeff Dairiki)
Extended pathname pattern matching. This function is similar to what is provided by the ``fnmatch`` module in the Python standard library, but: * can match complete (relative or absolute) path names, and not just file names, and * also supports a convenience pattern ("**") to match files at any directory level. Examples: >>> pathmatch('**.py', 'bar.py') True >>> pathmatch('**.py', 'foo/bar/baz.py') True >>> pathmatch('**.py', 'templates/index.html') False >>> pathmatch('./foo/**.py', 'foo/bar/baz.py') True >>> pathmatch('./foo/**.py', 'bar/baz.py') False >>> pathmatch('^foo/**.py', 'foo/bar/baz.py') True >>> pathmatch('^foo/**.py', 'bar/baz.py') False >>> pathmatch('**/templates/*.html', 'templates/index.html') True >>> pathmatch('**/templates/*.html', 'templates/foo/bar.html') False :param pattern: the glob pattern :param filename: the path name of the file to match against
str
, width: int
= 70, initial_indent: str
= '', subsequent_indent: str
= '') -> list[ str]
:
(source)
¶
Simple wrapper around the ``textwrap.wrap`` function in the standard library. This version does not wrap lines on hyphens in words. :param text: the text to wrap :param width: the maximum line width :param initial_indent: string that will be prepended to the first line of wrapped output :param subsequent_indent: string that will be prepended to all lines save the first of wrapped output