Skip to content
Parses nginx configuration with Pyparsing
Python
Branch: master
Clone or download
Latest commit f968c69 Jan 2, 2019

README.md

Nginx Configuration Parser

An nginx configuration parser that uses Pyparsing.

You can parse a nginx configuration file with load or loads method:

>>> from nginxparser import load
>>> load(open("/etc/nginx/sites-enabled/foo.conf"))

 [['server'], [
    ['listen', '80'],
    ['server_name', 'foo.com'],
    ['root', '/home/ubuntu/sites/foo/']]]]

Same as other serialization modules also you can export configuration with dump and dumps methods.

>>> from nginxparser import dumps
>>> dumps([['server'], [
            ['listen', '80'],
            ['server_name', 'foo.com'],
            ['root', '/home/ubuntu/sites/foo/']]])

'server {
    listen   80;
    server_name foo.com;
    root /home/ubuntu/sites/foo/;
 }'
You can’t perform that action at this time.