Как удалить ресурс (документ Google Docs) из корневой коллекции (папки)

Я использую библиотеку python gdata для копирования и перемещения файла Google Docs в определенную папку. Я использую метод MoveResource из DocsClient, файл появляется в нужной папке, но также остается в корневой папке.

Я не могу понять, как удалить его из корневой папки?!

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 )

person VanacK    schedule 21.01.2013    source источник


Ответы (1)


Вы можете удалить файл Документов Google из корневой коллекции, используя этот код:

doc_service.Delete('https://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/' + doc.resource_id.text, force=True)
person jjw    schedule 30.05.2013