An ORM for config files
Project description
Quickstart
>>> from reconfigure.configs import FSTabConfig
>>> from reconfigure.items.fstab import FilesystemData
>>>
>>> config = FSTabConfig(path='/etc/fstab')
>>> config.load()
>>> print config.tree
{
"filesystems": [
{
"passno": "0",
"device": "proc",
"mountpoint": "/proc",
"freq": "0",
"type": "proc",
"options": "nodev,noexec,nosuid"
},
{
"passno": "1",
"device": "UUID=dfccef1e-d46c-45b8-969d-51391898c55e",
"mountpoint": "/",
"freq": "0",
"type": "ext4",
"options": "errors=remount-ro"
}
]
}
>>> tmpfs = FilesystemData()
>>> tmpfs.mountpoint = '/srv/cache'
>>> tmpfs.type = 'tmpfs'
>>> tmpfs.device = 'none'
>>> config.tree.filesystems.append(tmpfs)
>>> config.save()
>>> quit()
$ cat /etc/fstab
proc /proc proc nodev,noexec,nosuid 0 0
UUID=dfccef1e-d46c-45b8-969d-51391898c55e / ext4 errors=remount-ro 0 1
none /srv/cache tmpfs none 0 0
This is actually a shortcut to:
>>> from reconfigure.parsers import SSVParser
>>> from reconfigure.builders import BoundBuilder
>>> from reconfigure.items.fstab import FSTabData
>>> content = open('/etc/fstab').read()
>>> syntax_tree = SSVParser().parse(content)
>>> syntax_tree
<reconfigure.nodes.RootNode object at 0x7f1319eeec50>
>>> print syntax_tree
(None)
(line)
(token)
value = proc
(token)
value = /proc
(token)
value = proc
(token)
value = nodev,noexec,nosuid
(token)
value = 0
(token)
value = 0
(line)
(token)
value = UUID=83810b56-ef4b-44de-85c8-58dc589aef48
(token)
value = /
(token)
value = ext4
(token)
value = errors=remount-ro
(token)
value = 0
(token)
value = 1
>>> builder = BoundBuilder(FSTabData)
>>> data_tree = builder.build(syntax_tree)
>>> print data_tree
{
"filesystems": [
{
"passno": "0",
"device": "proc",
"mountpoint": "/proc",
"freq": "0",
"type": "proc",
"options": "nodev,noexec,nosuid"
},
{
"passno": "1",
"device": "UUID=83810b56-ef4b-44de-85c8-58dc589aef48",
"mountpoint": "/",
"freq": "0",
"type": "ext4",
"options": "errors=remount-ro"
}
]
}
Parsers and builders can be paired in almost any possible combination.
Reconfigure can be easily extended with your own parsers and builders - read the docs!
Supported configs:
Ajenti (ajenti)
BIND9 DNS (bind9)
Crontabs (crontab)
Samba CTDB (ctdb)
ISC DHCPD / uDHCPD (dhcpd)
NFS /etc/exports (exports)
/etc/fstab (fstab)
/etc/group (group)
/etc/hosts (hosts)
iptables-save dump (iptables)
Netatalk afp.conf (netatalk)
NSD DNS (nsd)
/etc/passwd (passwd)
/etc/resolv.conf (resolv)
Samba (samba)
Squid 3 (squid)
Supervisord (supervisor)
Included parsers:
BIND9 config (bind9)
Crontab (crontab)
NFS Exports (exports)
.ini (ini)
iptables-save (iptables)
nginx-like (nginx)
squid (squid)
nsd (nsd)
CSV-like space-separated values (ssv)
JSON (jsonparser)
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 reconfigure-0.1.65.tar.gz.
File metadata
- Download URL: reconfigure-0.1.65.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6ad0a8067ca9f9ad6f93fa2b840caef474f29d8efb8ae6dda41f3b377292514
|
|
| MD5 |
b638bbe41274015322047d96e1da8be6
|
|
| BLAKE2b-256 |
48deb050d90dde79742da5923974ce6d199b0cbd2a0f22cd0ce5ebccd209059c
|
File details
Details for the file reconfigure-0.1.65-py2.py3-none-any.whl.
File metadata
- Download URL: reconfigure-0.1.65-py2.py3-none-any.whl
- Upload date:
- Size: 53.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c61e572e23bab7f02adb531bec6da75005dc31b0824387b6d2199214121f51
|
|
| MD5 |
c0daeb722cf3a73397314d651f8a3407
|
|
| BLAKE2b-256 |
c6d8545b015d38f47d7d5563e04d2d3968b83c76d21591aa104661cf2be8d29b
|