[MERGE] Bugfix #68124: Allow import plugins from zip archives

Alexander Belchenko bialix at ukr.net
Tue Jan 2 16:00:50 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley пишет:
> Alexander Belchenko wrote:
>>> Alexander Belchenko wrote:
>>>
>>>> No. Inside zip always used '/'.
>>>
>>> So then doing os.path.split is incorrect, because it depends on os.sep,
>>> right?
>>
>>
>> Actually, no:
>>
>>  Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
>> on win32
>>  Type "help", "copyright", "credits" or "license" for more information.
>>  >>> a = 'a\\b\\c'
>>  >>> b = 'a/b/c'
>>  >>> import os
>>  >>> os.path.split(a)
>>  ('a\\b', 'c')
>>  >>> os.path.split(b)
>>  ('a/b', 'c')
>>  >>>
>>
>> As you could see this function don't depends on os.sep.
> 
> When we're dealing with '/'-delimited paths, we use the functions in
> osutils.
> 
> I don't know why os.path.split('a/b/c') works on Windows, but I assume
> it's Windows-specific compatibility code.

I think it's true.
I could add explanation comment about Windows compatibility.

> Certainly, it behaves differently on Windows vs Unix:
>>>> a = 'a\\b\\c'
>>>> os.path.split(a)
> ('', 'a\\b\\c')

This example unrelated to my code, because inside zip archives always used
'/' as path separator.

> AFAIK, the only OSes that used something other than '/' are Windows, DOS
> and MacOS 1-9.  So it's unlikely that your code will run on a platform
> where '/' isn't supported as a separator.
> 
> But still, I think using osutils makes the code clearly correct, whereas
> os.path makes it suspect.

osutils won't help me here because it does not have corresponding function
to os.path.split. osutils.splitpath() is not answer because it splits by each
slash. os.path.split() split directory name from file name.
So the nearest analogue is

head, tail = name.rsplit('/',1)

I personally don't like this one.

Alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFmoGyzYr338mxwCURAlBNAJ4hJnyNq/KIIoSR/+PHVsEmLfPpugCfUGAv
1GHfSG9ep3ynJfvyqDGF9zo=
=qAEX
-----END PGP SIGNATURE-----





More information about the bazaar mailing list