WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] cpupools, xend: Add missing file sxputils

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] cpupools, xend: Add missing file sxputils.py
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Apr 2010 03:25:10 -0700
Delivery-date: Wed, 28 Apr 2010 03:25:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1272261039 -3600
# Node ID 7ccf597281d8538e9778e5088c1cea2a6ddd61f5
# Parent  c87ec146229ab2255ecdf005b862b943b1a5112e
cpupools, xend: Add missing file sxputils.py

Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
---
 tools/python/xen/util/sxputils.py |   64 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+)

diff -r c87ec146229a -r 7ccf597281d8 tools/python/xen/util/sxputils.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/util/sxputils.py Mon Apr 26 06:50:39 2010 +0100
@@ -0,0 +1,64 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (c) 2009 Fujitsu Technology Solutions
+#============================================================================
+
+""" convert sxp to map / map to sxp.
+"""
+
+import types
+from xen.xend import sxp
+
+def map2sxp(map_val):
+    """ conversion of all key-value pairs of a map (recursively) to sxp.
+        @param map_val: map; if a value contains a list or dict it is also
+                    converted to sxp
+        @type map_val: dict
+        @return sxp expr
+        @rtype: list
+    """
+    sxp_vals = []
+    for (k, v) in map_val.items():
+        if isinstance(v, types.DictionaryType):
+            sxp_vals += [[k] + map2sxp(v)]
+        elif isinstance(v, types.ListType):
+            sxp_vals += [[k] + v]
+        else:
+            sxp_vals += [[k, v]]
+    return sxp_vals
+
+def sxp2map( s ):
+    """ conversion of sxp to map.
+        @param s: sxp expr
+        @type s:  list
+        @return: map
+        @rtype: dict
+    """
+    sxphash = {}
+
+    for child in sxp.children( s ):
+        if isinstance( child, types.ListType ) and len( child ) > 1:
+            if isinstance( child[1], types.ListType ) and len( child[1] ) > 1:
+                sxphash[ child[0] ] = sxp2map( child )
+            else:
+                childs = sxp.children(child)
+                if len(childs) > 1:
+                    sxphash[ child[0] ] = childs
+                else:
+                    sxphash[ child[0] ] = childs[0]
+
+    return sxphash
+
+

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] cpupools, xend: Add missing file sxputils.py, Xen patchbot-unstable <=