Skip to main content

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


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.2.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distribution

Mymacroprocessor-0.0.2-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

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