Interface Script
.

Today I published a simple library on pypi, Interface Script.

Pitch,

    It's a data-interchange mechanism that you could think of as
    Multidimension CSV.

    I find much better for general use than rivals like XML, JSON, YAML.

    It is message-oriented, rather than document-oriented.

A key quality is /interface assertions/. That is: before you send a message,
you first need to assert the message type to the receiver. That way, if the
receiver disagrees about the message structure, you can have it fail-fast.

Website,

    https://github.com/cratuki/interface_script_py

Installation,

    pip install interface_script

Usage example follows.



$ python3 -B -m venv venv
$ . venv/bin/activate
(venv) $ pip install interface_script
[...]
(venv) $ cat > sample.py <<END
import interface_script

DATA = '''
    # assert the message vectors
    i org h name
    i person name age fk_org_h

    # messages
    org 0 "Piccadilly Steamship Company"
    org 1 "Victoria Square Consulting"
    person Jane 34 1
    person Steve 33 1
    person Alice 28 0
'''

class Handler:

    def on_org(self, h, name):
        print("Org: %s (%s)"%(name, h))

    def on_person(self, name, age, fk_org_h):
        print("Person: %s/%s (%s)"%(name, age, fk_org_h))

def main():
    handler = Handler()
    ob = interface_script.InterfaceScriptParser(handler)
    ob.parse(DATA)

if __name__ == '__main__':
    main()
END
(venv) $ python3 -B -m sample
Org: Piccadilly Steamship Company (0)
Org: Victoria Square Consulting (1)
Person: Jane/34 (1)
Person: Steve/33 (1)
Person: Alice/28 (0)
(venv) $