如何获取google文档资源的父文件夹?

2024-10-02 00:41:45 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的Goggle App Engine应用程序中使用pythonggdata,我试图复制一个googledocs资源,并将副本放在与源文件相同的文件夹中。我使用的CopyResource方法将副本放在根级别。在

你知道如何查询googledocs以获得文件所在的文件夹/集合列表吗?在

import gdata.docs.service
import gdata.docs.client
...

doc_service = gdata.docs.client.DocsClient() 
doc_service.ClientLogin('username', 'abc123', 'my app name')

try:
   doc = doc_service.GetResourceById(resourceId)
   newdoc = doc_service.CopyResource(doc, filename)

   # newdoc is copied at the root level of Google Drive
   # need to move it where the source file is located. 

   newdocid = newdoc.id.text.decode('utf-8').split('%3A')[1]

   # would like here to have my newly copied document
   # moved to the same directory as the source one.
   # assuming the source is only in one folder.

except gdata.client.RequestError, inst:
   logging.info('Copy Error: %s', inst.body)

Tags: thetoimport文件夹clientdocssourcedoc

热门问题