Skip to main content

epicsmacrolib

https://img.shields.io/travis/pcdshub/epicsmacrolib.svg https://img.shields.io/pypi/v/epicsmacrolib.svg

epics-base compliant macro tools.

What?

Do you want epics-base compliant macro expansion, with all of its idiosyncracies?

No? I didn’t think so. This is a really boring project and you probably don’t need it.

Then why?

This will be the future of the macro and IOC shell splitting tools in whatrecord, removing its reliance on Cython and epicscorelibs.

Examples

macros_from_string

from epicsmacrolib import macros_from_string

macros_from_string("A=5,  B=$(A=3)")
# -> {'A': '5', 'B': '$(A=3)'}

MacroContext

from epicsmacrolib import MacroContext

ctx = MacroContext(use_environment=True)
ctx.define(TEST="A")
print(ctx.expand("TEST=$(TEST) SHELL=$(SHELL)"))
# TEST=A SHELL=/bin/bash

ctx = MacroContext(use_environment=False)
ctx.define_from_string("A=5,B=6")
ctx.define(C="7")
print(ctx.expand("$(A) $(B) ${C} ${D=5} ${E}"))
# -> 5 6 7 5 $(E)

ctx = MacroContext(use_environment=False, show_warnings=True)
ctx.define_from_string("A=5,B=6")
ctx.define(C="7")
print(ctx.expand("$(A) $(B) ${C} ${D=5} ${E}"))
# -> 5 6 7 5 $(E,undefined)

ctx.define_from_string("A=5,B=$(B)")
print(ctx.expand("$(A) $(B)"))
# -> 5 $(B,recursive)

with ctx.scoped(A="10", B="0"):
    print(ctx.expand("$(A)"))
    # -> 10
    with ctx.scoped(A="0"):
        print(ctx.expand("$(A)"))
        # -> 0
    print(ctx.expand("$(A)"))
    # -> 10

split_iocsh_line (like shlex.split)

from epicsmacrolib import split_iocsh_line
split_iocsh_line("dbLoadRecords > output_filename")
# -> IocshSplit(
#     argv=["dbLoadRecords"],
#     redirects={1: IocshRedirect(fileno=1, name="output_filename", mode="w")},
#     error=None,
# )

License

The Python portions of this code is under a BSD-3 clause license (LicenseRef-BSD-3-Clause-SLAC, see LICENSE). Portions of epics-base have been vendored in src under its original license (see src/LICENSE).

Metadata

Release files for epicsmacrolib 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for epicsmacrolib 0.5.3
File Size Uploaded
epicsmacrolib-0.5.3.tar.gz 169.1 kB Details

Release files / epicsmacrolib-0.5.3.tar.gz

Download URL epicsmacrolib-0.5.3.tar.gz
Size 169.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8101e656b11b9a1e1e44bdde046a47335caab3701d31c092835d4aa858160ce3
BLAKE2b-256 checksum
How to use checksums
7c363fd38461a69ec53ccce1c111906849811b30c7bafe42be040c9b3c151784
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.8.3 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13

Release history Release notifications | RSS feed

0.6.1

26 release files

This release

0.5.3 This release

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page