Skip to content

Commit

Permalink
small changes to the scripts, add module example
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerg Raedler committed Apr 11, 2019
1 parent 1709e79 commit 74a6a76
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/CoTeTo-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# This file is part of CoTeTo - a code generation tool
# 20170602 Joerg Raedler [email protected]
#
# This is the commandline interface to CoTeTo.
# Run `python CoTeTo-cli.py --help` to get help on the
# commandline options and arguements

import os
import sys
Expand Down
3 changes: 3 additions & 0 deletions scripts/CoTeTo-gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# This file is part of CoTeTo - a code generation tool
# 20170602 Joerg Raedler [email protected]
#
# This is the graphical user interface to CoTeTo.
# Run `python CoTeTo-gui.py --help` to get help on the
# commandline options and arguements

import os
import sys
Expand Down
37 changes: 37 additions & 0 deletions scripts/CoTeTo-module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#
# This file is part of CoTeTo - a code generation tool
# 20190411 Joerg Raedler [email protected]
#
# This is an example of the usage of CoTeTo as a python module.
#

import os
import sys

# check if we are running in the development folder -
# just a hack to run this script without installing CoTeTo first -
# usually not needed for users
parent = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if os.path.isfile(os.path.join(parent, 'setup.py')):
sys.path.insert(0, parent)

#### Example Code

# 1. import the controller class from CoTeTo
from CoTeTo.Controller import Controller

# 2. initialize a controller instance
# for a list of optional arguments see CoTeTo/Controller.py
con = Controller()

# 3. choose a generator ...
# a list of available generators can be printed with print(con.generators.keys())
gen = con.generators['Example01Mako::1.0']

# 4. ... and execute it!
# arguments are:
# a list of input URIs (not used with the dummy loader)
# a filename or prefix for the output
gen.execute(('spam', ), 'ModuleTestOutput.txt')

0 comments on commit 74a6a76

Please sign in to comment.