Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
babel.messages.frontend Namespace Reference

Classes

class  BaseError
 
class  CommandLineInterface
 
class  CommandMixin
 
class  CompileCatalog
 
class  ConfigurationError
 
class  ExtractMessages
 
class  InitCatalog
 
class  OptionError
 
class  SetupError
 
class  UpdateCatalog
 

Functions

 listify_value (arg, split=None)
 
 _make_directory_filter (ignore_patterns)
 
 main ()
 
 parse_mapping (fileobj, filename=None)
 
 parse_mapping_cfg (fileobj, filename=None)
 
 _parse_config_object (dict config, *filename="(unknown)")
 
 _parse_mapping_toml (BinaryIO fileobj, str filename="(unknown)", Literal["standalone", "pyproject.toml"] style="standalone")
 
tuple[int|None, tuple[int|tuple[int, str],...]] _parse_spec (str s)
 
 parse_keywords (Iterable[str] strings=())
 
 __getattr__ (str name)
 

Variables

 log = logging.getLogger('babel')
 

Detailed Description

    babel.messages.frontend
    ~~~~~~~~~~~~~~~~~~~~~~~

    Frontends for the message extraction functionality.

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.

Function Documentation

◆ _make_directory_filter()

babel.messages.frontend._make_directory_filter (   ignore_patterns)
protected
Build a directory_filter function based on a list of ignore patterns.

◆ _parse_mapping_toml()

babel.messages.frontend._parse_mapping_toml ( BinaryIO  fileobj,
str   filename = "(unknown)",
Literal["standalone", "pyproject.toml"]   style = "standalone" 
)
protected
Parse an extraction method mapping from a binary file-like object.

.. warning: As of this version of Babel, this is a private API subject to changes.

:param fileobj: a readable binary file-like object containing the configuration TOML to parse
:param filename: the name of the file being parsed, for error messages
:param style: whether the file is in the style of a `pyproject.toml` file, i.e. whether to look for `tool.babel`.

◆ listify_value()

babel.messages.frontend.listify_value (   arg,
  split = None 
)
Make a list out of an argument.

Values from `distutils` argument parsing are always single strings;
values from `optparse` parsing may be lists of strings that may need
to be further split.

No matter the input, this function returns a flat list of whitespace-trimmed
strings, with `None` values filtered out.

>>> listify_value("foo bar")
['foo', 'bar']
>>> listify_value(["foo bar"])
['foo', 'bar']
>>> listify_value([["foo"], "bar"])
['foo', 'bar']
>>> listify_value([["foo"], ["bar", None, "foo"]])
['foo', 'bar', 'foo']
>>> listify_value("foo, bar, quux", ",")
['foo', 'bar', 'quux']

:param arg: A string or a list of strings
:param split: The argument to pass to `str.split()`.
:return:

◆ parse_keywords()

babel.messages.frontend.parse_keywords ( Iterable[str]   strings = ())
Parse keywords specifications from the given list of strings.

>>> import pprint
>>> keywords = ['_', 'dgettext:2', 'dngettext:2,3', 'pgettext:1c,2',
...             'polymorphic:1', 'polymorphic:2,2t', 'polymorphic:3c,3t']
>>> pprint.pprint(parse_keywords(keywords))
{'_': None,
 'dgettext': (2,),
 'dngettext': (2, 3),
 'pgettext': ((1, 'c'), 2),
 'polymorphic': {None: (1,), 2: (2,), 3: ((3, 'c'),)}}

The input keywords are in GNU Gettext style; see :doc:`cmdline` for details.

The output is a dictionary mapping keyword names to a dictionary of specifications.
Keys in this dictionary are numbers of arguments, where ``None`` means that all numbers
of arguments are matched, and a number means only calls with that number of arguments
are matched (which happens when using the "t" specifier). However, as a special
case for backwards compatibility, if the dictionary of specifications would
be ``{None: x}``, i.e., there is only one specification and it matches all argument
counts, then it is collapsed into just ``x``.

A specification is either a tuple or None. If a tuple, each element can be either a number
``n``, meaning that the nth argument should be extracted as a message, or the tuple
``(n, 'c')``, meaning that the nth argument should be extracted as context for the
messages. A ``None`` specification is equivalent to ``(1,)``, extracting the first
argument.

◆ parse_mapping_cfg()

babel.messages.frontend.parse_mapping_cfg (   fileobj,
  filename = None 
)
Parse an extraction method mapping from a file-like object.

:param fileobj: a readable file-like object containing the configuration
                text to parse
:param filename: the name of the file being parsed, for error messages