Commit dd943155 authored by Thibault Saunier's avatar Thibault Saunier

structure: Add a .keys() method and implement __str__

We are making it behave like a dict, so we should provide the
same kind of utilities.
parent 31dfe42b
......@@ -29,6 +29,8 @@ import inspect
from ..overrides import override
from ..importer import modules
from gi.repository import GLib
if sys.version_info >= (3, 0):
_basestring = str
......@@ -245,13 +247,27 @@ class Structure(Gst.Structure):
raise TypeError("wrong arguments when creating GstStructure object")
def __init__(self, *args, **kwargs):
def __getitem__(self, key):
return self.get_value(key)
def keys(self):
keys = set()
def foreach(fid, value, unused1, udata):
return True
self.foreach(foreach, None, None)
return keys
def __setitem__(self, key, value):
return self.set_value(key, value)
def __str__(self):
return self.to_string()
Structure = override(Structure)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment