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'}}}
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to