From cff5dfec5fbeb749332d13652120bf1413de5849 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Wed, 19 Nov 2014 12:01:26 +0800 Subject: [PATCH] Add header of inbundle function xml2obj Change-Id: I0190f83f571fc03e17800f371140871a139e4f6e Signed-off-by: Lin Yang --- common/utils.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/common/utils.py b/common/utils.py index 55a70f9..28475c2 100644 --- a/common/utils.py +++ b/common/utils.py @@ -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) -- 2.7.4