Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install srcgen

How to install srcgen

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install srcgen
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
1.1.0 Available View build log
Linux (32-bit)
1.1.0 Available View build log
Linux (64-bit)
1.1.0 Available View build log
1.1.0 Available View build log
 
Author
License
MIT
Dependencies
Imports
Lastest release
version 1.1.0 on Jul 19th, 2013

srcgen

Srcgen is a semantic code generation framework. Being semantic means that the code generator and the generated code bear similar structure, as well ; for instance, the body of an if statement is indented both in the generating and generated code. Here's a short example:

>>> from srcgen.python import PythonModule
>>>
>>> m = PythonModule("foo")
>>> m.import_("sys")
>>> m.import_("os")
>>> m.sep()
>>> m.stmt("x = 5")
>>> with m.if_("x > 8"):
...     m.stmt("print 'oh no'")
...
>>> with m.else_():
...     m.stmt("print 'oh yes'")
...
>>> print m
import sys
import os

x = 5
if x > 8:
    print 'oh no'
else:
    print 'oh yes'

You can nest deeper, of course, as well as extract common pieces of code into functions:

m = PythonModule("foo")
with m.class_("MyClass"):
    with m.method("__init__", "

Languages

At the moment Srcgen supports:

  • C
  • Python
  • Cython
  • HTML/XML

More languages will be added per public demand (you're welcome to join the effort!)

Subscribe to package updates

Last updated Jul 19th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.