• ANN: EmPy 4.2 -- a powerful, robust and mature templating system for Py

    From Erik Max Francis@21:1/5 to All on Sun Aug 25 16:40:01 2024
    # EmPy 4.2 release announcement

    I'm pleased to announce the release of EmPy 4.2.

    The 4._x_ series is a modernization of the software and a revamp of
    the EmPy system to update its feature set and make it more consistent
    with the latest Python versions and practices. EmPy 4._x_ was also
    relicensed to BSD.

    The 4._x_ series adds new markups, including inline comments,
    backquote literals, chained if-then-else extended expression,
    functional expressions, support for modern Pythonic controls,
    stringized and multiline significators, disabling and re-enabling
    output, named escapes, diacritics, icons, emojis, and customizable
    extension markups.

    It adds support for configuration objects (replacing options
    dictionaries); native support for Unicode, file buffering, reference
    counted `sys.stdout` proxies and error dispatchers and handlers; fixes
    several serious bugs; has a set of full unit and system tests, an
    extensive builtin help system; and the online documention has been
    rewritten and expanded. It also allows customizing the underlying
    interpreter core and full support for EmPy modules -- EmPy documents
    which can be imported as modules.

    Attempts have been made to make EmPy 4._x_ as backward compatible as
    is practical. Most common markup has not changed; the only changes
    being removal of `repr` (in favor of backquote literals) as well as
    literal close parenthesis, bracket and brace markup; in-place markup
    has changed syntax (to make way for emojis); and extension/custom
    markup is now parsed more sensibly.

    Most backward-incompatible changes are in the embedding interface.
    The `Interpreter` constructor and global `expand` function now require
    keyword arguments to prevent further backward compatibility problems,
    though effort has been made to make the behavior as backward
    compatible as possible. The supported environment variables have
    changed, as well as the filter, diversion and hook APIs, and options dictionaries no longer exist (in deference to configurations).

    For a comprehensive list of changes from 3._x_ to 4._x_, see: <http://www.alcyone.com/software/empy/ANNOUNCE.html#changes>


    ## Introduction: Welcome to EmPy!

    [EmPy](http://www.alcyone.com/software/empy/) is a powerful, robust and
    mature
    templating system for inserting Python code in template text. EmPy
    takes a source document, processes it, and produces output. This is accomplished via expansions, which are signals to the EmPy system
    where to act and are indicated with markup. Markup is set off by a customizable prefix (by default the at sign, `@`). EmPy can expand
    arbitrary Python expressions, statements and control structures in
    this way, as well as a variety of additional special forms. The
    remaining textual data is sent to the output, allowing Python to be
    used in effect as a markup language.

    EmPy also supports hooks, which can intercept and modify the behavior
    of a running interpreter; diversions, which allow recording and
    playback; filters, which are dynamic and can be chained together; and
    a dedicated user-customizable callback markup. The system is highly configurable via command line options, configuration files, and
    environment variables. EmPy documents can also be imported as
    modules, and an extensive API is also available for embedding EmPy functionality in your own Python programs.

    EmPy also has a supplemental library for additional non-essential
    features (`emlib`), a documentation building library used to create
    this documentation (`emdoc`), and an extensive help system (`emhelp`)
    which can be queried from the command line with the main executable
    `em.py` (`-h/--help`, `-H/--topics=TOPICS`). The base EmPy
    interpreter can function with only the `em.py`/`em` file/module
    available.

    EmPy can be used in a variety of roles, including as a templating
    system, a text processing system (preprocessing and/or
    postprocessing), a simple macro processor, a frontend for a content
    management system, annotating documents, for literate programming, as
    a souped-up text encoding converter, a text beautifier (with macros
    and filters), and many other purposes.


    ### Markup overview

    Expressions are embedded in text with the `@(...)` notation;
    variations include conditional expressions with `@(...?...!...)` and
    the ability to handle thrown exceptions with `@(...$...)`. As a
    shortcut, simple variables and expressions can be abbreviated as
    `@variable`, `@object.attribute`, `@sequence[index]`, `@function(arguments...)`, `@function{markup}{...}` and
    combinations. Full-fledged statements are embedded with `@{...}`.
    Control flow in terms of conditional or repeated expansion is
    available with `@[...]`. A `@` followed by any whitespace character
    (including a newline) expands to nothing, allowing string
    concatenations and line continuations. Line comments are indicated
    with `@#...` including the trailing newline. `@*...*` allows inline
    comments. Output can be disabled and re-enabled with `@-...` and
    `@+...`. Escapes are indicated with `@\...`; diacritics with
    `@^...`; icons with `@|...`; and emoji with `@:...:`. `@%...`,
    `@%!...`, `@%%...%%` and `@%%!...%%` indicate "significators,"
    which are distinctive forms of variable assignment intended to specify
    document metadata in a format easy to parse externally. In-place
    expressions are specified with `@$...$...$`. Context name and line
    number changes can be made with `@?...` and `@!...`, respectively.
    A set of markups (`@((...))`, `@[[...]]`, `@{{...}}`, `@<...>`)
    are customizable by the user and can be used for any desired purpose.
    `` @`...` `` allows literal escaping of any EmPy markup. Output can
    be toggled on and off with `@+` and `@-`, respectively. And
    finally, a `@@` sequence (the prefix repeated once) expands to a
    single literal at sign.

    The prefix defaults to `@` but can be changed with
    the command line option `-p/--prefix=CHAR` (_environment variable:_ `EMPY_PREFIX`, _configuration variable:_ `prefix`).


    ### Getting the software

    The current version of EmPy is 4.2.

    The official URL for this Web site is
    <http://www.alcyone.com/software/empy/>.

    The latest version of the software is available in a tarball here: <http://www.alcyone.com/software/empy/empy-latest.tar.gz>.

    The software can be installed through PIP via this shell command:

    ```
    % python3 -m pip install empy
    ```


    For information about upgrading from 3._x_ to 4._x_, see <http://www.alcyone.com/software/empy/ANNOUNCE.html#changes>.


    ### Requirements

    EmPy works with any modern version of Python. Python version 3._x_ is
    expected to be the default and all source file references to the
    Python interpreter (_e.g._, the bangpath of the .py scripts) use
    `python3`. EmPy also has legacy support for versions of Python going
    back all the way to 2.4, with special emphasis on 2.7 regardless of
    its end-of-life status. It has no dependency requirements on any
    third-party modules and can run directly off of a stock Python
    interpreter.

    EmPy will run on any operating system with a full-featured Python
    interpreter; this includes, but is probably not limited to, the
    operating systems Linux, Windows and macOS (Darwin). Using EmPy
    requires knowledge of the [Python language](https://www.python.org/).

    EmPy is compatible with many different Python implementations,
    interpreter variants, packaging systems, and enhanced shells:

    | Variant | Supported versions | Description |
    | --- | --- | --- |
    | [CPython](https://www.python.org/) | 2.4 and up | Standard
    implementation in C |
    | [PyPy](https://www.pypy.org/) | 2.7 and up | Implementation with
    just-in-time compiler |
    | [Stackless Python](https://github.com/stackless-dev/stackless/wiki/) |
    2.4 and up | Implementation supporting microthreading |
    | [IronPython](https://ironpython.net/) | 2.7 and up | Implementation
    for .NET CLR and Mono |
    | [Jython](https://www.jython.org/) | 2.5 to 2.7 (and up?) |
    Implementation for JVM |
    | [ActiveState Python](https://www.activestate.com/products/python/) |
    2.7 and up | Secure supply chain open source solution |
    | [eGenix PyRun](https://www.egenix.com/products/python/PyRun/) | 2.5
    and up | One-file, no-installation CPython environment |
    | [WinPython](https://winpython.github.io/) | 3.0 and up | Portable
    Scientific Python for Windows |
    | [PortablePython](https://portablepython.com/) | 2.7 and up |
    Minimalistic Python distribution for Windows |
    | [IDLE](https://docs.python.org/3/library/idle.html) | all | Python's Integrated Development and Learning Environment |
    | [IPython](https://ipython.org/) | all | Powerful interactive shell;
    kernel for [Jupyter](https://jupyter.org/) |

    EmPy is also compatible with scaled-down implementations of Python,
    provided they support the set of standard modules that EmPy requires,
    namely:

    - `codecs`
    - `copy`
    - `getopt`
    - `os`
    - `platform`
    - `re`
    - `sys`
    - `unicodedata`

    Only a few .py module file(s) are needed to use EmPy; they can be
    installed system-wide through a distribution package, via PIP, or just
    dropped into any desired directory in the `PYTHONPATH` (as a module)
    and/or `PATH` (as an executable). A minimal installation need only
    install the em.py file, either as an importable module or an
    executable, or both, depending on the user's needs.

    EmPy also has optional support for several [third-party emoji modules](#third-party-emoji-modules); see [Emoji
    markup](#emoji-markup) for details.

    The testing system included (the test.sh script and the tests and
    suites directories) is intended to run on Unix-like systems with a
    Bourne-like shell (_e.g._, sh, bash, zsh, etc.). EmPy is routinely
    tested with all supported versions of all available interpreters.

    If you find an incompatibility with your Python interpreter or
    operating system, [let me know](#reporting-bugs).


    ### License

    This software is licensed under
    [BSD (3-Clause)](https://opensource.org/licenses/bsd-3-clause/).


    ### Recent release history (since 3._x_)

    {#latest-release}
    4.2 (2024 Aug 25)

    : Add module support; add support for disabling output and switch
    markup; add support for reconfiguring stdin/stdout; support repeated
    curly braces with functional expression; add backward-compatible
    `Case` abstraction for match markup; add more preprocessing and
    postprocessing commands via command line options.

    4.1 (2024 Mar 24)

    : Add support for extension markup `@((...))`, `@[[...]]`,
    `@{{...}}`, `@<...>`, etc., with custom callbacks retained for
    backward compatibility; add `@[match]` control support; add
    interpreter cores for overriding interpreter behavior; add more
    command line option toggles; add notion of verbose/brief errors;
    more uniform error message formatting; various documentation
    updates.

    {#last-minor-release}
    4.0.1 (2023 Dec 24)

    : Add root context argument, serializers, and idents to interpreter;
    fix `setContext...` methods so they also modify the currents stack;
    better backward compatibility for `expand` function and
    `CompatibilityError`; fix inconsistent stack usage with `expand`
    method; add error dispatchers, cleaner error handling and
    `ignoreErrors`; have `expand` method/function raise
    exceptions to caller; eliminate need for `FullContext` class
    distinct from `Context`; support comments in "clean" controls; add
    `--no-none-symbol` option; add clearer errors for removed literal
    markup; add `Container` support class in `emlib`; hide non-standard
    proxy attributes and methods; support string errors (why not);
    update and expand tests; help subsystem and documentation updates.

    4.0 (2023 Nov 29)

    : A major revamp, refresh, and modernization. Major new features
    include inline comments `@*...*`; backquote literals `` @`...`
    ``; chained if-then-else expressions; functional expressions
    `@f{...}`; full support for `@[try]`, `@[while ...]` and `@[with
    ...]` control markup; `@[defined ...]` control markup; stringized
    and multiline significators; named escapes `@\^{...}`; diacritics
    `@^...`; icons `@|...`; emojis `@:...:`; configurations; full
    Unicode and file buffering support; proxy now reference counted;
    hooks can override behavior; many bug fixes; an extensive builtin
    help system (`emhelp`); and rewritten and expanded documentation in
    addition to a dedicated module (`emdoc`). Changes include
    relicensing to BSD, interpreter constructor now requires keyword
    arguments, `-d/--delete-on-error` instead of "fully buffered files";
    cleaned up environment variables; "repr" markup replaced with emoji
    markup; remove literal markups `@)`, `@]`, `@}`; context line
    markup `@!...` no longer pre-adjusts line; custom markup `@<...>`
    now parsed more sensibly; filter shortcuts removed; context now
    track column and character count; auxiliary classes moved to `emlib`
    module; use `argv` instead of `argc` for interpreter arguments. See
    [Full list of changes between EmPy 3._x_ and
    4.0](http://www.alcyone.com/software/empy/ANNOUNCE.html#all-changes)
    for a more
    comprehensive list.

    --
    Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
    San Jose, CA, USA && 37 18 N 121 57 W && Skype erikmaxfrancis
    Of all the supposed virtues, faith must be the most overrated.
    -- Christopher Hitchens

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)