Metadata-Version: 2.1
Name: codeg
Version: 0.2.0
Summary: Python library to generate and execute code dynamically
Home-page: https://github.com/nazime/codeg
Author: Nazime LAKEHAL
Author-email: nazime.lkh@gmail.com
Maintainer: Nazime LAKEHAL
Maintainer-email: nazime.lkh@gmail.com
License: MIT
Project-URL: Documentation, https://codeg.readthedocs.org/
Project-URL: Bug Tracker, https://github.com/nazime/codeg/issues
Project-URL: Source Code, https://github.com/nazime/codeg
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: attr
Requires-Dist: black
Provides-Extra: dev
Requires-Dist: coloring ; extra == 'dev'
Requires-Dist: coverage ; extra == 'dev'
Requires-Dist: hypothesis ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest (>=4.3.0) ; extra == 'dev'
Requires-Dist: sphinx ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme ; extra == 'dev'
Requires-Dist: sphinxcontrib.napoleon ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
Requires-Dist: sphinxcontrib.napoleon ; extra == 'docs'
Provides-Extra: tests
Requires-Dist: coloring ; extra == 'tests'
Requires-Dist: coverage ; extra == 'tests'
Requires-Dist: hypothesis ; extra == 'tests'
Requires-Dist: pytest (>=4.3.0) ; extra == 'tests'
Provides-Extra: travis
Requires-Dist: codecov ; extra == 'travis'
Requires-Dist: coloring ; extra == 'travis'
Requires-Dist: coverage ; extra == 'travis'
Requires-Dist: hypothesis ; extra == 'travis'
Requires-Dist: pre-commit ; extra == 'travis'
Requires-Dist: pytest (>=4.3.0) ; extra == 'travis'
Requires-Dist: sphinx ; extra == 'travis'
Requires-Dist: sphinx-rtd-theme ; extra == 'travis'
Requires-Dist: sphinxcontrib.napoleon ; extra == 'travis'
Requires-Dist: tox ; extra == 'travis'

[![Pypi version](https://img.shields.io/pypi/v/codeg.svg)](https://pypi.org/project/codeg/) [![Python versions](https://img.shields.io/pypi/pyversions/codeg.svg)](https://pypi.org/project/codeg/) [![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

-----------------

# codeg

Codeg (code generator) is a python library that allows you to generate python code dynamically.

**This library is still a work in progress**

## Quickstart

Let's say you want to generate the following class dynamically

```python
class Animal:
    def __init__(name: str):
        self.name = name
```



You can use the following code

```python
import codeg

code_cls = codeg.cls("Animal")
code__init = code_cls.method(
    "__init__", attributes=[codeg.Attribute("name", annotation=str)]
)
code__init.line("self.name = name")

code_cls.print()  # print the generated code

Animal = code_cls.build()  # eval the code and get it on a variable
animal = Animal("rex")
```


