xml parsing as YML parser does does

B

bab mis

Hi ,
Here is an example how i do yml parsing and a proper pythonic object returns , is it possible in XML, tried lxml,dom, but there is no straight forward solution:

[root@linux-source pyrun]# cat x.yml
#Section for specifying test process information

Test:

commoninfo:
buildhome : "/root/linuxbuilds"


Project:
default:

test_parameters:
svnuser : "vmbuild"
suite : "sanity"
username : "root"


Commands :
- name : generalcheck of destination
action : generalcheck

- name : retrieve source from svn
action : retsource
params : src=x,src1=y
[root@linux-source pyrun]

================================

[root@linux-source pyrun]# cat a.py
import yaml
fd = open("x.yml")
data = fd.read()
fd.close()
ydata = yaml.safe_load(data)
import pprint
pprint.pprint( ydata )

=======================


[root@linux-source pyrun]# python a.py
{'Test': {'Project': {'default': {'Commands': [{'action': 'generalcheck',
'name': 'generalcheck of destination'},
{'action': 'retsource',
'name': 'retrieve source from svn',
'params': 'src=x,src1=y'}],
'test_parameters': {
'suite': 'sanity',
'svnuser': 'vmbuild',
'username': 'root'}}},
'commoninfo': {'buildhome': '/root/linuxbuilds'}}}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] Sipper 2.0.0 Released 1
ANN main-4.4.0 0
[ANN] main-2.6.0 0
OutOfMemoryError in java app 0
ANN: Sequel 3.5.0 Released 0
[ANN] JRuby 1.4.0 Released 2
comp.lang.java.gui FAQ 0
Asp.net Important Topics. 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top