]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/xstat.py
Update base_version to 0.34~ for 0.34 development
[bup.git] / lib / bup / xstat.py
index 461c932f15865a4611c6342313f9220ae4917bdb..a0941294202864931e5e013318845aad1916d391 100644 (file)
@@ -20,6 +20,9 @@ try:
 except AttributeError as e:
     _bup_lutimes = False
 
+assert sys.version_info[0] < 3 \
+    or not (_bup_utimensat or _bup_utimes or _bup_lutimes)
+
 
 def timespec_to_nsecs(ts):
     ts_s, ts_ns = ts
@@ -58,8 +61,14 @@ def fstime_to_sec_bytes(fstime):
     else:
         return b'%d.%09d' % (s, ns)
 
-
-if _bup_utimensat:
+if sys.version_info[0] > 2:
+    def utime(path, times):
+        """Times must be provided as (atime_ns, mtime_ns)."""
+        os.utime(path, ns=times)
+    def lutime(path, times):
+        """Times must be provided as (atime_ns, mtime_ns)."""
+        os.utime(path, ns=times, follow_symlinks=False)
+elif _bup_utimensat:
     def utime(path, times):
         """Times must be provided as (atime_ns, mtime_ns)."""
         atime = nsecs_to_timespec(times[0])
@@ -93,6 +102,8 @@ def _fix_cygwin_id(id):
 
 
 class stat_result:
+    __slots__ = ('st_mode', 'st_ino', 'st_dev', 'st_nlink', 'st_uid', 'st_gid',
+                 'st_rdev', 'st_size', 'st_atime', 'st_mtime', 'st_ctime')
     @staticmethod
     def from_xstat_rep(st):
         global _cygwin_sys