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.5.2.tar.gz (160.8 kB view details)

Uploaded Source

File details

Details for the file epicsmacrolib-0.5.2.tar.gz.

File metadata

  • Download URL: epicsmacrolib-0.5.2.tar.gz
  • Upload date:
  • Size: 160.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for epicsmacrolib-0.5.2.tar.gz
Algorithm Hash digest
SHA256 d3ca70ee254fc5585e70185b4022c259492588220bba89c6a880f8834c98ced2
MD5 a55b63e66db8d7b4e386ca893fc4e9a1
BLAKE2b-256 3ac69620e2b8a81424247510d77dba04a6c6eed0c8633bc948d7be82fd6f2bdd

See more details on using hashes here.

Provenance

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