]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/xstat.py
do_bloom(): remove unused "count" variable
[bup.git] / lib / bup / xstat.py
index 23483f5991f6d0c226b672a03ce4445722dcf156..0eee9b2af2d956d495d4775f207ecd0e613c414f 100644 (file)
@@ -20,15 +20,12 @@ except AttributeError, e:
 
 
 def timespec_to_nsecs((ts_s, ts_ns)):
-    # c.f. _helpers.c: timespec_vals_to_py_ns()
-    if ts_ns < 0 or ts_ns > 999999999:
-        raise Exception('invalid timespec nsec value')
     return ts_s * 10**9 + ts_ns
 
 
 def nsecs_to_timespec(ns):
     """Return (s, ns) where ns is always non-negative
-    and t = s + ns / 10e8""" # metadata record rep (and libc rep)
+    and t = s + ns / 10e8""" # metadata record rep
     ns = int(ns)
     return (ns / 10**9, ns % 10**9)
 
@@ -119,6 +116,7 @@ def lstat(path):
 
 def mode_str(mode):
     result = ''
+    # FIXME: Other types?
     if pystat.S_ISREG(mode):
         result += '-'
     elif pystat.S_ISDIR(mode):
@@ -146,3 +144,23 @@ def mode_str(mode):
     result += 'w' if (mode & pystat.S_IWOTH) else '-'
     result += 'x' if (mode & pystat.S_IXOTH) else '-'
     return result
+
+
+def classification_str(mode, include_exec):
+    if pystat.S_ISREG(mode):
+        if include_exec \
+           and (pystat.S_IMODE(mode) \
+                & (pystat.S_IXUSR | pystat.S_IXGRP | pystat.S_IXOTH)):
+            return '*'
+        else:
+            return ''
+    elif pystat.S_ISDIR(mode):
+        return '/'
+    elif pystat.S_ISLNK(mode):
+        return '@'
+    elif pystat.S_ISFIFO(mode):
+        return '|'
+    elif pystat.S_ISSOCK(mode):
+        return '='
+    else:
+        return ''