nginxparser

by fatiherikli

fatiherikli / nginxparser

Parses nginx configuration with Pyparsing

473 Stars 104 Forks Last release: Not found MIT License 44 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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/; }'

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.