[英]Python - gphoto2 How to figure out what a function does?
I am playing around with gphoto2 and I found that camera
object has a public function file_get_info()
.我在玩 gphoto2,我发现camera
对象有一个公共函数file_get_info()
。 I would like to know:我想知道:
But so far I have failed to find any information about it.但到目前为止,我还没有找到任何关于它的信息。
This is what I do:这就是我所做的:
import gphoto2 as gp
portInfoList = gp.PortInfoList()
portInfoList.load()
abilitiesList = gp.CameraAbilitiesList()
abilitiesList.load()
cams = abilitiesList.detect(portInfoList)
for name, addr in cams:
print("%s at port %s"%(name, addr))
idx = portInfoList.lookup_path(addr)
camera = gp.Camera()
camera.set_port_info(portInfoList[idx])
camera.init()
camera.file_get_info()
This is what I get:这就是我得到的:
TypeError: Camera_file_get_info expected at least 2 arguments, got 0
What is even more frustrating is that no matter how hard I google I cannot find anything about the Camera_file_get_info
function.更令人沮丧的是,无论我如何用谷歌搜索,我都找不到有关Camera_file_get_info
函数的任何信息。
Am I approaching this wrong?我接近这个错误吗?
The file_get_info
method on a Camera
object is a more Pythonic version of the libgphoto2 function gp_camera_file_get_info
. Camera
对象上的file_get_info
方法是 libgphoto2 函数gp_camera_file_get_info
Pythonic 版本。 This would be a better term for web searching.这将是网络搜索的更好术语。
There are several ways to get the information you're looking for.有多种方法可以获取您要查找的信息。 Like other Python modules you can use pydoc:像其他 Python 模块一样,您可以使用 pydoc:
pydoc3 gphoto2.Camera.file_get_info
Help on method_descriptor in gphoto2.Camera:
gphoto2.Camera.file_get_info = file_get_info(...)
file_get_info(char const * folder, char const * file, Context context)
Retrieves information about a file.
Parameters
----------
* `camera` :
a Camera
* `folder` :
a folder
* `file` :
the name of the file
* `info` :
* `context` :
a GPContext
Returns
-------
a gphoto2 error code
See also gphoto2.gp_camera_file_get_info
This is taken from the "C" documentation, so the parameter list is a bit confusing - info
is a parameter in the C version but not in Python.这是取自“C”文档,因此参数列表有点混乱 - info
是 C 版本中的参数,但不是 Python 中的参数。 The two parameters you need are folder
and file
- these tell the function which file you want information about.你需要的两个参数是folder
和file
——它们告诉函数你想要关于哪个文件的信息。
You might prefer to use the C documentation directly: http://www.gphoto.org/doc/api/gphoto2-camera_8h.html#adda54321b1947b711d345936041f80c7 This includes a link to the info
structure.您可能更喜欢直接使用 C 文档: http : //www.gphoto.org/doc/api/gphoto2-camera_8h.html#adda54321b1947b711d345936041f80c7这包括指向info
结构的链接。
Finally, the list-files.py
example program included in python-gphoto2
shows a use of file_get_info
.最后, python-gphoto2
中包含的list-files.py
示例程序展示了file_get_info
的用法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.