[MERGE] include tortoise icons in windows binary distributions

John Arbash Meinel john at arbash-meinel.com
Wed Sep 3 15:27:44 BST 2008


John Arbash Meinel has voted resubmit.
Status is now: Resubmit
Comment:
+
+    # collect up our icons.
+    cwd = os.getcwd()
+    ico_root = os.path.join(tbzr_root, 'tbzrlib', 'resources')
+    os.chdir(ico_root)

^- Using 'chdir()' is rather ugly. Can't you just do:

for root, dirs, files in os.walk(ico_root):

instead?

I realize you then need to remove 'ico_root' as the prefix to all of the 
'root' paths, but I would really prefer it to seeing a 'chdir' call.

Another alternative is to use "bzrlib.osutils.walkdirs(root)" which 
gives you relative paths along with the absolute paths.

The signature is:

for ((dir_relpath, dir_abspath), entries) in walkdirs(root):
   for relpath, basename, kind, lstat, abspath in entries:

abspath is not technically pure abspath, it is the path including the 
'root' you supplied. You can also supply a custom 'prefix' for the 
relpath portions, but I don't think that is interesting for your use 
case.

+        fse = sys.getfilesystemencoding()
+        map_items = [(f.replace('\\', '/').decode(fse), rid)
+                     for rid, (_, f) in enumerate(icos)]
+        ico_map = dict(map_items)

Technically, getfilesystemencoding() is not valid on all platforms. I 
think BSD returns None. So you probably want 'osutils._fs_encoding', 
which we should probably make more public somehow. (I realize TBZR may 
not be bundled using setup.py for BSD, but it is probably good to use it 
anyway.)

I'm a bit concerned about how TBZR will lookup these icons. (Again, this 
seems like it should really be in the TBZR setup, to make sure to stay 
in sync with how to lookup icons at runtime with how to package them.)

I'm a bit uncomfortable using a pickle, as it is a known unsafe data 
structure. I suppose it might be okay as a first-run. (Again, we need to 
watch out for how bzr is packaging TBZR and how TBZR expects to be 
packaged getting out of sync.)



For details, see: 
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C000b01c90dbf%246bbc7fc0%2443357f40%24%40com.au%3E
Project: Bazaar



More information about the bazaar mailing list