libreria para leer y escribir los archivos de configuracion de apache
Project description
chibi_apache
libreria para leer y escribir los archivos de configuracion de apache
Free software: WTFPL
Documentation: https://chibi-apache.readthedocs.io.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chibi_apache-0.0.2.tar.gz.
File metadata
- Download URL: chibi_apache-0.0.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffa355b327c359833ea6612e3118ee20af15977c573de1c42142e94f1c1528a7
|
|
| MD5 |
5237e81d071d96ec214a8b1bda331f07
|
|
| BLAKE2b-256 |
22a44658b7cae355b39033483b33c3df63599174e913011f922a9eb0e3c946d9
|
File details
Details for the file chibi_apache-0.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: chibi_apache-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
580ea57b6be43318dd9cb2fd7d879e980061abfff13e2f0c6d0550a7f00d0450
|
|
| MD5 |
bdc4be7dfba733c8b40088a9747597a6
|
|
| BLAKE2b-256 |
75865c26cd8a5b87df6f10bd7e2e7816cc7e675fe5cc3cee932ae852ea58990c
|