| 1 |
#!/usr/bin/env python |
| 2 |
# Main Stetl program. |
| 3 |
# |
| 4 |
# Author: Just van den Broecke |
| 5 |
# |
| 6 |
from stetl.main import parse_args |
| 7 |
from stetl.etl import ETL |
| 8 |
from stetl.util import Util |
| 9 |
from stetl.version import __version__ |
| 10 |
import sys |
| 11 |
|
| 12 |
log = Util.get_log('main') |
| 13 |
|
| 14 |
|
| 15 |
def main(): |
| 16 |
"""The Stetl `main` program, to be called from commandline, like `stetl -c etl.cfg`. |
| 17 |
|
| 18 |
Args: |
| 19 |
-c --config <config_file> the Stetl config file. |
| 20 |
-s --section <section_name> the section in the Stetl config (ini) file to execute (default is [etl]). |
| 21 |
-a --args <arglist> zero or more substitutable args for symbolic, {arg}, values in Stetl config file, in format -a arg1=foo -a arg2=bar etc. |
| 22 |
-v --version Show the current version of stelt and exit |
| 23 |
-h --help <subject> Get component documentation like its configuration parameters, e.g. stetl doc stetl.inputs.fileinput.FileInput |
| 24 |
|
| 25 |
""" |
| 26 |
|
| 27 |
args = parse_args(sys.argv[1:]) |
| 28 |
|
| 29 |
if args.version: |
| 30 |
print('Stetl version: ', __version__) |
| 31 |
exit() |
| 32 |
|
| 33 |
if args.config_file: |
| 34 |
# Do the ETL |
| 35 |
etl = ETL(vars(args), args.config_args) |
| 36 |
etl.run() |
| 37 |
|
| 38 |
else: |
| 39 |
print('Try stetl -h for help') |
| 40 |
|
| 41 |
|
| 42 |
if __name__ == "__main__": |
| 43 |
main() |