Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Initial config parser support.

This commit is contained in:
Einar Ryeng 2007-02-27 16:08:22 +00:00
parent 686a1fdcd1
commit 1ba4bf5f82
2 changed files with 1791 additions and 21 deletions

View File

@ -4,12 +4,11 @@ from getopt import getopt
import sys import sys
from fluents import fluents, project, workflow from fluents import fluents, project, workflow
import workflows import workflows
import cfgparse, optparse
PROGRAM_NAME = 'fluents' PROGRAM_NAME = 'fluents'
VERSION = '0.1.0' VERSION = '0.1.0'
parameters = {'workflow': workflow.EmptyWorkflow}
def show_help(): def show_help():
print 'fluent %s' % VERSION print 'fluent %s' % VERSION
print 'This software is released under the GNU General Public Licence' print 'This software is released under the GNU General Public Licence'
@ -36,34 +35,43 @@ def list_workflows():
print print
def parse_options(): def parse_options():
short_opts = 'hlw:' cp = cfgparse.ConfigParser()
long_opts = ['help', 'list-workflows', 'workflow='] op = optparse.OptionParser()
options, params = getopt(sys.argv[1:], short_opts, long_opts) op.add_option('-l', '--list-workflows',
action='store_true',
default=False,
help='List available workflows.')
for opt, val in options: op.add_option('-w', '--workflow',
if opt in ['-h', '--help']: default='emptyview',
show_help() help='Start with selected workflow')
sys.exit(0)
elif opt in ['-l', '--list-workflows']: return cp.parse(op)
list_workflows()
sys.exit(0)
elif opt in ['-w', '--workflow']:
wfs = workflow.workflow_list()
for wf in wfs:
if wf.ident == val:
parameters['workflow'] = wf
parameters['workflow']
if __name__ == '__main__': if __name__ == '__main__':
parse_options() options, params = parse_options()
if options.list_workflows:
list_workflows()
sys.exit(0)
import gtk import gtk
import gnome import gnome
gnome.program_init(PROGRAM_NAME, VERSION) gnome.program_init(PROGRAM_NAME, VERSION)
app = fluents.FluentApp(parameters['workflow'])
selected_wf = workflow.EmptyWorkflow
workflow_list = workflow.workflow_list()
for wf in workflow_list:
if wf.ident == options.workflow:
selected_wf = wf
app = fluents.FluentApp(selected_wf)
fluents.app = app fluents.app = app
app.set_project(project.Project()) app.set_project(project.Project())
app.show() app.show()
gtk.main() gtk.main()

1762
cfgparse.py Normal file

File diff suppressed because it is too large Load Diff