[web] Stop using negative indices with os.stat results
authorRémi Cardona <remi.cardona@logilab.fr>
Fri, 03 Jul 2015 12:07:44 +0200
changeset 10505 a9becf2cce8b
parent 10504 3755cd64fff8
child 10506 774bf00ae3bb
[web] Stop using negative indices with os.stat results The python doc says: More items may be added at the end by some implementations. .st_mtime is also more readable than [-2].
web/propertysheet.py
--- a/web/propertysheet.py	Fri Jul 03 13:43:40 2015 +0200
+++ b/web/propertysheet.py	Fri Jul 03 12:07:44 2015 +0200
@@ -63,15 +63,15 @@
                 if not isinstance(self[name], type):
                     msg = "Configuration error: %s.%s should be a %s" % (fpath, name, type)
                     raise Exception(msg)
-        self._propfile_mtime[fpath] = os.stat(fpath)[-2]
+        self._propfile_mtime[fpath] = os.stat(fpath).st_mtime
         self._ordered_propfiles.append(fpath)
 
     def need_reload(self):
         for rid, (adirectory, rdirectory, mtime) in self._cache.items():
-            if os.stat(osp.join(rdirectory, rid))[-2] > mtime:
+            if os.stat(osp.join(rdirectory, rid)).st_mtime > mtime:
                 del self._cache[rid]
         for fpath, mtime in self._propfile_mtime.iteritems():
-            if os.stat(fpath)[-2] > mtime:
+            if os.stat(fpath).st_mtime > mtime:
                 return True
         return False
 
@@ -109,7 +109,7 @@
                 stream.write(content)
                 stream.close()
                 adirectory = self._cache_directory
-            self._cache[rid] = (adirectory, rdirectory, os.stat(sourcefile)[-2])
+            self._cache[rid] = (adirectory, rdirectory, os.stat(sourcefile).st_mtime)
             return adirectory
 
     def compile(self, content):