Revision: 7759
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7759&view=rev
Author: mdboom
Date: 2009-09-14 19:16:49 +0000 (Mon, 14 Sep 2009)
Log Message:
-----------
Improve speed of gallery thumbnail generation using multiprocessing
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/gen_gallery.py
Modified: trunk/matplotlib/doc/sphinxext/gen_gallery.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/gen_gallery.py 2009-09-14 17:16:41 UTC
(rev 7758)
+++ trunk/matplotlib/doc/sphinxext/gen_gallery.py 2009-09-14 19:16:49 UTC
(rev 7759)
@@ -39,15 +39,14 @@
'matplotlib_icon',
])
- print
- print "generating gallery: ",
data = []
+ thumbnails = {}
+
for subdir in ('api', 'pylab_examples', 'mplot3d', 'widgets', 'axes_grid'
):
origdir = os.path.join('build', rootdir, subdir)
thumbdir = os.path.join(outdir, rootdir, subdir, 'thumbnails')
if not os.path.exists(thumbdir):
os.makedirs(thumbdir)
- print subdir,
for filename in sorted(glob.glob(os.path.join(origdir, '*.png'))):
if filename.endswith("hires.png"):
@@ -56,16 +55,14 @@
path, filename = os.path.split(filename)
basename, ext = os.path.splitext(filename)
if basename in skips:
- sys.stdout.write('[skipping %s]' % basename)
- sys.stdout.flush()
continue
# Create thumbnails based on images in tmpdir, and place
# them within the build tree
orig_path = str(os.path.join(origdir, filename))
thumb_path = str(os.path.join(thumbdir, filename))
- if out_of_date(orig_path, thumb_path):
- image.thumbnail(orig_path, thumb_path, scale=0.3)
+ if out_of_date(orig_path, thumb_path) or True:
+ thumbnails[orig_path] = thumb_path
m = multiimage.match(basename)
if m is None:
@@ -77,10 +74,6 @@
data.append((subdir, basename,
os.path.join(rootdir, subdir, 'thumbnails',
filename)))
- sys.stdout.write(".")
- sys.stdout.flush()
- print
-
link_template = """\
<a href="%s"><img src="%s" border="0" alt="%s"/></a>
"""
@@ -99,5 +92,21 @@
fh.write(template%'\n'.join(rows))
fh.close()
+ try:
+ import multiprocessing
+ def make_thumbnail(args):
+ image.thumbnail(args[0], args[1], 0.3)
+
+ app.builder.info("generating thumbnails... ", nonl=True)
+ pool = multiprocessing.Pool()
+ pool.map(make_thumbnail, thumbnails.iteritems())
+ app.builder.info("done")
+
+ except ImportError:
+ for key in app.builder.status_iterator(
+ thumbnails.iterkeys(), "generating thumbnails... ",
+ length=len(thumbnails)):
+ image.thumbnail(key, thumbnails[key], 0.3)
+
def setup(app):
app.connect('env-updated', gen_gallery)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins