Please use os.path.join to combine paths

On Thu, Oct 4, 2012 at 12:58 AM, Nathan <[email protected]> wrote:
> Currently, if you set pyglet.resource.path to ["foo"] and load "abc.png"
> (foo/abc.png), and then change pyglet.resource.path to ["bar"] and try to
> load "abc.png", you still get foo/abc.png, since the caching looks at the
> name of the image file only.
>
> This simple patch makes it so that the images are cached per specific
> setting of pyglet.resource.path.  I included the patch as an attachment and
> inline below since it's so tiny.
>
> # HG changeset patch
> # User Nathan Stocks <[email protected]>
> # Date 1349326606 21600
> # Node ID f8102f9ee5b19c43c6129dac070bf393f82e3ef7
> # Parent  bf7f6c05275664ed76aab926944fe3a6a74ff022
> Made it so that once you load an image, you can still load more images of
> the same name by changing pyglet.resource.path.
>
> diff -r bf7f6c052756 -r f8102f9ee5b1 pyglet/resource.py
> --- a/pyglet/resource.py Sat Sep 15 16:48:08 2012 -0500
> +++ b/pyglet/resource.py Wed Oct 03 22:56:46 2012 -0600
> @@ -504,9 +504,9 @@
>          '''
>          self._require_index()
>          if name in self._cached_images:
> -            identity = self._cached_images[name]
> +            identity = self._cached_images[str(self.path)+name]
>          else:
> -            identity = self._cached_images[name] = self._alloc_image(name,
> +            identity = self._cached_images[str(self.path)+name] =
> self._alloc_image(name,
>                  atlas=atlas)
>
>          if not rotate and not flip_x and not flip_y:
>
>
> Works great for me!
>
> Thoughts?
>
> ~ Nathan
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to