Beispiel #1
0
def main(path):
    schema_decl = (
        # path, type, subschema
        ('changed', bool),
        ('code-remote', str),
        ('source', str),
        ('explorer', dict, (
            ('state', str),
        )),
        ('parameter', dict, (
            ('state', str),
        )),
        ('state', str),
        ('tags', dict, (
            ('exclude', list),
            ('include', list),
            ('only', list),
        )),
    )

    schema = cconfig.Schema(schema_decl)
    obj = cconfig.from_schema(schema)
    print(obj)
    obj['changed'] = True
    obj['tags'] = {'exclude': ['a', 'b'], 'include': set(('c', 'd')), 'only': ('x', 'y')}
    print('changed: ', obj['changed'])
    print('state: ', obj['state'])
    print('parameter[\'state\']: ', obj['parameter']['state'])
    print('explorer[\'state\']: ', obj['explorer']['state'])
    print(obj)
    import tempfile
    tmpdir = tempfile.mkdtemp()
    print('tmpdir: ', tmpdir)
    cconfig.to_dir(tmpdir, obj, schema=schema)
Beispiel #2
0
def main_(path):
    schema_decl = (
        # path, type, subschema
        ('changed', bool),
        ('code-remote', str),
        ('source', str),
        ('explorer', dict, (
            ('state', str),
        )),
        ('parameter', dict, (
            ('state', str),
        )),
        ('state', str),
    )

    schema = cconfig.Schema(schema_decl)
    obj = cconfig.from_schema(schema)
    print(obj)
    obj['changed'] = True
    print('changed: ', obj['changed'])
    print('state: ', obj['state'])
    print('parameter[\'state\']: ', obj['parameter']['state'])
    print('explorer[\'state\']: ', obj['explorer']['state'])
    print(obj)
    import tempfile
    tmpdir = tempfile.mkdtemp()
    print('tmpdir: ', tmpdir)
    cconfig.to_dir(tmpdir, obj, schema=schema)