summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2007-11-08 10:51:07 +0000
committerJohan Dahlin <johan@gnome.org>2007-11-08 10:51:07 +0000
commit5b5311a64f943cb75408703edb4d00a3ce3b7921 (patch)
tree38a04f225bb71cfc761ffc92b95218542dd5a5e6 /examples
parentfbd4ea3772f3a7f4170d95355a8122bc3d65ff83 (diff)
Add a new module, gstoption which allows you to fetch the
Original commit message from CVS: 2007-11-05 Johan Dahlin <johan@gnome.org> * gstoptionmodule.c: * Makefile.am: * configure.ac: Add a new module, gstoption which allows you to fetch the GOptionGroup from gstreamer without initializing and parsing the command line arguments. Requires PyGObject 2.15.0 Fixes #425847 * examples/option-parser.py (main): Example
Diffstat (limited to 'examples')
-rw-r--r--examples/option-parser.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/option-parser.py b/examples/option-parser.py
new file mode 100644
index 0000000..89e1a64
--- /dev/null
+++ b/examples/option-parser.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+import sys
+
+import pygtk
+pygtk.require('2.0')
+
+from gobject.option import OptionParser, OptionGroup
+import pygst
+pygst.require('0.10')
+
+import gstoption
+
+def main(args):
+ parser = OptionParser()
+
+ group = OptionGroup('flumotion', 'Flumotion options',
+ option_list=[])
+ group.add_option('-v', '--verbose',
+ action="store_true", dest="verbose",
+ help="be verbose")
+ group.add_option('', '--version',
+ action="store_true", dest="version",
+ default=False,
+ help="show version information")
+ parser.add_option_group(group)
+
+ parser.add_option_group(gstoption.get_group())
+
+ options, args = parser.parse_args(args)
+
+ if options.verbose:
+ print 'Verbose mode'
+
+ import gst
+
+ if options.version:
+ print sys.version, gst.version
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))