Created
July 2, 2015 14:29
-
-
Save malexandre/b29f26b9912c82230ee6 to your computer and use it in GitHub Desktop.
Copy the content of a docx inside another in python app engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from server.api.drive import Drive | |
from server.libs.docx import Document | |
from cStringIO import StringIO | |
driveFile = Drive.getFile('DRIVE_ID') | |
doc = Document(StringIO(Drive.downloadFile(driveFile['downloadUrl']))) | |
doc_to_copy = Document(StringIO(Drive.downloadFile(Drive.getFile('DRIVE_ID_TO_COPY')['downloadUrl']))) | |
for element in doc_to_copy._body._element: | |
doc._body._element.append(element) | |
output = StringIO() | |
doc.save(output) | |
Drive.uploadFile('test-result.docx', | |
driveFile.get('mimeType'), | |
output, | |
None, | |
False, | |
'owner.email@google.com') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment