Skip to content

Instantly share code, notes, and snippets.

View scanny's full-sized avatar

Steve Canny scanny

View GitHub Profile
@scanny
scanny / dpi_sensitive_image_placement.py
Created October 4, 2013 22:32
Some working code that adjusts the size of an image placed in python-pptx based on it's stated DPI, overriding the default DPI python-pptx v0.2.6 uses.
#
# forces python-pptx to display images at native size, based on DPI attribute
# in image file, from Chad ...
#
import Image
import Presentation
from pptx.util import Inches
left = Inches(0.83)
@scanny
scanny / rst_renderer.py
Created March 2, 2015 20:36
Code to translate RestructuredText into Microsoft Word document using python-docx
# encoding: utf-8
"""
Helper objects for rendering to .docx format.
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
import functools
from typing import Any, cast, Callable, Generic, TypeVar
T = TypeVar("T")
class lazyproperty(Generic[T]):
"""Decorator like @property, but evaluated only on first access.
Like @property, this can only be used to decorate methods having only a `self`