Skip to content

Instantly share code, notes, and snippets.

View bradleyayers's full-sized avatar

Bradley Ayers bradleyayers

View GitHub Profile
@bradleyayers
bradleyayers / gist:1480017
Created December 15, 2011 06:11
Fill a page with an image with ReportLab and PIL
def fill_page_with_image(path, canvas):
"""
Given the path to an image and a reportlab canvas, fill the current page
with the image.
This function takes into consideration EXIF orientation information (making
it compatible with photos taken from iOS devices).
This function makes use of ``canvas.setPageRotation()`` and
``canvas.setPageSize()`` which will affect subsequent pages, so be sure to
@bradleyayers
bradleyayers / req.py
Created April 24, 2011 08:59
Patch for copy_to_build_dir
def copy_to_build_dir(self, req_to_install):
target_dir = req_to_install.editable and self.src_dir or self.build_dir
logger.info("Copying %s to %s" % (req_to_install.name, target_dir))
dest = os.path.join(target_dir, req_to_install.name)
copytree(req_to_install.source_dir, dest)
call_subprocess(["python", "%s/setup.py" % dest, "clean"],
cwd=dest)