On Thu, Mar 26, 2009 at 1:54 PM, Guido van Rossum <gu...@python.org> wrote:
> 2009/3/26 Toshio Kuratomi <a.bad...@gmail.com>:
>> Guido van Rossum wrote:
>>> On Wed, Mar 25, 2009 at 9:40 PM, Tarek Ziadé <ziade.ta...@gmail.com> wrote:
>>>> I think Distutils (and therefore Setuptools) should provide some APIs
>>>> to play with special files (like resources) and to mark them as being 
>>>> special,
>>>> no matter where they end up in the target system.
>>>
>>> Yes, this should be done. PEP 302 has some hooks but they are optional
>>> and not available for the default case. A simple wrapper to access a
>>> resource file relative to a given module or package would be easy to
>>> add. It should probably support four APIs:
>>>
>>> - Open as a binary stream
>>> - Open as a text stream
>>> - Get contents as a binary string
>>> - Get contents as a text string
>>>
>> Depending on the definition of a "resource" there's additional
>> information that could be needed.  For instance, if resource includes
>> message catalogs, then being able to get the base directory that the
>> catalogs reside in is needed for passing to gettext.
>
> Well the whole point is that for certain loaders (e.g. zip files)
> there *is* no base directory. If you do need directories you won't be
> able to use PEP-302 loaders, and you can just use
> os.path.dirname(<some_module>.__file__).
>

Oops didnt see this msg ... AFAICR ... this is the kind of reasons
ResourceManager is there for in pkg_resources ... CMIIW anyway ...

However GvR was talking about PEP 302 loaders ... well ... the only
thing I can say is that bundling message catalogs in egg files (they
'r zip files anyway ;) and using them with Babel (... similar to
gettext ... I think ...) works fine for me using the aforementioned
functions in pkg_resources ... About whether PEP 302 loaders should
(look like | implement functions in) pkg_resources.ResourceManager or
not ... I'm not very sure ...

... and I'm talking about ...

{{{
>>> [x for x in dir(pkg_resources) if 'resource_' in x]
['resource_exists', 'resource_filename', 'resource_isdir',
'resource_listdir', 'resource_stream', 'resource_string']

}}}

--
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Comandos : Pipe Viewer ... ¿Qué está pasando por esta tubería?



-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Comandos : Pipe Viewer ... ¿Qué está pasando por esta tubería?
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to