An open API service indexing awesome lists of open source software.

https://github.com/gozaddy/jenna

A Python code generation tool
https://github.com/gozaddy/jenna

Last synced: about 1 year ago
JSON representation

A Python code generation tool

Awesome Lists containing this project

README

          

# Jenna
Jenna is a tool for generating python code using python code(🧠🧠🧠). This is useful for projects like [SchemaGen](https://github.com/GoZaddy/SchemaGen) where you need to generate code based on certain input.

# Usage
Here's a sample of how Jenna works:

Input:

```python
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:
```python
# 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.