Skip to main content

A simple Apache Config Parser

Project description

Simple Apache Config Parser

Welcome to the Simple Apache Config Parser! This package is intended to ease the parsing/analysis of apache config files. This parser uses the Apache Config Lexer provided by the pygments project.

This project is still very much in its infancy, but my focus is on providing easy to use/understand object interfaces to analyze and modify apache config files while attempting to minimize the deltas between the original configs and the modified content. If this software is not quite meeting your needs, drop in an Issue and I'll do my best to address/help, but even if that's failing checkout this other neat parser apacheconfig.

Example usage

Here are some example usages. Note that these examples assume your current working directory properly set to match Include patterns. In the examples below this is for a CentOS installation where the root apache directory tends to be /etc/httpd/.

Parsing

Parsing a config file is easy!

from sacp import *
cf = ConfigFile(file="conf/httpd.conf")

This will automatically parse the httpd.conf from the current directory. Any dependent configs (e.g. those that are listed in an Include or IncludeOptional directive) will also be loaded.

Walking the nodes

Visiting all the nodes is also easy!

from sacp import *

def visit(node):
    print("{}{}".format(node.depth * " ", type(node)))

cf = ConfigFile(file="conf/httpd.conf")
NodeVisitor([cf]).visit(visitor=visit)

This visits all of the nodes in the config file, including it's children, and prints each node type with it's relative depth represented as well.

Contribute

Want to contribute? Awesome! Fork, code, and create a PR.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sacp-0.7.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sacp-0.7.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file sacp-0.7.0.tar.gz.

File metadata

  • Download URL: sacp-0.7.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.0

File hashes

Hashes for sacp-0.7.0.tar.gz
Algorithm Hash digest
SHA256 34e010f80e446f0921c487273f10a35c7c256f0d6de5a7ae44a876184717bee9
MD5 b991a3fe56a7e30505954f2e2b0a3887
BLAKE2b-256 15fcb6efe317fdf59899bc4d6c6eac3d3405a68f942eae5564bd6dc40d5081bf

See more details on using hashes here.

File details

Details for the file sacp-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: sacp-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.0

File hashes

Hashes for sacp-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1b7e44af2493db9c1277806f24c0fcd7c5fcb40b3e4cdfff6dc0ee9988d3f2e
MD5 b894b9357b362e22a4ffac20afca40b0
BLAKE2b-256 a0f13ebe7e206c1797020817cd89dc9fa8e31732235847e7a3d848654d05dd0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page