]> arthur.barton.de Git - bup.git/commitdiff
Rename metadata exceptions and add a parent MetadataError class.
authorRob Browning <rlb@defaultvalue.org>
Sat, 13 Nov 2010 21:19:53 +0000 (15:19 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 13 Nov 2010 21:19:53 +0000 (15:19 -0600)
s/MetadataAcquisitionError/MetadataAcquireError/
s/MetadataApplicationError/MetadataApplyError/

lib/bup/metadata.py
lib/bup/t/tmetadata.py

index 7325355656fd1eb8c38534f689c548c04552c4ab..118688a42ca6d6c5721f439e01f169e077d8ec58 100644 (file)
@@ -146,12 +146,16 @@ _rec_tag_linux_attr = 6       # lsattr(1) chattr(1)
 _rec_tag_linux_xattr = 7      # getfattr(1) setfattr(1)
 
 
-class MetadataAcquisitionError(Exception):
+class MetadataError(Exception):
+    pass
+
+
+class MetadataAcquireError(MetadataError):
     # Thrown when unable to extract any given bit of metadata from a path.
     pass
 
 
-class MetadataApplicationError(Exception):
+class MetadataApplyError(MetadataError):
     # Thrown when unable to apply any given bit of metadata to a path.
     pass
 
@@ -511,7 +515,7 @@ class Metadata:
             self._apply_linux_attr_rec(path, restore_numeric_ids=num_ids)
             self._apply_linux_xattr_rec(path, restore_numeric_ids=num_ids)
         except Exception, e:
-            raise MetadataApplicationError(e)
+            raise MetadataApplyError(e)
 
 
 def from_path(path, archive_path=None, save_symlinks=True):
@@ -526,7 +530,7 @@ def from_path(path, archive_path=None, save_symlinks=True):
         result._add_linux_attr(path, st)
         result._add_linux_xattr(path, st)
     except Exception, e:
-        raise MetadataAcquisitionError(e)
+        raise MetadataAcquireError(e)
     return result
 
 
@@ -551,7 +555,7 @@ def save_tree(output_file, paths,
             try:
                 m = from_path(p, archive_path=safe_path,
                               save_symlinks=save_symlinks)
-            except MetadataAcquisitionError, e:
+            except MetadataAcquireError, e:
                 add_error(e)
 
             if verbose:
@@ -623,7 +627,7 @@ def finish_extract(file, restore_numeric_ids=False):
                 try:
                     meta.apply_to_path(path=xpath,
                                        restore_numeric_ids=restore_numeric_ids)
-                except MetadataApplicationError, e:
+                except MetadataApplyError, e:
                     add_error(e)
 
     all_dirs.sort(key = lambda x : len(x.path), reverse=True)
@@ -635,7 +639,7 @@ def finish_extract(file, restore_numeric_ids=False):
         try:
             dir.apply_to_path(path=xpath,
                               restore_numeric_ids=restore_numeric_ids)
-        except MetadataApplicationError, e:
+        except MetadataApplyError, e:
             add_error(e)
 
 
@@ -659,7 +663,7 @@ def extract(file, restore_numeric_ids=False, create_symlinks=True):
                     print >> sys.stderr, '=', meta.path
                 try:
                     meta.apply_to_path(restore_numeric_ids=restore_numeric_ids)
-                except MetadataApplicationError, e:
+                except MetadataApplyError, e:
                     add_error(e)
     all_dirs.sort(key = lambda x : len(x.path), reverse=True)
     for dir in all_dirs:
@@ -671,5 +675,5 @@ def extract(file, restore_numeric_ids=False, create_symlinks=True):
         try:
             dir.apply_to_path(path=dir.path,
                               restore_numeric_ids=restore_numeric_ids)
-        except MetadataApplicationError, e:
+        except MetadataApplyError, e:
             add_error(e)
index 8aa4f1d199e35d123fe5ed736f7de4b21714e185..d1f16fa2d24af4495dc88786313e7210e60cc311 100644 (file)
@@ -85,7 +85,7 @@ def test_from_path_error():
         m = metadata.from_path(path, archive_path=path, save_symlinks=True)
         WVPASSEQ(m.path, path)
         subprocess.call(['chmod', '000', path])
-        WVEXCEPT(metadata.MetadataAcquisitionError,
+        WVEXCEPT(metadata.MetadataAcquireError,
                  metadata.from_path,
                  path,
                  archive_path=path,
@@ -105,7 +105,7 @@ def test_apply_to_path_error():
         m = metadata.from_path(path, archive_path=path, save_symlinks=True)
         WVPASSEQ(m.path, path)
         subprocess.call(['chmod', '000', tmpdir])
-        WVEXCEPT(metadata.MetadataApplicationError,
+        WVEXCEPT(metadata.MetadataApplyError,
                  m.apply_to_path, path)
         subprocess.call(['chmod', '700', tmpdir])
     finally:
@@ -125,11 +125,11 @@ def test_restore_restricted_user_group():
         WVPASSEQ(m.apply_to_path(path), None)
         orig_uid = m.uid
         m.uid = 0;
-        WVEXCEPT(metadata.MetadataApplicationError,
+        WVEXCEPT(metadata.MetadataApplyError,
                  m.apply_to_path, path, restore_numeric_ids=True)
         m.uid = orig_uid
         m.gid = 0;
-        WVEXCEPT(metadata.MetadataApplicationError,
+        WVEXCEPT(metadata.MetadataApplyError,
                  m.apply_to_path, path, restore_numeric_ids=True)
     finally:
         subprocess.call(['rm', '-rf', tmpdir])