Closed GoogleCodeExporter closed 9 years ago
A notation for sub-paths has been omitted in the Resources class to avoid
confusion with path delimiter expectations of users. Hence accessing a resource
file via "<prefix><somedelim><resourcename>" should be avoided.
Enhancing Resources.scan() to consider non-directory paths as argument (and
using the directory part of them as entry point for scanning) will be
implemented:
appresources = Resources(__file__)
appresources.get_path("image.png")
...
Original comment by marcusvonappen@googlemail.com
on 16 Jul 2012 at 9:22
There is another more common user story to consider. When resources dir is
located in project subdirectory.
Resources(__file__, subdir="data")
Original comment by techtonik@gmail.com
on 16 Jul 2012 at 7:04
And another story when directory layout is:
checkout/
game.py
game.conf
data/
audio/
click.wav
fonts/
ter-u12b.bdf
ter-u12n.bdf
images/
background.jpg
button1.jpg
button2.jpg
info.dat
Original comment by techtonik@gmail.com
on 16 Jul 2012 at 7:20
PLease clarify what user story you mean with #c3.
Original comment by marcusvonappen@googlemail.com
on 16 Jul 2012 at 8:11
Non-directory paths and subdir arguments have been implemented in revision
d2fa3f4e547a - thanks!
Original comment by marcusvonappen@googlemail.com
on 17 Jul 2012 at 5:55
Nice. =) In #c3 I wondered how do I load the audio if get_path() doesn't
support subdirs. Looks like the only way through API is to provide separate
Reources() instance for each subdir.
audioresources = Resources(__file__, 'data/audio')
audioresources.get_path("click.wav")
fontresources = Resources(__file__, 'data/fonts')
fontresources.get_path("ter-u12n.bdf")
Original comment by techtonik@gmail.com
on 17 Jul 2012 at 1:28
Resources.scan() walks recursively through all subdirectories (if not excluded
by the excludepattern arguemnt). If you create (based on comment 3) a Resource
instance on the data
directory, you also will have access to the contents of audio, fonts, images,
...:
appresources = Resources(__file__, subdir="data")
appresources.get_path("click.wav")
Original comment by marcusvonappen@googlemail.com
on 17 Jul 2012 at 3:39
I see.
http://wiki.pgreloaded.googlecode.com/hg/documentation/modules/resources.html
says a lot, but doesn't mention this use case.
Original comment by techtonik@gmail.com
on 17 Jul 2012 at 4:50
A note about subdirectory scanning (and a file indexing limitation) has been
added. Thanks for pointing it out.
Original comment by marcusvonappen@googlemail.com
on 18 Jul 2012 at 5:58
Original issue reported on code.google.com by
techtonik@gmail.com
on 16 Jul 2012 at 7:57