]> arthur.barton.de Git - bup.git/commitdiff
metadata/xstat: fix a bunch of CodingStyle issues.
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Mar 2011 08:23:43 +0000 (01:23 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 20 Mar 2011 09:41:15 +0000 (02:41 -0700)
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/xstat-cmd.py
lib/bup/_helpers.c
lib/bup/metadata.py
lib/bup/t/tmetadata.py
lib/bup/xstat.py

index 6d60596810f7d8c50a885b3ee8db6dfdc0e707f1..c3a672cc5827b4bb58db21df3356b2bbd012b4a5 100755 (executable)
@@ -1,17 +1,10 @@
 #!/usr/bin/env python
-
 # Copyright (C) 2010 Rob Browning
 #
 # This code is covered under the terms of the GNU Library General
 # Public License as described in the bup LICENSE file.
-
-import errno
-import posix1e
-import stat
-import sys
-from bup import metadata
-from bup import options
-from bup import xstat
+import sys, stat, errno
+from bup import metadata, options, xstat
 from bup.helpers import handle_ctrl_c, saved_errors, add_error, log
 
 
index 9409b387539976d6059252948385065efb359f32..a5bc16db31195814576826a41ba15650e6f386c6 100644 (file)
@@ -669,7 +669,7 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args)
         return NULL;
 
     fd = open(path, O_RDONLY | O_NONBLOCK | O_LARGEFILE | O_NOFOLLOW);
-    if(fd == -1)
+    if (fd == -1)
         return PyErr_SetFromErrnoWithFilename(PyExc_IOError, path);
 
     rc = ioctl(fd, FS_IOC_SETFLAGS, &attr);
index a04d01f1e25dc39bd78108bb78ee1bc51a5f3f5b..38eb76b163c842d7e39198a01b675b3cb5d866aa 100644 (file)
@@ -76,7 +76,7 @@ def _clean_up_path_for_archive(p):
 
     # Take everything after any '/../'.
     pos = result.rfind('/../')
-    if(pos != -1):
+    if pos != -1:
         result = result[result.rfind('/../') + 4:]
 
     # Take everything after any remaining '../'.
@@ -248,7 +248,7 @@ class Metadata:
         elif stat.S_ISFIFO(self.mode):
             os.mknod(path, 0600 | stat.S_IFIFO)
         elif stat.S_ISLNK(self.mode):
-            if(self.symlink_target and create_symlinks):
+            if self.symlink_target and create_symlinks:
                 os.symlink(self.symlink_target, path)
         # FIXME: S_ISDOOR, S_IFMPB, S_IFCMP, S_IFNWK, ... see stat(2).
         # Otherwise, do nothing.
@@ -333,7 +333,7 @@ class Metadata:
 
     def _add_symlink_target(self, path, st):
         try:
-            if(stat.S_ISLNK(st.st_mode)):
+            if stat.S_ISLNK(st.st_mode):
                 self.symlink_target = os.readlink(path)
         except OSError, e:
             add_error('readlink: %s', e)
@@ -374,7 +374,7 @@ class Metadata:
             num_flags = posix1e.TEXT_ABBREVIATE | posix1e.TEXT_NUMERIC_IDS
             acl_reps = [acls[0].to_any_text('', '\n', txt_flags),
                         acls[1].to_any_text('', '\n', num_flags)]
-            if(len(acls) < 3):
+            if len(acls) < 3:
                 acl_reps += ['', '']
             else:
                 acl_reps.append(acls[2].to_any_text('', '\n', txt_flags))
@@ -387,14 +387,14 @@ class Metadata:
     def _load_posix1e_acl_rec(self, port):
         data = vint.read_bvec(port)
         acl_reps = vint.unpack('ssss', data)
-        if(acl_reps[2] == ''):
+        if acl_reps[2] == '':
             acl_reps = acl_reps[:2]
         self.posix1e_acl = [posix1e.ACL(text=x) for x in acl_reps]
 
     def _apply_posix1e_acl_rec(self, path, restore_numeric_ids=False):
-        if(self.posix1e_acl):
+        if self.posix1e_acl:
             acls = self.posix1e_acl
-            if(len(acls) > 2):
+            if len(acls) > 2:
                 if restore_numeric_ids:
                     acls[3].applyto(path, posix1e.ACL_TYPE_DEFAULT)
                 else:
@@ -411,7 +411,7 @@ class Metadata:
         if stat.S_ISREG(st.st_mode) or stat.S_ISDIR(st.st_mode):
             try:
                 attr = get_linux_file_attr(path)
-                if(attr != 0):
+                if attr != 0:
                     self.linux_attr = attr
             except IOError, e:
                 if e.errno == errno.EACCES:
@@ -432,7 +432,7 @@ class Metadata:
         self.linux_attr = vint.unpack('V', data)[0]
 
     def _apply_linux_attr_rec(self, path, restore_numeric_ids=False):
-        if(self.linux_attr):
+        if self.linux_attr:
             set_linux_file_attr(path, self.linux_attr)
 
 
@@ -466,7 +466,7 @@ class Metadata:
 
     def _apply_linux_xattr_rec(self, path, restore_numeric_ids=False):
         existing_xattrs = set(xattr.list(path, nofollow=True))
-        if(self.linux_xattr):
+        if self.linux_xattr:
             for k, v in self.linux_xattr:
                 if k not in existing_xattrs \
                         or v != xattr.get(path, k, nofollow=True):
@@ -517,7 +517,7 @@ class Metadata:
         tag = vint.read_vuint(port)
         try: # From here on, EOF is an error.
             result = Metadata()
-            while(True): # only exit is error (exception) or _rec_tag_end
+            while True: # only exit is error (exception) or _rec_tag_end
                 if tag == _rec_tag_path:
                     result._load_path_rec(port)
                 elif tag == _rec_tag_common:
@@ -567,7 +567,7 @@ def from_path(path, statinfo=None, archive_path=None, save_symlinks=True):
     result.path = archive_path
     st = statinfo if statinfo else lstat(path)
     result._add_common(path, st)
-    if(save_symlinks):
+    if save_symlinks:
         result._add_symlink_target(path, st)
     result._add_posix1e_acl(path, st)
     result._add_linux_attr(path, st)
@@ -584,7 +584,7 @@ def save_tree(output_file, paths,
     # Issue top-level rewrite warnings.
     for path in paths:
         safe_path = _clean_up_path_for_archive(path)
-        if(safe_path != path):
+        if safe_path != path:
             log('archiving "%s" as "%s"\n' % (path, safe_path))
 
     start_dir = os.getcwd()
index 17cec0128fe8c0f9cac1cf2188f6afafbdf9f3b4..8852a38942f8f38e474c4747a1a4c3fb1098c887 100644 (file)
@@ -1,9 +1,4 @@
-import grp
-import pwd
-import stat
-import subprocess
-import tempfile
-import xattr
+import glob, grp, pwd, stat, tempfile, subprocess, xattr
 import bup.helpers as helpers
 from bup import metadata
 from bup.helpers import clear_errors, detect_fakeroot
index d279b932be08b11c08e883b856599caad43fb6d1..56c85652c8519f244723019cb95df8687254d2f7 100644 (file)
@@ -1,7 +1,6 @@
 """Enhanced stat operations for bup."""
-import math
-import os
-import bup._helpers as _helpers
+import os, math
+from bup import _helpers
 
 
 try:
@@ -50,13 +49,10 @@ class FSTime():
         return (- (abs_val / 10**9), - (abs_val % 10**9))
 
     if _helpers._have_ns_fs_timestamps: # Use integer nanoseconds.
-
         @staticmethod
         def from_stat_time(stat_time):
             return FSTime.from_timespec(stat_time)
-
     else: # Use python default floating-point seconds.
-
         @staticmethod
         def from_stat_time(stat_time):
             ts = FSTime()
@@ -66,7 +62,6 @@ class FSTime():
 
 
 if _have_utimensat:
-
     def lutime(path, times):
         atime = times[0].to_timespec()
         mtime = times[1].to_timespec()
@@ -76,9 +71,7 @@ if _have_utimensat:
         atime = times[0].to_timespec()
         mtime = times[1].to_timespec()
         return _helpers.utimensat(_helpers.AT_FDCWD, path, (atime, mtime), 0)
-
 else:
-
     def lutime(path, times):
         return None
 
@@ -89,7 +82,6 @@ else:
 
 
 class stat_result():
-
     @staticmethod
     def from_stat_rep(st):
         result = stat_result()