# parse_apache_configs A simple python library that will parse apache configs and convert them to a python data structure.
parse_apache_configs
A simple python library that will parse apache configs and convert them to a python data structure. This will then allow the configs to be manipulated programatically.
Main Functions
To use:
from parse_apache_configs import parse_config
Parse the apache config via file path, and return a python object representation:
apache_parse_obj = parse_config.ParseApacheConfig(apache_config_path="/some/path/to/file")
apache_config = apache_parse_obj.parse_config()
or to parse the apache config as a string:
apache_parse_obj = parse_config.ParseApacheConfig(apache_file_as_string=apache_string_obj)
apache_config = apache_parse_obj.parse_config()
Now you can use the apache_config object to manipulate the apache config.
To add or override an existing directive and return the result:
apache_config = apache_parse_obj.add_directive(apache_config, "SomeDirectiveName", "SomeDirectiveArguments", "<VirtualHost *:80>")
The code above will add the line “SomeDirectiveName SomeDirectiveArguments” under <VirtualHost *:80>. If the directive is already there, then it’s arguments will be overridden. Keep in mind that directives in nested tags can also be added/overridden, but their full “path” must be fed into add_directive. For example, given the following apache file:
<VirtualHost *:80>
ServerName example.org
ServerAlias *.example.org
ErrorLog /var/log/httpd/example.err
DocumentRoot /var/www/example.org
<Directory "/var/www/example.org">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
To override the “Order” directive under <Directory “/var/www/example.org”>, the invocation to add_directive would look like this:
apache_config = apache_parse_obj.add_directive(apache_config, "Order", "deny,allow", "<VirtualHost *:80>", "<Directory "/var/www/example.org">")
To convert the apache_config object into a printable string:
apache_config_string = apache_parse_obj.get_apache_config(apache_config)
print apache_config_string
Metadata
Release files for parse_apache_configs 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| parse_apache_configs-0.0.2.tar.gz | 4.7 kB | Without provenance | Details for parse_apache_configs-0.0.2.tar.gz |
Release files / parse_apache_configs-0.0.2.tar.gz
| Download URL | parse_apache_configs-0.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
000a98f518636bc9f8c06ba6ea2f7fb8fb0298c780b6a8e9a242ec393ecd29ac
|
|
BLAKE2b-256 checksum How to use checksums |
3a59bfb842d06d90d3c1b55e097726061eb51da34dc4b23b6591c202094318cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for parse_apache_configs 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.