Mercurial > boomslang
diff pyntnclick/resources.py @ 625:85153f422522 pyntnclick
Differently yuck get_image().
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 11 Feb 2012 22:00:50 +0200 |
parents | 38f75cef86d0 |
children | d1ec9e739e23 |
line wrap: on
line diff
--- a/pyntnclick/resources.py Sat Feb 11 21:52:42 2012 +0200 +++ b/pyntnclick/resources.py Sat Feb 11 22:00:50 2012 +0200 @@ -58,23 +58,24 @@ paths.append(resource_filename(module, resource_path)) return paths - def get_image(self, image_name_fragments, transforms=(), basedir='images'): + def get_image(self, *image_name_fragments, **kw): """Load an image and optionally apply mutators. - The `image_name_fragments` parameter may be either a string or a list - of strings. The latter is a convenience for things that compose an - image name out of several fragments. + All positional params end up in `image_name_fragments` and are joined + with the path separator. + + Two keyword parameters are also accepted: - The `transforms` param may contain transforms, which modify an image - in-place to apply various effects. + * `transforms` may contain transforms, which modify an image in-place + to apply various effects. - The `basedir` param defaults to 'images', but may be overriden to load - images from other places. ('icons', for example.) + * `basedir` defaults to 'images', but may be overridden to load images + from other places. ('icons', for example.) """ - # Juggle our various params and find an appropriate image path. - if isinstance(image_name_fragments, basestring): - image_name_fragments = [image_name_fragments] + transforms = kw.get('transforms', ()) + basedir = kw.get('basedir', 'images') + image_path = self.get_resource_path(basedir, *image_name_fragments) key = (image_path, transforms)