Skip to main content

An ORM for config files

Project description

https://travis-ci.org/Eugeny/reconfigure.png

Browse API on SourceGraph

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


Download files

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

Source Distribution

reconfigure-0.1.75.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

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

reconfigure-0.1.75-py2.py3-none-any.whl (53.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file reconfigure-0.1.75.tar.gz.

File metadata

  • Download URL: reconfigure-0.1.75.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for reconfigure-0.1.75.tar.gz
Algorithm Hash digest
SHA256 d3da8c80ea69f8c1bc66efced24c7fcbf37c0fd4a14f182de087e22239e7dc6a
MD5 ea9f97edca373b4d1c12e7b6b910f455
BLAKE2b-256 862c3f033be30de14d1e12c44744788689e4a879eff2ad7fc93b870218a87192

See more details on using hashes here.

File details

Details for the file reconfigure-0.1.75-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for reconfigure-0.1.75-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c981ef2e458c32531ac5285926f914a6bba2bcbb1cf921d1ccacbe09e332e5e2
MD5 aa345da0b9216c39e36a5c87fd7f96b2
BLAKE2b-256 97d63744ac3b3930800247816dc3a2b02fa0a4dd7b432259ce35e6915373e83d

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