Whne your Python skills are not there

More
18 Jul 2023 21:30 - 18 Jul 2023 21:33 #275767 by cornholio
Been helping out with Litex-CNC and because 2.9 no longer defines EMC2_RTLIB_DIR, well config.h is no longer in the include directory for the dev package, there was a need to parse Makefile.modinc and cos my python is poor this is what I cam up with.
modinc_result = subprocess.run(["sed -n '/RUN_IN_PLACE/, /endif/{/EXTRA/d;/^LIB/d;/^prefix/d;s/[[:blank:]]:=//;s/=no/ 0/;s/=yes/ 1/;s/^R/#define R/;s/ifeq.*/#if RUN_IN_PLACE == 1/;s/^endif/#endif/;s/^else/#else/;s/RTLIBDIR /EMC2_RTLIB_DIR \"/;/EMC2/ s/$/\"/;p}' `halcompile --print-modinc`"], shell=True, capture_output=True, text=True)

If you look at it as all on one line you'll see the true horror that it is. And apparently I've forgooten how to English today as well.
Last edit: 18 Jul 2023 21:33 by cornholio.
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum