def write(models, out=None, base=None, propertybase=None, shorteners=None, logger=logging):
    '''
    models - input Versa models from which output is generated. Must be a sequence
                object, not an iterator
    '''
    assert out is not None #Output stream required
    if not isinstance(models, list): models = [models]
    shorteners = shorteners or {}

    all_propertybase = [propertybase] if propertybase else []
    all_propertybase.append(VERSA_BASEIRI)

    if any((base, propertybase, shorteners)):
        out.write('# @docheader\n\n* @iri:\n')
    if base:
        out.write('    * @base: {0}'.format(base))
    #for k, v in shorteners:
    #    out.write('    * @base: {0}'.format(base))

    out.write('\n\n')

    origin_space = set()
    #base_out = models[0].base
    for m in models:
        origin_space.update(all_origins(m))

    for o in origin_space:
        out.write('# {0}\n\n'.format(o))
        for o_, r, t, a in m.match(o):
            abbr_r = abbreviate(r, all_propertybase)
            value_format(t)
            out.write('* {0}: {1}\n'.format(abbr_r, value_format(t)))
            for k, v in a.items():
                abbr_k = abbreviate(k, all_propertybase)
                out.write('    * {0}: {1}\n'.format(k, value_format(v)))

        out.write('\n')
    return
def write ( models , out = None , base = None , propertybase = None , shorteners = None , logger = logging ) : assert out is not None if not isinstance ( models , list ) : models = [ models ] shorteners = shorteners or { } all_propertybase = [ propertybase ] if propertybase else [ ] all_propertybase . append ( VERSA_BASEIRI ) if any ( ( base , propertybase , shorteners ) ) : out . write ( '# @docheader\n\n* @iri:\n' ) if base : out . write ( '    * @base: {0}' . format ( base ) ) out . write ( '\n\n' ) origin_space = set ( ) for m in models : origin_space . update ( all_origins ( m ) ) for o in origin_space : out . write ( '# {0}\n\n' . format ( o ) ) for o_ , r , t , a in m . match ( o ) : abbr_r = abbreviate ( r , all_propertybase ) value_format ( t ) out . write ( '* {0}: {1}\n' . format ( abbr_r , value_format ( t ) ) ) for k , v in a . items ( ) : abbr_k = abbreviate ( k , all_propertybase ) out . write ( '    * {0}: {1}\n' . format ( k , value_format ( v ) ) ) out . write ( '\n' ) return
models - input Versa models from which output is generated. Must be a sequence
                object, not an iterator