Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 955 Bytes

README.md

File metadata and controls

42 lines (36 loc) · 955 Bytes

Jenna

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.

Usage

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')

Contributing

I'm currently busy with life et al and would really appreciate contributions to Jenna.