• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    Python
  • Created about 12 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Config-file-to-Python mapping library (ORM).

Reconfigure - Python object mapping for config files

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)

More Repositories

1

tabby

A terminal for a more modern age
TypeScript
57,415
star
2

russh

Rust SSH client & server library
Rust
814
star
3

tabby-web

Tabby Web - an SSH/Telnet/Serial client in your browser.
Python
774
star
4

rust-sinner

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋
Rust
308
star
5

ajenti-v

Virtual Hosting addon for Ajenti
Python
225
star
6

ajenti

DEPRECATED: Repo moved to https://github.com/ajenti/ajenti (into the `1.x` branch)
Python
209
star
7

catcher

Beautiful tracebacks for Python
Python
133
star
8

tabby-connection-gateway

Connection gateway for Tabby Web
Python
105
star
9

tabby-docker

Docker plugin for Tabby
TypeScript
46
star
10

instacode

JavaScript
44
star
11

tabby-theme-hype

A Terminus theme that imitates Hyper
SCSS
42
star
12

tabby-save-output

Terminus plugin to save console output into a file
TypeScript
35
star
13

tabby-clickable-links

Plugin that makes URLs and paths in Terminus clickable
TypeScript
35
star
14

macos-native-processlist

NodeJS - native macOS process list loader
C++
22
star
15

windows-native-registry

Native windows registry access for Node
C++
22
star
16

tabby-clippy

An example plugin for Tabby
TypeScript
21
star
17

exconsole

Emergency/postmortem Python console
Python
20
star
18

grip

A better package manager for Python
Python
15
star
19

MyOS

University project
C
10
star
20

terminus-shell-selector

Shell selector popup for Terminus
TypeScript
9
star
21

Labs

Лабораторные
C#
6
star
22

ajenti-customization-demo

Ajenti customization demo
CSS
5
star
23

OldProjects

My old stuff
4
star
24

ORMy

A powerful but lightweight SQLite ORM for Android
Java
4
star
25

awesome-crm

JavaScript
3
star
26

instacode-intellij-plugin

IntelliJ IDEA plugin for instacod.es
Java
3
star
27

fksis-schedule

Java
3
star
28

Cofeepot-Example

HTCPCP example for Ajenti
Python
3
star
29

cargo-llvm-cov-repro

Rust
2
star
30

Defective

A detective game without a detective
C#
2
star
31

Locality

C#
2
star
32

ebank-client

JavaScript
2
star
33

infinity-sampler

Deterministic reservoir sampling for Rust
Rust
2
star
34

shutterspeed2

Rust
2
star
35

eugeny

2
star
36

shutterspeed

super WIP
Rust
1
star
37

terminus-clickable-ips

This plugin makes IPs and file paths in the terminal clickable
TypeScript
1
star
38

native-process-working-directory

C++
1
star
39

car

Python
1
star
40

tabby-events-demo

TypeScript
1
star
41

EscapeFromNewMexico

Escape your sins on a fancy boat for as long as the booze lasts.
C#
1
star
42

angularjs-test-task

JavaScript
1
star
43

loop-bastard

Python
1
star
44

coding-challenge-py

Python
1
star
45

avr-sample

Rust
1
star
46

django-test-task

TSQL
1
star
47

final-master-thesis

TeX
1
star