Skip to main content

chibi_apache

https://img.shields.io/pypi/v/chibi_apache.svg https://img.shields.io/travis/dem4ply/chibi_apache.svg Documentation Status

libreria para leer y escribir los archivos de configuracion de apache

Install

pip install chibi-apache

Usage

cat > /etc/httpd/conf/httpd.conf << 'endmsg'
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost

<Directory />
        AllowOverride none
        Require all denied
</Directory>

<Directory "/var/www">
        AllowOverride None
        Require all granted
</Directory>

<Directory "/var/www/html">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory "/var/www/cgi-bin">
        AllowOverride None
        Options None
        Require all granted
</Directory>
DocumentRoot "/var/www/html"

<IfModule dir_module>
        DirectoryIndex index.html
</IfModule>

<IfModule log_config_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%h %l %u %t \"%r\" %>s %b" common

        <IfModule logio_module>
                LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
        </IfModule>
        CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
        ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<IfModule mime_module>
        TypesConfig /etc/mime.types
        AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
</IfModule>

<IfModule mime_magic_module>
        MIMEMagicFile conf/magic
</IfModule>

<Files ".ht*">
        Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
AddDefaultCharset UTF-8
EnableSendfile on
IncludeOptional conf.d/*.conf
endmsg
from chibi_apache import Chibi_apache

tmp = Chibi_nginx( '/etc/httpd/conf/httpd.conf' )
result = tmp.read()
expected = {
        'AddDefaultCharset': 'UTF-8',
        'Directory': {
                '"/var/www"': {
                        'AllowOverride': 'None',
                        'Require': 'all granted'
                },
                '"/var/www/cgi-bin"': {
                        'AllowOverride': 'None',
                        'Options': 'None',
                        'Require': 'all granted'
                },
                '"/var/www/html"': {
                        'AllowOverride': 'None',
                        'Options': 'Indexes FollowSymLinks',
                        'Require': 'all granted'
                },
                '/': {
                        'AllowOverride': 'none',
                        'Require': 'all denied'
                }
        },
        'DocumentRoot': '"/var/www/html"',
        'EnableSendfile': 'on',
        'ErrorLog': '"logs/error_log"',
        'Files': {'".ht*"': {'Require': 'all denied'}},
        'Group': 'apache',
        'IfModule': {
                'alias_module': {
                        'ScriptAlias': '/cgi-bin/ "/var/www/cgi-bin/"'
                },
                'dir_module': {
                        'DirectoryIndex': 'index.html'
                },
                'log_config_module': {
                        'CustomLog': '"logs/access_log" combined',
                        'IfModule': {
                                'logio_module': {
                                        'LogFormat': (
                                                r'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" '
                                                r'\"%{User-Agent}i\" %I %O" combinedio' )
                                }
                        },
                        'LogFormat': [
                                ( r'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" '
                                        r'\"%{User-Agent}i\"" combined' ),
                                r'"%h %l %u %t \"%r\" %>s %b" common'
                        ]
                },
                'mime_magic_module': {
                        'MIMEMagicFile': 'conf/magic'
                },
                'mime_module': {
                        'AddOutputFilter': 'INCLUDES .shtml',
                        'AddType': [
                                'application/x-compress .Z',
                                'application/x-gzip .gz .tgz',
                                'text/html .shtml'
                        ],
                        'TypesConfig': '/etc/mime.types'
                }
        },
        'Include': 'conf.modules.d/*.conf',
        'IncludeOptional': 'conf.d/*.conf',
        'Listen': '80',
        'LogLevel': 'warn',
        'ServerAdmin': 'root@localhost',
        'ServerRoot': '"/etc/httpd"',
        'User': 'apache'
}

assert result == expected

result.pop( 'User' )
result.User = 'root'
tmp.write( result )
new_result = tmp.read()
assert new_result.User == 'root'

result.Directory.pop( '"/var/www/cgi-bin"' )
tmp.write( result )
new_result = tmp.read()
assert '"/var/www/cgi-bin"' not in new_result[ 'Directory' ]

Features

  • read and write config files of apache httpd

History

0.0.1 (2023-04-15)

  • First release on PyPI.

Metadata

Release files for chibi-apache 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chibi-apache 0.0.2
File Size Uploaded Provenance
chibi_apache-0.0.2.tar.gz 11.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for chibi-apache 0.0.2
File Interpreter ABI Platform
chibi_apache-0.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.9 kB

Release files / chibi_apache-0.0.2.tar.gz

Download URL chibi_apache-0.0.2.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ffa355b327c359833ea6612e3118ee20af15977c573de1c42142e94f1c1528a7
BLAKE2b-256 checksum
How to use checksums
22a44658b7cae355b39033483b33c3df63599174e913011f922a9eb0e3c946d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / chibi_apache-0.0.2-py2.py3-none-any.whl

Download URL chibi_apache-0.0.2-py2.py3-none-any.whl
Size 4.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
580ea57b6be43318dd9cb2fd7d879e980061abfff13e2f0c6d0550a7f00d0450
BLAKE2b-256 checksum
How to use checksums
75865c26cd8a5b87df6f10bd7e2e7816cc7e675fe5cc3cee932ae852ea58990c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for chibi-apache 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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page