For review. Marcopg didn't like this patch when is_dir was hackier in the
packed case (which never gets exercised), so I've fixed that part.
From 8ed4af6b7197625026945c75e0296bba5c5cf961 Mon Sep 17 00:00:00 2001
From: chema <[EMAIL PROTECTED](none)>
Date: Thu, 10 Jul 2008 13:58:12 -0600
Subject: [PATCH] 7205: bundlebuilder accepts old "dist" cmd, checks for po dir

---
 src/sugar/activity/bundlebuilder.py |    8 ++++++++
 src/sugar/bundle/bundle.py          |   13 ++++++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py
index 5afd78f..abe91b6 100644
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -81,6 +81,10 @@ class Builder(object):
     def build_locale(self):
         po_dir = os.path.join(self.config.source_dir, 'po')
 
+        if not self.config.bundle.is_dir(po_dir):
+            logging.warn("Missing po/ dir, cannot build_locale")
+            return
+        
         for f in os.listdir(po_dir):
             if not f.endswith('.po'):
                 continue
@@ -214,6 +218,10 @@ def cmd_dist_xo(config, options, args):
     packager = XOPackager(config)
     packager.package()
 
+def cmd_dist(config, options, args):
+    logging.warn("dist deprecated, use dist_xo.")
+    cmd_dist_xo(config, options, args)
+
 def cmd_dist_source(config, options, args):
     packager = SourcePackager(config)
     packager.package()
diff --git a/src/sugar/bundle/bundle.py b/src/sugar/bundle/bundle.py
index 9e876c2..eccbe9a 100644
--- a/src/sugar/bundle/bundle.py
+++ b/src/sugar/bundle/bundle.py
@@ -132,7 +132,18 @@ class Bundle:
                 zip_file.close()
 
             return True
-                
+
+    def is_dir(self, filename):
+        if self._unpacked:
+            path = os.path.join(self._path, filename)
+            return os.path.isdir(path)
+        else:
+            zip_file = zipfile.ZipFile(self._path)
+            path = os.path.join(self._zip_root_dir, filename, "")
+            for subfile in zip_file.namelist():
+                if subfile.startswith(path):
+                    return True
+            return False
 
     def get_path(self):
         """Get the bundle path."""
-- 
1.5.2.5

_______________________________________________
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar

Reply via email to