Skip to main content

epics-base compliant macro tools

Project description

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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epicsmacrolib-0.6.1.tar.gz (197.8 kB view hashes)

Uploaded Source

Built Distributions

epicsmacrolib-0.6.1-pp39-pypy39_pp73-win_amd64.whl (237.5 kB view hashes)

Uploaded PyPy Windows x86-64

epicsmacrolib-0.6.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (251.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

epicsmacrolib-0.6.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (254.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

epicsmacrolib-0.6.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (236.8 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

epicsmacrolib-0.6.1-cp311-cp311-win_amd64.whl (249.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

epicsmacrolib-0.6.1-cp311-cp311-win32.whl (239.4 kB view hashes)

Uploaded CPython 3.11 Windows x86

epicsmacrolib-0.6.1-cp311-cp311-musllinux_1_1_x86_64.whl (670.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

epicsmacrolib-0.6.1-cp311-cp311-musllinux_1_1_i686.whl (647.6 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

epicsmacrolib-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (670.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

epicsmacrolib-0.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (648.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

epicsmacrolib-0.6.1-cp311-cp311-macosx_10_9_x86_64.whl (257.9 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

epicsmacrolib-0.6.1-cp310-cp310-win_amd64.whl (248.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

epicsmacrolib-0.6.1-cp310-cp310-win32.whl (238.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

epicsmacrolib-0.6.1-cp310-cp310-musllinux_1_1_x86_64.whl (633.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

epicsmacrolib-0.6.1-cp310-cp310-musllinux_1_1_i686.whl (611.0 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

epicsmacrolib-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

epicsmacrolib-0.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (611.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

epicsmacrolib-0.6.1-cp310-cp310-macosx_10_9_x86_64.whl (256.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

epicsmacrolib-0.6.1-cp39-cp39-win_amd64.whl (248.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

epicsmacrolib-0.6.1-cp39-cp39-win32.whl (238.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

epicsmacrolib-0.6.1-cp39-cp39-musllinux_1_1_x86_64.whl (631.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

epicsmacrolib-0.6.1-cp39-cp39-musllinux_1_1_i686.whl (612.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

epicsmacrolib-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

epicsmacrolib-0.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (610.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

epicsmacrolib-0.6.1-cp39-cp39-macosx_10_9_x86_64.whl (256.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page