Skip to main content

A script that substitutes macros in tamplate files.

Project description

CI Coverage PyPI License

ppmac_macro_substitution

A script that substitutes macros in template files.

Gets substitutes and template files and uses them to generate files (primarily kinematics). Default location of template files: configure/coord_templates.

The generated files are put in destination_folder which defaults to configure/coord_substitution.

Naming convention for generated kinematics:

    cs_<coordinate_system_number>_<name_of_template_file>

and for other files:

    tmp_<name_of_template_file>
Source https://github.com/DiamondLightSource/ppmac-macro-substitution
PyPI pip install ppmac-macro-substitution
Releases https://github.com/DiamondLightSource/ppmac-macro-substitution/releases

To print the version of the script you can do:

from ppmac_macro_substitution import __version__

print(f"Hello ppmac_macro_substitution {__version__}")

An example substitution file for 3 jack kinematic template:

from ppmac_macro_substitution import generate

substitutes = {}
substitutes["$(COORD)"] = "4"
substitutes["$(J1)"] = "1"
substitutes["$(J1X)"] = "20"
substitutes["$(J1Z)"] = "10"
substitutes["$(J2)"] = "2"
substitutes["$(J2X)"] = "12"
substitutes["$(J2Z)"] = "13"
substitutes["$(J3)"] = "3"
substitutes["$(J3X)"] = "15"
substitutes["$(J3Z)"] = "16"
substitutes["$(MD)"] = "10"
substitutes["$(MCX)"] = "100"
substitutes["$(MCZ)"] = "2"

kinematic_template_files = ["inv_3jack.kin", "fwd_3jack.kin"]

generate(
    substitutes,
    kinematic_template_files,
)

In order to generate the kinematics using default template folder and the default destination folder run the script in the folder above the configure folder.

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

ppmac_macro_substitution-1.0.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppmac_macro_substitution-1.0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file ppmac_macro_substitution-1.0.1.tar.gz.

File metadata

  • Download URL: ppmac_macro_substitution-1.0.1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for ppmac_macro_substitution-1.0.1.tar.gz
Algorithm Hash digest
SHA256 60f686a027381c566d04cc3c617ae3c1e83661a8f80afbbc7e5db86e51bd02a5
MD5 19f9d79004db560790e9cd25dc9a4a58
BLAKE2b-256 376304104674d63907d44c699a64171b146a553299253108e7802bc6b5dade35

See more details on using hashes here.

File details

Details for the file ppmac_macro_substitution-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ppmac_macro_substitution-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f572283a95645cae8a676cecc34297a1856a3854277ee49d58f7bc20efc25a58
MD5 919eab7fbafaa563492ac5c13075158d
BLAKE2b-256 5dd41dba4cb96daac9827246325092c8d2973bd19deedc3a958335c0787f622f

See more details on using hashes here.

Supported by

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