Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Of all the tyrannies that affect mankind, tyranny in religion is the worst." -- Thomas Paine


devel / comp.lang.python / ANN: EmPy 4.1 -- a powerful, robust and mature templating system for Python

SubjectAuthor
o ANN: EmPy 4.1 -- a powerful, robust and mature templating system for PythonErik Max Francis

1
ANN: EmPy 4.1 -- a powerful, robust and mature templating system for Python

<mailman.22.1711339821.3468.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=29732&group=comp.lang.python#29732

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: max@alcyone.com (Erik Max Francis)
Newsgroups: comp.lang.python
Subject: ANN: EmPy 4.1 -- a powerful, robust and mature templating system for
Python
Date: Sun, 24 Mar 2024 21:10:17 -0700
Organization: Alcyone Systems
Lines: 244
Message-ID: <mailman.22.1711339821.3468.python-list@python.org>
References: <9700aa35-1f1f-47d3-b0b9-98a4aff41099@alcyone.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de Nz9nf7ner5rRFNSFah71GQkTuyMmoNkUgSgS4e7oNIkQ==
Cancel-Lock: sha1:BcyX7/1vNQZ7f2hq9EXxMjUsU48= sha256:sizno6BCydJP4VIensgLa1YGkPisyetvYPxChH9pJgQ=
Return-Path: <max@alcyone.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=alcyone-com.20230601.gappssmtp.com
header.i=@alcyone-com.20230601.gappssmtp.com
header.b=unjvYYQe; dkim-adsp=none (unprotected policy);
dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'comments': 0.03; 'pip':
0.04; 'indicate': 0.05; 'usage': 0.05; 'variable': 0.05;
'windows,': 0.05; '(to': 0.07; 'filter': 0.07; 'linux,': 0.07;
'mar': 0.07; 'modules': 0.07; 'string': 0.07; 'template': 0.07;
'tests': 0.07; 'updates.': 0.07; 'python.': 0.08; '2.7': 0.09;
'3.2': 0.09; 'attempts': 0.09; 'compiler': 0.09; 'etc.).': 0.09;
'expansion': 0.09; 'frontend': 0.09; 'macos': 0.09; 'moved': 0.09;
'options,': 0.09; 'parse': 0.09; 'skip:` 10': 0.09; 'skip:` 20':
0.09; 'text.': 0.09; 'uniform': 0.09; 'upgrading': 0.09;
'subject:Python': 0.12; 'announce': 0.15; 'supported': 0.15;
'syntax': 0.15; '"fully': 0.16; '(potentially': 0.16; '(why':
0.16; '.py': 0.16; '3.4': 0.16; 'apis,': 0.16; 'arbitrary': 0.16;
'arguments': 0.16; 'attributes': 0.16; 'backward': 0.16;
'builtin': 0.16; 'cleaned': 0.16; 'column': 0.16; 'command:':
0.16; 'comments.': 0.16; 'conditional': 0.16; 'constructor': 0.16;
'cpython': 0.16; 'defaults': 0.16; 'document,': 0.16; 'encoding':
0.16; 'executable': 0.16; 'expressions': 0.16; 'file/module':
0.16; 'filter,': 0.16; 'fixes': 0.16; 'from:addr:max': 0.16;
'full-fledged': 0.16; 'icons': 0.16; 'interpreter': 0.16;
'jython': 0.16; 'legacy': 0.16; 'literals': 0.16; 'nothing,':
0.16; 'prefix': 0.16; 'python3': 0.16; 'pythonic': 0.16; 'received
:mail-pf1-x432.google.com': 0.16; 'repeated': 0.16; 'shortcuts':
0.16; 'specify': 0.16; 'structures': 0.16; 'subject: -- ': 0.16;
'subject:ANN': 0.16; 'system;': 0.16; 'tests,': 0.16; 'textual':
0.16; 'third-party': 0.16; 'unicode': 0.16; 'url:gz': 0.16;
'url:tar': 0.16; 'python': 0.16; 'api': 0.17; 'instead': 0.17;
'probably': 0.17; 'bug': 0.19; 'url': 0.19; 'to:addr:python-list':
0.20; 'option': 0.20; 'maybe': 0.22; 'skip:_ 10': 0.22; 'version':
0.23; 'install': 0.23; 'code': 0.23; 'command': 0.23; 'installed':
0.23; 'run': 0.23; '(and': 0.25; 'extension': 0.25; 'behavior':
0.26; 'classes': 0.26; 'library': 0.26; 'programming,': 0.26;
'recording': 0.26; 'function': 0.27; 'series': 0.28; 'global':
0.73; 'easy': 0.74; 'history': 0.75; 'features': 0.75; 'details.':
0.76; 'favor': 0.76; 'produces': 0.76; 'skip:k 20': 0.78;
'highly': 0.78; 'major': 0.78; 'indicated': 0.81; 'skype': 0.81;
'unit': 0.81; 'url-ip:199/8': 0.84; 'variety': 0.84; '3.0': 0.84;
'callback': 0.84; 'changed,': 0.84; 'cleaner': 0.84; 'comments,':
0.84; 'controls,': 0.84; 'eliminate': 0.84; 'etc.,': 0.84;
'exceptions': 0.84; 'file(s)': 0.84; 'forms.': 0.84;
'inconsistent': 0.84; 'licensed': 0.84; 'line;': 0.84; 'macro':
0.84; 'macros': 0.84; 'powerful,': 0.84; 'roles,': 0.84; 'sign,':
0.84; 'signals': 0.84; 'subject: \n ': 0.84; 'removal': 0.91;
'retained': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=alcyone-com.20230601.gappssmtp.com; s=20230601; t=1711339819; x=1711944619;
darn=python.org;
h=content-transfer-encoding:organization:subject:from:to
:content-language:user-agent:mime-version:date:message-id:from:to:cc
:subject:date:message-id:reply-to;
bh=yYFdzQXIw+jqLrrTO7YEe1DoVVU1Ainf0w4wR8MSPg8=;
b=unjvYYQeLIBF54rgLdZF2ihUi/HRsNbe1/dMiMagd12aUI83uaTkrMuZ0D6Bkbij5L
TbmazeYizDNYo8XhGGRyA+AgE0Uuutxu+vXM1G8tqeFWuTCgGltbqNqa7NW0HpwIx5Gt
et2noYOVtTBwNUsfQcIfy8zCVHqlVa+fyYy5BdDUPWys+/1b7kUHXlEtAg2qJqB4i0rT
4gygikAJb6rggOkXV2RWg8GaE1zOckvPFURpulYMLHB++3oKXIaER3Y3gWC/qQrQHvPX
MLAPokZEyHobuCtjJAxLAMJim07Me0S++C7Ks1nzCMvattwp9kvi5GLW1KTz2FGGFl7C
6Obg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1711339819; x=1711944619;
h=content-transfer-encoding:organization:subject:from:to
:content-language:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=yYFdzQXIw+jqLrrTO7YEe1DoVVU1Ainf0w4wR8MSPg8=;
b=jzNPgikNPxsUrOSqkV/r8LTcqVbDCesUM+CGqJQL/ALC6fd8Jfv1rTgwdfxHDPCjw4
xjhUdYL7BZtBMKEwaq+y7zJbDwi5ZicetaWSJXkAXyPRPhaNF4AR2Szd+8/GdcFShiiU
HAXHkYJGKfWeMd7VziwQS0CB+Je67W+5yWahh0UeML8B17jDRb5LaJMzeO6ELLym5xg7
P5KfO7phkjKKFctxWKs+vqzNQ/cSMJMYEVZxRmOSzIryWtPyA5xGRm1iruKZlGpeva4o
lMgWJ6LTkll2mZMAhGQWFviW1o+g/emglEzR0g9KrT9mKZQNWiIvLdQhNt5RIa1YvFvi
OpBA==
X-Gm-Message-State: AOJu0YwFNTJgu+1LXxTMbRXly+s6VmbaM78uqf0fIzOIwOVYW67SUtcf
mylHsEPyiYInB1xhwMK0fbfGfexT4F0eCxg8eMMNLMyCb35qg9x9c3Dux25mQehDQZWyOcdPYBu
v
X-Google-Smtp-Source: AGHT+IEAYTjcTzeFh8zbBOiqEPwSE7CpDMsYwu/Ot+/tjkTlLn5ZB7MBCowNcvdtFwp0AzV6VS5fEw==
X-Received: by 2002:a05:6a21:3101:b0:1a3:c971:56db with SMTP id
yz1-20020a056a21310100b001a3c97156dbmr1343273pzb.24.1711339818825;
Sun, 24 Mar 2024 21:10:18 -0700 (PDT)
User-Agent: Mozilla Thunderbird
Content-Language: en-US
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <9700aa35-1f1f-47d3-b0b9-98a4aff41099@alcyone.com>
 by: Erik Max Francis - Mon, 25 Mar 2024 04:10 UTC

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

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, named escapes, diacritics,
icons, and emojis.

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.

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 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. 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. Escapes are indicated with `@\...`; diacritics with
`@^...`; icons with `@|...`; and emoji with `@:...:`. `@%...`,
`@%!...`, `@%%...%%` and `@%%!...%%` indicate "significators,"
which are distinctive forms of variable assignment intended to specify
per-document identification information in a format easy to parse
externally, _e.g._, to indicate metadata. In-place expressions are
specified with `@$...$...$`. Context name and line number changes
can be made with `@?...` and `@!...`, respectively. `@<...>`
markup is customizable by the user and can be used for any desired
purpose. `` @`...` `` allows literal escaping of any EmPy markup.
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.1.

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.3, 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, Linux,
Windows, and macOS (Darwin). Using EmPy requires knowledge of the
[Python language](https://www.python.org/).

EmPy is also compatible with several different Python implementations:

| Implementation | Supported versions | Description |
| --- | --- | --- |
| CPython | 2.3 to 2.7; 3.0 and up | Standard implementation in C |
| PyPy | 2.7; 3.2 and up | Implementation with just-in-time compiler |
| IronPython | 2.7; 3.4 and up | Implementation for .NET CLR and Mono |
| Jython | 2.7 (and up?) | Implementation for JVM |

It's probable that EmPy is compatible with earlier versions than those
listed here (potentially going all the way back to 2.3), but this has
not been tested.

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

EmPy also has optional support for several [third-party
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_)

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.

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.


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor