mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
Make option parser work with glib before 2.13.2
This commit is contained in:
parent
fec6bf0848
commit
9e3ebe40cd
1 changed files with 12 additions and 5 deletions
|
@ -302,7 +302,11 @@ class OptionParser (object):
|
||||||
self.options = options
|
self.options = options
|
||||||
|
|
||||||
self.__remaining_args = []
|
self.__remaining_args = []
|
||||||
self.__entries.append ((gobject.OPTION_REMAINING, "\0", 0, "", "",))
|
|
||||||
|
# Remaining args parsing with pygobject does not work with glib before
|
||||||
|
# 2.13.2 (e.g. Ubuntu Feisty).
|
||||||
|
## if gobject.glib_version >= (2, 13, 2,):
|
||||||
|
## self.__entries.append ((gobject.OPTION_REMAINING, "\0", 0, "", "",))
|
||||||
|
|
||||||
def add_option (self, long_name, short_name = None, description = None,
|
def add_option (self, long_name, short_name = None, description = None,
|
||||||
arg_name = None, arg_parser = None, hidden = False):
|
arg_name = None, arg_parser = None, hidden = False):
|
||||||
|
@ -329,9 +333,10 @@ class OptionParser (object):
|
||||||
|
|
||||||
def __handle_option (self, option, arg, group):
|
def __handle_option (self, option, arg, group):
|
||||||
|
|
||||||
if option == gobject.OPTION_REMAINING:
|
# See __init__ for glib requirement.
|
||||||
self.__remaining_args.append (arg)
|
## if option == gobject.OPTION_REMAINING:
|
||||||
return
|
## self.__remaining_args.append (arg)
|
||||||
|
## return
|
||||||
|
|
||||||
for entry in self.__entries:
|
for entry in self.__entries:
|
||||||
long_name, short_name = entry[:2]
|
long_name, short_name = entry[:2]
|
||||||
|
@ -357,10 +362,12 @@ class OptionParser (object):
|
||||||
group.add_entries (self.__entries)
|
group.add_entries (self.__entries)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
context.parse (argv)
|
result_argv = context.parse (argv)
|
||||||
except gobject.GError, exc:
|
except gobject.GError, exc:
|
||||||
raise OptionError (exc.message)
|
raise OptionError (exc.message)
|
||||||
|
|
||||||
|
self.__remaining_args = result_argv[1:]
|
||||||
|
|
||||||
self.handle_parse_complete (self.__remaining_args)
|
self.handle_parse_complete (self.__remaining_args)
|
||||||
|
|
||||||
def get_parameter_string (self):
|
def get_parameter_string (self):
|
||||||
|
|
Loading…
Reference in a new issue