python file macro processor
Project description
Mymacroprocessor
python file macro processor
Support label
if,ifdef,ifndef,elif,else,endif,defined,define,undef
test.py
#%indentunit 4
#%define #dbglog(x) print(x)
##%log:1
#%define DEBUG
#%define TEST
#dbglog("test1")
#dbglog("test2")
#dbglog("test3")
#%if defined TEST:
print("this is test code.")
#%if defined TEST1:
print("--------TEST1----------.")
#%endif
#%else:
print("--------1----------.")
print("--------2----------.")
#%endif
command
python .\Mymacroprocessor.py .\test3.py
out
##%log:1
print("test1")
print("test2")
print("test3")
print("this is test code.")
call function
testcontent1='''
#%indentunit 4
#%define dbglog(x) ##(x)
##%log:1
#%define DEBUG
#%define TEST1
dbglog("test1")
dbglog("娴嬭瘯2")
dbglog("娴嬭瘯3")
#%if defined TEST:
print("this is test code.")
#%if defined TEST1:
print("--------TEST1----------.")
#%endif
#%else:
print("--------1----------.")
print("--------2----------.")
#%endif
#%if defined DEBUG:
M1
#%endif
'''
pyp=Mymacroprocessor()
newcontents=pyp.pymprocessor(testcontent1)
print("--new code---\n"+newcontents)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Mymacroprocessor-0.0.3.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for Mymacroprocessor-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 460376d2040b3686c02be903550f23682ce367f2477e2523666dddd85459ff52 |
|
MD5 | 6a99985c7d803cbce2171efd24cfd04c |
|
BLAKE2b-256 | 0508616b9abdab08905c7df57378a4f68d8037662cbd8df94cb2ffa4054aeced |