やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

GIMP python-fu 定義のコードを見ようとしたがエラー

 引数や戻り値の一覧を作成したかったのだが。

方法

 inspect.getsource()でオブジェクトのソースコードを閲覧しようとした。

手順

from gimpfu import *
dir(gimp)
dir(gimp.GroupLayer)
import inspect
inspect.getsource(gimp)
inspect.getsource(gimp.GroupLayer)
inspect.getsource(gimp.GroupLayer.mode)
inspect.getsource(gimp.GroupLayer.update)
inspect.getsource(pdb.gimp_xcf_save)

 inspect.getsourceの結果はどれもエラー。どゆこと? 

IOError: source code not available
IOError: source code not available
TypeError: <attribute 'mode' of 'gimp.Layer' objects> is not a module, class, method, function, traceback, frame, or code object
TypeError: <method 'update' of 'gimp.Drawable' objects> is not a module, class, method, function, traceback, frame, or code object
TypeError: <pdb function 'gimp_xcf_save'> is not a module, class, method, function, traceback, frame, or code object

他に試したこと

print inspect.getsourcefile(gimp)
print inspect.getsourcefile(gimp.GroupLayer)
None
None
print inspect.getsourcefile(gimpfu)
print inspect.getsourcefile(pdb)
NameError: name 'gimpfu' is not defined
TypeError: <gimp procedural database> is not a module, class, method, function, traceback, frame, or code object
print inspect.getargspec(gimp.GroupLayer.update)
TypeError: <method 'update' of 'gimp.Drawable' objects> is not a Python function
print inspect.getargspec(pdb.gimp_xcf_save)
TypeError: <pdb function 'gimp_xcf_save'> is not a Python function

所感

 ダメだ。python-fu関連のAPIソースコードを抽出できない……。せめてプロパティの型や関数の戻り値と引数について知りたいのだが……。特にgimp.なんちゃらの奴。

対象環境

$ uname -a
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux