[augeas-devel] [PATCH] Add binding for aug_mv

Free Ekanayaka free at 64studio.com
Thu Sep 4 10:42:37 UTC 2008


# HG changeset patch
# User Free Ekanayaka <free at 64studio.com>
# Date 1220524789 -7200
# Node ID 09855e22210a1fd66f5a1747df7c8d0ba21c854d
# Parent  ccbfbf8439268b22fc32c35a7c9803e53cd14979
Add binding for aug_mv

diff -r ccbfbf843926 -r 09855e22210a augeas.py
--- a/augeas.py	Thu Jul 03 13:57:38 2008 +0200
+++ b/augeas.py	Thu Sep 04 12:39:49 2008 +0200
@@ -138,6 +138,26 @@ class Augeas(object):
         if ret != 0:
             raise ValueError, "Unable to set value to path!"
 
+    def move(self, src, dst):
+        """Move the node 'src' to 'dst'. 'src' must match exactly one node
+           in the tree. 'dst' must either match exactly one node in the
+           tree, or may not exist yet. If 'dst' exists already, it and all
+           its descendants are deleted before moving 'src' there. If 'dst'
+           does not exist yet, it and all its missing ancestors are created."""
+
+        # Sanity checks
+        if type(src) != str:
+            raise TypeError, "src MUST be a string!"
+        if type(dst) != str:
+            raise TypeError, "dst MUST be a string!"
+        if not self.__handle:
+            raise RuntimeError, "The Augeas object has already been closed!"
+
+        # Call the function
+        ret = Augeas._libaugeas.aug_mv(self.__handle, src, dst)
+        if ret != 0:
+            raise ValueError, "Unable to move src to dst!"
+
     def insert(self, path, label, before=True):
         """Create a new sibling 'label' for 'path' by inserting into the tree 
         just before 'path' (if 'before' is True) or just after 'path' 




More information about the augeas-devel mailing list