Skip to content
This repository was archived by the owner on Jan 12, 2018. It is now read-only.

Commit 8f242f9

Browse files
committed
- Media folder not installed with site-packages template, created on the fly as needed later
1 parent df0beda commit 8f242f9

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.pyc
33
*.docx
44
build
5+
template/word/media

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ include template/*
22
include template/_rels/*
33
include template/docProps/*
44
include template/word/*
5-
include template/word/media/*
65
include template/word/theme/*

docx.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,12 @@ def picture(relationshiplist,picname,picdescription,pixelwidth=None,pixelheight=
236236
and an updated relationshiplist'''
237237
# http://openxmldeveloper.org/articles/462.aspx
238238

239-
'''Create an image. Size may be specified, otherwise it will based on the pixel size of image. Return a paragraph containing the picture'''
239+
'''Create an image. Size may be specified, otherwise it will based on the pixel size of image. Return a paragraph containing the picture'''
240240
# Copy the file into the media dir
241-
shutil.copyfile(picname, join(template_dir,'word','media',picname))
241+
media_dir = join(template_dir,'word','media')
242+
if not os.path.isdir(media_dir):
243+
os.mkdir(media_dir)
244+
shutil.copyfile(picname, join(media_dir,picname))
242245

243246
# Check if the user has specified a size
244247
if not pixelwidth or not pixelheight:

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
('docx-template/_rels', glob('template/_rels/.*')),
2121
('docx-template/docProps', glob('template/docProps/*.*')),
2222
('docx-template/word', glob('template/word/*.xml')),
23-
('docx-template/word/media', glob('template/word/media/*.*')),
2423
('docx-template/word/theme', glob('template/word/theme/*.*')),
2524
],
2625
)

template/word/media/image1.png

-44.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)