On Apr 15, 10:12 am, David Eyk <[EMAIL PROTECTED]> wrote:
> This seems like a more pythonic route for the module to take. I've
> been looking at the Loader implementation. Changing the index handle
> shouldn't be hard at all. I still dream of recursive indexing, but I
> haven't quite figured out how the current reindex method could be bent
> toward that end.
Putting my money where my mouth is, here's a patch for resource.py, to
handle data namespaces. I've tested this a little, but not
thoroughly. It does *not* handle names inside a zipfile, as I don't
quite understand what's going on in that section yet. Anything
indexed inside a zipfile *should* demonstrate the old, flat namespace
behavior.
Index: pyglet/resource.py
===================================================================
--- pyglet/resource.py (revision 2013)
+++ pyglet/resource.py (working copy)
@@ -328,7 +328,12 @@
# Filesystem directory
location = FileLocation(path)
for name in os.listdir(path):
- self._index_file(name, location)
+ try:
+ fullname =
os.path.normpath(os.path.join(path, name))
+ relative_name =
fullname.split(self._script_home)[1][1:]
+ except IndexError:
+ relative_name = name
+ self._index_file(relative_name, location)
else:
# Find path component that is the ZIP file.
dir = ''
@@ -366,7 +371,7 @@
'''
try:
location = self._index[name]
- return location.open(name, mode)
+ return location.open(os.path.basename(name), mode)
except KeyError:
raise ResourceNotFoundException(name)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---