DebugClients/Python/coverage/files.py

changeset 31
744cd0b4b8cd
parent 0
de9c2efb9d02
child 790
2c0ea0163ef4
diff -r 9513afbd57f1 -r 744cd0b4b8cd DebugClients/Python/coverage/files.py
--- a/DebugClients/Python/coverage/files.py	Thu Jan 07 13:42:05 2010 +0000
+++ b/DebugClients/Python/coverage/files.py	Thu Jan 07 13:42:51 2010 +0000
@@ -2,7 +2,7 @@
 
 import os, sys
 
-class FileLocator:
+class FileLocator(object):
     """Understand how filenames work."""
 
     def __init__(self):
@@ -18,23 +18,23 @@
 
     def relative_filename(self, filename):
         """Return the relative form of `filename`.
-        
+
         The filename will be relative to the current directory when the
         FileLocator was constructed.
-        
+
         """
         return filename.replace(self.relative_dir, "")
 
     def canonical_filename(self, filename):
         """Return a canonical filename for `filename`.
-        
+
         An absolute path with no redundant components and normalized case.
-        
+
         """
-        if not self.canonical_filename_cache.has_key(filename):
+        if filename not in self.canonical_filename_cache:
             f = filename
             if os.path.isabs(f) and not os.path.exists(f):
-                if not self.get_zip_data(f):
+                if self.get_zip_data(f) is None:
                     f = os.path.basename(f)
             if not os.path.isabs(f):
                 for path in [os.curdir] + sys.path:
@@ -48,10 +48,11 @@
 
     def get_zip_data(self, filename):
         """Get data from `filename` if it is a zip file path.
-        
-        Returns the data read from the zip file, or None if no zip file could
-        be found or `filename` isn't in it.
-        
+
+        Returns the string data read from the zip file, or None if no zip file
+        could be found or `filename` isn't in it.  The data returned will be
+        an empty string if the file is empty.
+
         """
         import zipimport
         markers = ['.zip'+os.sep, '.egg'+os.sep]
@@ -66,5 +67,7 @@
                     data = zi.get_data(parts[1])
                 except IOError:
                     continue
+                if sys.hexversion > 0x03000000:
+                    data = data.decode('utf8') # TODO: How to do this properly?
                 return data
         return None

eric ide

mercurial