libvips/python/find_class_methods.py

60 lines
1.6 KiB
Python
Raw Normal View History

2014-10-14 15:28:59 +02:00
#!/usr/bin/python
import sys
import logging
#logging.basicConfig(level = logging.DEBUG)
2016-07-24 15:47:22 +02:00
import gi
gi.require_version('Vips', '8.0')
2014-10-14 15:28:59 +02:00
from gi.repository import Vips, GObject
# Search for all VipsOperation which don't have an input image object ... these
# should be class methods and need to have their names pasted into Vips.py
# This is slow :-( so we don't do this dynamically
vips_type_image = GObject.GType.from_name("VipsImage")
vips_type_operation = GObject.GType.from_name("VipsOperation")
def find_class_methods(cls):
2016-01-05 09:00:40 +01:00
names = set()
2014-10-14 15:28:59 +02:00
if not cls.is_abstract():
op = Vips.Operation.new(cls.name)
found = False
for prop in op.props:
flags = op.get_argument_flags(prop.name)
if not flags & Vips.ArgumentFlags.INPUT:
continue
if not flags & Vips.ArgumentFlags.REQUIRED:
continue
if GObject.type_is_a(vips_type_image, prop.value_type):
found = True
break
if not found:
gtype = Vips.type_find("VipsOperation", cls.name)
2016-01-05 09:00:40 +01:00
names.add(Vips.nickname_find(gtype))
2014-10-14 15:28:59 +02:00
if len(cls.children) > 0:
for child in cls.children:
# not easy to get at the deprecated flag in an abtract type?
if cls.name != 'VipsWrap7':
2016-01-05 09:00:40 +01:00
names.update(find_class_methods(child))
return names
2014-10-14 15:28:59 +02:00
print 'found class methods:'
2016-01-05 09:00:40 +01:00
names = find_class_methods(vips_type_operation)
# filter out things we know we should not wrap
names -= set(["bandjoin", "bandrank"])
2014-10-14 15:28:59 +02:00
2016-01-05 09:00:40 +01:00
names = list(names)
names.sort()
for name in names:
print ' "%s",' % name