File: option.py

package info (click to toggle)
pygobject 2.14.2-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,732 kB
  • ctags: 1,489
  • sloc: ansic: 11,090; sh: 9,052; xml: 3,391; python: 2,565; makefile: 351
file content (30 lines) | stat: -rw-r--r-- 868 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# gnome-python/pygobject/examples/option.py

from gobject.option import OptionGroup, OptionParser, make_option

group = OptionGroup("example", "OptionGroup Example", "Shows all example options",
    option_list = [
        make_option("--example", 
                    action="store_true", 
                    dest="example", 
                    help="An example option."),
    ])

parser = OptionParser("NAMES ...", 
    description="A simple gobject.option example.",
    option_list = [
        make_option("--file", "-f", 
                    type="filename", 
                    action="store", 
                    dest="file",
                    help="A filename option"),
        # ...
    ])

parser.add_option_group(group)

parser.parse_args()

print "group: example ", group.values.example
print "parser: file", parser.values.file