After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 350522 - gst registry.get_feature_list should facilitate sorting
gst registry.get_feature_list should facilitate sorting
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-python
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
Johan (not receiving bugmail) Dahlin
Depends on:
Blocks:
 
 
Reported: 2006-08-09 03:27 UTC by Brendan Howell
Modified: 2006-08-10 16:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Brendan Howell 2006-08-09 03:27:56 UTC
As the number of plugins increases, it becomes useful to have a list of plugins sorted by name.  Currently the following code returns a list sorted by some index other than the name strings:

    registry = gst.registry_get_default()
    registrylist = registry.get_feature_list(gst.ElementFactory)
    registrylist.sort()

Results in this:

typefind
tee
filesink
queue
identity
filesrc
fdsink
fdsrc
fakesink
fakesrc
capsfilter
xvimagesink
ximagesink
...

The fastest option is probably to have gst.PluginFeature have it's own __cmp__ method like this:

def __cmp__(self, other):
    return cmp(self.get_name(), other.get_name())

This will make registrylist.sort() result in a list sorted alphabetically by name.

Then again, this may be something that should be added to the gstreamer core and is inappropriate for gst-python.  

The workaround is this:

registrylist.sort(lambda x, y: cmp(x.get_name(), y.get_name()))
Comment 1 Edward Hervey 2006-08-10 16:11:19 UTC
as you've just proved, it's easily do-able in one line of python, so there's not really any point in putting it in gst-python.

Closing.