Any python libs for parsing apache config files?

前端 未结 6 2085
离开以前
离开以前 2020-12-29 11:40

Any python libs for parsing apache config files or if not python anyone aware of such thing in other languages (perl, php, java, c#)? As i\'ll be able to rewrite them in pyt

6条回答
  •  悲&欢浪女
    2020-12-29 11:59

    There is also one new parser released.

    • http://pypi.python.org/pypi/apache_conf_parser/

    It still lacks documentation, however is quite straightforward for understanding.


    Example

    import apache_conf_parser
    import pprint
    
    DEFAULT_VHOST = '/etc/apache2/sites-available/000-default.conf'
    
    vhost_default = apache_conf_parser.ApacheConfParser(DEFAULT_VHOST)
    
    print vhost_default.nodes
    print vhost_default.nodes[0].body.nodes
    
    pprint.pprint( 
        {
            i.name: [i.arguments for i in vhost_default.nodes[0].body.nodes]
        }
    )
    

提交回复
热议问题