Add header of inbundle function xml2obj
authorLin Yang <lin.a.yang@intel.com>
Wed, 19 Nov 2014 04:01:26 +0000 (12:01 +0800)
committerLin Yang <lin.a.yang@intel.com>
Thu, 20 Nov 2014 03:07:15 +0000 (11:07 +0800)
Change-Id: I0190f83f571fc03e17800f371140871a139e4f6e
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
common/utils.py

index 55a70f9..28475c2 100644 (file)
@@ -162,6 +162,25 @@ def set_permissions(tpath, modes=(0644, 0755)):
             path = os.path.join(root, fname)
             os.chmod(path, os.stat(path).st_mode | modes[fname in dirs])
 
+def make_latest_link(snapshot_path):
+    """ make the latest repo link to the new repo
+        snapshot_path (str): the local path to snapshot
+    """
+    latest = os.path.join(snapshot_path, "../latest")
+    rel_path = os.path.basename(snapshot_path)
+    if os.path.lexists(latest):
+        os.unlink(latest)
+    os.symlink(rel_path, latest)
+
+# The function xml2obj is from http://code.activestate.com/recipes/534109/
+# and is distributed under the PSF License.
+#
+# Author: Wai Yip Tung
+# Last Updated: 2007/10/19
+# Version no: 1.3
+# License: PSF License
+# Source: http://code.activestate.com/recipes/534109/
+
 def xml2obj(src):
     """
     A simple function to converts XML data into native Python object.
@@ -257,13 +276,3 @@ def xml2obj(src):
     else:
         xml.sax.parse(src, builder)
     return builder.root._attrs.values()[0]
-
-def make_latest_link(snapshot_path):
-    """ make the latest repo link to the new repo
-        snapshot_path (str): the local path to snapshot
-    """
-    latest = os.path.join(snapshot_path, "../latest")
-    rel_path = os.path.basename(snapshot_path)
-    if os.path.lexists(latest):
-        os.unlink(latest)
-    os.symlink(rel_path, latest)