【发布时间】:2017-04-16 13:32:20
【问题描述】:
是否可以在 PyDrive 中使用 InsertPermission() 发送可选查询参数的值? PyDrive 文档似乎忽略了如何处理切换可选参数,如sendNotificationEmails。
我需要为特定用户而不是任何人添加文件权限,而不发送通知电子邮件,并且sendNotificationEmails 默认设置为True。
我考虑过将 files.py 的函数定义修改为以下内容,但我不确定这是否可行并且之前没有编辑过库:
def InsertPermission(self, new_permission):
"""Insert a new permission. Re-fetches all permissions after call.
:param new_permission: The new permission to insert, please see the official Google Drive API guide on permissions.insert for details.
:type new_permission: object
:return: The permission object.
:rtype: object
"""
file_id = self.metadata.get('id') or self['id']
try:
permission = self.auth.service.permissions().insert( fileId=file_id, body=new_permission, sendNotificationEmails=False).execute(http=self.http)
except errors.HttpError as error:
raise ApiRequestError(error)
else:
self.GetPermissions() # Update permissions field.
return permission
【问题讨论】:
-
不要修改库的代码。向 PyDrive 维护者发送一个功能请求,在它实现之前,在您自己的项目中拥有修改后的代码的副本。
-
PyDrive 维护者在这里,在这里打开一个错误:github.com/googledrive/PyDrive/issues。您可以分叉库并进行更改。如果它们有效,我很乐意将它们合并到主库中。
标签: python google-api google-drive-api google-api-python-client pydrive