mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-14 11:25:39 +00:00
overrides: accept Gst.Structure in Caps.__new__
Also rename misleading parameter (*kwargs -> *args) https://bugzilla.gnome.org/show_bug.cgi?id=793493
This commit is contained in:
parent
429b58ed29
commit
8a807cc1be
1 changed files with 16 additions and 7 deletions
|
@ -70,15 +70,24 @@ class Caps(Gst.Caps):
|
||||||
def __nonzero__(self):
|
def __nonzero__(self):
|
||||||
return not self.is_empty()
|
return not self.is_empty()
|
||||||
|
|
||||||
def __new__(cls, *kwargs):
|
def __new__(cls, *args):
|
||||||
if not kwargs:
|
if not args:
|
||||||
return Caps.new_empty()
|
return Caps.new_empty()
|
||||||
elif len(kwargs) > 1:
|
elif len(args) > 1:
|
||||||
raise TypeError("wrong arguments when creating GstCaps object")
|
raise TypeError("wrong arguments when creating GstCaps object")
|
||||||
elif isinstance(kwargs[0], str):
|
elif isinstance(args[0], str):
|
||||||
return Caps.from_string(kwargs[0])
|
return Caps.from_string(args[0])
|
||||||
elif isinstance(kwargs[0], Caps):
|
elif isinstance(args[0], Caps):
|
||||||
return kwargs[0].copy()
|
return args[0].copy()
|
||||||
|
elif isinstance(args[0], Structure):
|
||||||
|
res = Caps.new_empty()
|
||||||
|
res.append_structure(args[0])
|
||||||
|
return res
|
||||||
|
elif isinstance(args[0], (list, tuple)):
|
||||||
|
res = Caps.new_empty()
|
||||||
|
for e in args[0]:
|
||||||
|
res.append_structure(e)
|
||||||
|
return res
|
||||||
|
|
||||||
raise TypeError("wrong arguments when creating GstCaps object")
|
raise TypeError("wrong arguments when creating GstCaps object")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue