[Python-checkins] r57521 - sandbox/trunk/import_in_py/zipimport_/zipimport.py

brett.cannon python-checkins at python.org
Sun Aug 26 23:58:44 CEST 2007


Author: brett.cannon
Date: Sun Aug 26 23:58:43 2007
New Revision: 57521

Modified:
   sandbox/trunk/import_in_py/zipimport_/zipimport.py
Log:
Raise ZipImportError if no zip file is found in the path.


Modified: sandbox/trunk/import_in_py/zipimport_/zipimport.py
==============================================================================
--- sandbox/trunk/import_in_py/zipimport_/zipimport.py	(original)
+++ sandbox/trunk/import_in_py/zipimport_/zipimport.py	Sun Aug 26 23:58:43 2007
@@ -4,7 +4,7 @@
 #import contextlib
 #import datetime
 #import imp
-#import os
+import os
 #import time
 import zipfile
 
@@ -33,6 +33,12 @@
         """
         if len(archivepath) == 0:
             raise ZipImportError("archive path is empty")
+        while archivepath:
+            if zipfile.is_zipfile(archivepath):
+                break
+            archivepath = os.path.split(archivepath)[0]
+        else:
+            raise ZipImportError("not a zip file")
 
 
 


More information about the Python-checkins mailing list