Jenna is a tool for generating python code using python code(🧠🧠🧠). This is useful for projects like SchemaGen where you need to generate code based on certain input.
Here's a sample of how Jenna works:
Input:
from jenna import Jenna, If, IfElse, Expr, String
jen = Jenna('test.py')
ie = IfElse(
if_=If(
expr=Expr(f"{String('a')} != {String('b')}"),
action=[Expr("print('true')")]
),
else_action=[Expr("print('else')")]
)
ie.add_elif(
If(
expr=Expr(f"{String('a')} == {String('b')}"),
action=[Expr("print('false')")],
if_type='elif'
)
)
jen.write_if_else(ie)
Output:
# This file was generated by Jenna
if 'a' != 'b':
print('true')
elif 'a' == 'b':
print('false')
else:
print('else')
I'm currently busy with life et al and would really appreciate contributions to Jenna.