2013-01-21 1 views
1

파이썬 gdata 라이브러리를 사용하여 특정 폴더의 Google 문서 파일을 복사하고 이동합니다. DocsClient에서 MoveResource 메서드를 사용하면 파일이 원하는 폴더에 나타나지만 루트 폴더에도 남아 있습니다.루트 컬렉션 (폴더)에서 리소스 (Google 문서 도구 문서)를 제거하는 방법

루트 폴더에서 제거하는 방법을 알아낼 수 없습니까?

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

doc_service = gdata.docs.client.DocsClient() 
doc_service.ClientLogin('myId', 'myPassword', 'myAppName') 

# this is my source document 
doc = doc_service.GetResourceById('ABC123') 

# extracting the folder of my source document to move the copy in the same folder 
for parent in doc.InCollections(): 
    if parent.title == 'myFilter': 
     destination_folder_id = parent.href.split('%3A')[1] 
     destination_folder = doc_service.GetResourceById(destination_folder_id) 

# making a copy of my source 
newdoc = doc_service.CopyResource(doc, 'Test Python') 

# moving my copy to the same folder as my source 
# but the copy also stays in the root folder! 
moveddoc = doc_service.MoveResource(newdoc, destination_folder) 

답변

1

당신은이 코드를 사용하여 루트 모음에서 Google 문서 도구 파일을 제거 할 수 있습니다

doc_service.Delete('https://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/' + doc.resource_id.text, force=True) 
관련 문제