direct-io.hg

view tools/misc/sxp-pretty @ 14149: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
children
line source
1 #!/usr/bin/env python
2 # -*- mode: python; -*-
3 #============================================================================
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #============================================================================
17 # Copyright (c) 2007 XenSource Inc.
18 #============================================================================
21 import commands
22 import os.path
23 import pprint
24 import sys
26 result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]),
27 'xen-python-path'))
28 if result[0] != 0:
29 print >>sys.stderr, result[1]
30 sys.exit(1)
32 sys.path.append(result[1])
34 import xen.xend.sxp as sxp
36 def main():
37 if len(sys.argv) == 1 or sys.argv[1] in ['', '-']:
38 s = sxp.parse(sys.stdin)
39 else:
40 s = sxp.parse(open(sys.argv[1]))
42 pprint.pprint(s)
44 if __name__ == '__main__':
45 sys.exit(main())