source code generation library (with overuse with-syntax)
Project description
this is heavily inspired by srcgen .
(todo: gentle introduction)
features
generating code with with-syntax
string injection after writing string
generating code with with-syntax
from prestring.python import PythonModule
m = PythonModule()
with m.class_("Point", metaclass="InterfaceMeta"):
with m.def_("__init__", "self", "value"):
m.stmt("self.value = value")
with m.def_("__str__", "self"):
m.return_("self.value")
output is.
class Point(object, metaclass=InterfaceMeta)
def __init__(self, value):
self.value = value
def __str__(self):
return self.value
string injection after writing string
from prestring.python import PythonModule
m = PythonModule()
with m.def_("setup", "config"):
import_area = m.submodule()
m.sep()
for k in ["a", "b", "c", "d", "e"]:
import_area.stmt("from .plugins import {k}_plugin", k=k)
m.stmt("config.activate({}_plugin)", k)
print(m)
def setup(config):
from .plugins import(
a_plugin,
b_plugin,
c_plugin,
d_plugin,
e_plugin
)
config.activate(a_plugin)
config.activate(b_plugin)
config.activate(c_plugin)
config.activate(d_plugin)
config.activate(e_plugin)
0.3.0
go code output support
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
prestring-0.3.0.tar.gz
(8.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prestring-0.3.0.tar.gz.
File metadata
- Download URL: prestring-0.3.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a041e983d8e45a08e36fe242db864ff6e1e865d62a5dc5e659c2c4c73517323
|
|
| MD5 |
6d447b0c0a90b29baf7639540d4e4674
|
|
| BLAKE2b-256 |
5c0340dffb4a1472c06b811a605d881438ee4cac5b2f694a568884a8c99a12f8
|
File details
Details for the file prestring-0.3.0-py2.py3-none-any.whl.
File metadata
- Download URL: prestring-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b7b1daf519e4acab2a25c93a7df99febe404a0266fee3ede490c8b95fe5e7ed
|
|
| MD5 |
e2e107460743ea3e98855d03f6e79979
|
|
| BLAKE2b-256 |
4725a45f3d5835d2e440932e11fe8b79506a0c79ee487057eed38caa228e85f4
|