Explorar el Código

Cope with float times.

Jelmer Vernooij hace 16 años
padre
commit
2f345df8de
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      dulwich/index.py

+ 5 - 0
dulwich/index.py

@@ -42,6 +42,11 @@ def write_cache_time(f, t):
     """Write a cache time."""
     if isinstance(t, int):
         t = (t, 0)
+    elif isinstance(t, float):
+        (secs, nsecs) = divmod(t, 1.0)
+        t = (int(secs), int(nsecs * 1000000000))
+    elif not isinstance(t, tuple):
+        raise TypeError(t)
     f.write(struct.pack(">LL", *t))