ia64/xen-unstable

changeset 14159:8e3899a4f62d

Added SXP pretty-printer.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 27 13:58:40 2007 +0000 (2007-02-27)
parents b67c253d1cdb
children dd8c88744433
files tools/misc/sxp-pretty
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/misc/sxp-pretty	Tue Feb 27 13:58:40 2007 +0000
     1.3 @@ -0,0 +1,45 @@
     1.4 +#!/usr/bin/env python
     1.5 +#  -*- mode: python; -*-
     1.6 +#============================================================================
     1.7 +# This library is free software; you can redistribute it and/or
     1.8 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     1.9 +# License as published by the Free Software Foundation.
    1.10 +#
    1.11 +# This library is distributed in the hope that it will be useful,
    1.12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.14 +# Lesser General Public License for more details.
    1.15 +#
    1.16 +# You should have received a copy of the GNU Lesser General Public
    1.17 +# License along with this library; if not, write to the Free Software
    1.18 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.19 +#============================================================================
    1.20 +# Copyright (c) 2007 XenSource Inc.
    1.21 +#============================================================================
    1.22 +
    1.23 +
    1.24 +import commands
    1.25 +import os.path
    1.26 +import pprint
    1.27 +import sys
    1.28 +
    1.29 +result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]),
    1.30 +                                               'xen-python-path'))
    1.31 +if result[0] != 0:
    1.32 +    print >>sys.stderr, result[1]
    1.33 +    sys.exit(1)
    1.34 +
    1.35 +sys.path.append(result[1])
    1.36 +
    1.37 +import xen.xend.sxp as sxp
    1.38 +
    1.39 +def main():
    1.40 +    if len(sys.argv) == 1 or sys.argv[1] in ['', '-']:
    1.41 +        s = sxp.parse(sys.stdin)
    1.42 +    else:
    1.43 +        s = sxp.parse(open(sys.argv[1]))
    1.44 +
    1.45 +    pprint.pprint(s)
    1.46 +
    1.47 +if __name__ == '__main__':
    1.48 +    sys.exit(main())